Can DriverEntry call IoCreateDevice in a WDM

Hi,Dev!
Thank you for response!
But if I give a AddDevice route to the driver , It will soon be unloaded!
Are the drivers createdevice in DriverEntry called legacy-driver ?
Can Pnp Driver create device in DriverEntry?
If can ,is there something special should be cared?
Thanks!

Not necessary. You can call IoCreateDevice in DriverEntry too. It all
depends upon your need.

Dev

-----Original Message-----
From: f [mailto:xxxxx@eyou.com]
Sent: Friday, November 26, 2004 4:17 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can DriverEntry call IoCreateDevice in a WDM driver?

hi,
In a wdm driver–which have AddDevice route,IoCreateDevice can only be
called
in AddDevice route, isnt it?
3x

http://www.eyou.com
–Îȶ¨¿É¿¿µÄµç×ÓÐÅÏä ÓïÒôÓʼþ ÒÆ¶¯ÊéÇ© ÈÕÀú·þÎñ ÍøÂç´æ´¢…ÒÚÓÊδ¾¡

http://vip.eyou.com
–¿ì¿ìµÇ¼ÒÚÓÊVIPÐÅÏä ×¢²áÄúÖÐÒâµÄÓû§Ãû

http://sms.eyou.com
–ÎÞÓǶþ¶þ×å¡¢×ãÇò´ó¸»ÎÌ…¾¡ÔÚÒÚÓʶÌÐÅ

If you specify an AddDevice routine, but your service is not specified as a service or filter, your driver will be unloaded. The unload will not happen if you create a device in DriverEntry because there is an outstanding reference to your driver (the device created).

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of f
Sent: Sunday, November 28, 2004 10:21 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can DriverEntry call IoCreateDevice in a WDM

Hi,Dev!
Thank you for response!
But if I give a AddDevice route to the driver , It will soon be unloaded!
Are the drivers createdevice in DriverEntry called legacy-driver ?
Can Pnp Driver create device in DriverEntry?
If can ,is there something special should be cared?
Thanks!

Not necessary. You can call IoCreateDevice in DriverEntry too. It all
depends upon your need.

Dev

-----Original Message-----
From: f [mailto:xxxxx@eyou.com]
Sent: Friday, November 26, 2004 4:17 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Can DriverEntry call IoCreateDevice in a WDM driver?

hi,
In a wdm driver–which have AddDevice route,IoCreateDevice can only be
called
in AddDevice route, isnt it?
3x

http://www.eyou.com
–?ȶ??ɿ??ĵ??? ???ʼ? ?ƶ???ǩ ??? ???洢…???δ??

http://vip.eyou.com
–???¼???VIP??? ע???û???

http://sms.eyou.com
–???Ƕ???塢???..???ʶ???


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

You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Dev!
The following is pseudocode :

PDEVICE_OBJECT gCdo;// control device object
NTSTATUS DriverEntry()
{

DriverObject->DriverUnload = MY_DriverUnload;
status=IoCreateDevice(DriverObject…&gCdo);
if( !NT_SUCCESS(status) )
{
return status;
}
DriverObject->DriverExtension->AddDevice = MY_AddDevice;

return status;
}

It looks win2k will check the whether a driver is a legacy driver.
If the driver isnot a legacy driver and it create a device in DriverEntry
,win2k will call the Driver’s unload route!

If you specify an AddDevice routine, but your service is not specified as a
service or filter, your driver will be unloaded. The unload will not happen
if you create a device in DriverEntry because there is an outstanding
reference to your driver (the device created).

d

http://www.eyou.com
–Îȶ¨¿É¿¿µÄµç×ÓÐÅÏä ÓïÒôÓʼþ ÒÆ¶¯ÊéÇ© ÈÕÀú·þÎñ ÍøÂç´æ´¢…ÒÚÓÊδ¾¡

http://vip.eyou.com
–¿ì¿ìµÇ¼ÒÚÓÊVIPÐÅÏä ×¢²áÄúÖÐÒâµÄÓû§Ãû

http://sms.eyou.com
–ÎÞÓǶþ¶þ×å¡¢×ãÇò´ó¸»ÎÌ…¾¡ÔÚÒÚÓʶÌÐÅ

> Can Pnp Driver create device in DriverEntry?

Yes it can.

But it will be unloaded immediately if there are no PnP devices serviced by it.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Thank you.
I will take a try.

> Can Pnp Driver create device in DriverEntry?

Yes it can.

But it will be unloaded immediately if there are no PnP devices serviced by
it.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com


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

You are currently subscribed to ntdev as: xxxxx@eyou.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

http://www.eyou.com
–Îȶ¨¿É¿¿µÄµç×ÓÐÅÏä ÓïÒôÓʼþ ÒÆ¶¯ÊéÇ© ÈÕÀú·þÎñ ÍøÂç´æ´¢…ÒÚÓÊδ¾¡

http://vip.eyou.com
–¿ì¿ìµÇ¼ÒÚÓÊVIPÐÅÏä ×¢²áÄúÖÐÒâµÄÓû§Ãû

http://sms.eyou.com
–ÎÞÓǶþ¶þ×å¡¢×ãÇò´ó¸»ÎÌ…¾¡ÔÚÒÚÓʶÌÐÅ