mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-16 04:57:28 +00:00
winedbg: Use QueryFullProcessImageNameW to retrieve the main image name.
Remove the psapi fallback that didn't work anyway. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
405666b736
commit
39b20a2bd3
|
@ -404,6 +404,7 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx)
|
||||||
char bufferA[256];
|
char bufferA[256];
|
||||||
WCHAR buffer[256];
|
WCHAR buffer[256];
|
||||||
} u;
|
} u;
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
gdbctx->exec_tid = de->dwThreadId;
|
gdbctx->exec_tid = de->dwThreadId;
|
||||||
gdbctx->other_tid = de->dwThreadId;
|
gdbctx->other_tid = de->dwThreadId;
|
||||||
|
@ -417,10 +418,8 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx)
|
||||||
if (!gdbctx->process)
|
if (!gdbctx->process)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
memory_get_string_indirect(gdbctx->process,
|
size = ARRAY_SIZE(u.buffer);
|
||||||
de->u.CreateProcessInfo.lpImageName,
|
QueryFullProcessImageNameW( gdbctx->process->handle, 0, u.buffer, &size );
|
||||||
de->u.CreateProcessInfo.fUnicode,
|
|
||||||
u.buffer, ARRAY_SIZE(u.buffer));
|
|
||||||
dbg_set_process_name(gdbctx->process, u.buffer);
|
dbg_set_process_name(gdbctx->process, u.buffer);
|
||||||
|
|
||||||
fprintf(stderr, "%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
|
fprintf(stderr, "%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
|
||||||
|
|
|
@ -297,33 +297,15 @@ 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 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,
|
static void fetch_module_name(void* name_addr, BOOL unicode, void* mod_addr,
|
||||||
WCHAR* buffer, size_t bufsz, BOOL is_pcs)
|
WCHAR* buffer, size_t bufsz)
|
||||||
{
|
{
|
||||||
static const WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0};
|
|
||||||
static const WCHAR dlladdr[] = {'D','L','L','_','%','0','8','l','x',0};
|
static const WCHAR dlladdr[] = {'D','L','L','_','%','0','8','l','x',0};
|
||||||
|
|
||||||
memory_get_string_indirect(dbg_curr_process, name_addr, unicode, buffer, bufsz);
|
memory_get_string_indirect(dbg_curr_process, name_addr, unicode, buffer, bufsz);
|
||||||
if (!buffer[0] &&
|
if (!buffer[0] &&
|
||||||
!GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz))
|
!GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz))
|
||||||
{
|
{
|
||||||
if (is_pcs)
|
snprintfW(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr);
|
||||||
{
|
|
||||||
HMODULE h;
|
|
||||||
WORD (WINAPI *gpif)(HANDLE, LPWSTR, DWORD);
|
|
||||||
|
|
||||||
/* On Windows, when we get the process creation debug event for a process
|
|
||||||
* created by winedbg, the modules' list is not initialized yet. Hence,
|
|
||||||
* GetModuleFileNameExA (on the main module) will generate an error.
|
|
||||||
* Psapi (starting on XP) provides GetProcessImageFileName() which should
|
|
||||||
* give us the expected result
|
|
||||||
*/
|
|
||||||
if (!(h = GetModuleHandleA("psapi")) ||
|
|
||||||
!(gpif = (void*)GetProcAddress(h, "GetProcessImageFileNameW")) ||
|
|
||||||
!(gpif)(dbg_curr_process->handle, buffer, bufsz))
|
|
||||||
snprintfW(buffer, bufsz, pcspid, dbg_curr_pid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
snprintfW(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +315,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
||||||
char bufferA[256];
|
char bufferA[256];
|
||||||
WCHAR buffer[256];
|
WCHAR buffer[256];
|
||||||
} u;
|
} u;
|
||||||
DWORD cont = DBG_CONTINUE;
|
DWORD size, cont = DBG_CONTINUE;
|
||||||
|
|
||||||
dbg_curr_pid = de->dwProcessId;
|
dbg_curr_pid = de->dwProcessId;
|
||||||
dbg_curr_tid = de->dwThreadId;
|
dbg_curr_tid = de->dwThreadId;
|
||||||
|
@ -383,10 +365,12 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
||||||
WINE_ERR("Couldn't create process\n");
|
WINE_ERR("Couldn't create process\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fetch_module_name(de->u.CreateProcessInfo.lpImageName,
|
size = ARRAY_SIZE(u.buffer);
|
||||||
de->u.CreateProcessInfo.fUnicode,
|
if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size ))
|
||||||
de->u.CreateProcessInfo.lpBaseOfImage,
|
{
|
||||||
u.buffer, ARRAY_SIZE(u.buffer), TRUE);
|
static const WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0};
|
||||||
|
snprintfW( u.buffer, ARRAY_SIZE(u.buffer), pcspid, dbg_curr_pid);
|
||||||
|
}
|
||||||
|
|
||||||
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
|
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId,
|
||||||
|
@ -481,7 +465,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
||||||
fetch_module_name(de->u.LoadDll.lpImageName,
|
fetch_module_name(de->u.LoadDll.lpImageName,
|
||||||
de->u.LoadDll.fUnicode,
|
de->u.LoadDll.fUnicode,
|
||||||
de->u.LoadDll.lpBaseOfDll,
|
de->u.LoadDll.lpBaseOfDll,
|
||||||
u.buffer, ARRAY_SIZE(u.buffer), FALSE);
|
u.buffer, ARRAY_SIZE(u.buffer));
|
||||||
|
|
||||||
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
|
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
|
||||||
de->dwProcessId, de->dwThreadId,
|
de->dwProcessId, de->dwThreadId,
|
||||||
|
|
Loading…
Reference in a new issue