From a256e5c48a923dfed9b651260f136eddd1aa2a91 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 1 Oct 2026 10:33:24 -0700 Subject: [PATCH] sketch out linux non-host layer, for mapping numeric exception codes to metadata on debugger frontend. also do not always call XQueryKeymap/XQueryPointer; these are very expensive and we only use them in scenarios where we can take the most recently cached value from events. --- src/dbg_engine/dbg_engine.mdesk | 76 -------- src/dbg_engine/dbg_engine_ctrl.c | 3 +- src/linux/generated/linux.meta.c | 5 + src/linux/generated/linux.meta.h | 9 + src/linux/linux.c | 4 + src/linux/linux.h | 9 + src/linux/linux.mdesk | 38 ++++ src/linux/linux_inc.c | 4 + src/linux/linux_inc.h | 9 + .../window_manager/linux_window_manager.c | 27 +-- .../window_manager/linux_window_manager.h | 2 + src/raddbg/raddbg_main.c | 2 + src/win32/generated/win32.meta.c | 176 ++++++++++++++++++ src/win32/generated/win32.meta.h | 60 ++++++ src/win32/win32.c | 4 + src/win32/win32.h | 9 + src/win32/win32.mdesk | 154 +++++++++++++++ src/win32/win32_inc.c | 1 + src/win32/win32_inc.h | 1 + 19 files changed, 503 insertions(+), 90 deletions(-) create mode 100644 src/linux/generated/linux.meta.c create mode 100644 src/linux/generated/linux.meta.h create mode 100644 src/linux/linux.c create mode 100644 src/linux/linux.h create mode 100644 src/linux/linux.mdesk create mode 100644 src/linux/linux_inc.c create mode 100644 src/linux/linux_inc.h create mode 100644 src/win32/generated/win32.meta.c create mode 100644 src/win32/generated/win32.meta.h create mode 100644 src/win32/win32.c create mode 100644 src/win32/win32.h create mode 100644 src/win32/win32.mdesk diff --git a/src/dbg_engine/dbg_engine.mdesk b/src/dbg_engine/dbg_engine.mdesk index c7c9b904..13cd3753 100644 --- a/src/dbg_engine/dbg_engine.mdesk +++ b/src/dbg_engine/dbg_engine.mdesk @@ -211,79 +211,3 @@ D_ExceptionCodeKindTable: `0`; @expand(D_ExceptionCodeKindTable a) `$(a.default)`; } - -//////////////////////////////// -//~ rjf: Exception Sub-Codes - -@table(name, value) -DL_ExceptionSubCodeKindTable: -{ - { W32_FAST_FAIL_LEGACY_GS_VIOLATION 0 } - { W32_FAST_FAIL_VTGUARD_CHECK_FAILURE 1 } - { W32_FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2 } - { W32_FAST_FAIL_CORRUPT_LIST_ENTRY 3 } - { W32_FAST_FAIL_INCORRECT_STACK 4 } - { W32_FAST_FAIL_INVALID_ARG 5 } - { W32_FAST_FAIL_GS_COOKIE_INIT 6 } - { W32_FAST_FAIL_FATAL_APP_EXIT 7 } - { W32_FAST_FAIL_RANGE_CHECK_FAILURE 8 } - { W32_FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9 } - { W32_FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10 } - { W32_FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11 } - { W32_FAST_FAIL_INVALID_FIBER_SWITCH 12 } - { W32_FAST_FAIL_INVALID_SET_OF_CONTEXT 13 } - { W32_FAST_FAIL_INVALID_REFERENCE_COUNT 14 } - { W32_FAST_FAIL_INVALID_JUMP_BUFFER 18 } - { W32_FAST_FAIL_MRDATA_MODIFIED 19 } - { W32_FAST_FAIL_CERTIFICATION_FAILURE 20 } - { W32_FAST_FAIL_INVALID_EXCEPTION_CHAIN 21 } - { W32_FAST_FAIL_CRYPTO_LIBRARY 22 } - { W32_FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23 } - { W32_FAST_FAIL_INVALID_IMAGE_BASE 24 } - { W32_FAST_FAIL_DLOAD_PROTECTION_FAILURE 25 } - { W32_FAST_FAIL_UNSAFE_EXTENSION_CALL 26 } - { W32_FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27 } - { W32_FAST_FAIL_INVALID_BUFFER_ACCESS 28 } - { W32_FAST_FAIL_INVALID_BALANCED_TREE 29 } - { W32_FAST_FAIL_INVALID_NEXT_THREAD 30 } - { W32_FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31 } - { W32_FAST_FAIL_APCS_DISABLED 32 } - { W32_FAST_FAIL_INVALID_IDLE_STATE 33 } - { W32_FAST_FAIL_MRDATA_PROTECTION_FAILURE 34 } - { W32_FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35 } - { W32_FAST_FAIL_INVALID_LOCK_STATE 36 } - { W32_FAST_FAIL_GUARD_JUMPTABLE 37 } - { W32_FAST_FAIL_INVALID_LONGJUMP_TARGET 38 } - { W32_FAST_FAIL_INVALID_DISPATCH_CONTEXT 39 } - { W32_FAST_FAIL_INVALID_THREAD 40 } - { W32_FAST_FAIL_INVALID_SYSCALL_NUMBER 41 } - { W32_FAST_FAIL_INVALID_FILE_OPERATION 42 } - { W32_FAST_FAIL_LPAC_ACCESS_DENIED 43 } - { W32_FAST_FAIL_GUARD_SS_FAILURE 44 } - { W32_FAST_FAIL_LOADER_CONTINUITY_FAILURE 45 } - { W32_FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46 } - { W32_FAST_FAIL_INVALID_CONTROL_STACK 47 } - { W32_FAST_FAIL_SET_CONTEXT_DENIED 48 } - { W32_FAST_FAIL_INVALID_IAT 49 } - { W32_FAST_FAIL_HEAP_METADATA_CORRUPTION 50 } - { W32_FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51 } - { W32_FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52 } - { W32_FAST_FAIL_ENCLAVE_CALL_FAILURE 53 } - { W32_FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54 } - { W32_FAST_FAIL_ADMINLESS_ACCESS_DENIED 55 } - { W32_FAST_FAIL_UNEXPECTED_CALL 56 } - { W32_FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57 } - { W32_FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58 } - { W32_FAST_FAIL_FLAGS_CORRUPTION 59 } - { W32_FAST_FAIL_VEH_CORRUPTION 60 } - { W32_FAST_FAIL_ETW_CORRUPTION 61 } - { W32_FAST_FAIL_RIO_ABORT 62 } - { W32_FAST_FAIL_INVALID_PFN 63 } - { W32_FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64 } - { W32_FAST_FAIL_CAST_GUARD 65 } - { W32_FAST_FAIL_HOST_VISIBILITY_CHANGE 66 } - { W32_FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67 } - { W32_FAST_FAIL_PATCH_CALLBACK_FAILED 68 } - { W32_FAST_FAIL_NTDLL_PATCH_FAILED 69 } - { W32_FAST_FAIL_INVALID_FLS_DATA 70 } -} diff --git a/src/dbg_engine/dbg_engine_ctrl.c b/src/dbg_engine/dbg_engine_ctrl.c index 020cb26c..4efe2707 100644 --- a/src/dbg_engine/dbg_engine_ctrl.c +++ b/src/dbg_engine/dbg_engine_ctrl.c @@ -1339,6 +1339,7 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list) if(process != &d_entity_nil) { D_Entity *thread = d_entity_alloc(store, process, D_EntityKind_Thread, event->arch, event->entity, (U64)event->entity_id); + thread->os = process->os; D_Entity *first_thread = d_entity_child_from_kind(process, D_EntityKind_Thread); if(first_thread == thread) { @@ -1369,7 +1370,6 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list) thread->stack_base = event->stack_base; thread->tls_root_vaddr = event->tls_root; } - //d_cached_ip_from_thread(&store->ctx, event->entity); }break; case D_EventKind_EndThread: { @@ -1446,6 +1446,7 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list) d_entity_equip_string(store, module, event->string); module->timestamp = event->timestamp; module->vaddr_range = event->vaddr_rng; + module->os = process->os; D_Entity *first_module = d_entity_child_from_kind(process, D_EntityKind_Module); if(first_module == module && process->string.size == 0) { diff --git a/src/linux/generated/linux.meta.c b/src/linux/generated/linux.meta.c new file mode 100644 index 00000000..0378fad9 --- /dev/null +++ b/src/linux/generated/linux.meta.c @@ -0,0 +1,5 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + diff --git a/src/linux/generated/linux.meta.h b/src/linux/generated/linux.meta.h new file mode 100644 index 00000000..84082495 --- /dev/null +++ b/src/linux/generated/linux.meta.h @@ -0,0 +1,9 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +#ifndef LINUX_META_H +#define LINUX_META_H + +#endif // LINUX_META_H diff --git a/src/linux/linux.c b/src/linux/linux.c new file mode 100644 index 00000000..478fc32d --- /dev/null +++ b/src/linux/linux.c @@ -0,0 +1,4 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#include "linux/generated/linux.meta.c" diff --git a/src/linux/linux.h b/src/linux/linux.h new file mode 100644 index 00000000..2d97ad1b --- /dev/null +++ b/src/linux/linux.h @@ -0,0 +1,9 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef LINUX_H +#define LINUX_H + +#include "linux/generated/linux.meta.h" + +#endif // LINUX_H diff --git a/src/linux/linux.mdesk b/src/linux/linux.mdesk new file mode 100644 index 00000000..4bcee0fc --- /dev/null +++ b/src/linux/linux.mdesk @@ -0,0 +1,38 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +@table(name code repeatable) LNX_SignalCodeTable: +{ + { SIGHUP 1 1 } + { SIGINT 2 1 } + { SIGQUIT 3 1 } + { SIGILL 4 1 } + { SIGTRAP 5 1 } + { SIGABRT 6 1 } + { SIGIOT 6 1 } + { SIGBUS 7 1 } + { SIGFPE 8 1 } + { SIGKILL 9 1 } + { SIGUSR1 10 1 } + { SIGSEGV 11 1 } + { SIGUSR2 12 1 } + { SIGPIPE 13 1 } + { SIGALRM 14 1 } + { SIGTERM 15 1 } + { SIGSTKFLT 16 1 } + { SIGCHLD 17 0 } + { SIGCONT 18 0 } + { SIGSTOP 19 1 } + { SIGTSTP 20 1 } + { SIGTTIN 21 1 } + { SIGTTOU 22 1 } + { SIGURG 23 0 } + { SIGXCPU 24 1 } + { SIGXFSZ 25 1 } + { SIGVTALRM 26 1 } + { SIGPROF 27 1 } + { SIGWINCH 28 0 } + { SIGIO 29 1 } + { SIGPWR 30 1 } + { SIGSYS 31 1 } +} diff --git a/src/linux/linux_inc.c b/src/linux/linux_inc.c new file mode 100644 index 00000000..31120e72 --- /dev/null +++ b/src/linux/linux_inc.c @@ -0,0 +1,4 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#include "linux.c" diff --git a/src/linux/linux_inc.h b/src/linux/linux_inc.h new file mode 100644 index 00000000..ea471525 --- /dev/null +++ b/src/linux/linux_inc.h @@ -0,0 +1,9 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef LINUX_INC_H +#define LINUX_INC_H + +#include "linux.h" + +#endif // LINUX_INC_H diff --git a/src/linux/window_manager/linux_window_manager.c b/src/linux/window_manager/linux_window_manager.c index 81f5c609..a7b501a3 100644 --- a/src/linux/window_manager/linux_window_manager.c +++ b/src/linux/window_manager/linux_window_manager.c @@ -1231,6 +1231,18 @@ wm_get_events(Arena *arena, B32 wait) B32 is_right_sided = 0; WM_Key key = lnx_wm_key_from_keysym(keysym, &is_right_sided); + // rjf: update modifier / key down state + if(evt.type == KeyPress) + { + lnx_wm_state->modifier_state |= modifiers; + lnx_wm_state->key_down_state[key/64] |= (1ull<<(key%64)); + } + else + { + lnx_wm_state->modifier_state &= ~modifiers; + lnx_wm_state->key_down_state[key/64] &= ~(1ull<<(key%64)); + } + // rjf: push text event if(evt.type == KeyPress && text_size != 0) { @@ -1465,25 +1477,14 @@ wm_get_events(Arena *arena, B32 wait) internal WM_Modifiers wm_get_modifiers(void) { - WM_Modifiers mods = 0; - if(wm_key_is_down(WM_Key_Shift)) { mods |= WM_Modifier_Shift; } - if(wm_key_is_down(WM_Key_Alt)) { mods |= WM_Modifier_Alt; } - if(wm_key_is_down(WM_Key_Ctrl)) { mods |= WM_Modifier_Ctrl; } + WM_Modifiers mods = lnx_wm_state->modifier_state; return mods; } internal B32 wm_key_is_down(WM_Key key) { - B32 result = 0; - { - char keys[32]; - XQueryKeymap(lnx_wm_state->display, keys); - KeySym sym = lnx_wm_keysym_from_key(key); - KeyCode code = XKeysymToKeycode(lnx_wm_state->display, sym); - B32 is_down = !!(keys[code/8] & (1u<<(code%8))); - result = is_down; - } + B32 result = !!(lnx_wm_state->key_down_state[key/64] & (1ull<<(key%64))); return result; } diff --git a/src/linux/window_manager/linux_window_manager.h b/src/linux/window_manager/linux_window_manager.h index 36f9dba8..9a4f4622 100644 --- a/src/linux/window_manager/linux_window_manager.h +++ b/src/linux/window_manager/linux_window_manager.h @@ -95,6 +95,8 @@ struct LNX_WM_State LNX_WM_WindowClientArea *free_client_area; long *icon_image_data; U64 icon_image_data_count; + WM_Modifiers modifier_state; + U64 key_down_state[(WM_Key_COUNT+63)/64]; }; //////////////////////////////// diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 86802f7b..753b0150 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -403,6 +403,7 @@ #include "base/base_inc.h" #include "x64/x64_inc.h" #include "win32/win32_inc.h" +#include "linux/linux_inc.h" #include "linker/base_ext/base_bit_array.h" #include "artifact_cache/artifact_cache.h" #include "rdi/rdi_local.h" @@ -465,6 +466,7 @@ #include "base/base_inc.c" #include "x64/x64.c" #include "win32/win32_inc.c" +#include "linux/linux_inc.c" #include "linker/base_ext/base_bit_array.c" #include "artifact_cache/artifact_cache.c" #include "rdi/rdi_local.c" diff --git a/src/win32/generated/win32.meta.c b/src/win32/generated/win32.meta.c new file mode 100644 index 00000000..8f03f81d --- /dev/null +++ b/src/win32/generated/win32.meta.c @@ -0,0 +1,176 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +C_LINKAGE_BEGIN +U32 w32_exception_code_kind_code_table[38] = +{ +0, +0x40010005, +0x40010008, +0x40080201, +0x40080202, +0x0000071a, +0x80000002, +0xc0000005, +0xc0000006, +0xc0000008, +0xc0000017, +0xc000001d, +0xc0000025, +0xc0000026, +0xc000008c, +0xc000008d, +0xc000008e, +0xc000008f, +0xc0000090, +0xc0000091, +0xc0000092, +0xc0000093, +0xc0000094, +0xc0000095, +0xc0000096, +0xc00000fd, +0xc0000135, +0xc0000138, +0xc0000139, +0xc0000142, +0xc00002b4, +0xc00002b5, +0xc0000420, +0xc06d007e, +0xc06d007f, +0xe073616e, +0xe0736171, +0x0000087a, +}; + +String8 w32_exception_code_kind_display_string_table[38] = +{ +{0}, +str8_lit_comp("Control-C"), +str8_lit_comp("Control-Break"), +str8_lit_comp("WinRT Originate Error"), +str8_lit_comp("WinRT Transform Error"), +str8_lit_comp("RPC Call Cancelled"), +str8_lit_comp("Data Type Misalignment"), +str8_lit_comp("Access Violation"), +str8_lit_comp("In Page Error"), +str8_lit_comp("Invalid Handle Specified"), +str8_lit_comp("Not Enough Quota"), +str8_lit_comp("Illegal Instruction"), +str8_lit_comp("Cannot Continue From Exception"), +str8_lit_comp("Invalid Exception Disposition Returned By Handler"), +str8_lit_comp("Array Bounds Exceeded"), +str8_lit_comp("Floating-Point Denormal Operand"), +str8_lit_comp("Floating-Point Division By Zero"), +str8_lit_comp("Floating-Point Inexact Result"), +str8_lit_comp("Floating-Point Invalid Operation"), +str8_lit_comp("Floating-Point Overflow"), +str8_lit_comp("Floating-Point Stack Check"), +str8_lit_comp("Floating-Point Underflow"), +str8_lit_comp("Integer Division By Zero"), +str8_lit_comp("Integer Overflow"), +str8_lit_comp("Privileged Instruction"), +str8_lit_comp("Stack Overflow"), +str8_lit_comp("Unable To Locate DLL"), +str8_lit_comp("Ordinal Not Found"), +str8_lit_comp("Entry Point Not Found"), +str8_lit_comp("DLL Initialization Failed"), +str8_lit_comp("Floating Point SSE Multiple Faults"), +str8_lit_comp("Floating Point SSE Multiple Traps"), +str8_lit_comp("Assertion Failed"), +str8_lit_comp("Module Not Found"), +str8_lit_comp("Procedure Not Found"), +str8_lit_comp("Sanitizer Error Detected"), +str8_lit_comp("Sanitizer Raw Access Violation"), +str8_lit_comp("DirectX Debug Layer"), +}; + +String8 w32_exception_code_kind_lowercase_code_string_table[38] = +{ +{0}, +str8_lit_comp("ctrl_c"), +str8_lit_comp("ctrl_break"), +str8_lit_comp("win_rt_originate_error"), +str8_lit_comp("win_rt_transform_error"), +str8_lit_comp("rpc_call_cancelled"), +str8_lit_comp("datatype_misalignment"), +str8_lit_comp("access_violation"), +str8_lit_comp("in_page_error"), +str8_lit_comp("invalid_handle"), +str8_lit_comp("not_enough_quota"), +str8_lit_comp("illegal_instruction"), +str8_lit_comp("cannot_continue_exception"), +str8_lit_comp("invalid_exception_disposition"), +str8_lit_comp("array_bounds_exceeded"), +str8_lit_comp("floating_point_denormal_operand"), +str8_lit_comp("floating_point_division_by_zero"), +str8_lit_comp("floating_point_inexact_result"), +str8_lit_comp("floating_point_invalid_operation"), +str8_lit_comp("floating_point_overflow"), +str8_lit_comp("floating_point_stack_check"), +str8_lit_comp("floating_point_underflow"), +str8_lit_comp("integer_division_by_zero"), +str8_lit_comp("integer_overflow"), +str8_lit_comp("privileged_instruction"), +str8_lit_comp("stack_overflow"), +str8_lit_comp("unable_to_locate_dll"), +str8_lit_comp("ordinal_not_found"), +str8_lit_comp("entry_point_not_found"), +str8_lit_comp("dll_initialization_failed"), +str8_lit_comp("floating_point_sse_multiple_faults"), +str8_lit_comp("floating_point_sse_multiple_traps"), +str8_lit_comp("assertion_failed"), +str8_lit_comp("module_not_found"), +str8_lit_comp("procedure_not_found"), +str8_lit_comp("sanitizer_error_detected"), +str8_lit_comp("sanitizer_raw_access_violation"), +str8_lit_comp("directx_debug_layer"), +}; + +B8 w32_exception_code_kind_default_enable_table[38] = +{ +0, +1, +1, +0, +0, +0, +0, +1, +0, +1, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +1, +0, +0, +1, +0, +1, +}; + +C_LINKAGE_END + diff --git a/src/win32/generated/win32.meta.h b/src/win32/generated/win32.meta.h new file mode 100644 index 00000000..8104ddad --- /dev/null +++ b/src/win32/generated/win32.meta.h @@ -0,0 +1,60 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//- GENERATED CODE + +#ifndef WIN32_META_H +#define WIN32_META_H + +typedef enum W32_ExceptionCodeKind +{ +W32_ExceptionCodeKind_Null, +W32_ExceptionCodeKind_CtrlC, +W32_ExceptionCodeKind_CtrlBreak, +W32_ExceptionCodeKind_WinRTOriginateError, +W32_ExceptionCodeKind_WinRTTransformError, +W32_ExceptionCodeKind_RPCCallCancelled, +W32_ExceptionCodeKind_DatatypeMisalignment, +W32_ExceptionCodeKind_AccessViolation, +W32_ExceptionCodeKind_InPageError, +W32_ExceptionCodeKind_InvalidHandle, +W32_ExceptionCodeKind_NotEnoughQuota, +W32_ExceptionCodeKind_IllegalInstruction, +W32_ExceptionCodeKind_CannotContinueException, +W32_ExceptionCodeKind_InvalidExceptionDisposition, +W32_ExceptionCodeKind_ArrayBoundsExceeded, +W32_ExceptionCodeKind_FloatingPointDenormalOperand, +W32_ExceptionCodeKind_FloatingPointDivisionByZero, +W32_ExceptionCodeKind_FloatingPointInexactResult, +W32_ExceptionCodeKind_FloatingPointInvalidOperation, +W32_ExceptionCodeKind_FloatingPointOverflow, +W32_ExceptionCodeKind_FloatingPointStackCheck, +W32_ExceptionCodeKind_FloatingPointUnderflow, +W32_ExceptionCodeKind_IntegerDivisionByZero, +W32_ExceptionCodeKind_IntegerOverflow, +W32_ExceptionCodeKind_PrivilegedInstruction, +W32_ExceptionCodeKind_StackOverflow, +W32_ExceptionCodeKind_UnableToLocateDLL, +W32_ExceptionCodeKind_OrdinalNotFound, +W32_ExceptionCodeKind_EntryPointNotFound, +W32_ExceptionCodeKind_DLLInitializationFailed, +W32_ExceptionCodeKind_FloatingPointSSEMultipleFaults, +W32_ExceptionCodeKind_FloatingPointSSEMultipleTraps, +W32_ExceptionCodeKind_AssertionFailed, +W32_ExceptionCodeKind_ModuleNotFound, +W32_ExceptionCodeKind_ProcedureNotFound, +W32_ExceptionCodeKind_SanitizerErrorDetected, +W32_ExceptionCodeKind_SanitizerRawAccessViolation, +W32_ExceptionCodeKind_DirectXDebugLayer, +W32_ExceptionCodeKind_COUNT, +} W32_ExceptionCodeKind; + +C_LINKAGE_BEGIN +extern U32 w32_exception_code_kind_code_table[38]; +extern String8 w32_exception_code_kind_display_string_table[38]; +extern String8 w32_exception_code_kind_lowercase_code_string_table[38]; +extern B8 w32_exception_code_kind_default_enable_table[38]; + +C_LINKAGE_END + +#endif // WIN32_META_H diff --git a/src/win32/win32.c b/src/win32/win32.c new file mode 100644 index 00000000..642f431f --- /dev/null +++ b/src/win32/win32.c @@ -0,0 +1,4 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#include "win32/generated/win32.meta.c" diff --git a/src/win32/win32.h b/src/win32/win32.h new file mode 100644 index 00000000..b71adaff --- /dev/null +++ b/src/win32/win32.h @@ -0,0 +1,9 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef WIN32_H +#define WIN32_H + +#include "win32/generated/win32.meta.h" + +#endif // WIN32_H diff --git a/src/win32/win32.mdesk b/src/win32/win32.mdesk new file mode 100644 index 00000000..5b6370dd --- /dev/null +++ b/src/win32/win32.mdesk @@ -0,0 +1,154 @@ +// Copyright (c) Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +//////////////////////////////// +//~ rjf: Exception Codes + +@table(name lower_name code default display_string) +W32_ExceptionCodeKindTable: +{ + {CtrlC ctrl_c 0x40010005 1 "Control-C" } + {CtrlBreak ctrl_break 0x40010008 1 "Control-Break" } + {WinRTOriginateError win_rt_originate_error 0x40080201 0 "WinRT Originate Error" } + {WinRTTransformError win_rt_transform_error 0x40080202 0 "WinRT Transform Error" } + {RPCCallCancelled rpc_call_cancelled 0x0000071a 0 "RPC Call Cancelled" } + {DatatypeMisalignment datatype_misalignment 0x80000002 0 "Data Type Misalignment" } + {AccessViolation access_violation 0xc0000005 1 "Access Violation" } + {InPageError in_page_error 0xc0000006 0 "In Page Error" } + {InvalidHandle invalid_handle 0xc0000008 1 "Invalid Handle Specified" } + {NotEnoughQuota not_enough_quota 0xc0000017 0 "Not Enough Quota" } + {IllegalInstruction illegal_instruction 0xc000001d 0 "Illegal Instruction" } + {CannotContinueException cannot_continue_exception 0xc0000025 0 "Cannot Continue From Exception" } + {InvalidExceptionDisposition invalid_exception_disposition 0xc0000026 0 "Invalid Exception Disposition Returned By Handler" } + {ArrayBoundsExceeded array_bounds_exceeded 0xc000008c 0 "Array Bounds Exceeded" } + {FloatingPointDenormalOperand floating_point_denormal_operand 0xc000008d 0 "Floating-Point Denormal Operand" } + {FloatingPointDivisionByZero floating_point_division_by_zero 0xc000008e 0 "Floating-Point Division By Zero" } + {FloatingPointInexactResult floating_point_inexact_result 0xc000008f 0 "Floating-Point Inexact Result" } + {FloatingPointInvalidOperation floating_point_invalid_operation 0xc0000090 0 "Floating-Point Invalid Operation" } + {FloatingPointOverflow floating_point_overflow 0xc0000091 0 "Floating-Point Overflow" } + {FloatingPointStackCheck floating_point_stack_check 0xc0000092 0 "Floating-Point Stack Check" } + {FloatingPointUnderflow floating_point_underflow 0xc0000093 0 "Floating-Point Underflow" } + {IntegerDivisionByZero integer_division_by_zero 0xc0000094 0 "Integer Division By Zero" } + {IntegerOverflow integer_overflow 0xc0000095 0 "Integer Overflow" } + {PrivilegedInstruction privileged_instruction 0xc0000096 0 "Privileged Instruction" } + {StackOverflow stack_overflow 0xc00000fd 0 "Stack Overflow" } + {UnableToLocateDLL unable_to_locate_dll 0xc0000135 0 "Unable To Locate DLL" } + {OrdinalNotFound ordinal_not_found 0xc0000138 0 "Ordinal Not Found" } + {EntryPointNotFound entry_point_not_found 0xc0000139 0 "Entry Point Not Found" } + {DLLInitializationFailed dll_initialization_failed 0xc0000142 0 "DLL Initialization Failed" } + {FloatingPointSSEMultipleFaults floating_point_sse_multiple_faults 0xc00002b4 0 "Floating Point SSE Multiple Faults" } + {FloatingPointSSEMultipleTraps floating_point_sse_multiple_traps 0xc00002b5 0 "Floating Point SSE Multiple Traps" } + {AssertionFailed assertion_failed 0xc0000420 1 "Assertion Failed" } + {ModuleNotFound module_not_found 0xc06d007e 0 "Module Not Found" } + {ProcedureNotFound procedure_not_found 0xc06d007f 0 "Procedure Not Found" } + {SanitizerErrorDetected sanitizer_error_detected 0xe073616e 1 "Sanitizer Error Detected" } + {SanitizerRawAccessViolation sanitizer_raw_access_violation 0xe0736171 0 "Sanitizer Raw Access Violation" } + {DirectXDebugLayer directx_debug_layer 0x0000087a 1 "DirectX Debug Layer" } +} + +@enum W32_ExceptionCodeKind: +{ + Null, + @expand(W32_ExceptionCodeKindTable a) `$(a.name)`, + COUNT, +} + +@data(U32) w32_exception_code_kind_code_table: +{ + `0`; + @expand(W32_ExceptionCodeKindTable a) `$(a.code)`; +} + +@data(String8) w32_exception_code_kind_display_string_table: +{ + `{0}`; + @expand(W32_ExceptionCodeKindTable a) `str8_lit_comp("$(a.display_string)")`; +} + +@data(String8) w32_exception_code_kind_lowercase_code_string_table: +{ + `{0}`; + @expand(W32_ExceptionCodeKindTable a) `str8_lit_comp("$(a.lower_name)")`; +} + +@data(B8) w32_exception_code_kind_default_enable_table: +{ + `0`; + @expand(W32_ExceptionCodeKindTable a) `$(a.default)`; +} + +//////////////////////////////// +//~ rjf: Exception Sub-Codes + +@table(name, value) +W32_ExceptionSubCodeKindTable: +{ + { W32_FAST_FAIL_LEGACY_GS_VIOLATION 0 } + { W32_FAST_FAIL_VTGUARD_CHECK_FAILURE 1 } + { W32_FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2 } + { W32_FAST_FAIL_CORRUPT_LIST_ENTRY 3 } + { W32_FAST_FAIL_INCORRECT_STACK 4 } + { W32_FAST_FAIL_INVALID_ARG 5 } + { W32_FAST_FAIL_GS_COOKIE_INIT 6 } + { W32_FAST_FAIL_FATAL_APP_EXIT 7 } + { W32_FAST_FAIL_RANGE_CHECK_FAILURE 8 } + { W32_FAST_FAIL_UNSAFE_REGISTRY_ACCESS 9 } + { W32_FAST_FAIL_GUARD_ICALL_CHECK_FAILURE 10 } + { W32_FAST_FAIL_GUARD_WRITE_CHECK_FAILURE 11 } + { W32_FAST_FAIL_INVALID_FIBER_SWITCH 12 } + { W32_FAST_FAIL_INVALID_SET_OF_CONTEXT 13 } + { W32_FAST_FAIL_INVALID_REFERENCE_COUNT 14 } + { W32_FAST_FAIL_INVALID_JUMP_BUFFER 18 } + { W32_FAST_FAIL_MRDATA_MODIFIED 19 } + { W32_FAST_FAIL_CERTIFICATION_FAILURE 20 } + { W32_FAST_FAIL_INVALID_EXCEPTION_CHAIN 21 } + { W32_FAST_FAIL_CRYPTO_LIBRARY 22 } + { W32_FAST_FAIL_INVALID_CALL_IN_DLL_CALLOUT 23 } + { W32_FAST_FAIL_INVALID_IMAGE_BASE 24 } + { W32_FAST_FAIL_DLOAD_PROTECTION_FAILURE 25 } + { W32_FAST_FAIL_UNSAFE_EXTENSION_CALL 26 } + { W32_FAST_FAIL_DEPRECATED_SERVICE_INVOKED 27 } + { W32_FAST_FAIL_INVALID_BUFFER_ACCESS 28 } + { W32_FAST_FAIL_INVALID_BALANCED_TREE 29 } + { W32_FAST_FAIL_INVALID_NEXT_THREAD 30 } + { W32_FAST_FAIL_GUARD_ICALL_CHECK_SUPPRESSED 31 } + { W32_FAST_FAIL_APCS_DISABLED 32 } + { W32_FAST_FAIL_INVALID_IDLE_STATE 33 } + { W32_FAST_FAIL_MRDATA_PROTECTION_FAILURE 34 } + { W32_FAST_FAIL_UNEXPECTED_HEAP_EXCEPTION 35 } + { W32_FAST_FAIL_INVALID_LOCK_STATE 36 } + { W32_FAST_FAIL_GUARD_JUMPTABLE 37 } + { W32_FAST_FAIL_INVALID_LONGJUMP_TARGET 38 } + { W32_FAST_FAIL_INVALID_DISPATCH_CONTEXT 39 } + { W32_FAST_FAIL_INVALID_THREAD 40 } + { W32_FAST_FAIL_INVALID_SYSCALL_NUMBER 41 } + { W32_FAST_FAIL_INVALID_FILE_OPERATION 42 } + { W32_FAST_FAIL_LPAC_ACCESS_DENIED 43 } + { W32_FAST_FAIL_GUARD_SS_FAILURE 44 } + { W32_FAST_FAIL_LOADER_CONTINUITY_FAILURE 45 } + { W32_FAST_FAIL_GUARD_EXPORT_SUPPRESSION_FAILURE 46 } + { W32_FAST_FAIL_INVALID_CONTROL_STACK 47 } + { W32_FAST_FAIL_SET_CONTEXT_DENIED 48 } + { W32_FAST_FAIL_INVALID_IAT 49 } + { W32_FAST_FAIL_HEAP_METADATA_CORRUPTION 50 } + { W32_FAST_FAIL_PAYLOAD_RESTRICTION_VIOLATION 51 } + { W32_FAST_FAIL_LOW_LABEL_ACCESS_DENIED 52 } + { W32_FAST_FAIL_ENCLAVE_CALL_FAILURE 53 } + { W32_FAST_FAIL_UNHANDLED_LSS_EXCEPTON 54 } + { W32_FAST_FAIL_ADMINLESS_ACCESS_DENIED 55 } + { W32_FAST_FAIL_UNEXPECTED_CALL 56 } + { W32_FAST_FAIL_CONTROL_INVALID_RETURN_ADDRESS 57 } + { W32_FAST_FAIL_UNEXPECTED_HOST_BEHAVIOR 58 } + { W32_FAST_FAIL_FLAGS_CORRUPTION 59 } + { W32_FAST_FAIL_VEH_CORRUPTION 60 } + { W32_FAST_FAIL_ETW_CORRUPTION 61 } + { W32_FAST_FAIL_RIO_ABORT 62 } + { W32_FAST_FAIL_INVALID_PFN 63 } + { W32_FAST_FAIL_GUARD_ICALL_CHECK_FAILURE_XFG 64 } + { W32_FAST_FAIL_CAST_GUARD 65 } + { W32_FAST_FAIL_HOST_VISIBILITY_CHANGE 66 } + { W32_FAST_FAIL_KERNEL_CET_SHADOW_STACK_ASSIST 67 } + { W32_FAST_FAIL_PATCH_CALLBACK_FAILED 68 } + { W32_FAST_FAIL_NTDLL_PATCH_FAILED 69 } + { W32_FAST_FAIL_INVALID_FLS_DATA 70 } +} diff --git a/src/win32/win32_inc.c b/src/win32/win32_inc.c index 6f8f5874..4fe735a8 100644 --- a/src/win32/win32_inc.c +++ b/src/win32/win32_inc.c @@ -1,6 +1,7 @@ // Copyright (c) Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +#include "win32/win32.c" #if defined(X64_H) # include "win32/x64/win32_x64.c" #endif diff --git a/src/win32/win32_inc.h b/src/win32/win32_inc.h index 062fd9e5..f64fabb1 100644 --- a/src/win32/win32_inc.h +++ b/src/win32/win32_inc.h @@ -4,6 +4,7 @@ #ifndef WIN32_INC_H #define WIN32_INC_H +#include "win32/win32.h" #if defined(X64_H) # include "win32/x64/win32_x64.h" #endif