Hello guyz)
I have usb device object address and want to send IRP_MN_REMOVE_DEVICE :
What I do wrong?
I have usb device object address and want to send IRP_MN_REMOVE_DEVICE :
Code: Select all
And have BSOD IRQL_NOT_LESS_OR_EQUAL......
PIRP Irp;
PIO_STACK_LOCATION IrpStack;
IO_STATUS_BLOCK IoStatusBlock;
KEVENT Event;
NTSTATUS Status;
PDEVICE_OBJECT TopDeviceObject;
PAGED_CODE();
TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
Irp = IoAllocateIrp(TopDeviceObject->StackSize + 1, FALSE);
if(!Irp)
return STATUS_INSUFFICIENT_RESOURCES;
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
IrpStack = IoGetNextIrpStackLocation(Irp);
IrpStack->DeviceObject = TopDeviceObject;
IrpStack->MajorFunction = IRP_MJ_PNP;
IrpStack->MinorFunction = IRP_MN_REMOVE_DEVICE;
Irp->UserIosb = &IoStatusBlock;
Irp->UserEvent = &Event;
Status = IoCallDriver(TopDeviceObject, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock.Status;
}
ObDereferenceObject(TopDeviceObject);
...
What I do wrong?