mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-08 14:58:08 +00:00
custom module loads -> support manually specifying pdb path
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
# define raddbg_add_breakpoint(ptr, size, r, w, x) raddbg_add_or_remove_breakpoint__impl((ptr), (1), (size), (r), (w), (x))
|
# define raddbg_add_breakpoint(ptr, size, r, w, x) raddbg_add_or_remove_breakpoint__impl((ptr), (1), (size), (r), (w), (x))
|
||||||
# define raddbg_remove_breakpoint(ptr, size, r, w, x) raddbg_add_or_remove_breakpoint__impl((ptr), (0), (size), (r), (w), (x))
|
# define raddbg_remove_breakpoint(ptr, size, r, w, x) raddbg_add_or_remove_breakpoint__impl((ptr), (0), (size), (r), (w), (x))
|
||||||
# define raddbg_annotate_vaddr_range(ptr, size, ...) raddbg_annotate_vaddr_range__impl((ptr), (size), __VA_ARGS__)
|
# define raddbg_annotate_vaddr_range(ptr, size, ...) raddbg_annotate_vaddr_range__impl((ptr), (size), __VA_ARGS__)
|
||||||
# define raddbg_load_module(ptr, size, name) raddbg_load_module__impl((ptr), (size), (name))
|
# define raddbg_load_module(ptr, size, name, dbg_path) raddbg_load_module__impl((ptr), (size), (name), (dbg_path))
|
||||||
#else
|
#else
|
||||||
# define raddbg_is_attached(...) (0)
|
# define raddbg_is_attached(...) (0)
|
||||||
# define raddbg_thread_id(...) ((void)0)
|
# define raddbg_thread_id(...) ((void)0)
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
# define raddbg_add_breakpoint(ptr, size, r, w, x) ((void)0)
|
# define raddbg_add_breakpoint(ptr, size, r, w, x) ((void)0)
|
||||||
# define raddbg_remove_breakpoint(ptr, size, r, w, x) ((void)0)
|
# define raddbg_remove_breakpoint(ptr, size, r, w, x) ((void)0)
|
||||||
# define raddbg_annotate_vaddr_range(ptr, size, ...) ((void)0)
|
# define raddbg_annotate_vaddr_range(ptr, size, ...) ((void)0)
|
||||||
# define raddbg_load_module(ptr, size, name) ((void)0)
|
# define raddbg_load_module(ptr, size, name, dbg_path) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -469,7 +469,7 @@ raddbg_annotate_vaddr_range__impl(void *ptr, unsigned __int64 size, char *fmt, .
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
raddbg_load_module__impl(void *ptr, unsigned __int64 size, char *name)
|
raddbg_load_module__impl(void *ptr, unsigned __int64 size, char *name, char *dbg_path)
|
||||||
{
|
{
|
||||||
if(raddbg_is_attached())
|
if(raddbg_is_attached())
|
||||||
{
|
{
|
||||||
@@ -480,12 +480,14 @@ raddbg_load_module__impl(void *ptr, unsigned __int64 size, char *name)
|
|||||||
unsigned __int64 vaddr;
|
unsigned __int64 vaddr;
|
||||||
unsigned __int64 size;
|
unsigned __int64 size;
|
||||||
unsigned __int64 name_vaddr;
|
unsigned __int64 name_vaddr;
|
||||||
|
unsigned __int64 dbg_path_vaddr;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
RADDBG_LoadModuleInfo info;
|
RADDBG_LoadModuleInfo info;
|
||||||
info.vaddr = (unsigned __int64)ptr;
|
info.vaddr = (unsigned __int64)ptr;
|
||||||
info.size = size;
|
info.size = size;
|
||||||
info.name_vaddr = (unsigned __int64)name;
|
info.name_vaddr = (unsigned __int64)name;
|
||||||
|
info.dbg_path_vaddr = (unsigned __int64)dbg_path;
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 6320 6322)
|
#pragma warning(disable: 6320 6322)
|
||||||
__try
|
__try
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ w32_dmn_read_memory_str16(Arena *arena, HANDLE process_handle, U64 address)
|
|||||||
//- rjf: modules
|
//- rjf: modules
|
||||||
|
|
||||||
internal DMN_ModuleInfo *
|
internal DMN_ModuleInfo *
|
||||||
w32_dmn_module_info_from_process_module(Arena *arena, HANDLE process, HANDLE module, U64 base_vaddr, U64 module_name_vaddr, B32 module_name_is_unicode, B32 is_main_module)
|
w32_dmn_module_info_from_process_module(Arena *arena, HANDLE process, HANDLE module, U64 base_vaddr, U64 module_name_vaddr, B32 module_name_is_unicode, B32 is_main_module, U64 dbg_path_vaddr)
|
||||||
{
|
{
|
||||||
DMN_ModuleInfo *info = push_array(arena, DMN_ModuleInfo, 1);
|
DMN_ModuleInfo *info = push_array(arena, DMN_ModuleInfo, 1);
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
@@ -791,6 +791,16 @@ w32_dmn_module_info_from_process_module(Arena *arena, HANDLE process, HANDLE mod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- rjf: nonzero debug path address -> try to read new path from it
|
||||||
|
if(dbg_path_vaddr != 0)
|
||||||
|
{
|
||||||
|
String8 debug_path_override_maybe = w32_dmn_str8_cstring_from_process_vaddr(arena, process, dbg_path_vaddr);
|
||||||
|
if(debug_path_override_maybe.size != 0)
|
||||||
|
{
|
||||||
|
debug_info_path = debug_path_override_maybe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: fill info
|
//- rjf: fill info
|
||||||
info->arch = arch;
|
info->arch = arch;
|
||||||
info->vsize = image_vsize;
|
info->vsize = image_vsize;
|
||||||
@@ -2087,7 +2097,7 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
B32 module_name_is_unicode = (evt.u.CreateProcessInfo.fUnicode != 0);
|
B32 module_name_is_unicode = (evt.u.CreateProcessInfo.fUnicode != 0);
|
||||||
|
|
||||||
// rjf: parse module info
|
// rjf: parse module info
|
||||||
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process_handle, module_handle, module_base, module_name_vaddr, module_name_is_unicode, 1);
|
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process_handle, module_handle, module_base, module_name_vaddr, module_name_is_unicode, 1, 0);
|
||||||
|
|
||||||
// rjf: create process/module entities (module is implied for processes - not reported directly via module events)
|
// rjf: create process/module entities (module is implied for processes - not reported directly via module events)
|
||||||
W32_DMN_Entity *process = w32_dmn_entity_alloc(w32_dmn_shared->entities_base, W32_DMN_EntityKind_Process, evt.dwProcessId);
|
W32_DMN_Entity *process = w32_dmn_entity_alloc(w32_dmn_shared->entities_base, W32_DMN_EntityKind_Process, evt.dwProcessId);
|
||||||
@@ -2324,7 +2334,7 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
HANDLE module_handle = evt.u.LoadDll.hFile;
|
HANDLE module_handle = evt.u.LoadDll.hFile;
|
||||||
U64 module_name_vaddr = (U64)evt.u.LoadDll.lpImageName;
|
U64 module_name_vaddr = (U64)evt.u.LoadDll.lpImageName;
|
||||||
B32 module_name_is_unicode = (evt.u.LoadDll.fUnicode != 0);
|
B32 module_name_is_unicode = (evt.u.LoadDll.fUnicode != 0);
|
||||||
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process->handle, module_handle, module_base, module_name_vaddr, module_name_is_unicode, 0);
|
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process->handle, module_handle, module_base, module_name_vaddr, module_name_is_unicode, 0, 0);
|
||||||
|
|
||||||
// rjf: create module entity
|
// rjf: create module entity
|
||||||
W32_DMN_Entity *module = w32_dmn_entity_alloc(process, W32_DMN_EntityKind_Module, module_base);
|
W32_DMN_Entity *module = w32_dmn_entity_alloc(process, W32_DMN_EntityKind_Module, module_base);
|
||||||
@@ -2780,10 +2790,11 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
|
|||||||
U64 vaddr = exception->ExceptionInformation[0];
|
U64 vaddr = exception->ExceptionInformation[0];
|
||||||
U64 size = exception->ExceptionInformation[1];
|
U64 size = exception->ExceptionInformation[1];
|
||||||
U64 name_vaddr = exception->ExceptionInformation[2];
|
U64 name_vaddr = exception->ExceptionInformation[2];
|
||||||
|
U64 dbg_path_vaddr = exception->ExceptionInformation[3];
|
||||||
|
|
||||||
// rjf: parse module info
|
// rjf: parse module info
|
||||||
W32_DMN_Entity *process = w32_dmn_entity_from_kind_id(W32_DMN_EntityKind_Process, evt.dwProcessId);
|
W32_DMN_Entity *process = w32_dmn_entity_from_kind_id(W32_DMN_EntityKind_Process, evt.dwProcessId);
|
||||||
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process->handle, 0, vaddr, name_vaddr, 0, 0);
|
DMN_ModuleInfo *module_info = w32_dmn_module_info_from_process_module(arena, process->handle, 0, vaddr, name_vaddr, 0, 0, dbg_path_vaddr);
|
||||||
|
|
||||||
// rjf: create module entity
|
// rjf: create module entity
|
||||||
W32_DMN_Entity *module = w32_dmn_entity_alloc(process, W32_DMN_EntityKind_Module, vaddr);
|
W32_DMN_Entity *module = w32_dmn_entity_alloc(process, W32_DMN_EntityKind_Module, vaddr);
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ internal String16 w32_dmn_read_memory_str16(Arena *arena, HANDLE process_handle,
|
|||||||
#define w32_dmn_process_write_struct(process, vaddr, ptr) w32_dmn_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
|
#define w32_dmn_process_write_struct(process, vaddr, ptr) w32_dmn_process_write((process), r1u64((vaddr), (vaddr)+(sizeof(*ptr))), ptr)
|
||||||
|
|
||||||
//- rjf: modules
|
//- rjf: modules
|
||||||
internal DMN_ModuleInfo *w32_dmn_module_info_from_process_module(Arena *arena, HANDLE process, HANDLE module, U64 base_vaddr, U64 module_name_vaddr, B32 module_name_is_unicode, B32 is_main_module);
|
internal DMN_ModuleInfo *w32_dmn_module_info_from_process_module(Arena *arena, HANDLE process, HANDLE module, U64 base_vaddr, U64 module_name_vaddr, B32 module_name_is_unicode, B32 is_main_module, U64 dbg_path_vaddr);
|
||||||
|
|
||||||
//- rjf: threads
|
//- rjf: threads
|
||||||
internal B32 w32_dmn_thread_read_reg_block(Arch arch, HANDLE thread, void *reg_block);
|
internal B32 w32_dmn_thread_read_reg_block(Arch arch, HANDLE thread, void *reg_block);
|
||||||
|
|||||||
Reference in New Issue
Block a user