Commit 46684a9f authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Moved ELF module loading interfaces to Unicode.

The core the code remains ANSI, as all the information is stored as ANSI.
parent 6a859fb0
...@@ -422,7 +422,7 @@ extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* si ...@@ -422,7 +422,7 @@ extern BOOL elf_fetch_file_info(const char* name, DWORD* base, DWORD* si
struct elf_file_map; struct elf_file_map;
extern BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap); extern BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap);
extern struct module* extern struct module*
elf_load_module(struct process* pcs, const char* name, unsigned long); elf_load_module(struct process* pcs, const WCHAR* name, unsigned long);
extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs); extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs);
extern BOOL elf_synchronize_module_list(struct process* pcs); extern BOOL elf_synchronize_module_list(struct process* pcs);
struct elf_thunk_area; struct elf_thunk_area;
...@@ -449,11 +449,6 @@ extern struct module* ...@@ -449,11 +449,6 @@ extern struct module*
unsigned long addr, unsigned long size, unsigned long addr, unsigned long size,
unsigned long stamp, unsigned long checksum); unsigned long stamp, unsigned long checksum);
extern struct module* extern struct module*
module_newA(struct process* pcs, const char* name,
enum module_type type, BOOL virtual,
unsigned long addr, unsigned long size,
unsigned long stamp, unsigned long checksum);
extern struct module*
module_get_container(const struct process* pcs, module_get_container(const struct process* pcs,
const struct module* inner); const struct module* inner);
extern struct module* extern struct module*
......
...@@ -1063,7 +1063,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module, ...@@ -1063,7 +1063,7 @@ static BOOL elf_load_debug_info_from_map(struct module* module,
dbg_link = (const BYTE*) elf_map_section(fmap, debuglink_sect); dbg_link = (const BYTE*) elf_map_section(fmap, debuglink_sect);
if (dbg_link != ELF_NO_MAP) if (dbg_link != ELF_NO_MAP)
{ {
lret = elf_debuglink_parse (module, pool, ht_symtab, dbg_link); lret = elf_debuglink_parse(module, pool, ht_symtab, dbg_link);
if (!lret) if (!lret)
WARN("Couldn't load linked debug file for %s\n", WARN("Couldn't load linked debug file for %s\n",
debugstr_w(module->module.ModuleName)); debugstr_w(module->module.ModuleName));
...@@ -1111,7 +1111,7 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap) ...@@ -1111,7 +1111,7 @@ BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
char LoadedImageName[MAX_PATH]; char LoadedImageName[MAX_PATH];
fmap = &my_fmap; fmap = &my_fmap;
WideCharToMultiByte(CP_ACP, 0, module->module.LoadedImageName, -1, WideCharToMultiByte(CP_UNIXCP, 0, module->module.LoadedImageName, -1,
LoadedImageName, MAX_PATH, NULL, NULL); LoadedImageName, MAX_PATH, NULL, NULL);
ret = elf_map_file(LoadedImageName, fmap); ret = elf_map_file(LoadedImageName, fmap);
} }
...@@ -1209,12 +1209,14 @@ static BOOL elf_load_file(struct process* pcs, const char* filename, ...@@ -1209,12 +1209,14 @@ static BOOL elf_load_file(struct process* pcs, const char* filename,
if (elf_info->flags & ELF_INFO_MODULE) if (elf_info->flags & ELF_INFO_MODULE)
{ {
WCHAR wfilename[MAX_PATH];
struct elf_module_info *elf_module_info = struct elf_module_info *elf_module_info =
HeapAlloc(GetProcessHeap(), 0, sizeof(struct elf_module_info)); HeapAlloc(GetProcessHeap(), 0, sizeof(struct elf_module_info));
if (!elf_module_info) goto leave; if (!elf_module_info) goto leave;
elf_info->module = module_newA(pcs, filename, DMT_ELF, FALSE, MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, wfilename, sizeof(wfilename) / sizeof(WCHAR));
(load_offset) ? load_offset : fmap.elf_start, elf_info->module = module_new(pcs, wfilename, DMT_ELF, FALSE,
fmap.elf_size, 0, calc_crc32(&fmap)); (load_offset) ? load_offset : fmap.elf_start,
fmap.elf_size, 0, calc_crc32(&fmap));
if (!elf_info->module) if (!elf_info->module)
{ {
HeapFree(GetProcessHeap(), 0, elf_module_info); HeapFree(GetProcessHeap(), 0, elf_module_info);
...@@ -1508,7 +1510,7 @@ struct elf_load ...@@ -1508,7 +1510,7 @@ struct elf_load
{ {
struct process* pcs; struct process* pcs;
struct elf_info elf_info; struct elf_info elf_info;
const char* name; char name[MAX_PATH];
BOOL ret; BOOL ret;
}; };
...@@ -1543,23 +1545,26 @@ static BOOL elf_load_cb(const char* name, unsigned long addr, void* user) ...@@ -1543,23 +1545,26 @@ static BOOL elf_load_cb(const char* name, unsigned long addr, void* user)
* Also, find module real name and load address from * Also, find module real name and load address from
* the real loaded modules list in pcs address space * the real loaded modules list in pcs address space
*/ */
struct module* elf_load_module(struct process* pcs, const char* name, unsigned long addr) struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
{ {
struct elf_load el; struct elf_load el;
TRACE("(%p %s %08lx)\n", pcs, name, addr); TRACE("(%p %s %08lx)\n", pcs, debugstr_w(name), addr);
el.elf_info.flags = ELF_INFO_MODULE; el.elf_info.flags = ELF_INFO_MODULE;
el.ret = FALSE; el.ret = FALSE;
if (pcs->dbg_hdr_addr) /* we're debugging a life target */ if (pcs->dbg_hdr_addr) /* we're debugging a life target */
{ {
const WCHAR* ptr;
el.pcs = pcs; el.pcs = pcs;
/* do only the lookup from the filename, not the path (as we lookup module /* do only the lookup from the filename, not the path (as we lookup module
* name in the process' loaded module list) * name in the process' loaded module list)
*/ */
el.name = strrchr(name, '/'); ptr = strrchrW(name, '/');
if (!el.name++) el.name = name; if (!ptr++) ptr = name;
WideCharToMultiByte(CP_UNIXCP, 0, ptr, -1, el.name, sizeof(el.name), NULL, NULL);
el.ret = FALSE; el.ret = FALSE;
if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el)) if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el))
...@@ -1567,7 +1572,8 @@ struct module* elf_load_module(struct process* pcs, const char* name, unsigned ...@@ -1567,7 +1572,8 @@ struct module* elf_load_module(struct process* pcs, const char* name, unsigned
} }
else if (addr) else if (addr)
{ {
el.ret = elf_search_and_load_file(pcs, name, addr, &el.elf_info); WideCharToMultiByte(CP_UNIXCP, 0, name, -1, el.name, sizeof(el.name), NULL, NULL);
el.ret = elf_search_and_load_file(pcs, el.name, addr, &el.elf_info);
} }
if (!el.ret) return NULL; if (!el.ret) return NULL;
assert(el.elf_info.module); assert(el.elf_info.module);
...@@ -1597,7 +1603,7 @@ BOOL elf_enum_modules(HANDLE hProc, elf_enum_modules_cb cb, void* user) ...@@ -1597,7 +1603,7 @@ BOOL elf_enum_modules(HANDLE hProc, elf_enum_modules_cb cb, void* user)
return FALSE; return FALSE;
} }
struct module* elf_load_module(struct process* pcs, const char* name, unsigned long addr) struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
{ {
return NULL; return NULL;
} }
......
...@@ -177,17 +177,6 @@ struct module* module_new(struct process* pcs, const WCHAR* name, ...@@ -177,17 +177,6 @@ struct module* module_new(struct process* pcs, const WCHAR* name,
return module; return module;
} }
struct module* module_newA(struct process* pcs, const char* name,
enum module_type type, BOOL virtual,
unsigned long mod_addr, unsigned long size,
unsigned long stamp, unsigned long checksum)
{
WCHAR wname[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR));
return module_new(pcs, wname, type, virtual, mod_addr, size, stamp, checksum);
}
/*********************************************************************** /***********************************************************************
* module_find_by_name * module_find_by_name
* *
...@@ -527,7 +516,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam ...@@ -527,7 +516,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
if (!(module = pe_load_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll))) if (!(module = pe_load_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)))
{ {
if (module_get_type_by_name(ImageName) == DMT_ELF && if (module_get_type_by_name(ImageName) == DMT_ELF &&
(module = elf_load_module(pcs, ImageName, BaseOfDll))) (module = elf_load_module(pcs, wImageName, BaseOfDll)))
goto done; goto done;
FIXME("Should have successfully loaded debug information for image %s\n", FIXME("Should have successfully loaded debug information for image %s\n",
debugstr_w(wImageName)); debugstr_w(wImageName));
......
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