-----------how to synchronous two file ----------

I want to synchronous two files c:\test.txt and d:\test1.txt, How can I
do it ?
Do you have any other ideas ?

the following is my workflow:

1.catch the I/O calls (FileObject filename is c:\test.txt )

2.Used IoAllocateIrp to allocate new IRP(FileObject filename is
d:\test1.txt)
,and completion this IRP
(remark:the new IRP all parameter equal original IRP all parameter except
for DeviceObject and FileObject)

3.completion the original IRP

in step 2.
2.1)RtlInitUnicodeString
2.2)InitializeObjectAttributes
2.3)ZwCreateFile
2.4)ObReferenceObjectByHandle
2.5)IoGetRelatedDeviceObject
2.6)IoAllocateIrp
2.7)set new IRP a part of parameter equals original IRP
2.8)IoSetCompletionRoutine
2.9)KeInitializeEvent
2.a)IoCallDriver
2.b)KeWaitForSingleObject
2.c)ZwClose

in this process i successed to catch IRP and Allocate new IRP and
completion it .i trace the d:\test1.txt I/O request,the new IRP is send to
ok.

but in following code ,DbgPrint Irp->IoStatus.Status is
STATUS_INVALID_PARAMETER ¡¢STATUS_END_OF_FILE and
STATUS_INVALID_USER_BUFFER.operation c:\test.txt is ok,but operation
d:\test1.txt is fail.

NTSTATUS FileSynchronousComplete( PDEVICE_OBJECT DeviceObject, PIRP Irp,
PVOID Context )
{
*Irp->UserIosb = Irp->IoStatus;
if( !NT_SUCCESS(Irp->IoStatus.Status) ) {
DbgPrint((“ERROR ON IRP: %x\n”, Irp->IoStatus.Status ));
}

KeSetEvent(Irp->UserEvent, 0, FALSE);

IoFreeIrp(Irp);

return STATUS_MORE_PROCESSING_REQUIRED;
}

such as:
read c:\test.txt ,DbgPrint Irp->IoStatus.Status is
STATUS_INVALID_PARAMETER and STATUS_END_OF_FILE .

write c:\test.txt ,DbgPrint Irp->IoStatus.Status is
STATUS_INVALID_PARAMETER and STATUS_END_OF_FILE ,and
STATUS_INVALID_USER_BUFFER.

delete c:\test.txt,DbgPrint Irp->IoStatus.Status is
STATUS_INVALID_PARAMETER and STATUS_END_OF_FILE ,and
STATUS_INVALID_USER_BUFFER.

can you help me.

Thanks & Regards,

– riceworm


Ãâ·ÑÏÂÔØ MSN Explorer: http://explorer.msn.com/lccn