Skip to content

Add KeDelayExecutionThread mock - #323

Draft
D. Michael Agun (mikeagun) wants to merge 1 commit into
microsoft:mainfrom
mikeagun:add-kedelay-execution-thread-mock
Draft

D. Michael Agun (mikeagun) wants to merge 1 commit into
microsoft:mainfrom
mikeagun:add-kedelay-execution-thread-mock

Conversation

@mikeagun

Copy link
Copy Markdown
Contributor

Description

Adds a user-mode mock for KeDelayExecutionThread, the WDM primitive a kernel thread uses to delay its own execution for a relative or absolute interval. This API was not previously provided by usersim.

Changes

  • inc/usersim/ke.h — declares KeDelayExecutionThread with SAL matching the WDK wdm.h contract (_IRQL_requires_min_(PASSIVE_LEVEL), _IRQL_requires_max_(APC_LEVEL)).
  • src/ke.cpp — mock implementation. A negative Interval is a delay relative to the current time and is converted from 100-ns units to milliseconds (rounded up) and passed to Sleep; a non-negative (absolute) Interval is not tracked by the mock and is treated as no delay. Returns STATUS_SUCCESS (non-alertable waits only; STATUS_ALERTED/STATUS_USER_APC are not modeled).
  • tests/ke_test.cpp — adds a KeDelayExecutionThread test verifying that a relative interval blocks for at least the requested duration (conservative lower bound to avoid timer-granularity flakiness) and that a zero interval returns immediately.

Testing

usersim unit tests ([ke] tag) green, Debug + Release x64.

Add a user-mode mock for KeDelayExecutionThread, the WDM primitive a kernel
thread uses to delay its own execution for a relative or absolute interval.
This API was not previously provided by usersim.

- inc/usersim/ke.h: declare KeDelayExecutionThread with SAL matching the WDK
  wdm.h contract (_IRQL_requires_min_(PASSIVE_LEVEL), _IRQL_requires_max_(APC_LEVEL)).
- src/ke.cpp: mock implementation. A negative Interval is a delay relative to
  the current time, converted from 100-ns units to milliseconds (rounded up)
  and passed to Sleep; a non-negative (absolute) Interval is not tracked by the
  mock and is treated as no delay. Returns STATUS_SUCCESS (non-alertable waits
  only; STATUS_ALERTED/STATUS_USER_APC are not modeled).
- tests/ke_test.cpp: add a test verifying a relative interval blocks for at
  least the requested duration and a zero interval returns immediately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3e1f4d8c-9f26-40cc-ae7d-089fa6c8f959
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant