Re: Can TerminateThread() kill a thread that has entered the kernel?

Tech-Archive recommends: Speed Up your PC by fixing your registry




"Maxim S. Shatskih" <maxim@xxxxxxxxxxxxxxxx> wrote in message
news:u8sBHD8wGHA.4972@xxxxxxxxxxxxxxxxxxxxxxx
Is is possible for one user mode thread, say thread A, to kill (via
TermiateThread() ) another user mode thread, thread B, while thread B
is called into a kernel driver via DeviceIoControl()?

Yes. It will be terminated on return from the kernel to user, after
running
through your DispatchIoctl path.

Also, KeWaitForSingleObject(UserMode) will be abruptly interrupted, and
the
function will return STATUS_USER_APC. KeWaitForSingleObject(KernelMode) -
will
not, the thread termination will be delayed till the wait will be
satisfied.

In no way TerminateThread can interrupt kernel mode code execution.

I am seeing a strange problem and the only way I can explain it, so
far, is if a user thread calls into my driver and is terminated before
it finishes the execution of one of my functions.

Impossible.

These are the best kinds of conversations... the problem is researched by
the OP, their understanding of it stated as clearly as possible, and the
answer is unequivocal.




.



Relevant Pages