Sebastian Lackner : kernel32/tests: Add tests for K32GetModuleInformation.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Oct 7 14:49:56 CDT 2014
Module: wine
Branch: master
Commit: 9d30002f7db68fc7facf280d65d58967f081ad68
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9d30002f7db68fc7facf280d65d58967f081ad68
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Wed Oct 1 15:54:51 2014 +0200
kernel32/tests: Add tests for K32GetModuleInformation.
---
dlls/kernel32/tests/module.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c
index 0d140a4..b54b4e3 100644
--- a/dlls/kernel32/tests/module.c
+++ b/dlls/kernel32/tests/module.c
@@ -20,12 +20,15 @@
#include "wine/test.h"
#include <windows.h>
+#include <psapi.h>
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();
}
More information about the wine-cvs
mailing list