mirror of
https://github.com/reactos/reactos.git
synced 2025-05-07 18:56:48 +00:00
[WINESYNC] dbghelp: Store process struct pointer in dump context.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 6b3018d03da983050516821caa2aada2f4814678 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
fbc5f830fc
commit
ca7d01b33f
4 changed files with 35 additions and 22 deletions
|
@ -929,7 +929,7 @@ static BOOL x86_64_fetch_minidump_module(struct dump_context* dc, unsigned index
|
||||||
const RUNTIME_FUNCTION* rtf;
|
const RUNTIME_FUNCTION* rtf;
|
||||||
ULONG size;
|
ULONG size;
|
||||||
|
|
||||||
if (!(pcs = process_find_by_handle(dc->hProcess)) ||
|
if (!(pcs = process_find_by_handle(dc->process->handle)) ||
|
||||||
!(module = module_find_by_addr(pcs, dc->modules[index].base, DMT_UNKNOWN)))
|
!(module = module_find_by_addr(pcs, dc->modules[index].base, DMT_UNKNOWN)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
rtf = (const RUNTIME_FUNCTION*)pe_map_directory(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size);
|
rtf = (const RUNTIME_FUNCTION*)pe_map_directory(module, IMAGE_DIRECTORY_ENTRY_EXCEPTION, &size);
|
||||||
|
@ -947,7 +947,7 @@ static BOOL x86_64_fetch_minidump_module(struct dump_context* dc, unsigned index
|
||||||
/* we need to read into the other process */
|
/* we need to read into the other process */
|
||||||
/* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + (rtf->UnwindData & ~1)); */
|
/* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + (rtf->UnwindData & ~1)); */
|
||||||
}
|
}
|
||||||
if (ReadProcessMemory(dc->hProcess,
|
if (ReadProcessMemory(dc->process->handle,
|
||||||
(void*)(dc->modules[index].base + rtf->UnwindData),
|
(void*)(dc->modules[index].base + rtf->UnwindData),
|
||||||
&ui, sizeof(ui), NULL))
|
&ui, sizeof(ui), NULL))
|
||||||
minidump_add_memory_block(dc, dc->modules[index].base + rtf->UnwindData,
|
minidump_add_memory_block(dc, dc->modules[index].base + rtf->UnwindData,
|
||||||
|
|
|
@ -529,7 +529,7 @@ struct dump_thread
|
||||||
struct dump_context
|
struct dump_context
|
||||||
{
|
{
|
||||||
/* process & thread information */
|
/* process & thread information */
|
||||||
HANDLE hProcess;
|
struct process *process;
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
unsigned flags_out;
|
unsigned flags_out;
|
||||||
/* thread information */
|
/* thread information */
|
||||||
|
|
|
@ -93,7 +93,7 @@ static void fetch_thread_stack(struct dump_context* dc, const void* teb_addr,
|
||||||
NT_TIB tib;
|
NT_TIB tib;
|
||||||
ADDRESS64 addr;
|
ADDRESS64 addr;
|
||||||
|
|
||||||
if (ReadProcessMemory(dc->hProcess, teb_addr, &tib, sizeof(tib), NULL) &&
|
if (ReadProcessMemory(dc->process->handle, teb_addr, &tib, sizeof(tib), NULL) &&
|
||||||
dbghelp_current_cpu &&
|
dbghelp_current_cpu &&
|
||||||
dbghelp_current_cpu->get_addr(NULL /* FIXME */, ctx, cpu_addr_stack, &addr) && addr.Mode == AddrModeFlat)
|
dbghelp_current_cpu->get_addr(NULL /* FIXME */, ctx, cpu_addr_stack, &addr) && addr.Mode == AddrModeFlat)
|
||||||
{
|
{
|
||||||
|
@ -170,9 +170,9 @@ static BOOL fetch_thread_info(struct dump_context* dc, int thd_idx,
|
||||||
{
|
{
|
||||||
EXCEPTION_POINTERS ep;
|
EXCEPTION_POINTERS ep;
|
||||||
|
|
||||||
ReadProcessMemory(dc->hProcess, except->ExceptionPointers,
|
ReadProcessMemory(dc->process->handle, except->ExceptionPointers,
|
||||||
&ep, sizeof(ep), NULL);
|
&ep, sizeof(ep), NULL);
|
||||||
ReadProcessMemory(dc->hProcess, ep.ContextRecord,
|
ReadProcessMemory(dc->process->handle, ep.ContextRecord,
|
||||||
&lctx, sizeof(lctx), NULL);
|
&lctx, sizeof(lctx), NULL);
|
||||||
pctx = &lctx;
|
pctx = &lctx;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ static BOOL add_module(struct dump_context* dc, const WCHAR* name,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (is_elf ||
|
if (is_elf ||
|
||||||
!GetModuleFileNameExW(dc->hProcess, (HMODULE)(DWORD_PTR)base,
|
!GetModuleFileNameExW(dc->process->handle, (HMODULE)(DWORD_PTR)base,
|
||||||
dc->modules[dc->num_modules].name,
|
dc->modules[dc->num_modules].name,
|
||||||
ARRAY_SIZE(dc->modules[dc->num_modules].name)))
|
ARRAY_SIZE(dc->modules[dc->num_modules].name)))
|
||||||
lstrcpynW(dc->modules[dc->num_modules].name, name,
|
lstrcpynW(dc->modules[dc->num_modules].name, name,
|
||||||
|
@ -243,7 +243,7 @@ static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size
|
||||||
|
|
||||||
if (!validate_addr64(base)) return FALSE;
|
if (!validate_addr64(base)) return FALSE;
|
||||||
|
|
||||||
if (pe_load_nt_header(dc->hProcess, base, &nth))
|
if (pe_load_nt_header(dc->process->handle, base, &nth))
|
||||||
add_module(user, name, base, size,
|
add_module(user, name, base, size,
|
||||||
nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum,
|
nth.FileHeader.TimeDateStamp, nth.OptionalHeader.CheckSum,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -289,7 +289,7 @@ static BOOL fetch_macho_module_info_cb(const WCHAR* name, unsigned long base,
|
||||||
/* NB: if we have a non-null base from the live-target use it. If we have
|
/* NB: if we have a non-null base from the live-target use it. If we have
|
||||||
* a null base, then grab its base address from Mach-O file.
|
* a null base, then grab its base address from Mach-O file.
|
||||||
*/
|
*/
|
||||||
if (!macho_fetch_file_info(dc->hProcess, name, base, &rbase, &size, &checksum))
|
if (!macho_fetch_file_info(dc->process->handle, name, base, &rbase, &size, &checksum))
|
||||||
size = checksum = 0;
|
size = checksum = 0;
|
||||||
add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
|
add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -323,7 +323,7 @@ static void fetch_memory64_info(struct dump_context* dc)
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
|
|
||||||
addr = 0;
|
addr = 0;
|
||||||
while (VirtualQueryEx(dc->hProcess, (LPCVOID)addr, &mbi, sizeof(mbi)) != 0)
|
while (VirtualQueryEx(dc->process->handle, (LPCVOID)addr, &mbi, sizeof(mbi)) != 0)
|
||||||
{
|
{
|
||||||
/* Memory regions with state MEM_COMMIT will be added to the dump */
|
/* Memory regions with state MEM_COMMIT will be added to the dump */
|
||||||
if (mbi.State == MEM_COMMIT)
|
if (mbi.State == MEM_COMMIT)
|
||||||
|
@ -340,14 +340,14 @@ static void fetch_memory64_info(struct dump_context* dc)
|
||||||
|
|
||||||
static void fetch_modules_info(struct dump_context* dc)
|
static void fetch_modules_info(struct dump_context* dc)
|
||||||
{
|
{
|
||||||
EnumerateLoadedModulesW64(dc->hProcess, fetch_pe_module_info_cb, dc);
|
EnumerateLoadedModulesW64(dc->process->handle, fetch_pe_module_info_cb, dc);
|
||||||
/* Since we include ELF modules in a separate stream from the regular PE ones,
|
/* Since we include ELF modules in a separate stream from the regular PE ones,
|
||||||
* we can always include those ELF modules (they don't eat lots of space)
|
* we can always include those ELF modules (they don't eat lots of space)
|
||||||
* And it's always a good idea to have a trace of the loaded ELF modules for
|
* And it's always a good idea to have a trace of the loaded ELF modules for
|
||||||
* a given application in a post mortem debugging condition.
|
* a given application in a post mortem debugging condition.
|
||||||
*/
|
*/
|
||||||
elf_enum_modules(dc->hProcess, fetch_elf_module_info_cb, dc);
|
elf_enum_modules(dc->process->handle, fetch_elf_module_info_cb, dc);
|
||||||
macho_enum_modules(dc->hProcess, fetch_macho_module_info_cb, dc);
|
macho_enum_modules(dc->process->handle, fetch_macho_module_info_cb, dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
|
static void fetch_module_versioninfo(LPCWSTR filename, VS_FIXEDFILEINFO* ffi)
|
||||||
|
@ -447,11 +447,11 @@ static unsigned dump_exception_info(struct dump_context* dc,
|
||||||
{
|
{
|
||||||
EXCEPTION_POINTERS ep;
|
EXCEPTION_POINTERS ep;
|
||||||
|
|
||||||
ReadProcessMemory(dc->hProcess,
|
ReadProcessMemory(dc->process->handle,
|
||||||
except->ExceptionPointers, &ep, sizeof(ep), NULL);
|
except->ExceptionPointers, &ep, sizeof(ep), NULL);
|
||||||
ReadProcessMemory(dc->hProcess,
|
ReadProcessMemory(dc->process->handle,
|
||||||
ep.ExceptionRecord, &rec, sizeof(rec), NULL);
|
ep.ExceptionRecord, &rec, sizeof(rec), NULL);
|
||||||
ReadProcessMemory(dc->hProcess,
|
ReadProcessMemory(dc->process->handle,
|
||||||
ep.ContextRecord, &ctx, sizeof(ctx), NULL);
|
ep.ContextRecord, &ctx, sizeof(ctx), NULL);
|
||||||
prec = &rec;
|
prec = &rec;
|
||||||
pctx = &ctx;
|
pctx = &ctx;
|
||||||
|
@ -537,7 +537,7 @@ static unsigned dump_modules(struct dump_context* dc, BOOL dump_elf)
|
||||||
MINIDUMP_CALLBACK_OUTPUT cbout;
|
MINIDUMP_CALLBACK_OUTPUT cbout;
|
||||||
|
|
||||||
cbin.ProcessId = dc->pid;
|
cbin.ProcessId = dc->pid;
|
||||||
cbin.ProcessHandle = dc->hProcess;
|
cbin.ProcessHandle = dc->process->handle;
|
||||||
cbin.CallbackType = ModuleCallback;
|
cbin.CallbackType = ModuleCallback;
|
||||||
|
|
||||||
cbin.u.Module.FullPath = ms->Buffer;
|
cbin.u.Module.FullPath = ms->Buffer;
|
||||||
|
@ -804,7 +804,7 @@ static unsigned dump_threads(struct dump_context* dc,
|
||||||
MINIDUMP_CALLBACK_OUTPUT cbout;
|
MINIDUMP_CALLBACK_OUTPUT cbout;
|
||||||
|
|
||||||
cbin.ProcessId = dc->pid;
|
cbin.ProcessId = dc->pid;
|
||||||
cbin.ProcessHandle = dc->hProcess;
|
cbin.ProcessHandle = dc->process->handle;
|
||||||
cbin.CallbackType = ThreadCallback;
|
cbin.CallbackType = ThreadCallback;
|
||||||
cbin.u.Thread.ThreadId = dc->threads[i].tid;
|
cbin.u.Thread.ThreadId = dc->threads[i].tid;
|
||||||
cbin.u.Thread.ThreadHandle = 0; /* FIXME */
|
cbin.u.Thread.ThreadHandle = 0; /* FIXME */
|
||||||
|
@ -881,7 +881,7 @@ static unsigned dump_memory_info(struct dump_context* dc)
|
||||||
for (pos = 0; pos < dc->mem[i].size; pos += sizeof(tmp))
|
for (pos = 0; pos < dc->mem[i].size; pos += sizeof(tmp))
|
||||||
{
|
{
|
||||||
len = min(dc->mem[i].size - pos, sizeof(tmp));
|
len = min(dc->mem[i].size - pos, sizeof(tmp));
|
||||||
if (ReadProcessMemory(dc->hProcess,
|
if (ReadProcessMemory(dc->process->handle,
|
||||||
(void*)(DWORD_PTR)(dc->mem[i].base + pos),
|
(void*)(DWORD_PTR)(dc->mem[i].base + pos),
|
||||||
tmp, len, NULL))
|
tmp, len, NULL))
|
||||||
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
||||||
|
@ -939,7 +939,7 @@ static unsigned dump_memory64_info(struct dump_context* dc)
|
||||||
for (pos = 0; pos < dc->mem64[i].size; pos += sizeof(tmp))
|
for (pos = 0; pos < dc->mem64[i].size; pos += sizeof(tmp))
|
||||||
{
|
{
|
||||||
len = min(dc->mem64[i].size - pos, sizeof(tmp));
|
len = min(dc->mem64[i].size - pos, sizeof(tmp));
|
||||||
if (ReadProcessMemory(dc->hProcess,
|
if (ReadProcessMemory(dc->process->handle,
|
||||||
(void*)(ULONG_PTR)(dc->mem64[i].base + pos),
|
(void*)(ULONG_PTR)(dc->mem64[i].base + pos),
|
||||||
tmp, len, NULL))
|
tmp, len, NULL))
|
||||||
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
||||||
|
@ -982,8 +982,18 @@ BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile,
|
||||||
MINIDUMP_DIRECTORY mdDir;
|
MINIDUMP_DIRECTORY mdDir;
|
||||||
DWORD i, nStreams, idx_stream;
|
DWORD i, nStreams, idx_stream;
|
||||||
struct dump_context dc;
|
struct dump_context dc;
|
||||||
|
BOOL sym_initialized = FALSE;
|
||||||
|
|
||||||
|
if (!(dc.process = process_find_by_handle(hProcess)))
|
||||||
|
{
|
||||||
|
if (!(sym_initialized = SymInitializeW(hProcess, NULL, TRUE)))
|
||||||
|
{
|
||||||
|
WARN("failed to initialize process\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
dc.process = process_find_by_handle(hProcess);
|
||||||
|
}
|
||||||
|
|
||||||
dc.hProcess = hProcess;
|
|
||||||
dc.hFile = hFile;
|
dc.hFile = hFile;
|
||||||
dc.pid = pid;
|
dc.pid = pid;
|
||||||
dc.modules = NULL;
|
dc.modules = NULL;
|
||||||
|
@ -1119,6 +1129,9 @@ BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess, DWORD pid, HANDLE hFile,
|
||||||
for (i = idx_stream; i < nStreams; i++)
|
for (i = idx_stream; i < nStreams; i++)
|
||||||
writeat(&dc, mdHead.StreamDirectoryRva + i * sizeof(emptyDir), &emptyDir, sizeof(emptyDir));
|
writeat(&dc, mdHead.StreamDirectoryRva + i * sizeof(emptyDir), &emptyDir, sizeof(emptyDir));
|
||||||
|
|
||||||
|
if (sym_initialized)
|
||||||
|
SymCleanup(hProcess);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, dc.mem);
|
HeapFree(GetProcessHeap(), 0, dc.mem);
|
||||||
HeapFree(GetProcessHeap(), 0, dc.mem64);
|
HeapFree(GetProcessHeap(), 0, dc.mem64);
|
||||||
HeapFree(GetProcessHeap(), 0, dc.modules);
|
HeapFree(GetProcessHeap(), 0, dc.modules);
|
||||||
|
|
|
@ -4,4 +4,4 @@ files:
|
||||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||||
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
||||||
tags:
|
tags:
|
||||||
wine: be9072ec743e22ed6a20288e5539b8ba307f9280
|
wine: 6b3018d03da983050516821caa2aada2f4814678
|
||||||
|
|
Loading…
Reference in a new issue