mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[WINESYNC] dbghelp: Introduce read_process_memory helper.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 26f5bfdd4d071a91a38b25c0064ed5ea48993249 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
4959c2568a
commit
27e660114b
6 changed files with 22 additions and 32 deletions
|
@ -947,9 +947,7 @@ static BOOL x86_64_fetch_minidump_module(struct dump_context* dc, unsigned index
|
|||
/* we need to read into the other process */
|
||||
/* rtf = (RUNTIME_FUNCTION*)(module->module.BaseOfImage + (rtf->UnwindData & ~1)); */
|
||||
}
|
||||
if (ReadProcessMemory(dc->process->handle,
|
||||
(void*)(dc->modules[index].base + rtf->UnwindData),
|
||||
&ui, sizeof(ui), NULL))
|
||||
if (read_process_memory(dc->process, dc->modules[index].base + rtf->UnwindData, &ui, sizeof(ui)))
|
||||
minidump_add_memory_block(dc, dc->modules[index].base + rtf->UnwindData,
|
||||
FIELD_OFFSET(UNWIND_INFO, UnwindCode) + ui.CountOfCodes * sizeof(UNWIND_CODE), 0);
|
||||
rtf++;
|
||||
|
|
|
@ -448,6 +448,11 @@ struct process
|
|||
BOOL is_64bit;
|
||||
};
|
||||
|
||||
static inline BOOL read_process_memory(const struct process *process, UINT64 addr, void *buf, size_t size)
|
||||
{
|
||||
return ReadProcessMemory(process->handle, (void*)(UINT_PTR)addr, buf, size, NULL);
|
||||
}
|
||||
|
||||
struct line_info
|
||||
{
|
||||
ULONG_PTR is_first : 1,
|
||||
|
|
|
@ -1486,9 +1486,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
|
|||
UINT64 l_next, l_prev;
|
||||
} lm;
|
||||
|
||||
if (!pcs->dbg_hdr_addr ||
|
||||
!ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr,
|
||||
&dbg_hdr, sizeof(dbg_hdr), NULL))
|
||||
if (!pcs->dbg_hdr_addr || !read_process_memory(pcs, pcs->dbg_hdr_addr, &dbg_hdr, sizeof(dbg_hdr)))
|
||||
return FALSE;
|
||||
|
||||
/* Now walk the linked list. In all known ELF implementations,
|
||||
|
@ -1498,12 +1496,11 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
|
|||
*/
|
||||
for (lm_addr = dbg_hdr.r_map; lm_addr; lm_addr = lm.l_next)
|
||||
{
|
||||
if (!ReadProcessMemory(pcs->handle, (void*)lm_addr, &lm, sizeof(lm), NULL))
|
||||
if (!read_process_memory(pcs, lm_addr, &lm, sizeof(lm)))
|
||||
return FALSE;
|
||||
|
||||
if (lm.l_prev && /* skip first entry, normally debuggee itself */
|
||||
lm.l_name &&
|
||||
ReadProcessMemory(pcs->handle, (void*)(ULONG_PTR)lm.l_name, bufstr, sizeof(bufstr), NULL))
|
||||
lm.l_name && read_process_memory(pcs, lm.l_name, bufstr, sizeof(bufstr)))
|
||||
{
|
||||
bufstr[sizeof(bufstr) - 1] = '\0';
|
||||
MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW));
|
||||
|
@ -1531,9 +1528,7 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
|
|||
UINT32 l_next, l_prev;
|
||||
} lm;
|
||||
|
||||
if (!pcs->dbg_hdr_addr ||
|
||||
!ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr,
|
||||
&dbg_hdr, sizeof(dbg_hdr), NULL))
|
||||
if (!pcs->dbg_hdr_addr || !read_process_memory(pcs, pcs->dbg_hdr_addr, &dbg_hdr, sizeof(dbg_hdr)))
|
||||
return FALSE;
|
||||
|
||||
/* Now walk the linked list. In all known ELF implementations,
|
||||
|
@ -1543,13 +1538,11 @@ static BOOL elf_enum_modules_internal(const struct process* pcs,
|
|||
*/
|
||||
for (lm_addr = dbg_hdr.r_map; lm_addr; lm_addr = lm.l_next)
|
||||
{
|
||||
if (!ReadProcessMemory(pcs->handle, (void*)lm_addr, &lm, sizeof(lm), NULL))
|
||||
if (!read_process_memory(pcs, lm_addr, &lm, sizeof(lm)))
|
||||
return FALSE;
|
||||
|
||||
if (lm.l_prev && /* skip first entry, normally debuggee itself */
|
||||
lm.l_name &&
|
||||
ReadProcessMemory(pcs->handle, (void *)(DWORD_PTR)lm.l_name,
|
||||
bufstr, sizeof(bufstr), NULL))
|
||||
lm.l_name && read_process_memory(pcs, lm.l_name, bufstr, sizeof(bufstr)))
|
||||
{
|
||||
bufstr[sizeof(bufstr) - 1] = '\0';
|
||||
MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, ARRAY_SIZE(bufstrW));
|
||||
|
|
|
@ -1349,7 +1349,7 @@ static BOOL image_uses_split_segs(struct process* process, ULONG_PTR load_addr)
|
|||
UINT32 target_magic = (process->is_64bit) ? MACHO_MH_MAGIC_64 : MACHO_MH_MAGIC_32;
|
||||
struct macho_header header;
|
||||
|
||||
if (ReadProcessMemory(process->handle, (void*)load_addr, &header, FIELD_OFFSET(struct macho_header, reserved), NULL) &&
|
||||
if (read_process_memory(process, load_addr, &header, FIELD_OFFSET(struct macho_header, reserved)) &&
|
||||
header.magic == target_magic && header.cputype == target_cpu &&
|
||||
header.flags & MACHO_DYLD_IN_SHARED_CACHE)
|
||||
{
|
||||
|
@ -1629,8 +1629,7 @@ static BOOL macho_enum_modules_internal(const struct process* pcs,
|
|||
else
|
||||
len = sizeof(image_infos.infos32);
|
||||
if (!pcs->dbg_hdr_addr ||
|
||||
!ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr,
|
||||
&image_infos, len, NULL))
|
||||
!read_process_memory(pcs, pcs->dbg_hdr_addr, &image_infos, len))
|
||||
goto done;
|
||||
if (!pcs->is_64bit)
|
||||
{
|
||||
|
@ -1649,8 +1648,7 @@ static BOOL macho_enum_modules_internal(const struct process* pcs,
|
|||
len *= image_infos.infos64.infoArrayCount;
|
||||
info_array = HeapAlloc(GetProcessHeap(), 0, len);
|
||||
if (!info_array ||
|
||||
!ReadProcessMemory(pcs->handle, (void*)image_infos.infos64.infoArray,
|
||||
info_array, len, NULL))
|
||||
!read_process_memory(pcs, image_infos.infos64.infoArray, info_array, len))
|
||||
goto done;
|
||||
TRACE("... read image infos\n");
|
||||
|
||||
|
@ -1666,7 +1664,7 @@ static BOOL macho_enum_modules_internal(const struct process* pcs,
|
|||
info.imageFilePath = info32->imageFilePath;
|
||||
}
|
||||
if (info.imageFilePath &&
|
||||
ReadProcessMemory(pcs->handle, (void*)info.imageFilePath, bufstr, sizeof(bufstr), NULL))
|
||||
read_process_memory(pcs, info.imageFilePath, bufstr, sizeof(bufstr)))
|
||||
{
|
||||
bufstr[sizeof(bufstr) - 1] = '\0';
|
||||
TRACE("[%d] image file %s\n", i, debugstr_a(bufstr));
|
||||
|
@ -1850,7 +1848,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in
|
|||
len = sizeof(image_infos.infos64);
|
||||
else
|
||||
len = sizeof(image_infos.infos32);
|
||||
if (ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, &image_infos, len, NULL))
|
||||
if (read_process_memory(pcs, pcs->dbg_hdr_addr, &image_infos, len))
|
||||
{
|
||||
if (pcs->is_64bit)
|
||||
len = sizeof(image_info.info64);
|
||||
|
@ -1862,7 +1860,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in
|
|||
len = sizeof(image_info.info32);
|
||||
}
|
||||
if (image_infos.infos64.infoArray && image_infos.infos64.infoArrayCount &&
|
||||
ReadProcessMemory(pcs->handle, (void*)image_infos.infos64.infoArray, &image_info, len, NULL))
|
||||
read_process_memory(pcs, image_infos.infos64.infoArray, &image_info, len))
|
||||
{
|
||||
if (!pcs->is_64bit)
|
||||
{
|
||||
|
@ -1872,7 +1870,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in
|
|||
}
|
||||
for (len = sizeof(path); image_info.info64.imageFilePath && len > 0; len /= 2)
|
||||
{
|
||||
if (ReadProcessMemory(pcs->handle, (void*)image_info.info64.imageFilePath, path, len, NULL))
|
||||
if (read_process_memory(pcs, image_info.info64.imageFilePath, path, len))
|
||||
{
|
||||
path[len - 1] = 0;
|
||||
got_path = TRUE;
|
||||
|
|
|
@ -854,9 +854,7 @@ static unsigned dump_memory_info(struct dump_context* dc)
|
|||
for (pos = 0; pos < dc->mem[i].size; pos += sizeof(tmp))
|
||||
{
|
||||
len = min(dc->mem[i].size - pos, sizeof(tmp));
|
||||
if (ReadProcessMemory(dc->process->handle,
|
||||
(void*)(DWORD_PTR)(dc->mem[i].base + pos),
|
||||
tmp, len, NULL))
|
||||
if (read_process_memory(dc->process, dc->mem[i].base + pos, tmp, len))
|
||||
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
||||
}
|
||||
dc->rva += mdMem.Memory.DataSize;
|
||||
|
@ -912,9 +910,7 @@ static unsigned dump_memory64_info(struct dump_context* dc)
|
|||
for (pos = 0; pos < dc->mem64[i].size; pos += sizeof(tmp))
|
||||
{
|
||||
len = min(dc->mem64[i].size - pos, sizeof(tmp));
|
||||
if (ReadProcessMemory(dc->process->handle,
|
||||
(void*)(ULONG_PTR)(dc->mem64[i].base + pos),
|
||||
tmp, len, NULL))
|
||||
if (read_process_memory(dc->process, dc->mem64[i].base + pos, tmp, len))
|
||||
WriteFile(dc->hFile, tmp, len, &written, NULL);
|
||||
}
|
||||
filepos.QuadPart += mdMem64.DataSize;
|
||||
|
|
|
@ -4,4 +4,4 @@ files:
|
|||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
|
||||
tags:
|
||||
wine: 53b5c3b6c674f4bd6d02f20986598b5b6580a2d8
|
||||
wine: 26f5bfdd4d071a91a38b25c0064ed5ea48993249
|
||||
|
|
Loading…
Reference in a new issue