ntdll: Temporarily allow KeUserModeCallback calls from client stack.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-12-09 03:15:04 +01:00 committed by Alexandre Julliard
parent a34e8c2bc3
commit 1facdbbdcb
5 changed files with 34 additions and 0 deletions

View File

@ -700,6 +700,14 @@ NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void
{
struct user_callback_frame callback_frame = { { 0 }, ret_ptr, ret_len };
/* if we have no syscall frame, call the callback directly */
if ((char *)&callback_frame < (char *)ntdll_get_thread_data()->kernel_stack ||
(char *)&callback_frame > (char *)arm_thread_data()->syscall_frame)
{
NTSTATUS (WINAPI *func)(const void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( args, len );
}
if ((char *)ntdll_get_thread_data()->kernel_stack + min_kernel_stack > (char *)&callback_frame)
return STATUS_STACK_OVERFLOW;

View File

@ -738,6 +738,14 @@ NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void
{
struct user_callback_frame callback_frame = { {{ 0 }}, ret_ptr, ret_len };
/* if we have no syscall frame, call the callback directly */
if ((char *)&callback_frame < (char *)ntdll_get_thread_data()->kernel_stack ||
(char *)&callback_frame > (char *)arm64_thread_data()->syscall_frame)
{
NTSTATUS (WINAPI *func)(const void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( args, len );
}
if ((char *)ntdll_get_thread_data()->kernel_stack + min_kernel_stack > (char *)&callback_frame)
return STATUS_STACK_OVERFLOW;

View File

@ -1569,6 +1569,14 @@ NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void
{
struct user_callback_frame callback_frame = { { 0 }, ret_ptr, ret_len };
/* if we have no syscall frame, call the callback directly */
if ((char *)&callback_frame < (char *)ntdll_get_thread_data()->kernel_stack ||
(char *)&callback_frame > (char *)x86_thread_data()->syscall_frame)
{
NTSTATUS (WINAPI *func)(const void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( args, len );
}
if ((char *)ntdll_get_thread_data()->kernel_stack + min_kernel_stack > (char *)&callback_frame)
return STATUS_STACK_OVERFLOW;

View File

@ -2293,6 +2293,14 @@ NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void
{
struct user_callback_frame callback_frame = { { 0 }, ret_ptr, ret_len };
/* if we have no syscall frame, call the callback directly */
if ((char *)&callback_frame < (char *)ntdll_get_thread_data()->kernel_stack ||
(char *)&callback_frame > (char *)amd64_thread_data()->syscall_frame)
{
NTSTATUS (WINAPI *func)(const void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( args, len );
}
if ((char *)ntdll_get_thread_data()->kernel_stack + min_kernel_stack > (char *)&callback_frame)
return STATUS_STACK_OVERFLOW;

View File

@ -80,6 +80,8 @@ extern void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp );
} \
} while (0);
NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void **ret_ptr, ULONG *ret_len );
/* wide char string functions */
static inline size_t ntdll_wcslen( const WCHAR *str )