I have a simple query. When I create the deviceobject using IoCreateDevice in DriverEntry I store the returned handle globally.
This is fine, and I even manage to create a device extension in the same method. However there is a callback function that I am creating a WorkItem in that requires the device object.
I only store the handle to the device object and not the device extension.
The example I am working from states
PIO_WORKITEM pWorkItem = IoAllocateWorkItem(g_DeviceExtension->pDeviceObject);
Now I don’t have a g_DeviceExtension. Is it ok to create this in DriverEntry? What is the best way to pass the device object and/or device extension around?
Look at the example, you probably will find that pDeviceObject is a pointer
to the device object which has g_DeviceExtension as its extension. Some
people and examples prefer to pass the device extension and others prefer to
pass the device object and get the extension from the object.
Either is a fine approach, if you pass the device object you can always get
the extension.
–
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
wrote in message news:xxxxx@ntdev…
>I have a simple query. When I create the deviceobject using IoCreateDevice
>in DriverEntry I store the returned handle globally.
>
> This is fine, and I even manage to create a device extension in the same
> method. However there is a callback function that I am creating a WorkItem
> in that requires the device object.
>
> I only store the handle to the device object and not the device extension.
>
> The example I am working from states
>
> PIO_WORKITEM pWorkItem =
> IoAllocateWorkItem(g_DeviceExtension->pDeviceObject);
>
> Now I don’t have a g_DeviceExtension. Is it ok to create this in
> DriverEntry? What is the best way to pass the device object and/or device
> extension around?
>
>
>
>