A forum for reverse engineering, OS internals and malware analysis 

Forum for discussion about kernel-mode development.
 #22014  by Vrtule
 Tue Jan 21, 2014 9:17 am
Hello,

when thread A calls (Nt/Zw)TerminateThread in order to terminate thread B, the B thread does not disappear at once. A special user APC is scheduled to it and is serviced only in certain points of execution.

Does anybody have some information about when the special user (termination) APC is actually serviced? I know that one execution point is when the target thread just performed a system call (NtXXX function) triggered from user mode, and is just about to return there (to user mode). Are special user APCs serviced in the same place even if the target thread is returning from a system call triggered from kernel mode (ZwXXX function)? Are there other execution points as well?

Thanks in advance
Vrtule