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];
|
||||
WCHAR buffer[256];
|
||||
} u;
|
||||
DWORD size;
|
||||
|
||||
gdbctx->exec_tid = de->dwThreadId;
|
||||
gdbctx->other_tid = de->dwThreadId;
|
||||
|
@ -417,10 +418,8 @@ static BOOL handle_debug_event(struct gdb_context* gdbctx)
|
|||
if (!gdbctx->process)
|
||||
return TRUE;
|
||||
|
||||
memory_get_string_indirect(gdbctx->process,
|
||||
de->u.CreateProcessInfo.lpImageName,
|
||||
de->u.CreateProcessInfo.fUnicode,
|
||||
u.buffer, ARRAY_SIZE(u.buffer));
|
||||
size = ARRAY_SIZE(u.buffer);
|
||||
QueryFullProcessImageNameW( gdbctx->process->handle, 0, u.buffer, &size );
|
||||
dbg_set_process_name(gdbctx->process, u.buffer);
|
||||
|
||||
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 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};
|
||||
|
||||
memory_get_string_indirect(dbg_curr_process, name_addr, unicode, buffer, bufsz);
|
||||
if (!buffer[0] &&
|
||||
!GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz))
|
||||
{
|
||||
if (is_pcs)
|
||||
{
|
||||
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);
|
||||
snprintfW(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,7 +315,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
|||
char bufferA[256];
|
||||
WCHAR buffer[256];
|
||||
} u;
|
||||
DWORD cont = DBG_CONTINUE;
|
||||
DWORD size, cont = DBG_CONTINUE;
|
||||
|
||||
dbg_curr_pid = de->dwProcessId;
|
||||
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");
|
||||
break;
|
||||
}
|
||||
fetch_module_name(de->u.CreateProcessInfo.lpImageName,
|
||||
de->u.CreateProcessInfo.fUnicode,
|
||||
de->u.CreateProcessInfo.lpBaseOfImage,
|
||||
u.buffer, ARRAY_SIZE(u.buffer), TRUE);
|
||||
size = ARRAY_SIZE(u.buffer);
|
||||
if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size ))
|
||||
{
|
||||
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",
|
||||
de->dwProcessId, de->dwThreadId,
|
||||
|
@ -481,7 +465,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
|
|||
fetch_module_name(de->u.LoadDll.lpImageName,
|
||||
de->u.LoadDll.fUnicode,
|
||||
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",
|
||||
de->dwProcessId, de->dwThreadId,
|
||||
|
|
Loading…
Reference in New Issue