diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-20 15:22:16 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-20 15:22:16 -0500 |
| commit | db0dc8bd5ebce6e2bc27d47085f7f104eb3037d3 (patch) | |
| tree | 4fb3edca45f8b4dd3368c6ac2a0e4fdc8ed7065c /runtime/src/main.cpp | |
Initial commit: Leonida, build-it-yourself PC port groundwork
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
| -rw-r--r-- | runtime/src/main.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp new file mode 100644 index 000000000..e69906c14 --- /dev/null +++ b/runtime/src/main.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | // gta6rt: native runtime for the Xbox Series build. | ||
| 2 | // | ||
| 3 | // gta6rt --dry-run <image> [--game-dir DIR] | ||
| 4 | // Maps the image and its bundled modules, applies relocations, binds every import and prints a report. | ||
| 5 | // No code from the image runs. | ||
| 6 | #include <windows.h> | ||
| 7 | |||
| 8 | #include <cstdio> | ||
| 9 | #include <map> | ||
| 10 | #include <string> | ||
| 11 | |||
| 12 | #include "pe_loader.h" | ||
| 13 | |||
| 14 | namespace { | ||
| 15 | |||
| 16 | const char* binding_name(rt::Binding b) { | ||
| 17 | switch (b) { | ||
| 18 | case rt::Binding::Shim: return "shim"; | ||
| 19 | case rt::Binding::Host: return "host"; | ||
| 20 | case rt::Binding::Module: return "module"; | ||
| 21 | default: return "UNIMPLEMENTED"; | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | int usage() { | ||
| 26 | std::fprintf(stderr, "usage: gta6rt --dry-run <image> [--game-dir DIR]\n"); | ||
| 27 | return 2; | ||
| 28 | } | ||
| 29 | |||
| 30 | } // namespace | ||
| 31 | |||
| 32 | int wmain(int argc, wchar_t** argv) { | ||
| 33 | std::filesystem::path image, game_dir; | ||
| 34 | bool dry_run = false; | ||
| 35 | for (int i = 1; i < argc; ++i) { | ||
| 36 | std::wstring a = argv[i]; | ||
| 37 | if (a == L"--dry-run") dry_run = true; | ||
| 38 | else if (a == L"--game-dir" && i + 1 < argc) game_dir = argv[++i]; | ||
| 39 | else if (image.empty()) image = a; | ||
| 40 | else return usage(); | ||
| 41 | } | ||
| 42 | if (image.empty()) return usage(); | ||
| 43 | if (!dry_run) { | ||
| 44 | std::fprintf(stderr, "Only --dry-run exists so far: running game code needs the shims listed by it first.\n"); | ||
| 45 | return 2; | ||
| 46 | } | ||
| 47 | if (game_dir.empty()) game_dir = image.parent_path(); | ||
| 48 | |||
| 49 | try { | ||
| 50 | rt::Loader loader(game_dir); | ||
| 51 | loader.load(image); | ||
| 52 | int unimplemented = 0; | ||
| 53 | for (auto* m : loader.modules()) { | ||
| 54 | std::map<rt::Binding, int> counts; | ||
| 55 | for (auto& r : m->imports) counts[r.binding]++; | ||
| 56 | std::printf("%-36s base=%p%s size=%u entry=+%#x shim=%d host=%d module=%d unimplemented=%d\n", | ||
| 57 | m->name.c_str(), m->base, m->relocated ? " (relocated)" : "", m->size, m->entry_rva, | ||
| 58 | counts[rt::Binding::Shim], counts[rt::Binding::Host], counts[rt::Binding::Module], | ||
| 59 | counts[rt::Binding::Unimplemented]); | ||
| 60 | for (auto& r : m->imports) | ||
| 61 | if (r.binding == rt::Binding::Unimplemented || r.binding == rt::Binding::Shim) { | ||
| 62 | std::printf(" %-13s %s!%s\n", binding_name(r.binding), r.dll.c_str(), r.name.c_str()); | ||
| 63 | unimplemented += r.binding == rt::Binding::Unimplemented; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | std::printf("%zu module(s) mapped, %d unimplemented import(s)\n", loader.modules().size(), unimplemented); | ||
| 67 | return 0; | ||
| 68 | } catch (const std::exception& e) { | ||
| 69 | std::fprintf(stderr, "error: %s\n", e.what()); | ||
| 70 | return 1; | ||
| 71 | } | ||
| 72 | } | ||