Do you handle the close on the read file object and tear down the io target? Does WdfIoTargetOpen succeed? Opening an io target the way you are should succeed without sending any io down the stack. If your PDO is not getting created, you are somehow blocking a state changing pnp irp from completing. When you are in that state, I would run !stacks 0 2 mouclass (and with mouhid) to see if there are any stuck stacks with those drivers in them,
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, March 10, 2011 11:31 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filtering around mouhid with kmdf
Hi Doron,
thank you for your help.
I attached a snippet of the EvtFileCreate code. Actually besides a couple of sanity checks at the beginning is pretty much all of it.
If I run this code and I install the driver in place of mouhid (so no upperfilter/lowfilter key and only needs=mouclass.services in the inf file) I get reports just fine and I do get initialized the connectdata but posting stuff through it doesn’t do anything. My driver creates also a raw pdo in the add device and I never see it enumerated (usually windows would detect it as a device and I never get to that point). So it seems that something is stuck but is not clear what.
If I don’t call WdfIoTargetOpen, the enumeration succeeds but of course no chance to get reports from the device.
If I install the driver as upperfilter of mouhid, reads don’t go through (I guess mouhid refuses them) but I can initialize what you see as nextDevice with
nextDevice = WdfIoTargetWdmGetTargetPhysicalDevice(WdfDeviceGetIoTarget(Device));
so that I target the PDO directly and then again I get the reports but the upper section of the stack is stuck again. Interestingly, if I install the hook in the connectdata so that I get the processed report, I can see the hook being called and I get my reports too but still no way to move the cursor on the screen.
If I install the driver as lowerfilter I have no access to connectdata at all. On top of it, for reasons that I don’t seem to understand, the reads that I see seem to have their buffer in a place that WdfRequestRetrieveOutputBuffer cannot decode.
Under many circumstances, when WdfIoTargetOpen is used I can see ExtFileCreate being called several times (like 20 times).
In any case the driver is initialized as filter.
I hope you see what’s wrong with it because I’m really stumped.
Thanks!
Marco.
---- snippet from EvtFileCreate
WdfRequestGetParameters(Request, &requestParameters);
if(requestParameters.Parameters.Create.SecurityContext->DesiredAccess & FILE_READ_DATA)
{
WDFIOTARGET ioTarget;
DEVICE_OBJECT *nextDevice;
WDF_IO_TARGET_OPEN_PARAMS ioTargetOpenParams;
WDF_REQUEST_SEND_OPTIONS_INIT(&requestSendOptions, WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);
WdfRequestFormatRequestUsingCurrentType(Request);
WdfRequestSend(Request, WdfDeviceGetIoTarget(Device), &requestSendOptions);
if(filterExt->ReadIoTarget == NULL)
{
filterExt->ReadIoTarget = WdfDeviceGetIoTarget(Device);
// Create and open a new remote ioTarget based on the same FILE_OBJECT
if(!NT_SUCCESS(WdfIoTargetCreate(Device, WDF_NO_OBJECT_ATTRIBUTES, &ioTarget)))
{
DebugPrint((“IoTargetCreate failed.\n”));
}
nextDevice = WdfDeviceWdmGetAttachedDevice(Device);
WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE(&ioTargetOpenParams, nextDevice);
filterExt->FileObject = IoGetCurrentIrpStackLocation(WdfRequestWdmGetIrp(Request))->FileObject;
ioTargetOpenParams.TargetFileObject = filterExt->FileObject;
DebugPrint((“FileCreate (fo = %x)\n”, filterExt->FileObject));
if(!NT_SUCCESS(WdfIoTargetOpen(ioTarget, &ioTargetOpenParams)))
{
DebugPrint((“IoTargetOpen failed.\n”));
}
filterExt->ReadIoTarget = ioTarget;
if(!NT_SUCCESS(StartHidReader(Device, filterExt->ReportMaxSize)))
{
DebugPrint((“StartHidReader failed.\n”));
}
}
}
else
{
// we really never get here
DebugPrint((“Not a simple FILE_READ_DATA open\n”));
WDF_REQUEST_SEND_OPTIONS_INIT(&requestSendOptions, WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);
WdfRequestFormatRequestUsingCurrentType(Request);
WdfRequestSend(Request, WdfDeviceGetIoTarget(Device), &requestSendOptions);
}
// Complete everything
{
WDF_REQUEST_COMPLETION_PARAMS params;
WdfRequestGetCompletionParams(Request, ¶ms);
WdfRequestComplete(Request, params.IoStatus.Status);
}
— snippet from EvtInternalIoCtl
case IOCTL_INTERNAL_MOUSE_CONNECT:
if (filterExt->UpperConnectData.ClassService != NULL)
{
status = STATUS_SHARING_VIOLATION;
break;
}
status = WdfRequestRetrieveInputBuffer(Request, sizeof(CONNECT_DATA), &connectData, &length);
if(!NT_SUCCESS(status)){
DebugPrint((“WdfRequestRetrieveInputBuffer failed %x\n”, status));
break;
}
filterExt->UpperConnectData = *connectData;
DebugPrint((“ConnectData ClassDeviceObject %x, ClassService %x\n”,
filterExt->UpperConnectData.ClassDeviceObject,
filterExt->UpperConnectData.ClassService));
connectData->ClassDeviceObject = WdfDeviceWdmGetDeviceObject(hDevice);
connectData->ClassService = MouseActivityCallback; // just a logging function. Only assigned when driver is upperfilter.
break;
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer