On 2016-09-18 16:24, janderwald(a)svn.reactos.org wrote:
+NTSTATUS
+SubmitUrbSync(
+ IN PKSDEVICE Device,
+ IN PURB Urb)
+{
+ PIRP Irp;
+ KEVENT Event;
+ PDEVICE_EXTENSION DeviceExtension;
+ IO_STATUS_BLOCK IoStatus;
+ PIO_STACK_LOCATION IoStack;
+ NTSTATUS Status;
+
+ // init event
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ // get device extension
+ DeviceExtension = (PDEVICE_EXTENSION)Device->Context;
+
+ // build irp
+ Irp = IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_USB_SUBMIT_URB,
+ DeviceExtension->LowerDevice,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ TRUE,
+ &Event,
+ &IoStatus);
+
+ if (!Irp)
+ {
+ //
+ // no memory
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ // get next stack location
+ IoStack = IoGetNextIrpStackLocation(Irp);
+
+ // store urb
+ IoStack->Parameters.Others.Argument1 = Urb;
+
+ // set completion routine
+ IoSetCompletionRoutine(Irp, USBAudioCancelCompleteSynch, &Event, TRUE, TRUE,
TRUE);
You don't need a completion routine here, completing the IRP will set
the event specified in IoBuildDeviceIoControlRequest.
See
https://support.microsoft.com/en-us/kb/326315#bookmark-2