|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include <dttr_config.h>#include <dttr_crashdump.h>#include <dttr_errors.h>#include <dttr_imgui.h>#include <dttr_path.h>#include <dttr_sdl.h>#include <Zydis/Zydis.h>#include <dbghelp.h>#include <dttr_log.h>#include <sds.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | CrashDisasmLine |
Macros | |
| #define | MAX_STACK_FRAMES 64 |
| #define | SYMBOL_NAME_CAPACITY 256 |
| #define | SYMBOL_BUFFER_SIZE (sizeof(IMAGEHLP_SYMBOL) + SYMBOL_NAME_CAPACITY) |
| #define | DISASM_BYTES_BEFORE 16u |
| #define | DISASM_BYTES_AFTER 32u |
| #define | DISASM_MAX_BYTES (DISASM_BYTES_BEFORE + DISASM_BYTES_AFTER) |
| #define | DISASM_MAX_INSTRUCTIONS 6 |
| #define | DISASM_MAX_LINES (DISASM_BYTES_BEFORE + DISASM_MAX_INSTRUCTIONS) |
| #define | DISASM_TEXT_CAPACITY 160 |
Functions | |
| static BOOL | init_dbghelp_lock (PINIT_ONCE, PVOID, PVOID *) |
| static void | enter_dbghelp_lock () |
| static void | leave_dbghelp_lock () |
| static void | invoke_symbol_provider (HANDLE process) |
| void | DTTR_CrashDump_SetSymbolProvider (DTTR_CrashDump_SymbolProvider provider, void *context) |
| Registers a synchronous symbol provider used by crash stack formatting. | |
| void | DTTR_CrashDump_ClearSymbolProvider () |
| static bool | memory_protection_is_readable (DWORD protect) |
| static sds | append_disassembly_unavailable (sds message, const char *reason) |
| static sds | append_disassembly_line (sds message, DWORD address, const char *text, bool failed) |
| static bool | format_instruction_at (ZydisDecoder *decoder, ZydisFormatter *formatter, const uint8_t *bytes, size_t size, DWORD address, ZydisDecodedInstruction *instruction, char *text, size_t text_size) |
| static sds | append_failed_instruction_decode (sds message, ZydisDecoder *decoder, ZydisFormatter *formatter, const uint8_t *bytes, size_t size, DWORD failed_eip) |
| static sds | append_disassembly_from_bytes (sds message, const uint8_t *bytes, size_t size, DWORD runtime_base, DWORD failed_eip) |
| static sds | append_registers (sds message, const CONTEXT *ctx) |
| static sds | append_disassembly_window (sds message, HANDLE process, DWORD failed_eip) |
| static sds | append_crash_diagnostics (sds message, HANDLE process, const CONTEXT *context) |
| static MINIDUMP_TYPE | minidump_type () |
| static sds | build_crash_message (DWORD code, const char *filename) |
| sds | DTTR_CrashDump_AppendReportMessage (sds message, const char *stack_trace) |
| sds | DTTR_CrashDump_Write (HANDLE process, DWORD pid, DWORD tid, EXCEPTION_POINTERS *exception_info) |
| void | DTTR_CrashDump_LogAndTraceReport (const char *message) |
| sds | DTTR_CrashDump_FormatStackTrace (HANDLE process, HANDLE thread, const CONTEXT *context) |
| Formats a stack trace from a thread context. Caller frees the returned sds. | |
| static LONG | unhandled_exception_filter (EXCEPTION_POINTERS *const exception_info) |
| static bool | set_dump_dir (const char *base_dir) |
| void | DTTR_CrashDump_Init (const char *const dump_dir) |
Variables | |
| static char | crash_dump_dir [MAX_PATH] |
| static INIT_ONCE | dbghelp_lock_once = INIT_ONCE_STATIC_INIT |
| static CRITICAL_SECTION | dbghelp_lock |
| static DTTR_CrashDump_SymbolProvider | crash_symbol_provider |
| static void * | crash_symbol_provider_context |
| #define DISASM_BYTES_AFTER 32u |
Definition at line 61 of file crashdump.c.
Referenced by append_disassembly_window().
| #define DISASM_BYTES_BEFORE 16u |
Definition at line 60 of file crashdump.c.
Referenced by append_disassembly_window().
| #define DISASM_MAX_BYTES (DISASM_BYTES_BEFORE + DISASM_BYTES_AFTER) |
Definition at line 62 of file crashdump.c.
Referenced by append_disassembly_window().
| #define DISASM_MAX_INSTRUCTIONS 6 |
Definition at line 63 of file crashdump.c.
Referenced by append_disassembly_from_bytes(), and append_failed_instruction_decode().
| #define DISASM_MAX_LINES (DISASM_BYTES_BEFORE + DISASM_MAX_INSTRUCTIONS) |
Definition at line 64 of file crashdump.c.
Referenced by append_disassembly_from_bytes().
| #define DISASM_TEXT_CAPACITY 160 |
Definition at line 65 of file crashdump.c.
Referenced by append_failed_instruction_decode().
| #define MAX_STACK_FRAMES 64 |
Definition at line 57 of file crashdump.c.
Referenced by DTTR_CrashDump_FormatStackTrace().
| #define SYMBOL_BUFFER_SIZE (sizeof(IMAGEHLP_SYMBOL) + SYMBOL_NAME_CAPACITY) |
Definition at line 59 of file crashdump.c.
Referenced by DTTR_CrashDump_FormatStackTrace().
| #define SYMBOL_NAME_CAPACITY 256 |
Definition at line 58 of file crashdump.c.
Referenced by DTTR_CrashDump_FormatStackTrace().
|
static |
Definition at line 381 of file crashdump.c.
References append_disassembly_window(), and append_registers().
Referenced by DTTR_CrashDump_FormatStackTrace().
|
static |
Definition at line 179 of file crashdump.c.
References CrashDisasmLine::address, append_disassembly_line(), append_disassembly_unavailable(), append_failed_instruction_decode(), decoder, DISASM_MAX_INSTRUCTIONS, DISASM_MAX_LINES, DWORD, format_instruction_at(), and size.
Referenced by append_disassembly_window().
|
static |
Definition at line 99 of file crashdump.c.
References DWORD.
Referenced by append_disassembly_from_bytes(), and append_failed_instruction_decode().
|
static |
Definition at line 86 of file crashdump.c.
Referenced by append_disassembly_from_bytes(), append_disassembly_window(), and append_failed_instruction_decode().
|
static |
Definition at line 327 of file crashdump.c.
References append_disassembly_from_bytes(), append_disassembly_unavailable(), DISASM_BYTES_AFTER, DISASM_BYTES_BEFORE, DISASM_MAX_BYTES, DWORD, memory_protection_is_readable(), and size.
Referenced by append_crash_diagnostics().
|
static |
Definition at line 140 of file crashdump.c.
References append_disassembly_line(), append_disassembly_unavailable(), decoder, DISASM_MAX_INSTRUCTIONS, DISASM_TEXT_CAPACITY, DWORD, format_instruction_at(), and size.
Referenced by append_disassembly_from_bytes().
|
static |
Definition at line 272 of file crashdump.c.
References ctx.
Referenced by append_crash_diagnostics().
|
static |
Definition at line 399 of file crashdump.c.
References DWORD.
Referenced by unhandled_exception_filter().
| sds DTTR_CrashDump_AppendReportMessage | ( | sds | message, |
| const char * | stack_trace ) |
Definition at line 416 of file crashdump.c.
References DTTR_REPORT_SUFFIX.
Referenced by unhandled_exception_filter(), and write_child_dump().
| void DTTR_CrashDump_ClearSymbolProvider | ( | ) |
Definition at line 53 of file crashdump.c.
References DTTR_CrashDump_SetSymbolProvider(), and NULL.
Referenced by dttr_pcdogs_crash_symbols_clear().
| sds DTTR_CrashDump_FormatStackTrace | ( | HANDLE | process, |
| HANDLE | thread, | ||
| const CONTEXT * | context ) |
Formats a stack trace from a thread context. Caller frees the returned sds.
Definition at line 496 of file crashdump.c.
References append_crash_diagnostics(), ctx, DWORD, enter_dbghelp_lock(), invoke_symbol_provider(), leave_dbghelp_lock(), MAX_STACK_FRAMES, NULL, SYMBOL_BUFFER_SIZE, and SYMBOL_NAME_CAPACITY.
Referenced by dttr_sidecar_write_exception_report(), unhandled_exception_filter(), and write_child_dump().
| void DTTR_CrashDump_Init | ( | const char * | dump_dir | ) |
Installs an exception filter that writes dumps under the given directory and shows a crash dialog.
Definition at line 636 of file crashdump.c.
References crash_dump_dir, DTTR_LOG_DEBUG, DTTR_LOG_ERROR, set_dump_dir(), and unhandled_exception_filter().
Referenced by DTTR_Hook_WinMainCallback(), and dttr_launcher_main().
| void DTTR_CrashDump_LogAndTraceReport | ( | const char * | message | ) |
Definition at line 486 of file crashdump.c.
References DTTR_LOG_ERROR.
Referenced by unhandled_exception_filter(), and write_child_dump().
| void DTTR_CrashDump_SetSymbolProvider | ( | DTTR_CrashDump_SymbolProvider | provider, |
| void * | context ) |
Registers a synchronous symbol provider used by crash stack formatting.
Definition at line 43 of file crashdump.c.
References crash_symbol_provider, crash_symbol_provider_context, enter_dbghelp_lock(), and leave_dbghelp_lock().
Referenced by DTTR_CrashDump_ClearSymbolProvider(), and dttr_pcdogs_crash_symbols_register().
| sds DTTR_CrashDump_Write | ( | HANDLE | process, |
| DWORD | pid, | ||
| DWORD | tid, | ||
| EXCEPTION_POINTERS * | exception_info ) |
Writes a process minidump and returns the dump filename. The caller should free the returned sds.
Definition at line 428 of file crashdump.c.
References BOOL, crash_dump_dir, DTTR_LOG_ERROR, DTTR_LOG_INFO, DWORD, enter_dbghelp_lock(), FALSE, leave_dbghelp_lock(), minidump_type(), NULL, and st.
Referenced by dttr_sidecar_write_exception_report(), unhandled_exception_filter(), and write_child_dump().
|
static |
Definition at line 28 of file crashdump.c.
References dbghelp_lock, dbghelp_lock_once, init_dbghelp_lock(), and NULL.
Referenced by DTTR_CrashDump_FormatStackTrace(), DTTR_CrashDump_SetSymbolProvider(), and DTTR_CrashDump_Write().
|
static |
Definition at line 112 of file crashdump.c.
References decoder, DWORD, and size.
Referenced by append_disassembly_from_bytes(), and append_failed_instruction_decode().
|
static |
Definition at line 23 of file crashdump.c.
References BOOL, and dbghelp_lock.
Referenced by enter_dbghelp_lock().
|
static |
Definition at line 37 of file crashdump.c.
References crash_symbol_provider, and crash_symbol_provider_context.
Referenced by DTTR_CrashDump_FormatStackTrace().
|
static |
Definition at line 33 of file crashdump.c.
References dbghelp_lock.
Referenced by DTTR_CrashDump_FormatStackTrace(), DTTR_CrashDump_SetSymbolProvider(), and DTTR_CrashDump_Write().
|
static |
Definition at line 67 of file crashdump.c.
References DWORD.
Referenced by append_disassembly_window().
|
static |
Definition at line 391 of file crashdump.c.
References dttr_config, and DTTR_MINIDUMP_DETAILED.
Referenced by draw_general_tab(), and DTTR_CrashDump_Write().
|
static |
Definition at line 611 of file crashdump.c.
References crash_dump_dir, DTTR_LOG_ERROR, DTTR_Path_AppendSegment(), DTTR_Path_AppendSeparator(), DTTR_Path_CopySds(), DTTR_PATH_NATIVE_SEPARATOR, and NULL.
Referenced by DTTR_CrashDump_Init().
|
static |
Definition at line 576 of file crashdump.c.
References build_crash_message(), dttr_config, DTTR_CrashDump_AppendReportMessage(), DTTR_CrashDump_FormatStackTrace(), DTTR_CrashDump_LogAndTraceReport(), DTTR_CrashDump_Write(), DTTR_ImGui_ErrorShow(), DTTR_SDL_ShowSimpleMessageBox(), DWORD, and NULL.
Referenced by DTTR_CrashDump_Init().
|
static |
Definition at line 16 of file crashdump.c.
Referenced by DTTR_CrashDump_Init(), DTTR_CrashDump_Write(), and set_dump_dir().
|
static |
Definition at line 20 of file crashdump.c.
Referenced by DTTR_CrashDump_SetSymbolProvider(), and invoke_symbol_provider().
|
static |
Definition at line 21 of file crashdump.c.
Referenced by DTTR_CrashDump_SetSymbolProvider(), and invoke_symbol_provider().
|
static |
Definition at line 19 of file crashdump.c.
Referenced by enter_dbghelp_lock(), init_dbghelp_lock(), and leave_dbghelp_lock().
|
static |
Definition at line 18 of file crashdump.c.
Referenced by enter_dbghelp_lock().