Commit c050df12 authored by Alexandre Julliard's avatar Alexandre Julliard

winedbg: Use GetMappedFileNameW() as fallback when fetching module names.

parent 39b20a2b
......@@ -419,6 +419,7 @@ extern enum dbg_start dbg_active_auto(int argc, char* argv[]);
extern enum dbg_start dbg_active_minidump(int argc, char* argv[]);
extern void dbg_active_wait_for_first_exception(void);
extern BOOL dbg_attach_debuggee(DWORD pid);
extern void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bufsz);
/* tgt_minidump.c */
extern void minidump_write(const char*, const EXCEPTION_RECORD*);
......
......@@ -443,10 +443,8 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx)
return TRUE;
case LOAD_DLL_DEBUG_EVENT:
memory_get_string_indirect(gdbctx->process,
de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
u.buffer, ARRAY_SIZE(u.buffer));
fetch_module_name( de->u.LoadDll.lpImageName, de->u.LoadDll.lpBaseOfDll,
u.buffer, ARRAY_SIZE(u.buffer) );
fprintf(stderr, "%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
dbg_W2A(u.buffer, -1),
......
......@@ -296,15 +296,22 @@ static DWORD dbg_handle_exception(const EXCEPTION_RECORD* rec, BOOL first_chance
static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill);
static void fetch_module_name(void* name_addr, BOOL unicode, void* mod_addr,
WCHAR* buffer, size_t bufsz)
void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bufsz)
{
static const WCHAR dlladdr[] = {'D','L','L','_','%','0','8','l','x',0};
memory_get_string_indirect(dbg_curr_process, name_addr, unicode, buffer, bufsz);
if (!buffer[0] &&
!GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz))
memory_get_string_indirect(dbg_curr_process, name_addr, TRUE, buffer, bufsz);
if (!buffer[0] && !GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz))
{
if (GetMappedFileNameW( dbg_curr_process->handle, mod_addr, buffer, bufsz ))
{
/* FIXME: proper NT->Dos conversion */
static const WCHAR nt_prefixW[] = {'\\','?','?','\\'};
if (!strncmpW( buffer, nt_prefixW, 4 ))
memmove( buffer, buffer + 4, (lstrlenW(buffer + 4) + 1) * sizeof(WCHAR) );
}
else
snprintfW(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr);
}
}
......@@ -462,9 +469,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
WINE_ERR("Unknown thread\n");
break;
}
fetch_module_name(de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
de->u.LoadDll.lpBaseOfDll,
fetch_module_name(de->u.LoadDll.lpImageName, de->u.LoadDll.lpBaseOfDll,
u.buffer, ARRAY_SIZE(u.buffer));
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
......
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