- your code segment is (more than) a bit incomplete so there could be
numerous bugs not revealed by the sample. In addition you provided no actual
data from your system crash, like a bug check code and a stack trace. That
sort of information is really helpful in isolating exactly what this
specific problem is, especially as my guess is that you are having multiple
problems, so you could be fixing bugs and still getting crashes.
1.) if you are going to do a ‘send and wait’ you should just use
IoBuildSynchronousFsdRequest.
-
you should not specify a data buffer for pnp irps. These sort of irps
have their own peculiar rules for how they send data. Generally data is
transferred back towards the originator using Irp.IoStatus.Information. In
your specific case, as is clearly described in the DDK, the instance ID
string is returned in IRP.IoStatus.Information, and it is your
responsibility to deallocate this buffer after you are done with it.
-
you MUST set IRP.IoStatus.Status to STATUS_NOT_SUPPORTED.
-
You don’t need a StartingOffset parameter, so just set this to NULL.
-
If you take my advice and use IoBuildSynchronousFsdRequest you don’t need
a completion handler, and as that is most likely where most of your bugs
are, this is goodness.
-
You don’t set the MajorFunction field - it is set by the call to
IoBuildSynchronousFsdRequest. Just set the MinorFunction field.
-
you should set IRP.IoStatus.Information to NULL.
-
FYI: it looks like your call to IoSetCompletionHandler does not pass the
address of your ‘syncEvent’. How exactly was your completion handler
supposed to set this event?
=====================
Mark Roddy
Windows .NET/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@mcdi.com
Sent: Monday, March 22, 2004 3:52 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Create IRP
Hello,
I would like to create a IRP from my upper filter driver in order to
retrieve the InstanceId from the PDO.
Is there any example to create this kind of IRP?
I perform these following instructions while I receive IRP_MN_START_DEVICE
in the filter driver.
My system crashes when the system loads this driver.
Anybody could help me to fix this small problem…
// START_DEVICE
// Instance Id
BufLen = 8 * sizeof(WCHAR);
Buffer = ExAllocatePool(PagedPool, BufLen);
if (!Buffer) {
status = STATUS_INSUFFICIENT_RESOURCES;
return status;
}
// create IRP here
irp = IoBuildAsynchronousFsdRequest(IRP_MJ_PNP,
deviceExtension->NextLowerDriver,
Buffer,
BufLen,
&largeInt,
NULL);
IoSetCompletionRoutine(irp,
(PIO_COMPLETION_ROUTINE) FilterQueryInstanceRoutine,
NULL,
TRUE,
TRUE,
TRUE);
irpStack_2 = IoGetNextIrpStackLocation(irp);
irpStack_2->MajorFunction = IRP_MJ_PNP;
irpStack_2->MinorFunction = IRP_MN_QUERY_ID;
irpStack_2->Parameters.QueryId.IdType = BusQueryInstanceID;
KeInitializeEvent(&syncEvent, SynchronizationEvent, FALSE);
status = IoCallDriver(deviceExtension->NextLowerDriver, irp);
if (status == STATUS_PENDING) {
KeWaitForSingleObject(&syncEvent, Executive, KernelMode, FALSE,
NULL);
status = irp->IoStatus.Status;
}
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: xxxxx@hollistech.com To unsubscribe send a blank email to
xxxxx@lists.osr.com