Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mock for KeExpandKernelStackAndCalloutEx #207

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions inc/usersim/ke.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,26 @@ KeBugCheckEx(
ULONG_PTR bug_check_parameter3,
ULONG_PTR bug_check_parameter4);

typedef
_IRQL_requires_same_
_Function_class_(EXPAND_STACK_CALLOUT)
VOID
(NTAPI EXPAND_STACK_CALLOUT) (
_In_opt_ PVOID Parameter
);

typedef EXPAND_STACK_CALLOUT *PEXPAND_STACK_CALLOUT;

USERSIM_API
NTSTATUS
KeExpandKernelStackAndCalloutEx (
_In_ PEXPAND_STACK_CALLOUT Callout,
_In_opt_ PVOID Parameter,
_In_ SIZE_T Size,
_In_ BOOLEAN Wait,
_In_opt_ PVOID Context
);

CXPLAT_EXTERN_C_END

#if defined(__cplusplus)
Expand Down
19 changes: 19 additions & 0 deletions src/ke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,4 +975,23 @@ _wait_for_kevent(_Inout_ KEVENT* event, _In_opt_ PLARGE_INTEGER timeout)
}
}

NTSTATUS KeExpandKernelStackAndCalloutEx(
_In_ PEXPAND_STACK_CALLOUT Callout,
_In_opt_ PVOID Parameter,
_In_ SIZE_T Size,
_In_ BOOLEAN Wait,
_In_opt_ PVOID Context)
{
// This is a mock implementation of KeExpandKernelStackAndCalloutEx that does not
// actually expand the stack. This is sufficient for the purposes of the tests.
UNREFERENCED_PARAMETER(Size);
UNREFERENCED_PARAMETER(Wait);
UNREFERENCED_PARAMETER(Context);

// Invoke the callout function.
Callout(Parameter);

return STATUS_SUCCESS;
}

#pragma endregion events