diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2023-11-20 20:22:55 +0000 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2023-12-04 19:30:09 +0000 |
commit | 324ebec00666aeaa45828712fcc27b70ef86350a (patch) | |
tree | b4353c23d9237c3acd2bac82b9b3f923e52244d5 /src/dbg.c | |
parent | 44d805746e27c58f906ba73f541abcb363323a75 (diff) |
Add cutscene skipping to L4D quick reset
Also done with quite a lot of RE help from bill - thanks again!
Diffstat (limited to 'src/dbg.c')
-rw-r--r-- | src/dbg.c | 40 |
1 files changed, 25 insertions, 15 deletions
@@ -24,9 +24,27 @@ #include "ppmagic.h" #include "udis86.h" +#ifdef _WIN32 +usize dbg_toghidra(const void *addr) { + const void *mod; + if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (ushort *)addr, + (HMODULE *)&mod /* please leave me alone */)) { + con_warn("dbg_toghidra: couldn't get base address\n"); + return 0; + } + return (const char *)addr - (const char *)mod + 0x10000000; +} +#endif + void dbg_hexdump(const char *name, const void *p, int len) { struct rgba nice_colour = {160, 64, 200, 255}; // a nice purple colour - con_colourmsg(&nice_colour, "Hex dump \"%s\" (%p):", name, p); +#ifdef _WIN32 + con_colourmsg(&nice_colour, "Hex dump \"%s\" (%p | %p):\n", name, p, + (void *)dbg_toghidra(p)); +#else + con_colourmsg(&nice_colour, "Hex dump \"%s\" (%p):\n", name, p); +#endif for (const uchar *cp = p; cp - (uchar *)p < len; ++cp) { // group into words and wrap every 8 words switch ((cp - (uchar *)p) & 31) { @@ -45,23 +63,15 @@ void dbg_asmdump(const char *name, const void *p, int len) { ud_set_mode(&udis, 32); ud_set_input_buffer(&udis, p, len); ud_set_syntax(&udis, UD_SYN_INTEL); - con_colourmsg(&nice_colour, "Disassembly \"%s\" (%p)\n", name, p); +#ifdef _WIN32 + con_colourmsg(&nice_colour, "Disassembly \"%s\" (%p | %p):\n", name, p, + (void *)dbg_toghidra(p)); +#else + con_colourmsg(&nice_colour, "Disassembly \"%s\" (%p):\n", name, p); +#endif while (ud_disassemble(&udis)) { con_colourmsg(&nice_colour, " %s\n", ud_insn_asm(&udis)); } } -#ifdef _WIN32 -usize dbg_toghidra(const void *addr) { - const void *mod; - if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (ushort *)addr, - (HMODULE *)&mod /* please leave me alone */)) { - con_warn("dbg_toghidra: couldn't get base address\n"); - return 0; - } - return (const char *)addr - (const char *)mod + 0x10000000; -} -#endif - // vi: sw=4 ts=4 noet tw=80 cc=80 |