Hello,
I just want to know If am getting the facts right:
The point of my interest now are special kernel-mode APCs. Let's have a thread that is executing code somewhere inside my driver. The code performs memory allocations and other standard operations. If special kernel-mode APCs are enabled, the thread can "disappear" (be terminated by a call to TerminateThread from user-mode) in any moment, am I right? Well, threads of the System process maybe not but let's talk about the regular threads.
So, if my code performs a series of memory allocations it have to use guarded region, so the thread cannot be terminated just in the middle of the allocations which would imply a memory leak. And when the series of memory allocations finishes and the thread is about to leave the guarded region, it should make a note somewhere because it must deallocate the memory even in case somebody terminates it violently. I think these deallocations can be performed inside Thread Notify Callback registered by a call to PsSetCreateThreadNotifyRoutine.
Am I correct? Or am I missing something that leads me to posting these (maybe stupid) questions?
I just want to know If am getting the facts right:
The point of my interest now are special kernel-mode APCs. Let's have a thread that is executing code somewhere inside my driver. The code performs memory allocations and other standard operations. If special kernel-mode APCs are enabled, the thread can "disappear" (be terminated by a call to TerminateThread from user-mode) in any moment, am I right? Well, threads of the System process maybe not but let's talk about the regular threads.
So, if my code performs a series of memory allocations it have to use guarded region, so the thread cannot be terminated just in the middle of the allocations which would imply a memory leak. And when the series of memory allocations finishes and the thread is about to leave the guarded region, it should make a note somewhere because it must deallocate the memory even in case somebody terminates it violently. I think these deallocations can be performed inside Thread Notify Callback registered by a call to PsSetCreateThreadNotifyRoutine.
Am I correct? Or am I missing something that leads me to posting these (maybe stupid) questions?