Getting Device IO Control Code In EvtIoDefault

What would be the best/most efficient way to obtain the device I/O control code in the EvtIoDefault callback? I have been trying to implement the EvtIoDefault callback function to handle the StartIo routine code from a legacy WDM driver. The issue is that the I/O Control Code is not given as an input parameter to the event handler whereas it is in the EvtIoDeviceControl event handler accepts the IoControlCode as an input parameter.

What I have implemented in EvtIoDefault callback in order to obtain the I/O control code is the following:
Irp = WdfRequestWdmGetIrp(Request)
IrpStack = IoGetCurrentIrpStackLocation(Irp);
IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode

However, this doesn’t look like the best way to get access to it. I am curious if there is some support in the WDF API that I do not see?

Thank you very much.

xxxxx@gmail.com wrote:

What would be the best/most efficient way to obtain the device I/O control code in the EvtIoDefault callback? I have been trying to implement the EvtIoDefault callback function to handle the StartIo routine code from a legacy WDM driver. The issue is that the I/O Control Code is not given as an input parameter to the event handler whereas it is in the EvtIoDeviceControl event handler accepts the IoControlCode as an input parameter.

What I have implemented in EvtIoDefault callback in order to obtain the I/O control code is the following:
Irp = WdfRequestWdmGetIrp(Request)
IrpStack = IoGetCurrentIrpStackLocation(Irp);
IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode

However, this doesn’t look like the best way to get access to it. I am curious if there is some support in the WDF API that I do not see?

You can use WdfRequestGetParameters.
WDF_REQUEST_PARAMETERS.Parameters.DeviceIoControl.IoControlCode has the
same information. However, I don’t see a thing wrong with what you have
up there.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you Tim,

I had not considered the WdfRequestGetParameters call yet. I just didn’t want to use a call that was used in an old library like wdm.h in my kmdf driver. I can use the WdfRequestGetParameters call also, that works just as well.

Thank you

xxxxx@gmail.com wrote:

I had not considered the WdfRequestGetParameters call yet. I just didn’t want to use a call that was used in an old library like wdm.h in my kmdf driver. I can use the WdfRequestGetParameters call also, that works just as well.

There’s nothing wrong with wdm.h. KMDF is a wrapper around WDM, not a
replacement for it. What your driver actually gets is an IRP; KMDF
creates a WDFREQUEST to allow it to point into the IRP. It’s the same
base data.

You need to use whatever makes you comfortable, but don’t turn up your
nose at WDM just because it’s older.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I understand that KMDF is a wrapper around WDM. I do use parts of WDM in the KMDF driver, and the interface between the two makes sense.

Thank you for the help, I appreciate it.