A forum for reverse engineering, OS internals and malware analysis 

Forum for discussion about kernel-mode development.
 #7770  by EP_X0FF
 Fri Jul 29, 2011 4:25 pm
Make this local variable dynamic or move to global.
Unless you have any waiting after PsCreateSystemThread.
 #7772  by Alex
 Fri Jul 29, 2011 5:58 pm
Tigzy wrote:you're right the variable must be destroyed at the end of the function...
Which "variable must be destroyed at the end of the function"? If you will move it (the struct) to global you don't need to do anything, but if you will allocate a chunk of kernel pool, than yes, you will need to free (somewhere) this memory. I don't see in the code you've posted calling of ZwClose for thread handle and PsTerminateSystemThread called from inside of thread routine (see documentation), proper initialization of ObjectAttributes (depending on process context).

PsCreateSystemThread Routine
I've Got Work To Do - Worker Threads & Work Queues