- Correct way to release event created by KeInitializeEvent
- Posted by Alex F on April 19th, 2008
IN KMDF driver, I have KEVENT member of DEVICE_CONTEXT. It is initialized in
EvtDevicePrepareHardware function:
KeInitializeEvent(&pDeviceContext->MyEvent, NotificationEvent, FALSE);
I think that I must release it in the EvtDeviceReleaseHardware function,
what function should be used for this?
- Posted by Don Burn on April 19th, 2008
There is no converse for Initialize for Events or other Ke objects these
Initialize calls are just set the memory that was already allocated to an
initial state. Note: Ex calls do have a Delete call for their resources,
but those are a higher level abstraction.
--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"Alex F" <AlexF@discussions.microsoft.com> wrote in message
news:71904F11-37D0-4762-9A4F-D05A13048A96@microsoft.com...
- Posted by Alex F on April 19th, 2008
Thank you. Does this mean that only allocation in my case is done by
framework which creates DEVICE_CONTEXT with KEVENT member? Though I call
KeInitializeEvent every time EvtDevicePrepareHardware and don't release
anything in EvtDeviceReleaseHardware, this doesn't create memory and resource
leak.
Sorry for annoying questions, but this is not described in documentation,
and I want to understand this.
- Posted by Don Burn on April 19th, 2008
Yes, you have the gist of it. You allocate the space for the event or other
Ke object where you want to and free it as appropriate. KeInitializeEvent
call is only for the initialization of the already allocated memory.
--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply
"Alex F" <AlexF@discussions.microsoft.com> wrote in message
news:62E95052-0DC0-4756-BAD5-6F86CAB6A46E@microsoft.com...
- Posted by Alex F on April 19th, 2008
Thank you.
- Posted by Doron Holan [MSFT] on April 22nd, 2008
you should initialize the KEVENT in your AddDevice routine after you create
the device. this way you do not have a problem reinitializing the field on
subsequent PrepareHardware() calls
d
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Alex F" <AlexF@discussions.microsoft.com> wrote in message
news:5725DC18-765E-4FF6-AEB5-7A6862770839@microsoft.com...