Commit 31001978 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

dbghelp: Use WINELOADER environment variable from debuggee process in get_wine_loader_name.

parent ea5249fe
...@@ -651,7 +651,7 @@ extern void module_reset_debug_info(struct module* module) DECLSPEC_HIDD ...@@ -651,7 +651,7 @@ extern void module_reset_debug_info(struct module* module) DECLSPEC_HIDD
extern BOOL module_remove(struct process* pcs, extern BOOL module_remove(struct process* pcs,
struct module* module) DECLSPEC_HIDDEN; struct module* module) DECLSPEC_HIDDEN;
extern void module_set_module(struct module* module, const WCHAR* name) DECLSPEC_HIDDEN; extern void module_set_module(struct module* module, const WCHAR* name) DECLSPEC_HIDDEN;
extern WCHAR * get_wine_loader_name(struct process *pcs) DECLSPEC_HIDDEN; extern const WCHAR *get_wine_loader_name(struct process *pcs) DECLSPEC_HIDDEN;
/* msc.c */ /* msc.c */
extern BOOL pe_load_debug_directory(const struct process* pcs, extern BOOL pe_load_debug_directory(const struct process* pcs,
......
...@@ -1752,13 +1752,10 @@ static const struct loader_ops elf_loader_ops = ...@@ -1752,13 +1752,10 @@ static const struct loader_ops elf_loader_ops =
BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr) BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr)
{ {
struct elf_info elf_info; struct elf_info elf_info;
WCHAR *loader;
BOOL ret; BOOL ret;
elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE; elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE;
loader = get_wine_loader_name(pcs); ret = elf_search_and_load_file(pcs, get_wine_loader_name(pcs), addr, 0, &elf_info);
ret = elf_search_and_load_file(pcs, loader, addr, 0, &elf_info);
heap_free(loader);
if (!ret || !elf_info.dbg_hdr_addr) return FALSE; if (!ret || !elf_info.dbg_hdr_addr) return FALSE;
TRACE("Found ELF debug header %#lx\n", elf_info.dbg_hdr_addr); TRACE("Found ELF debug header %#lx\n", elf_info.dbg_hdr_addr);
......
...@@ -1885,12 +1885,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in ...@@ -1885,12 +1885,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in
} }
} }
if (!ret) if (!ret) ret = macho_search_and_load_file(pcs, get_wine_loader_name(pcs), 0, macho_info);
{
WCHAR *loader = get_wine_loader_name(pcs);
ret = loader && macho_search_and_load_file(pcs, loader, 0, macho_info);
heap_free(loader);
}
return ret; return ret;
} }
......
...@@ -138,37 +138,12 @@ void module_set_module(struct module* module, const WCHAR* name) ...@@ -138,37 +138,12 @@ void module_set_module(struct module* module, const WCHAR* name)
} }
/* Returned string must be freed by caller */ /* Returned string must be freed by caller */
WCHAR *get_wine_loader_name(struct process *pcs) const WCHAR *get_wine_loader_name(struct process *pcs)
{ {
static const WCHAR wineW[] = {'w','i','n','e',0}; const WCHAR *name = process_getenv(pcs, L"WINELOADER");
static const WCHAR suffixW[] = {'6','4',0}; if (!name) name = pcs->is_64bit ? L"wine64" : L"wine";
WCHAR *buffer, *p; TRACE("returning %s\n", debugstr_w(name));
const char *env; return name;
/* All binaries are loaded with WINELOADER (if run from tree) or by the
* main executable
*/
if ((env = getenv("WINELOADER")))
{
DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, env, -1, NULL, 0 );
buffer = heap_alloc( len * sizeof(WCHAR) );
MultiByteToWideChar( CP_UNIXCP, 0, env, -1, buffer, len );
}
else
{
buffer = heap_alloc( sizeof(wineW) + 2 * sizeof(WCHAR) );
lstrcpyW( buffer, wineW );
}
p = buffer + lstrlenW( buffer ) - lstrlenW( suffixW );
if (p > buffer && !wcscmp( p, suffixW ))
*p = 0;
if (pcs->is_64bit)
lstrcatW(buffer, suffixW);
TRACE( "returning %s\n", debugstr_w(buffer) );
return buffer;
} }
static const char* get_module_type(enum module_type type, BOOL virtual) static const char* get_module_type(enum module_type type, BOOL virtual)
......
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