阅读:2232回复:2
请问怎样在filter driver中创建并发送设置文件FILE_BASIC_INFORMATION属性的IRP?
我在程序中用如下方法却不行,请问问题出在哪里?先谢了~_~
BOOLEAN SetFileBasicInformation(PFILE_OBJECT FileObject, PFILE_BASIC_INFORMATION BasicInformation, PIO_STATUS_BLOCK IoStatusBlock) { PIRP irp; PDEVICE_OBJECT fsdDevice = IoGetRelatedDeviceObject(FileObject); KEVENT event; PIO_STACK_LOCATION ioStackLocation; // // Allocate an irp for this request. This could also come from a // private pool, for instance. // irp = IoAllocateIrp(fsdDevice->StackSize, FALSE); if (!irp) { // // Failure! // return FALSE; } irp->AssociatedIrp.SystemBuffer = BasicInformation; irp->UserEvent = &event; irp->UserIosb = IoStatusBlock; irp->Tail.Overlay.Thread = PsGetCurrentThread(); irp->Tail.Overlay.OriginalFileObject = FileObject; irp->RequestorMode = KernelMode; // // Initialize the event // KeInitializeEvent(&event, SynchronizationEvent, FALSE); // // Set up the I/O stack location. // ioStackLocation = IoGetNextIrpStackLocation(irp); ioStackLocation->MajorFunction = IRP_MJ_SET_INFORMATION; ioStackLocation->DeviceObject = fsdDevice; ioStackLocation->FileObject = FileObject; ioStackLocation->Parameters.SetFile.Length = sizeof(FILE_BASIC_INFORMATION); ioStackLocation->Parameters.SetFile.FileInformationClass = FileBasicInformation; // // Set the completion routine. // IoSetCompletionRoutine(irp, IoSetBasicInfoCompletion, 0, TRUE, TRUE, TRUE); // // Send it to the FSD // (void) IoCallDriver(fsdDevice, irp); // // Wait for the I/O // KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0); // // Done! // return NT_SUCCESS( IoStatusBlock->Status ); } NTSTATUS IoSetBasicInfoCompletion( PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context ) { // // Copy the status information back into the \"user\" IOSB. // *Irp->UserIosb = Irp->IoStatus; if( !NT_SUCCESS(Irp->IoStatus.Status) ) { DbgPrint((\" ERROR ON IRP: \\n\")); } // // Set the user event - wakes up the mainline code doing this. // KeSetEvent(Irp->UserEvent, 0, FALSE); // // Free the IRP now that we are done with it. // IoFreeIrp(Irp); // // We return STATUS_MORE_PROCESSING_REQUIRED because this \"magic\" return value // tells the I/O Manager that additional processing will be done by this driver // to the IRP - in fact, it might (as it is in this case) already BE done - and // the IRP cannot be completed. // return STATUS_MORE_PROCESSING_REQUIRED; } |
|
沙发#
发布于:2004-05-27 11:42
大家帮忙呀,万分感谢!!!!!
|
|
板凳#
发布于:2012-06-16 16:05
这个论坛真垃圾
|
|