From: Eric Pouech eric.pouech@gmail.com
Signed-off-by: Eric Pouech eric.pouech@gmail.com --- dlls/dbghelp/tests/dbghelp.c | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
diff --git a/dlls/dbghelp/tests/dbghelp.c b/dlls/dbghelp/tests/dbghelp.c index 73f8ee5f14f..85ec3ce1dbb 100644 --- a/dlls/dbghelp/tests/dbghelp.c +++ b/dlls/dbghelp/tests/dbghelp.c @@ -190,6 +190,70 @@ static void test_search_path(void) ok(!strcmp(search_path, "."), "Got search path '%s', expected '.'\n", search_path); }
+static const USHORT machines[2] = +{ +#if defined(__i386__) || defined( __x86_64__) + IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_I386 +#elif defined(__i386__) || defined( __x86_64__) + IMAGE_FILE_MACHINE_ARM64, IMAGE_FILE_MACHINE_ARM +#else +#error To be defined for your processor +#endif +}; + +static void test_modules(void) +{ + BOOL ret; + DWORD attr; + const DWORD64 base1 = 0x00010000; + const DWORD64 base2 = 0x08010000; + IMAGEHLP_MODULEW64 im; + + im.SizeOfStruct = sizeof(im); + + /* can sym load an exec of different bitness even if 32Bit flag not set */ + + SymSetOptions(SymGetOptions() & ~SYMOPT_INCLUDE_32BIT_MODULES); + ret = SymInitialize(GetCurrentProcess(), 0, FALSE); + ok(ret, "SymInitialize failed: %lu\n", GetLastError()); + + /* not always present */ + attr = GetFileAttributesA("C:\windows\syswow64\notepad.exe"); + todo_wine_if(sizeof(void*) == 8) + if (attr != INVALID_FILE_ATTRIBUTES) + { + ret = SymLoadModule(GetCurrentProcess(), NULL, "C:\windows\syswow64\notepad.exe", NULL, base2, 0); + ok(ret, "SymLoadModule failed: %lu\n", GetLastError()); + ret = SymGetModuleInfoW64(GetCurrentProcess(), base2, &im); + ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError()); + ok(im.BaseOfImage == base2, "Wrong base address\n"); + ok(im.MachineType == machines[1], + "Wrong machine %lx\n", im.MachineType); + } + + ret = SymLoadModule(GetCurrentProcess(), NULL, "C:\windows\system32\notepad.exe", NULL, base1, 0); + ok(ret, "SymLoadModule failed: %lu\n", GetLastError()); + ret = SymGetModuleInfoW64(GetCurrentProcess(), base1, &im); + ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError()); + ok(im.BaseOfImage == base1, "Wrong base address\n"); + ok(im.MachineType == (sizeof(void*) == 8) ? machines[0] : machines[1], + "Wrong machine %lx\n", im.MachineType); + + /* still can access first module after loading second */ + todo_wine_if(sizeof(void*) == 8) + if (attr != INVALID_FILE_ATTRIBUTES) + { + ret = SymGetModuleInfoW64(GetCurrentProcess(), base2, &im); + ok(ret, "SymGetModuleInfoW64 failed: %lu\n", GetLastError()); + ok(im.BaseOfImage == base2, "Wrong base address\n"); + ok(im.MachineType == machines[1], + "Wrong machine %lx\n", im.MachineType); + } + + ret = SymCleanup(GetCurrentProcess()); + ok(ret, "SymCleanup failed: %lu\n", GetLastError()); +} + START_TEST(dbghelp) { BOOL ret; @@ -206,4 +270,6 @@ START_TEST(dbghelp)
ret = SymCleanup(GetCurrentProcess()); ok(ret, "got error %lu\n", GetLastError()); + + test_modules(); }