dbghelp: Rewrote the loaded modules enumeration so that Unicode version is the core.
This commit is contained in:
parent
aac77c98a2
commit
fcd3972fa8
|
@ -628,12 +628,76 @@ BOOL WINAPI SymEnumerateModules64(HANDLE hProcess,
|
|||
* EnumerateLoadedModules64 (DBGHELP.@)
|
||||
*
|
||||
*/
|
||||
struct enum_load_modW64_64
|
||||
{
|
||||
PENUMLOADED_MODULES_CALLBACK64 cb;
|
||||
PVOID user;
|
||||
char module[MAX_PATH];
|
||||
};
|
||||
|
||||
static BOOL CALLBACK enum_load_modW64_64(PWSTR name, DWORD64 base, ULONG size,
|
||||
PVOID user)
|
||||
{
|
||||
struct enum_load_modW64_64* x = user;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
|
||||
return x->cb(x->module, base, size, x->user);
|
||||
}
|
||||
|
||||
BOOL WINAPI EnumerateLoadedModules64(HANDLE hProcess,
|
||||
PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,
|
||||
PVOID UserContext)
|
||||
{
|
||||
struct enum_load_modW64_64 x;
|
||||
|
||||
x.cb = EnumLoadedModulesCallback;
|
||||
x.user = UserContext;
|
||||
|
||||
return EnumerateLoadedModulesW64(hProcess, enum_load_modW64_64, &x);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* EnumerateLoadedModules (DBGHELP.@)
|
||||
*
|
||||
*/
|
||||
struct enum_load_modW64_32
|
||||
{
|
||||
PENUMLOADED_MODULES_CALLBACK cb;
|
||||
PVOID user;
|
||||
char module[MAX_PATH];
|
||||
};
|
||||
|
||||
static BOOL CALLBACK enum_load_modW64_32(PWSTR name, DWORD64 base, ULONG size,
|
||||
PVOID user)
|
||||
{
|
||||
struct enum_load_modW64_32* x = user;
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
|
||||
return x->cb(x->module, (DWORD)base, size, x->user);
|
||||
}
|
||||
|
||||
BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess,
|
||||
PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
|
||||
PVOID UserContext)
|
||||
{
|
||||
struct enum_load_modW64_32 x;
|
||||
|
||||
x.cb = EnumLoadedModulesCallback;
|
||||
x.user = UserContext;
|
||||
|
||||
return EnumerateLoadedModulesW64(hProcess, enum_load_modW64_32, &x);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* EnumerateLoadedModulesW64 (DBGHELP.@)
|
||||
*
|
||||
*/
|
||||
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess,
|
||||
PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback,
|
||||
PVOID UserContext)
|
||||
{
|
||||
HMODULE* hMods;
|
||||
char base[256], mod[256];
|
||||
WCHAR modW[256];
|
||||
DWORD i, sz;
|
||||
MODULEINFO mi;
|
||||
|
||||
|
@ -654,7 +718,8 @@ BOOL WINAPI EnumerateLoadedModules64(HANDLE hProcess,
|
|||
!GetModuleBaseNameA(hProcess, hMods[i], base, sizeof(base)))
|
||||
continue;
|
||||
module_fill_module(base, mod, sizeof(mod));
|
||||
EnumLoadedModulesCallback(mod, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
|
||||
MultiByteToWideChar(CP_ACP, 0, mod, -1, modW, sizeof(modW) / sizeof(modW));
|
||||
EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
|
||||
UserContext);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, hMods);
|
||||
|
@ -662,68 +727,6 @@ BOOL WINAPI EnumerateLoadedModules64(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.@)
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue