Commit 07efff4e authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernelbase: Let GetModuleBaseName succeed on 64bit modules in wow64.

parent c56971ff
...@@ -876,6 +876,13 @@ static BOOL get_ldr_module32( HANDLE process, HMODULE module, LDR_DATA_TABLE_ENT ...@@ -876,6 +876,13 @@ static BOOL get_ldr_module32( HANDLE process, HMODULE module, LDR_DATA_TABLE_ENT
struct module_iterator iter; struct module_iterator iter;
INT ret; INT ret;
#ifdef _WIN64
if ((ULONG_PTR)module >> 32)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
#endif
if (!init_module_iterator( &iter, process, TRUE )) return FALSE; if (!init_module_iterator( &iter, process, TRUE )) return FALSE;
while ((ret = module_iterator_next( &iter )) > 0) while ((ret = module_iterator_next( &iter )) > 0)
...@@ -1320,7 +1327,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameA( HANDLE process, HMODULE modul ...@@ -1320,7 +1327,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameA( HANDLE process, HMODULE modul
DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE module, DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE module,
WCHAR *name, DWORD size ) WCHAR *name, DWORD size )
{ {
BOOL wow64; BOOL wow64, found = FALSE;
if (!IsWow64Process( process, &wow64 )) return 0; if (!IsWow64Process( process, &wow64 )) return 0;
...@@ -1328,13 +1335,15 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE modul ...@@ -1328,13 +1335,15 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleBaseNameW( HANDLE process, HMODULE modul
{ {
LDR_DATA_TABLE_ENTRY32 ldr_module32; LDR_DATA_TABLE_ENTRY32 ldr_module32;
if (!get_ldr_module32(process, module, &ldr_module32)) return 0; if (get_ldr_module32(process, module, &ldr_module32))
{
size = min( ldr_module32.BaseDllName.Length / sizeof(WCHAR), size ); size = min( ldr_module32.BaseDllName.Length / sizeof(WCHAR), size );
if (!ReadProcessMemory( process, (void *)(DWORD_PTR)ldr_module32.BaseDllName.Buffer, if (ReadProcessMemory( process, (void *)(DWORD_PTR)ldr_module32.BaseDllName.Buffer,
name, size * sizeof(WCHAR), NULL )) name, size * sizeof(WCHAR), NULL ))
return 0; found = TRUE;
} }
else }
if (!found)
{ {
LDR_DATA_TABLE_ENTRY ldr_module; LDR_DATA_TABLE_ENTRY ldr_module;
......
...@@ -241,7 +241,6 @@ static BOOL test_EnumProcessModulesEx_snapshot(HANDLE proc, struct moduleex_snap ...@@ -241,7 +241,6 @@ static BOOL test_EnumProcessModulesEx_snapshot(HANDLE proc, struct moduleex_snap
case LIST_MODULES_64BIT: break; case LIST_MODULES_64BIT: break;
} }
ret = GetModuleBaseNameA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer)); ret = GetModuleBaseNameA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer));
todo_wine_if(fail)
ok(ret, "GetModuleBaseName failed: %lu (%u/%lu=%p)\n", GetLastError(), j, mxsnap[i].num_modules, mxsnap[i].modules[j]); ok(ret, "GetModuleBaseName failed: %lu (%u/%lu=%p)\n", GetLastError(), j, mxsnap[i].num_modules, mxsnap[i].modules[j]);
ret = GetModuleFileNameExA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer)); ret = GetModuleFileNameExA(proc, mxsnap[i].modules[j], buffer, sizeof(buffer));
todo_wine_if(fail) todo_wine_if(fail)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment