ntoskrnl.exe/tests: Introduce get_proc_address helper.

Based on a patch by Michael Müller.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-02-06 23:35:00 +01:00 committed by Alexandre Julliard
parent 4498648ec1
commit 4505ef6cfd
1 changed files with 19 additions and 11 deletions

View File

@ -174,6 +174,23 @@ static void winetest_end_todo(void)
#define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine) #define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine)
#define win_skip(...) win_skip_(__FILE__, __LINE__, __VA_ARGS__) #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) static void test_currentprocess(void)
{ {
PEPROCESS current; PEPROCESS current;
@ -555,17 +572,9 @@ static void test_stack_callout(void)
{ {
NTSTATUS (WINAPI *pKeExpandKernelStackAndCallout)(PEXPAND_STACK_CALLOUT,void*,SIZE_T); NTSTATUS (WINAPI *pKeExpandKernelStackAndCallout)(PEXPAND_STACK_CALLOUT,void*,SIZE_T);
NTSTATUS (WINAPI *pKeExpandKernelStackAndCalloutEx)(PEXPAND_STACK_CALLOUT,void*,SIZE_T,BOOLEAN,void*); NTSTATUS (WINAPI *pKeExpandKernelStackAndCalloutEx)(PEXPAND_STACK_CALLOUT,void*,SIZE_T,BOOLEAN,void*);
UNICODE_STRING str;
NTSTATUS ret; NTSTATUS ret;
static const WCHAR KeExpandKernelStackAndCalloutW[] = pKeExpandKernelStackAndCallout = get_proc_address("KeExpandKernelStackAndCallout");
{'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);
if (pKeExpandKernelStackAndCallout) if (pKeExpandKernelStackAndCallout)
{ {
callout_cnt = 0; callout_cnt = 0;
@ -575,8 +584,7 @@ static void test_stack_callout(void)
} }
else win_skip("KeExpandKernelStackAndCallout is not available\n"); else win_skip("KeExpandKernelStackAndCallout is not available\n");
RtlInitUnicodeString(&str, KeExpandKernelStackAndCalloutExW); pKeExpandKernelStackAndCalloutEx = get_proc_address("KeExpandKernelStackAndCalloutEx");
pKeExpandKernelStackAndCalloutEx = MmGetSystemRoutineAddress(&str);
if (pKeExpandKernelStackAndCalloutEx) if (pKeExpandKernelStackAndCalloutEx)
{ {
callout_cnt = 0; callout_cnt = 0;