Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Unfortunately, although the simple form looks easiest to use, if your driver does allocations or initializations that allocate resources in the create vector, but does not wait and interpret the result of the lower-level drivers processing the IRP, you will leak those allocations. The following variant of the simple form is subject to this, and is incorrect.
static NTSTATUS YourSubunit_CreateVector(PDEVICE_OBJECT devObj, PIRP Irp)
{
NTSTATUS status;
//
// Allocate some resources for us
//
YOURSUBUNIT_DEVICE_EXTENSION * ysde = devObj->DeviceExtension;
ysde->ysde_SomeSortOfArray = ExAllocatePool(NonPagedPool, 32000);
if (ysde->ysde_SomeSortOfArray)
{
//
// Now that we have allocated our resources, send the IRP down.
//
IoSkipCurrentIrpStackLocation(Irp);
//
// 'ParentDeviceObject', below, is the value returned from your
// call to IoAttachDeviceToDeviceStack().
//
status = IoCallDriver(ParentDeviceObject, Irp);
}
else
status = STATUS_INSUFFICIENT_RESOURCES;
return(status);
}
Send Feedback on this topic to the authors