Files
mandy/runtime/shims/process_shim.h
Emre Demir fa4d54f22d process shim: keep the game's command line wide so a non-ASCII argument can't crash --run (RT-84)
main.cpp turned each game argument into std::filesystem::path::string(),
which throws std::system_error under MSVC when the ANSI code page has no
mapping for a character. Nothing caught it, so gta6rt --run ended in
0xc0000409 before the game started.

set_command_line now takes wide strings: __wargv and GetCommandLineW hold
the arguments exactly, and the narrow argv and GetCommandLineA are their
CP_ACP text from WideCharToMultiByte, which replaces a character the code
page lacks instead of failing, as the CRT does.

process_cmdline_test passes wide arguments and checks a Latin-1 one and a
Greek, Cyrillic and CJK one that no single-byte code page holds, so the
crash is covered on every system locale, not only 1253.
2026-11-22 13:28:05 +03:00

20 lines
993 B
C++

// The game's command line and exit, for `gta6rt --run` (shims/process.cpp).
#pragma once
#include <cstddef>
#include <string>
#include <vector>
namespace rt::process {
// What the game sees as argv[0..] and GetCommandLine: `program` then `args`, quoted where needed. The wide forms
// (__wargv, GetCommandLineW) hold the arguments exactly; the narrow ones are their ANSI code page text, with a
// character the code page can't represent replaced as the CRT does (RT-84).
void set_command_line(const std::wstring& program, const std::vector<std::wstring>& args);
// Runs a mapped EXE's entry point on a new thread with `stack_bytes` of reserved stack and returns the game's
// exit code: the entry point's return value, or what it passed to exit/ExitProcess (3 for abort). Returns when
// the first of those happens; other game threads are left running (the host process ends them when it exits).
int run_entry(void* entry, std::size_t stack_bytes = 8u << 20);
} // namespace rt::process