Commit 039d54a4 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Make elf_enum_modules a Unicode function.

parent 89bc6569
...@@ -416,7 +416,7 @@ extern void* fetch_buffer(struct process* pcs, unsigned size); ...@@ -416,7 +416,7 @@ extern void* fetch_buffer(struct process* pcs, unsigned size);
/* elf_module.c */ /* elf_module.c */
#define ELF_NO_MAP ((const void*)0xffffffff) #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_enum_modules(HANDLE hProc, elf_enum_modules_cb, void*);
extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* size, DWORD* checksum); extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* size, DWORD* checksum);
struct elf_file_map; struct elf_file_map;
......
...@@ -1358,6 +1358,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, ...@@ -1358,6 +1358,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
void* lm_addr; void* lm_addr;
struct link_map lm; struct link_map lm;
char bufstr[256]; char bufstr[256];
WCHAR bufstrW[MAX_PATH];
if (!pcs->dbg_hdr_addr || if (!pcs->dbg_hdr_addr ||
!ReadProcessMemory(pcs->handle, (void*)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, ...@@ -1380,7 +1381,8 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
{ {
bufstr[sizeof(bufstr) - 1] = '\0'; bufstr[sizeof(bufstr) - 1] = '\0';
if (main_name && !bufstr[0]) strcpy(bufstr, main_name); 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; return TRUE;
...@@ -1392,11 +1394,13 @@ struct elf_sync ...@@ -1392,11 +1394,13 @@ struct elf_sync
struct elf_info elf_info; 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; 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; return TRUE;
} }
...@@ -1520,10 +1524,13 @@ struct elf_load ...@@ -1520,10 +1524,13 @@ struct elf_load
* Callback for elf_load_module, used to walk the list of loaded * Callback for elf_load_module, used to walk the list of loaded
* modules. * 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; struct elf_load* el = user;
const char* p; 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 /* memcmp is needed for matches when bufstr contains also version information
* el->name: libc.so, name: libc.so.6.0 * el->name: libc.so, name: libc.so.6.0
......
...@@ -270,22 +270,22 @@ static BOOL WINAPI fetch_pe_module_info_cb(WCHAR* name, DWORD64 base, DWORD size ...@@ -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 * 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) void* user)
{ {
struct dump_context* dc = (struct dump_context*)user; struct dump_context* dc = (struct dump_context*)user;
DWORD rbase, size, checksum; DWORD rbase, size, checksum;
WCHAR tmp[MAX_PATH]; char tmp[MAX_PATH];
/* FIXME: there's no relevant timestamp on ELF modules */ /* FIXME: there's no relevant timestamp on ELF modules */
/* NB: if we have a non-null base from the live-target use it (whenever /* 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 * 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 * 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; size = checksum = 0;
MultiByteToWideChar(CP_UNIXCP, 0, name, -1, tmp, sizeof(tmp) / sizeof(WCHAR)); add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
add_module(dc, tmp, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
return TRUE; return TRUE;
} }
......
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