diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index 0d140a497b5..b54b4e39842 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -20,12 +20,15 @@ #include "wine/test.h" #include +#include static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR); static DWORD (WINAPI *pGetDllDirectoryW)(DWORD,LPWSTR); static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR); static BOOL (WINAPI *pGetModuleHandleExA)(DWORD,LPCSTR,HMODULE*); static BOOL (WINAPI *pGetModuleHandleExW)(DWORD,LPCWSTR,HMODULE*); +static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module, + MODULEINFO *modinfo, DWORD cb); static BOOL is_unicode_enabled = TRUE; @@ -514,7 +517,20 @@ static void init_pointers(void) MAKEFUNC(SetDllDirectoryA); MAKEFUNC(GetModuleHandleExA); MAKEFUNC(GetModuleHandleExW); + MAKEFUNC(K32GetModuleInformation); #undef MAKEFUNC + + /* not all Windows versions export this in kernel32 */ + if (!pK32GetModuleInformation) + { + HMODULE hPsapi = LoadLibraryA("psapi.dll"); + if (hPsapi) + { + pK32GetModuleInformation = (void *)GetProcAddress(hPsapi, "GetModuleInformation"); + if (!pK32GetModuleInformation) FreeLibrary(hPsapi); + } + } + } static void testGetModuleHandleEx(void) @@ -696,6 +712,34 @@ static void testGetModuleHandleEx(void) FreeLibrary( mod_kernel32 ); } +static void testK32GetModuleInformation(void) +{ + MODULEINFO info; + HMODULE mod; + BOOL ret; + + if (!pK32GetModuleInformation) + { + win_skip("K32GetModuleInformation not available\n"); + return; + } + + mod = GetModuleHandleA(NULL); + memset(&info, 0xAA, sizeof(info)); + ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info)); + ok(ret, "K32GetModuleInformation failed for main module\n"); + ok(info.lpBaseOfDll == mod, "Wrong info.lpBaseOfDll = %p, expected %p\n", info.lpBaseOfDll, mod); + todo_wine + ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n"); + + mod = GetModuleHandleA("kernel32.dll"); + memset(&info, 0xAA, sizeof(info)); + ret = pK32GetModuleInformation(GetCurrentProcess(), mod, &info, sizeof(info)); + ok(ret, "K32GetModuleInformation failed for kernel32 module\n"); + ok(info.lpBaseOfDll == mod, "Wrong info.lpBaseOfDll = %p, expected %p\n", info.lpBaseOfDll, mod); + ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n"); +} + START_TEST(module) { WCHAR filenameW[MAX_PATH]; @@ -724,4 +768,5 @@ START_TEST(module) testGetProcAddress_Wrong(); testLoadLibraryEx(); testGetModuleHandleEx(); + testK32GetModuleInformation(); }