I have a question about KeDelayExecutionThread().

Do I understand the documentation correctly: If I call
KeDelayExecutionThread() to block in my IRP_MJ_WRITE handler, and the
thread which called WriteFile() is terminated by TerminateThread(),
will Ke... return immediately, no matter what I specify for the
Alertable parameter?

Thorsten

Re: Blocking in IRP_MJ_WRITE, KeDelayExecutionThread, threads by Nick

Nick
Fri Sep 05 18:34:27 CDT 2003

Yes, as long as WaitMode==UserMode. TerminateThread works in an odd way.
It first schedules a normal kernel-mode APC, which, when executed,
schedules a special user-mode APC and sets a flag in the thread
structure. This flag causes KeDelayExecutionThread() (or whatever wait
function the thread invoked) to return even if the Alertable parameter
is set to FALSE. The thread finally exits when it returns to user-mode
and the APC is executed.

Thorsten Jens wrote:

> I have a question about KeDelayExecutionThread().
>
> Do I understand the documentation correctly: If I call
> KeDelayExecutionThread() to block in my IRP_MJ_WRITE handler, and the
> thread which called WriteFile() is terminated by TerminateThread(),
> will Ke... return immediately, no matter what I specify for the
> Alertable parameter?
>
> Thorsten

--
Nick Ryan (MVP for DDK)


Re: Blocking in IRP_MJ_WRITE, KeDelayExecutionThread, threads by thojens

thojens
Mon Sep 08 05:39:54 CDT 2003

Nick Ryan <nryan@nryan.com>:
> Yes, as long as WaitMode==UserMode. TerminateThread works in an odd way.
> It first schedules a normal kernel-mode APC, which, when executed,
> schedules a special user-mode APC and sets a flag in the thread
> structure. This flag causes KeDelayExecutionThread() (or whatever wait
> function the thread invoked) to return even if the Alertable parameter
> is set to FALSE. The thread finally exits when it returns to user-mode
> and the APC is executed.

I see. Thanks.

Thorsten