I found the reason for BSOD and of course it wasn't related to
DriverUnload hook :). Still, would be interesting to get some comments
on whether approach I'm using for working with global variables is
2016-06-19 17:18 GMT+03:00 Alexander Ivash <elderorb@xxxxxxxxx>:
What are the right places to allocate/de-allocate memory for global******************
variables in AVStream drivers?
At the moment I'm allocating memory inside DriverEntry right after
KsInitializeDriver call and de-allocate inside the hook for
'DriverUnload', which I installed also after KsInitializeDriver call.
Is it correct way of working with global variables? I'm asking because
from time to time I'm getting BSODs with the following error:
The current thread is making a bad pool request. Typically this is at
a bad IRQL level or double freeing the same allocation, etc.
Arg1: 0000000000000007, Attempt to free pool which was already freed
Arg2: 000000000000126c, (reserved)
Arg3: 0000000000080008, Memory contents of the pool block
Arg4: ffffe000f8f23f10, Address of the block of pool being deallocated
Based on the stack trace it is caused by my attempt to de-allocate
global variable. So it looks like this memory might have been already
freed by someone else, but the issue is that there should be no
'someone else'. Is there any driver-related magic involved here, like
'all the non-paged pool allocations gets unallocated automatically by
the time of DriverUnload' or something like this? What is the
recommended way of working with driver-global (not filter-specific)