Architecture Overview
ReXGlue is a complete static recompilation system that transforms Xbox 360 PowerPC executables into native C++ code. This page explains the core components and how they work together.System Architecture
Core Components
1. Analysis Engine
The analysis engine (src/codegen) processes Xbox 360 executables to understand their structure:
- Binary Parsing: Reads XEX format files and extracts code sections, headers, and metadata
- Function Discovery: Identifies function boundaries using entry points, prologue patterns, and call analysis
- Control Flow Analysis: Builds control flow graphs to track jumps, branches, and switch tables
- Data Region Detection: Distinguishes embedded data from code using configurable thresholds
The analyzer can detect jump tables and switch statements automatically, but complex cases may require manual configuration via TOML hints.
2. Code Generator
The code generator (src/codegen) translates PowerPC assembly to C++:
- Register Mapping: PowerPC GPRs (r0-r31), FPRs (f0-f31), and special registers (LR, CTR, CR, XER)
- Condition Flags: Accurate CR field tracking for conditional branches
- Exception Handling: Optional SEH wrapper generation for Windows structured exception handling
- Optimization: Dead code elimination, register allocation, and local variable promotion
3. Runtime System
The runtime provides Xbox 360 environment emulation:Processor (rex::runtime::Processor)
Manages execution state and module loading:
include/rex/system/processor.h:64-128
Kernel State (rex::system::KernelState)
Emulates Xbox 360 kernel services:
include/rex/system/kernel_state.h:111-254
Provides:
- Thread management (XThread)
- Synchronization primitives (XEvent, XSemaphore, XMutant)
- File I/O and virtual filesystem
- Object handle table
- Module loading and symbol resolution
Memory Management (rex::memory::Memory)
Emulates Xbox 360 memory layout:
- Physical Memory: 512MB base allocation at fixed address
- Virtual Memory: Page table management with Xbox 360 addressing
- Memory Mapping: Support for memory-mapped I/O (MMIO) handlers
- Big Endian: Automatic endianness conversion for memory operations
4. Graphics Backends
ReXGlue translates Xbox 360 GPU commands to modern graphics APIs:- D3D12 (Windows)
- Vulkan (Linux)
Direct3D 12 Backend (
src/graphics/d3d12)- Command list translation
- Resource binding compatibility
- Shader translation (HLSL)
- Hardware-accelerated rendering
REXGLUE_USE_D3D12=ON5. Platform Abstraction
Platform-specific implementations:| Component | Windows | Linux |
|---|---|---|
| Window | Win32 API | GTK |
| Input | XInput/DirectInput | evdev/SDL |
| Audio | XAudio2 | PulseAudio/ALSA |
| Threading | Win32 Threads | pthreads |
| Filesystem | NTFS paths | POSIX paths |
Module Organization
The SDK is organized into layered modules:Configuration System
ReXGlue uses TOML configuration files for code generation:include/rex/codegen/config.h:71-134
Build System Integration
ReXGlue integrates with CMake for seamless builds:rexglue_configure_target() helper automatically:
- Links platform entry point
- Adds ReXApp framework code
- Configures graphics backend
- Sets compiler flags for Clang
Next Steps
Installation
Install the SDK and configure your toolchain
Quick Start
Create your first recompiled project