|
建立iocontrol的irp,用这个
- NTSTATUS OtherDeviceIoControl(
- IN ULONG IoControlCode,
- IN PDEVICE_OBJECT DeviceObject,
- IN PVOID InputBuffer OPTIONAL,
- IN ULONG InputBufferLength,
- OUT PVOID OutputBuffer OPTIONAL,
- IN ULONG OutputBufferLength,
- IN BOOLEAN InternalDeviceIoControl
- )
- {
- IO_STATUS_BLOCK ioStatus;
- NTSTATUS ntStatus;
- KEVENT event;
- PIRP irp;
- PIO_STACK_LOCATION stack;
- ULONG bytes;
-
- KeInitializeEvent(&event, NotificationEvent, FALSE);
- bytes = sizeof (ULONG);
- irp = IoBuildDeviceIoControlRequest(
- IoControlCode,
- DeviceObject,
- InputBuffer,
- InputBufferLength,
- OutputBuffer,
- OutputBufferLength,
- InternalDeviceIoControl,
- &event,
- &ioStatus);
- if(NULL == irp) {
- BulkUsb_DbgPrint(1, ("memory alloc for irp failed\n"));
- return STATUS_INSUFFICIENT_RESOURCES;
- }
- ntStatus = IoCallDriver(DeviceObject, irp);
- if(STATUS_PENDING == ntStatus) {
- KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
- }
- else {
- ioStatus.Status = ntStatus;
- }
- ntStatus = ioStatus.Status;
- return ntStatus;
- }
复制代码 |
|