KMDF Quick Question

In KMDF, what’s the opposite of EvtDriverDeviceAdd? That is, if I
allocate some per-device resource in my DeviceAdd callback, where do I
release it? My first-blush guess is EvtDeviceReleaseHardware. Is that
correct?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Typically it would be in the EvtObjectCleanup() callback for the
WDFDEVICE that you created in EvtDriverDeviceAdd().
ReleaseHw is paired with PrepareHw() and can be called multiple times.
EvtObjectCleanup() is called once. Furthermore, after you have
successfully created a WDFDEVICE in EvtDriverDeviceAdd(), if you return
!NT_SUCCESS, the cleanup routine will still be invoked so you can have a
much simpler AddDevice() routine and exit immediately (usually).

d

– I can spell, I just can’t type.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, June 20, 2006 2:35 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF Quick Question

In KMDF, what’s the opposite of EvtDriverDeviceAdd? That is, if I
allocate some per-device resource in my DeviceAdd callback, where do I
release it? My first-blush guess is EvtDeviceReleaseHardware. Is that
correct?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


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

Doron Holan wrote:

Typically it would be in the EvtObjectCleanup() callback for the
WDFDEVICE that you created in EvtDriverDeviceAdd().
ReleaseHw is paired with PrepareHw() and can be called multiple times.
EvtObjectCleanup() is called once. Furthermore, after you have
successfully created a WDFDEVICE in EvtDriverDeviceAdd(), if you return
!NT_SUCCESS, the cleanup routine will still be invoked so you can have a
much simpler AddDevice() routine and exit immediately (usually).

Thanks. That answer occurred to me about 2 minutes after I sent the
question, but it’s good to get the confirmation.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.