diff --git a/dlls/dbghelp/dbghelp.spec b/dlls/dbghelp/dbghelp.spec index 8457a353c71..7ceefb77de5 100644 --- a/dlls/dbghelp/dbghelp.spec +++ b/dlls/dbghelp/dbghelp.spec @@ -3,8 +3,8 @@ @ stdcall EnumDirTree(long str str ptr ptr ptr) @ stub EnumDirTreeW @ stdcall EnumerateLoadedModules(long ptr ptr) -@ stub EnumerateLoadedModules64 -@ stub EnumerateLoadedModulesW64 +@ stdcall EnumerateLoadedModules64(long ptr ptr) +@ stdcall EnumerateLoadedModulesW64(long ptr ptr) @ stdcall ExtensionApiVersion() @ stdcall FindDebugInfoFile(str str ptr) @ stdcall FindDebugInfoFileEx(str str ptr ptr ptr) diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index ce1cc07861e..e7214b3ab20 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -620,12 +620,12 @@ BOOL WINAPI SymEnumerateModules64(HANDLE hProcess, } /****************************************************************** - * EnumerateLoadedModules (DBGHELP.@) + * EnumerateLoadedModules64 (DBGHELP.@) * */ -BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess, - PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, - PVOID UserContext) +BOOL WINAPI EnumerateLoadedModules64(HANDLE hProcess, + PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, + PVOID UserContext) { HMODULE* hMods; char base[256], mod[256]; @@ -649,7 +649,7 @@ BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess, !GetModuleBaseNameA(hProcess, hMods[i], base, sizeof(base))) continue; module_fill_module(base, mod, sizeof(mod)); - EnumLoadedModulesCallback(mod, (DWORD)mi.lpBaseOfDll, mi.SizeOfImage, + EnumLoadedModulesCallback(mod, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage, UserContext); } HeapFree(GetProcessHeap(), 0, hMods); @@ -657,6 +657,68 @@ BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess, return sz != 0 && i == sz; } +/****************************************************************** + * EnumerateLoadedModules (DBGHELP.@) + * + */ +struct enum_load_mod64_32 +{ + PENUMLOADED_MODULES_CALLBACK cb; + PVOID user; +}; + +static BOOL CALLBACK enum_load_mod64_32(PSTR name, DWORD64 base, ULONG size, + PVOID user) +{ + struct enum_load_mod64_32* x = user; + return x->cb(name, (DWORD)base, size, x->user); +} + +BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess, + PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, + PVOID UserContext) +{ + struct enum_load_mod64_32 x; + + x.cb = EnumLoadedModulesCallback; + x.user = UserContext; + + return EnumerateLoadedModules64(hProcess, enum_load_mod64_32, &x); +} + +/****************************************************************** + * EnumerateLoadedModulesW64 (DBGHELP.@) + * + */ +struct enum_load_mod64_W64 +{ + PENUMLOADED_MODULES_CALLBACKW64 cb; + PVOID user; + WCHAR module[MAX_PATH]; +}; + +static BOOL CALLBACK enum_load_mod64_W64(PSTR name, DWORD64 base, ULONG size, + PVOID user) +{ + struct enum_load_mod64_W64* x = user; + + MultiByteToWideChar(CP_ACP, 0, name, -1, + x->module, sizeof(x->module) / sizeof(WCHAR)); + return x->cb(x->module, base, size, x->user); +} + +BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, + PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, + PVOID UserContext) +{ + struct enum_load_mod64_W64 x; + + x.cb = EnumLoadedModulesCallback; + x.user = UserContext; + + return EnumerateLoadedModules64(hProcess, enum_load_mod64_W64, &x); +} + /****************************************************************** * SymGetModuleInfo (DBGHELP.@) * diff --git a/include/dbghelp.h b/include/dbghelp.h index 9afaa90a28d..3840a1e6f69 100644 --- a/include/dbghelp.h +++ b/include/dbghelp.h @@ -758,6 +758,8 @@ typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(PSTR, ULONG, ULONG, PVOID) BOOL WINAPI EnumerateLoadedModules(HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID); typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(PSTR, DWORD64, ULONG, PVOID); BOOL WINAPI EnumerateLoadedModules64(HANDLE, PENUMLOADED_MODULES_CALLBACK64, PVOID); +typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(PWSTR, DWORD64, ULONG, PVOID); +BOOL WINAPI EnumerateLoadedModulesW64(HANDLE, PENUMLOADED_MODULES_CALLBACKW64, PVOID); typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(PSTR, ULONG, PVOID); BOOL WINAPI SymEnumerateModules(HANDLE, PSYM_ENUMMODULES_CALLBACK, PVOID); typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(PSTR, DWORD64, PVOID);