From 4505ef6cfde3eb7bc60f069e4a6db40cb67cfac2 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 6 Feb 2019 23:35:00 +0100 Subject: [PATCH] ntoskrnl.exe/tests: Introduce get_proc_address helper. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a patch by Michael Müller. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/ntoskrnl.exe/tests/driver.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index da316b85f19..5897ac0a14f 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -174,6 +174,23 @@ static void winetest_end_todo(void) #define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine) #define win_skip(...) win_skip_(__FILE__, __LINE__, __VA_ARGS__) +static void *get_proc_address(const char *name) +{ + UNICODE_STRING name_u; + ANSI_STRING name_a; + NTSTATUS status; + void *ret; + + RtlInitAnsiString(&name_a, name); + status = RtlAnsiStringToUnicodeString(&name_u, &name_a, TRUE); + ok (!status, "RtlAnsiStringToUnicodeString failed: %#x\n", status); + if (status) return NULL; + + ret = MmGetSystemRoutineAddress(&name_u); + RtlFreeUnicodeString(&name_u); + return ret; +} + static void test_currentprocess(void) { PEPROCESS current; @@ -555,17 +572,9 @@ static void test_stack_callout(void) { NTSTATUS (WINAPI *pKeExpandKernelStackAndCallout)(PEXPAND_STACK_CALLOUT,void*,SIZE_T); NTSTATUS (WINAPI *pKeExpandKernelStackAndCalloutEx)(PEXPAND_STACK_CALLOUT,void*,SIZE_T,BOOLEAN,void*); - UNICODE_STRING str; NTSTATUS ret; - static const WCHAR KeExpandKernelStackAndCalloutW[] = - {'K','e','E','x','p','a','n','d','K','e','r','n','e','l','S','t','a','c','k','A','n','d','C','a','l','l','o','u','t',0}; - static const WCHAR KeExpandKernelStackAndCalloutExW[] = - {'K','e','E','x','p','a','n','d','K','e','r','n','e','l','S','t','a','c','k','A','n','d','C','a','l','l','o','u','t','E','x',0}; - - - RtlInitUnicodeString(&str, KeExpandKernelStackAndCalloutW); - pKeExpandKernelStackAndCallout = MmGetSystemRoutineAddress(&str); + pKeExpandKernelStackAndCallout = get_proc_address("KeExpandKernelStackAndCallout"); if (pKeExpandKernelStackAndCallout) { callout_cnt = 0; @@ -575,8 +584,7 @@ static void test_stack_callout(void) } else win_skip("KeExpandKernelStackAndCallout is not available\n"); - RtlInitUnicodeString(&str, KeExpandKernelStackAndCalloutExW); - pKeExpandKernelStackAndCalloutEx = MmGetSystemRoutineAddress(&str); + pKeExpandKernelStackAndCalloutEx = get_proc_address("KeExpandKernelStackAndCalloutEx"); if (pKeExpandKernelStackAndCalloutEx) { callout_cnt = 0;