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.
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.