Caution
This project is in early development. Expect things to not work quite right and there to be significant changes and breaking public API updates as development progresses. Contributions and feedback are welcome, but please be aware that the codebase is still evolving rapidly.
Static recompilation runtime SDK for Xbox 360
ReXGlue converts Xbox 360 PowerPC code into portable C++ that runs natively on modern platforms.
ReXGlue is heavily rooted on the foundations of Xenia, the Xbox 360 emulator. Rather than interpreting or JIT-compiling PPC instructions at runtime, ReXGlue takes a different path: it generates C++ source code ahead of time, an approach inspired by XenonRecomp and rexdex's recompiler.
Download the latest release and extract it to a location of your choice. This will be your REXSDK path. Set this as an environment variable using your preferred method.
git clone --recursive https://github.com/rexglue/rexglue-sdk
cd rexglue
cmake --preset <platform>
cmake --build out/build/<platform> --target installThis will perform a multi-config build and put the SDK at out/install/<platform>. You may move this folder and then set this path on your environment variable as REXSDK using your preferred method (system or CMakeUserPresets.json in your target project).
rexglue init --app_name [project name] --app_root [project root path]This generates a project with CMakeLists.txt, CMakePresets.json, and starter source files.
Ensure the install path of the SDK is correctly set as an environment variable REXSDK.
The rexglue init command generates a <project>_config.toml file that controls the codegen pipeline. Run codegen with:
rexglue codegen <project>_config.toml| Key | Description |
|---|---|
project_name |
Name used for generated output files |
file_path |
Path to the Xbox 360 XEX or ELF binary |
out_directory_path |
Directory for generated C++ code (default: generated) |
These control how PPC registers and instructions are translated to C++. All default to false.
| Key | Description |
|---|---|
skip_lr |
Skip link register saves/restores. Reduces generated code for leaf functions. |
skip_msr |
Skip MSR (Machine State Register) instructions. |
ctr_as_local |
Emit CTR (Count Register) as a local variable instead of reading/writing thread state. Reduces memory traffic in loops. |
xer_as_local |
Emit XER (Integer Exception Register) as a local variable. |
cr_as_local |
Emit CR (Condition Register) fields as local variables. Significant codegen improvement for branch-heavy code. |
reserved_as_local |
Emit reserved registers (r1, r2, r13) as local variables. |
non_argument_as_local |
Emit non-argument volatile registers (r11-r12) as local variables. |
non_volatile_as_local |
Emit non-volatile registers (r14-r31) as local variables. Only safe when the function's save/restore behavior is well understood. |
| Key | Description |
|---|---|
setjmp_address |
Address of the setjmp function in the binary. Required for correct non-local jump handling. |
longjmp_address |
Address of the longjmp function in the binary. |
| Key | Default | Description |
|---|---|---|
max_jump_extension |
65536 |
Maximum bytes to extend a function when following jump table targets. |
data_region_threshold |
16 |
Consecutive invalid instructions before marking a region as embedded data. |
large_function_threshold |
1048576 |
Byte threshold for "large function" warnings. |
exception_handler_funcs |
[] |
Array of addresses for exception handler functions beyond auto-detected ones. |
Define function boundaries, names, or parent-child relationships when auto-detection gets it wrong:
[functions]
# Name a function
0x82000000 = { name = "MyFunction" }
# Explicit size (bytes)
0x82000100 = { size = 64 }
# Explicit end address (exclusive)
0x82000200 = { end = 0x82000280 }
# Discontinuous chunk belonging to a parent function
0x82000300 = { parent = 0x82000000, size = 32 }Fields: name, size, end (mutually exclusive with size), parent (makes it a chunk of another function).
Manually define switch/jump tables when auto-detection fails:
[[switch_tables]]
address = 0x82000000 # Address of the bctr instruction
register = 11 # GPR used as the jump index
labels = [0x82000100, 0x82000200, 0x82000300] # Branch target addressesInject calls to native C++ functions at specific instruction addresses:
[[midasm_hook]]
address = 0x82000000
name = "MyHook"
registers = ["r3", "r4"] # Registers passed to the hook function
after_instruction = false # Insert before (false) or after (true) the instruction
# Control flow after hook (pick one):
# return = true # Return from the function after the hook
# jump_address = 0x82001000 # Jump to a different address after the hook
# Conditional control flow (hook returns bool):
# return_on_true = true
# return_on_false = true
# jump_address_on_true = 0x82001000
# jump_address_on_false = 0x82002000Mark data patterns that the disassembler misidentifies as code:
[[invalid_instructions]]
data = 0x12345678 # The raw instruction word
size = 4 # Size of the data region in bytesReXGlue is not affiliated with nor endorsed by Microsoft or Xbox. It is an independent project created for educational and development purposes. All trademarks and copyrights belong to their respective owners.
This project is not intended to promote piracy nor unauthorized use of copyrighted material. Any misuse of this software to endorse or enable this type of activity is strictly prohibited.
- Tom (crack) - Lead developer and project founder. Creator of the recompiler and core architecture of ReXGlue.
- Loreaxe - Testing on various hardware and helping found the project.
- Soren/Roxxsen - Lead project manager and git maintainer.
- Toby - Graphic designer.
- Project Xenia - Their invaluable work on Xbox 360 emulation laid the groundwork for ReXGlue's development. This project (and numerous others) would not exist without their hard work and dedication.
- XenonRecomp - For pioneering the modern static recompilation approach for Xbox 360. A lot of the codegen analysis logic and instruction translations are based on their work. Thank you!
- rexdex's recompiler - The OG static recompiler for Xbox 360.
- Many others in the Xbox 360 homebrew and modding communities whose work and research have contributed to the collective knowledge that makes projects like this possible.
