diff options
| author | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 14:26:58 +0100 |
|---|---|---|
| committer | Vonsek <45567075+Vonsek@users.noreply.github.com> | 2026-11-22 14:26:58 +0100 |
| commit | 354e129c2029b34f05285d6b100e1fdf02958772 (patch) | |
| tree | 719b557b3923c830eb06f82f8abf0bdb4db53b69 /runtime/src/main.cpp | |
| parent | 452fb3f9a8701ef2ef644535fa5368b1e6a74aaa (diff) | |
| parent | a0acd33d77babe67a28e398b2936a9f735a50f5d (diff) | |
Merge main into test/valu-int-misc (#1492)
Conflicts: runtime/test/shaders/check.py, scripts/run_gpu_tests.py, tests/semantic/regen_fixtures.py, tests/semantic/test_value_semantics.py
AI-assisted.
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 9ceccf53a..7d3491653 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp | |||
| @@ -1,18 +1,21 @@ | |||
| 1 | // gta6rt: native runtime for the Xbox Series build. | 1 | // gta6rt: native runtime for the Xbox Series build. |
| 2 | // | 2 | // |
| 3 | // gta6rt --dry-run <image> [--game-dir DIR] | 3 | // gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR] |
| 4 | // Maps the image and its bundled modules, applies relocations, binds every import, installs static TLS for | 4 | // Maps the image and its bundled modules, applies relocations, binds every import, installs static TLS for |
| 5 | // this thread and prints a report. No code from the mapped images | 5 | // this thread and prints a report. No code from the mapped images |
| 6 | // runs. TLS needs the runtime's own gta6rt_tls_host.dll, which reserves the module TLS index; system DLLs are | 6 | // runs. TLS needs the runtime's own gta6rt_tls_host.dll, which reserves the module TLS index; system DLLs are |
| 7 | // loaded to resolve host imports, as before. | 7 | // loaded to resolve host imports, as before. |
| 8 | // | 8 | // |
| 9 | // gta6rt --init <image> [--game-dir DIR] | 9 | // gta6rt --init <image> [--game-dir DIR] [--overlay DIR] |
| 10 | // The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. | 10 | // The same mapping, then each loaded DLL's TLS callbacks and DllMain(DLL_PROCESS_ATTACH) are run. |
| 11 | // | 11 | // |
| 12 | // gta6rt --run <exe> [--game-dir DIR] [--trace-d3d12] [-- game arguments...] | 12 | // gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...] |
| 13 | // The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and | 13 | // The same, then the EXE's own TLS callbacks and its entry point, on a game thread. The game's argv and |
| 14 | // command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run | 14 | // command line are <exe name> plus the arguments after "--"; exit/ExitProcess from the game end the run |
| 15 | // (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. | 15 | // (shims/process.cpp). gta6rt prints the binding report first and returns the game's exit code. |
| 16 | // | ||
| 17 | // --game-dir is also where a title's GAME: paths read from; anything it writes or deletes goes to the overlay | ||
| 18 | // (--overlay, default <game-dir>/overlay) so the package is never modified (shims/file_system.cpp). | ||
| 16 | #include <windows.h> | 19 | #include <windows.h> |
| 17 | 20 | ||
| 18 | #include <cstdio> | 21 | #include <cstdio> |
| @@ -22,6 +25,7 @@ | |||
| 22 | 25 | ||
| 23 | #include "pe_loader.h" | 26 | #include "pe_loader.h" |
| 24 | #include "../shims/d3d12_trace.h" | 27 | #include "../shims/d3d12_trace.h" |
| 28 | #include "../shims/file_system.h" | ||
| 25 | #include "../shims/process_shim.h" | 29 | #include "../shims/process_shim.h" |
| 26 | #include "../shims/shims.h" | 30 | #include "../shims/shims.h" |
| 27 | 31 | ||
| @@ -38,16 +42,16 @@ const char* binding_name(rt::Binding b) { | |||
| 38 | 42 | ||
| 39 | int usage() { | 43 | int usage() { |
| 40 | std::fprintf(stderr, | 44 | std::fprintf(stderr, |
| 41 | "usage: gta6rt --dry-run <image> [--game-dir DIR]\n" | 45 | "usage: gta6rt --dry-run <image> [--game-dir DIR] [--overlay DIR]\n" |
| 42 | " gta6rt --init <image> [--game-dir DIR] [--trace-d3d12]\n" | 46 | " gta6rt --init <image> [--game-dir DIR] [--overlay DIR] [--trace-d3d12]\n" |
| 43 | " gta6rt --run <exe> [--game-dir DIR] [--trace-d3d12] [-- game arguments...]\n"); | 47 | " gta6rt --run <exe> [--game-dir DIR] [--overlay DIR] [--trace-d3d12] [-- game arguments...]\n"); |
| 44 | return 2; | 48 | return 2; |
| 45 | } | 49 | } |
| 46 | 50 | ||
| 47 | } // namespace | 51 | } // namespace |
| 48 | 52 | ||
| 49 | int wmain(int argc, wchar_t** argv) { | 53 | int wmain(int argc, wchar_t** argv) { |
| 50 | std::filesystem::path image, game_dir; | 54 | std::filesystem::path image, game_dir, overlay_dir; |
| 51 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; | 55 | bool dry_run = false, init = false, run = false, trace_d3d12 = false; |
| 52 | std::vector<std::wstring> game_args; // wide: path::string() throws on a character the code page lacks (RT-84) | 56 | 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) { | 57 | for (int i = 1; i < argc; ++i) { |
| @@ -61,6 +65,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 61 | else if (a == L"--run") run = true; | 65 | else if (a == L"--run") run = true; |
| 62 | else if (a == L"--trace-d3d12") trace_d3d12 = true; | 66 | else if (a == L"--trace-d3d12") trace_d3d12 = true; |
| 63 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; | 67 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; |
| 68 | else if (a == L"--overlay" && i + 1 < argc) overlay_dir = argv[++i]; | ||
| 64 | else if (image.empty()) image = a; | 69 | else if (image.empty()) image = a; |
| 65 | else return usage(); | 70 | else return usage(); |
| 66 | } | 71 | } |
| @@ -68,6 +73,9 @@ int wmain(int argc, wchar_t** argv) { | |||
| 68 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. | 73 | // Exactly one mode: --dry-run --run would otherwise initialise the modules and call the entry point. |
| 69 | if (dry_run + init + run != 1) return usage(); | 74 | if (dry_run + init + run != 1) return usage(); |
| 70 | if (game_dir.empty()) game_dir = image.parent_path(); | 75 | if (game_dir.empty()) game_dir = image.parent_path(); |
| 76 | // GAME: paths read under --game-dir; whatever a title writes lands in the overlay, never in the package. | ||
| 77 | if (overlay_dir.empty()) overlay_dir = game_dir / "overlay"; | ||
| 78 | rt::fs::configure(game_dir, overlay_dir); | ||
| 71 | rt::d3d12_trace::set_enabled(trace_d3d12); | 79 | rt::d3d12_trace::set_enabled(trace_d3d12); |
| 72 | 80 | ||
| 73 | try { | 81 | try { |
| @@ -105,6 +113,7 @@ int wmain(int argc, wchar_t** argv) { | |||
| 105 | return 1; | 113 | return 1; |
| 106 | } | 114 | } |
| 107 | rt::process::set_command_line(image.filename().wstring(), game_args); | 115 | rt::process::set_command_line(image.filename().wstring(), game_args); |
| 116 | std::printf("console paths: GAME: -> %ls, writes -> %ls\n", game_dir.c_str(), overlay_dir.c_str()); | ||
| 108 | std::printf("running %s\n", main_module.name.c_str()); | 117 | std::printf("running %s\n", main_module.name.c_str()); |
| 109 | std::fflush(stdout); | 118 | std::fflush(stdout); |
| 110 | const int code = rt::process::run_entry(main_module.base + main_module.entry_rva); | 119 | const int code = rt::process::run_entry(main_module.base + main_module.entry_rva); |