Alexandre Julliard : ntdll/tests: Add tests for 64-bit modules in Wow64 mode.
Alexandre Julliard
julliard at winehq.org
Wed Jun 30 16:10:59 CDT 2021
Module: wine
Branch: master
Commit: 7700467a38408b7a4161e2a180f00abdf466164c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7700467a38408b7a4161e2a180f00abdf466164c
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Jun 30 11:11:32 2021 +0200
ntdll/tests: Add tests for 64-bit modules in Wow64 mode.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/tests/wow64.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c
index 8065221c416..d31afa373e2 100644
--- a/dlls/ntdll/tests/wow64.c
+++ b/dlls/ntdll/tests/wow64.c
@@ -463,6 +463,94 @@ static void test_cpu_area(void)
#else /* _WIN64 */
+static ULONG64 main_module, ntdll_module, wow64_module, wow64cpu_module, wow64win_module;
+
+static void enum_modules64( void (*func)(ULONG64,const WCHAR *) )
+{
+ typedef struct
+ {
+ LIST_ENTRY64 InLoadOrderLinks;
+ LIST_ENTRY64 InMemoryOrderLinks;
+ LIST_ENTRY64 InInitializationOrderLinks;
+ ULONG64 DllBase;
+ ULONG64 EntryPoint;
+ ULONG SizeOfImage;
+ UNICODE_STRING64 FullDllName;
+ UNICODE_STRING64 BaseDllName;
+ /* etc. */
+ } LDR_DATA_TABLE_ENTRY64;
+
+ TEB64 *teb64 = (TEB64 *)NtCurrentTeb()->GdiBatchCount;
+ PEB64 peb64;
+ ULONG64 ptr;
+ PEB_LDR_DATA64 ldr;
+ LDR_DATA_TABLE_ENTRY64 entry;
+ NTSTATUS status;
+ HANDLE process;
+
+ process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId() );
+ ok( process != 0, "failed to open current process %u\n", GetLastError() );
+ status = pNtWow64ReadVirtualMemory64( process, teb64->Peb, &peb64, sizeof(peb64), NULL );
+ ok( !status, "NtWow64ReadVirtualMemory64 failed %x\n", status );
+ todo_wine
+ ok( peb64.LdrData, "LdrData not initialized\n" );
+ if (!peb64.LdrData) goto done;
+ status = pNtWow64ReadVirtualMemory64( process, peb64.LdrData, &ldr, sizeof(ldr), NULL );
+ ok( !status, "NtWow64ReadVirtualMemory64 failed %x\n", status );
+ ptr = ldr.InLoadOrderModuleList.Flink;
+ for (;;)
+ {
+ WCHAR buffer[256];
+ status = pNtWow64ReadVirtualMemory64( process, ptr, &entry, sizeof(entry), NULL );
+ ok( !status, "NtWow64ReadVirtualMemory64 failed %x\n", status );
+ status = pNtWow64ReadVirtualMemory64( process, entry.BaseDllName.Buffer, buffer, sizeof(buffer), NULL );
+ ok( !status, "NtWow64ReadVirtualMemory64 failed %x\n", status );
+ if (status) break;
+ func( entry.DllBase, buffer );
+ ptr = entry.InLoadOrderLinks.Flink;
+ if (ptr == peb64.LdrData + offsetof( PEB_LDR_DATA64, InLoadOrderModuleList )) break;
+ }
+done:
+ NtClose( process );
+}
+
+static void check_module( ULONG64 base, const WCHAR *name )
+{
+ if (base == (ULONG_PTR)GetModuleHandleW(0))
+ {
+ WCHAR *p, module[MAX_PATH];
+
+ GetModuleFileNameW( 0, module, MAX_PATH );
+ if ((p = wcsrchr( module, '\\' ))) p++;
+ else p = module;
+ ok( !wcsicmp( name, p ), "wrong name %s / %s\n", debugstr_w(name), debugstr_w(module));
+ main_module = base;
+ return;
+ }
+#define CHECK_MODULE(mod) if (!wcsicmp( name, L"" #mod ".dll" )) { mod ## _module = base; return; }
+ CHECK_MODULE(ntdll);
+ CHECK_MODULE(wow64);
+ CHECK_MODULE(wow64cpu);
+ CHECK_MODULE(wow64win);
+#undef CHECK_MODULE
+ ok( 0, "unknown module %s %s found\n", wine_dbgstr_longlong(base), wine_dbgstr_w(name));
+}
+
+static void test_modules(void)
+{
+ if (!is_wow64) return;
+ if (!pNtWow64ReadVirtualMemory64) return;
+ enum_modules64( check_module );
+ todo_wine
+ {
+ ok( main_module, "main module not found\n" );
+ ok( ntdll_module, "64-bit ntdll not found\n" );
+ ok( wow64_module, "wow64.dll not found\n" );
+ ok( wow64cpu_module, "wow64cpu.dll not found\n" );
+ ok( wow64win_module, "wow64win.dll not found\n" );
+ }
+}
+
static void test_nt_wow64(void)
{
const char str[] = "hello wow64";
@@ -574,5 +662,6 @@ START_TEST(wow64)
test_cpu_area();
#else
test_nt_wow64();
+ test_modules();
#endif
}
More information about the wine-cvs
mailing list