upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/main.cpp
diff options
context:
space:
mode:
authorEmre Demir <274893088+EmreO33@users.noreply.github.com>2026-11-22 13:28:05 +0300
committerEmre Demir <274893088+EmreO33@users.noreply.github.com>2026-11-22 13:28:05 +0300
commitfa4d54f22d8f20a4fd9ef9fc1880e36bbe0a3957 (patch)
tree0af904832274bfa68e4d17ee2592a29010db34ae /runtime/src/main.cpp
parentf85582e23d4ab9e19acbf694358f137d6b8531b1 (diff)
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.
Diffstat (limited to 'runtime/src/main.cpp')
-rw-r--r--runtime/src/main.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp
index c0248e819..9ceccf53a 100644
--- a/runtime/src/main.cpp
+++ b/runtime/src/main.cpp
@@ -49,11 +49,11 @@ int usage() {
49int wmain(int argc, wchar_t** argv) { 49int wmain(int argc, wchar_t** argv) {
50 std::filesystem::path image, game_dir; 50 std::filesystem::path image, game_dir;
51 bool dry_run = false, init = false, run = false, trace_d3d12 = false; 51 bool dry_run = false, init = false, run = false, trace_d3d12 = false;
52 std::vector<std::string> game_args; 52 std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84)
53 for (int i = 1; i < argc; ++i) { 53 for (int i = 1; i < argc; ++i) {
54 std::wstring a = argv[i]; 54 std::wstring a = argv[i];
55 if (a == L"--") { 55 if (a == L"--") {
56 for (++i; i < argc; ++i) game_args.push_back(std::filesystem::path(argv[i]).string()); 56 for (++i; i < argc; ++i) game_args.push_back(argv[i]);
57 break; 57 break;
58 } 58 }
59 if (a == L"--dry-run") dry_run = true; 59 if (a == L"--dry-run") dry_run = true;
@@ -104,7 +104,7 @@ int wmain(int argc, wchar_t** argv) {
104 std::fprintf(stderr, "error: %s has no entry point\n", main_module.name.c_str()); 104 std::fprintf(stderr, "error: %s has no entry point\n", main_module.name.c_str());
105 return 1; 105 return 1;
106 } 106 }
107 rt::process::set_command_line(image.filename().string(), game_args); 107 rt::process::set_command_line(image.filename().wstring(), game_args);
108 std::printf("running %s\n", main_module.name.c_str()); 108 std::printf("running %s\n", main_module.name.c_str());
109 std::fflush(stdout); 109 std::fflush(stdout);
110 const int code = rt::process::run_entry(main_module.base + main_module.entry_rva); 110 const int code = rt::process::run_entry(main_module.base + main_module.entry_rva);