Complete IRP_MJ_DEVICE_CONTROL synchronously

Hi gentlemen.

I have a WDF driver and I want to complete specific IO control synchronously.

I call WdfDeviceInitAssignWdmIrpPreprocessCallback to register my WdmIrpPreprocess function, which does the job and calls IoCompleteRequest.

The problem is that DeviceIoControl (with OVERLAPPED pointer) still returns an error condition, GetLastError() == ERROR_IO_PENDING.

Is there anything else I should do to force synchronous completion of a device control operation. Basically I want to complete the request immediately so that application doesnโ€™t wait or pend it if immediate completion is impossible.

Thanks, guys.

Sorry, guys, it actually works :slight_smile: forgot about getchar() in my testing application. LOL.