Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/loader.c | 2 ++ dlls/ntdll/tests/rtl.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 63972f360f..d1b71efc07 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1845,6 +1845,8 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, DWORD exp_size; NTSTATUS ret = STATUS_PROCEDURE_NOT_FOUND;
+ *address = NULL; + RtlEnterCriticalSection( &loader_section );
/* check if the module itself is invalid to return the proper error */ diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index f3ed4100c1..fb90de6785 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -82,6 +82,7 @@ static BOOL (WINAPI *pRtlIsCriticalSectionLockedByThread)(CRITICAL_SECTION static NTSTATUS (WINAPI *pRtlInitializeCriticalSectionEx)(CRITICAL_SECTION *, ULONG, ULONG); static NTSTATUS (WINAPI *pLdrEnumerateLoadedModules)(void *, void *, void *); static NTSTATUS (WINAPI *pLdrGetDllFullName)(HMODULE, PUNICODE_STRING); +static NTSTATUS (WINAPI *pLdrGetProcedureAddress)(HMODULE, PCANSI_STRING, WORD, void **); static NTSTATUS (WINAPI *pLdrRegisterDllNotification)(ULONG, PLDR_DLL_NOTIFICATION_FUNCTION, void *, void **); static NTSTATUS (WINAPI *pLdrUnregisterDllNotification)(void *);
@@ -123,6 +124,7 @@ static void InitFunctionPtrs(void) pRtlInitializeCriticalSectionEx = (void *)GetProcAddress(hntdll, "RtlInitializeCriticalSectionEx"); pLdrEnumerateLoadedModules = (void *)GetProcAddress(hntdll, "LdrEnumerateLoadedModules"); pLdrGetDllFullName = (void *)GetProcAddress(hntdll, "LdrGetDllFullName"); + pLdrGetProcedureAddress = (void *)GetProcAddress(hntdll, "LdrGetProcedureAddress"); pLdrRegisterDllNotification = (void *)GetProcAddress(hntdll, "LdrRegisterDllNotification"); pLdrUnregisterDllNotification = (void *)GetProcAddress(hntdll, "LdrUnregisterDllNotification"); } @@ -3546,6 +3548,26 @@ static void test_LdrGetDllFullName(void) wine_dbgstr_w(ntdll_path), wine_dbgstr_w(path_buffer)); }
+static void test_LdrGetProcedureAddress(void) +{ + NTSTATUS status; + FARPROC fp; + + if (!pLdrGetProcedureAddress) + { + win_skip("LdrGetProcedureAddress not available\n"); + return; + } + + if (0) /* crashes on Windows */ + status = pLdrGetProcedureAddress(NULL, NULL, 0, NULL); + + fp = (FARPROC)0xdeadbeef; + status = pLdrGetProcedureAddress(NULL, NULL, 0, (void **)&fp); + ok(status == STATUS_DLL_NOT_FOUND, "Expected STATUS_DLL_NOT_FOUND, got %08x\n", status); + ok(!fp, "Expected NULL function pointer, got %p\n", fp); +} + START_TEST(rtl) { InitFunctionPtrs(); @@ -3587,4 +3609,5 @@ START_TEST(rtl) test_RtlMakeSelfRelativeSD(); test_LdrRegisterDllNotification(); test_LdrGetDllFullName(); + test_LdrGetProcedureAddress(); }