I am sending an IOCTL like this to a lower level driver (driver below) along with a WDFREQUEST -- the WDFREQUEST handle is showing a different address (in the lower level driver) from what I sent.
status = WdfIoTargetFormatRequestForInternalIoctl(
WdfUsbTargetDeviceGetIoTarget(fdoData->WdfUsbTargetDevice),
fdoData->WdfRequest,
IoctlControlCode,
inputMem,
NULL,
outputMem,
NULL
);
if (!NT_SUCCESS(status)) {
return status;
}
WdfRequestSetCompletionRoutine(
fdoData->WdfRequest,
SendIOCTLToTargetAsyncComplete,
NULL
);
if (WdfRequestSend(
fdoData->WdfRequest,
WdfUsbTargetDeviceGetIoTarget(fdoData->WdfUsbTargetDevice),
WDF_NO_SEND_OPTIONS
) == FALSE) {
status = WdfRequestGetStatus(fdoData->WdfRequest);
}
I have also associated the WDFREQUEST with a "requestContext" like this:
WDF_OBJECT_ATTRIBUTES_INIT(&attrib);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(
&attrib,
REQUEST_CONTEXT
);
status = WdfObjectAllocateContext(
fdoData->WdfRequest,
&attrib,
&reqContext
);
attribsTwo.ParentObject = fdoData->WdfRequest;
I made sure the "reqContext" is valid and associated with fdoData->WdfRequest by getting the context with reqContext = GetRequestContext(fdoData->WdfRequest);
This is the debugger info about the WDFREQUEST at this point (driver that is sending the IOCTL):
kd> !wdfrequest 0x76967dd0
!IRP 0x89263150
State: Allocated by driver, IRP allocated by WDF
!WDFIOTARGET 0x763cea98
After I receive the IOCTL_I_Sent, in the lower level driver, somehow the WDFREQUEST address is different in the lower driver than when it was created and sent from the driver above. Also, when I try to do --
reqContext = GetRequestContext(fdoData->WdfRequest), this gives me a NULL reqContext.
This is associated debug output:
3: kd> g
Breakpoint 7 hit
MyDrv!SendIOCTLToTargetAsync+0x10d:
bac29ffd 6a00 push 0
3: kd> g
==> PORT_EvtInternalIoDeviceControl
==> PORT_PDOInternalIoControl
InternalIoCntl: 0x222460
Breakpoint 1 hit
Port!PORT_PDOInternalIoControl+0x2d7:
b9b47167 8b550c mov edx,dword ptr [ebp+0Ch]
This shows the WDFREQUEST in the lower level driver:-
3: kd> !wdfrequest 0x76dd0918
!IRP 0x89263150
!WDFQUEUE 0x762ece08
State: Pending, Allocated by WDF for incoming IRP
3: kd> p
Port!PORT_PDOInternalIoControl+0x2e3:
b9b47173 6a00 push 0
3: kd> !wdfqueue 0x762ece08
Dumping WDFQUEUE 0x762ece08
Parallel, Default, Power-managed, PowerOn, Can accept, Can dispatch, ExecutionLevelDispatch, SynchronizationScopeNone
Number of driver owned requests: 2
!WDFREQUEST 0x76d5a408 !IRP 0x00000000
!WDFREQUEST 0x76dd0918 !IRP 0x89263150
Number of waiting requests: 0
Any clue on what may be going wrong and why the WDFREQUEST passed is "DIFFERENT" from what I sent, obviously that is why I am not able to fetch the "reqContext" associated with the WDFREQUEST.
Any ideas?
Thanks!
Vidya