阅读:1341回复:2
有关拔出USB设备时产生的“不安全的设备删除“对话框的问题?
我看了站长的这个帖子http://www.driverdevelop.com/forum/viewthread.php?tid=301,按照这样做了,可还是不行,哪位大侠能给我看看除了什么毛病。
NTSTATUS BulkUsb_QueryCapabilities( IN PDEVICE_OBJECT LowerDeviceObject, IN PDEVICE_CAPABILITIES DeviceCapabilities ) { PIO_STACK_LOCATION nextStack; PIRP irp; NTSTATUS ntStatus; KEVENT event; // This is a DDK-defined DBG-only macro that ASSERTS we are not running pageable code // at higher than APC_LEVEL. PAGED_CODE(); // Build an IRP for us to generate an internal query request to the PDO irp = IoAllocateIrp(LowerDeviceObject->StackSize, FALSE); if (!irp) { return STATUS_INSUFFICIENT_RESOURCES; } // // Preinit the device capability structures appropriately. // RtlZeroMemory( DeviceCapabilities, sizeof(DEVICE_CAPABILITIES) ); DeviceCapabilities->Size = sizeof(DEVICE_CAPABILITIES); DeviceCapabilities->Version = 1; DeviceCapabilities->Address = -1; DeviceCapabilities->UINumber = -1; DeviceCapabilities->SurpriseRemovalOK=TRUE; DeviceCapabilities->Removable=TRUE; DeviceCapabilities->EjectSupported=TRUE; DeviceCapabilities->WarmEjectSupported=TRUE; // IoGetNextIrpStackLocation gives a higher level driver access to the next-lower // driver\'s I/O stack location in an IRP so the caller can set it up for the lower driver. nextStack = IoGetNextIrpStackLocation(irp); nextStack->MajorFunction= IRP_MJ_PNP; nextStack->MinorFunction= IRP_MN_QUERY_CAPABILITIES; // init an event to tell us when the completion routine\'s been called KeInitializeEvent(&event, NotificationEvent, FALSE); // Set a completion routine so it can signal our event when // the next lower driver is done with the Irp IoSetCompletionRoutine(irp, BulkUsb_IrpCompletionRoutine, &event, // pass the event as Context to completion routine TRUE, // invoke on success TRUE, // invoke on error TRUE); // invoke on cancellation of the Irp // set our pointer to the DEVICE_CAPABILITIES struct nextStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities; // preset the irp to report not supported irp->IoStatus.Status = STATUS_NOT_SUPPORTED; ntStatus = IoCallDriver(LowerDeviceObject, irp); //BULKUSB_KdPrint( DBGLVL_MEDIUM,(\" BulkUsb_QueryCapabilities() ntStatus from IoCallDriver to PCI = 0x%x\\n\", ntStatus)); if (ntStatus == STATUS_PENDING) { // wait for irp to complete KeWaitForSingleObject( &event, Suspended, KernelMode, FALSE, NULL); ntStatus = irp->IoStatus.Status; } // failed? this is probably a bug //BULKUSB_KdPrintCond( DBGLVL_DEFAULT,(!NT_SUCCESS(ntStatus)), (\"BulkUsb_QueryCapabilities() failed\\n\")); IoFreeIrp(irp); return ntStatus; } |
|
|
沙发#
发布于:2003-01-09 19:26
你把顺序搞反了。先传下去,再修改。
|
|
|
驱动小牛
![]() |
板凳#
发布于:2008-03-17 16:03
标记一下,备用
|