Unloading a Windows Driver

63 Views Asked by At

I am creating a Network driver using Windows KMDF Driver and Windows Filtering Platform(WFP) API.

In my driver, I am allocating memory X using ExAllocatePoolWithTag() and using that address in localRedirectContext.

I am fetching that data (localRedirectContext) from a user-mode application and using that data.

I have to deallocate the data after using it in user-mode application or it should be deallocated after particular time (timeout).

While unloading the driver, I should deallocate all the memory allocated by the driver to avoid memory leaks.

While I deallocate the allocated memory, it's throwing errors in WinDbg that the caller is trying to free an incorrect Special Pool memory block or the address has data with different tag and size.

How to know whether the memory has been deallocated already, or yet to deallocated?

Now, I am using a data structure to store the allocated memories with its addresses.

When I unload the driver, I am deallocating the allocated memory, but this method also throwing breakpoints due to Special Pool Access Violation and Invalid Memory Address due to double deallocation errors.

How to safely unload a driver and deallocate memories to avoid memory leaks?

0

There are 0 best solutions below