How to call IoCreateDevice() function in dispatch routine.

I want to create some device objects in IRP_MJ_DEVICE_CONTROL routine, but
failed.

When I create device object in DriverEntry() routine, it is OK. When I
create device object in IRP_MJ_DEVICE_CONTROL routine, the IoCreateDevice()
function return value is STATUS_SUCCESS, but when I check the device object
with Winobj.exe
it’s invalid, and I also can’t use this device object’s name to create a
symbliclink name.

Hand the task off to a worker thread. You generally want to create the
device objects in a system process context rather than in a user process
context.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sun Jiajie
Sent: Wednesday, April 19, 2006 4:41 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to call IoCreateDevice() function in dispatch
routine.

I want to create some device objects in IRP_MJ_DEVICE_CONTROL routine,
but
failed.

When I create device object in DriverEntry() routine, it is OK. When I
create device object in IRP_MJ_DEVICE_CONTROL routine, the
IoCreateDevice()
function return value is STATUS_SUCCESS, but when I check the device
object
with Winobj.exe
it’s invalid, and I also can’t use this device object’s name to create a

symbliclink name.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Remeber that if you create a device object outside of Driver Entry
that you have to clear the Initializing bit in the Device Object Flags
field, or you will never be able to use the device object.

–Mark Cariddi
OSR

On Wed, 19 Apr 2006 16:40:45 +0800, “Sun Jiajie”
wrote:

>I want to create some device objects in IRP_MJ_DEVICE_CONTROL routine, but
>failed.
>
>When I create device object in DriverEntry() routine, it is OK. When I
>create device object in IRP_MJ_DEVICE_CONTROL routine, the IoCreateDevice()
>function return value is STATUS_SUCCESS, but when I check the device object
>with Winobj.exe
>it’s invalid, and I also can’t use this device object’s name to create a
>symbliclink name.
>
>