dbghelp: Make elf_enum_modules a Unicode function.

This commit is contained in:
Eric Pouech 2007-02-21 21:56:17 +01:00 committed by Alexandre Julliard
parent 89bc65695f
commit 039d54a4bf
3 changed files with 19 additions and 12 deletions

View File

@ -416,7 +416,7 @@ extern void* fetch_buffer(struct process* pcs, unsigned size);
/* elf_module.c */
#define ELF_NO_MAP ((const void*)0xffffffff)
typedef BOOL (*elf_enum_modules_cb)(const char*, unsigned long addr, void* user);
typedef BOOL (*elf_enum_modules_cb)(const WCHAR*, unsigned long addr, void* user);
extern BOOL elf_enum_modules(HANDLE hProc, elf_enum_modules_cb, void*);
extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* size, DWORD* checksum);
struct elf_file_map;

View File

@ -1358,6 +1358,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
void* lm_addr;
struct link_map lm;
char bufstr[256];
WCHAR bufstrW[MAX_PATH];
if (!pcs->dbg_hdr_addr ||
!ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr,
@ -1380,7 +1381,8 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
{
bufstr[sizeof(bufstr) - 1] = '\0';
if (main_name && !bufstr[0]) strcpy(bufstr, main_name);
if (!cb(bufstr, (unsigned long)lm.l_addr, user)) break;
MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, sizeof(bufstrW) / sizeof(WCHAR));
if (!cb(bufstrW, (unsigned long)lm.l_addr, user)) break;
}
}
return TRUE;
@ -1392,11 +1394,13 @@ struct elf_sync
struct elf_info elf_info;
};
static BOOL elf_enum_sync_cb(const char* name, unsigned long addr, void* user)
static BOOL elf_enum_sync_cb(const WCHAR* name, unsigned long addr, void* user)
{
struct elf_sync* es = user;
char tmp[MAX_PATH];
elf_search_and_load_file(es->pcs, name, addr, &es->elf_info);
WideCharToMultiByte(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp), 0, 0);
elf_search_and_load_file(es->pcs, tmp, addr, &es->elf_info);
return TRUE;
}
@ -1520,10 +1524,13 @@ struct elf_load
* Callback for elf_load_module, used to walk the list of loaded
* modules.
*/
static BOOL elf_load_cb(const char* name, unsigned long addr, void* user)
static BOOL elf_load_cb(const WCHAR* nameW, unsigned long addr, void* user)
{
struct elf_load* el = user;
const char* p;
char name[MAX_PATH];
WideCharToMultiByte(CP_UNIXCP, 0, nameW, -1, name, sizeof(name), 0, 0);
/* memcmp is needed for matches when bufstr contains also version information
* el->name: libc.so, name: libc.so.6.0

View File

@ -270,22 +270,22 @@ static BOOL WINAPI fetch_pe_module_info_cb(WCHAR* name, DWORD64 base, DWORD size
*
* Callback for accumulating in dump_context an ELF modules set
*/
static BOOL fetch_elf_module_info_cb(const char* name, unsigned long base,
static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base,
void* user)
{
struct dump_context* dc = (struct dump_context*)user;
DWORD rbase, size, checksum;
WCHAR tmp[MAX_PATH];
char tmp[MAX_PATH];
/* FIXME: there's no relevant timestamp on ELF modules */
/* NB: if we have a non-null base from the live-target use it (whenever
* the ELF module is relocatable or not). If we have a null base (ELF
* module isn't relocatable) then grab its base address from ELF file
*/
if (!elf_fetch_file_info(name, &rbase, &size, &checksum))
WideCharToMultiByte(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp), 0, 0);
if (!elf_fetch_file_info(tmp, &rbase, &size, &checksum))
size = checksum = 0;
MultiByteToWideChar(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp) / sizeof(WCHAR));
add_module(dc, tmp, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
return TRUE;
}