you do not need to handle hardware IDs, you are loaded way too late to effect that. Why are you looking at the previous stack location? To see if you are recursing?
Off the top of my head, you are completing the request and then touching it (by giving it back to the framework). If you complete the request, just return ntStatus after completing it. Also, run this with driver verifier enabled on your driver. I think you will need to send the request down the stack first and then process the request when the irp is travelling up the stack.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, July 10, 2008 10:50 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KMDF HIDUSBFX2 sample: what is the NULL service for?
Hi Doron,
thank you for your help.
Regarding your first reply, yes the filter is loaded as lower filter (I basically copied the HIDUSBFX2 inf file). May be I did something wrong in the preprocess routine: is it correct to complete the request from within the preprocess procedure? Here is the code of the routine (just a test) before I attempted to set the completion routine (and attempt the post process).
Anyway thank you so much, I’ll try a little harder since I really don’t like the current solution: I like the idea to stay within the framework as much as I can.
Stra.
NTSTATUS HidKmjEvtWdmPreprocessMnQueryId(IN WDFDEVICE Device, IN OUT PIRP Irp)
{
NTSTATUS ntStatus;
PDEVICE_OBJECT DeviceObject;
PIO_STACK_LOCATION IrpStack, previousSp;
PWCHAR buffer;
//
// Perform IRP preprocessing operations here.
//
IrpStack = IoGetCurrentIrpStackLocation(Irp);
DeviceObject = WdfDeviceWdmGetDeviceObject(Device);
previousSp = ((PIO_STACK_LOCATION) ((UCHAR *) (IrpStack) + sizeof(IO_STACK_LOCATION)));
if (previousSp->DeviceObject == DeviceObject) {
ntStatus = Irp->IoStatus.Status;
}
else
{
switch (IrpStack->Parameters.QueryId.IdType)
{
case BusQueryDeviceID:
case BusQueryHardwareIDs:
buffer = (PWCHAR)ExAllocatePoolWithTag(NonPagedPool, KMJ_VIRTUALDEVICE_IDS_LENGTH, KMJ_POOL_TAG);
if(buffer)
{
RtlCopyMemory(buffer, KMJ_VIRTUALDEVICE_IDS, KMJ_VIRTUALDEVICE_IDS_LENGTH);
Irp->IoStatus.Information = (ULONG_PTR)buffer;
ntStatus = STATUS_SUCCESS;
}
else
{
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
}
Irp->IoStatus.Status = ntStatus;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
break;
}
}
//
// Deliver the IRP back to the framework.
//
IoSkipCurrentIrpStackLocation(Irp);
return WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
}
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