I am creating a Network driver using Windows KMDF Driver and Windows Filtering Platform(WFP) API.
While unloading the driver, I should deallocate all the memory allocated by the driver to avoid memory leaks.
I have an object X which gets allocated and deallocated within Driver itself. There is no problem with that object.
I have another object Y which is getting allocated in Driver using ExAllocatePoolWithTag()
and I am setting that address in localRedirectContext
of FWPS_CONNECT_REQUEST0
struct.
And then I am fetching that data using WSAIoctl
and using it in the User-mode application. Should I need to handle the deallocation of object Y. But if I deallocate the object Y, it throws an error in WinDbg, so I assumed that it should not be deallocated.
Am I doing it correct or not?