Commit Graph

3 Commits

Author SHA1 Message Date
0e70866b9a fix(startup_trace): guard SEH unwind in VEH handler and tear down safely at exit 2026-11-22 14:58:44 -03:00
d6443b1524 Startup trace: never replace an existing file; write UTF-8 only
Review on #1756 (Vonsek):
- The trace is opened before the loader reads the image, so `wb` could
  truncate an input named by mistake (the image itself). open() now
  uses "x" mode and fails with EEXIST on an existing path; gta6rt says
  so and exits with 2.
- OutputDebugStringA text is in the ANSI code page. It is converted
  to UTF-8 before quoting, so a byte such as 0xE9 no longer breaks the
  JSON lines. Host module names now come from GetModuleFileNameW,
  converted to UTF-8, for the same reason.

startup_trace_test: an existing file is refused with EEXIST and its
bytes survive, the trace stays off; an ANSI debug string with 0xE9
appears as its UTF-8 form and the whole file is valid UTF-8.
2026-11-22 12:06:49 -03:00
2dca597bd9 Runtime: opt-in startup trace (gta6rt --trace FILE)
Writes one JSON object per line, flushed per event: module maps, TLS
callbacks, DllMain results, the first call of each unimplemented import
with its caller as module+RVA, OutputDebugString text, exceptions with
module+RVA and a short unwind, and the exit code. A vectored handler
records and returns EXCEPTION_CONTINUE_SEARCH, so behaviour is unchanged.
Off by default.

startup_trace_test builds a synthetic DLL image (no game data) and
checks each event kind.
2026-11-22 12:03:22 -03:00