codegen command analyzes Xbox 360 executable files and generates recompiled C++ code, headers, and build integration files.
Usage
Arguments
Path to TOML configuration fileThis file specifies the XEX input path, output directory, and codegen options. See Configuration Reference.
Flags
General Flags
Generate output even if validation errors occurBy default, codegen aborts if it detects errors during analysis. Use
--force to generate code anyway (useful for iterative development).Enable generation of SEH exception handler codeGenerates code for Structured Exception Handling (SEH) found in the XEX binary.
Output Control
Number of functions per generated .cpp fileControls file splitting to keep compilation units manageable. Range: 1-100000.
Log progress every N functionsControls how often progress messages are logged during code generation. Range: 1-100000.
Analysis Parameters
Maximum iterations for function discovery convergenceLimits the iterative function discovery process. Range: 1-100000.
Maximum iterations for vtable discoveryLimits the C++ vtable discovery process. Range: 1-100000.
Maximum iterations for call target resolutionLimits the call graph resolution process. Range: 1-100000.
Exception Handling Limits
Maximum C++ EH states before rejecting handlerFunctions with more exception states are skipped. Range: 1-100000.
Maximum try blocks before rejecting handlerFunctions with more try blocks are skipped. Range: 1-100000.
Maximum IP-to-state map entriesControls exception handler table size limits. Range: 1-100000.
Maximum SEH scope table entriesControls SEH handler table size limits. Range: 1-100000.
Jump Table Discovery
Maximum instructions to scan backward for jump table patternsControls how far to look back when detecting switch/jump tables. Range: 1-10000.
Maximum entries per detected jump tablePrevents runaway jump table detection. Range: 1-100000.
Safety limit on basic blocks per functionPrevents analysis of pathologically large functions. Range: 1-1000000.
Examples
Basic Code Generation
Enable Exception Handlers
Force Generation with Errors
Adjust Output File Size
.cpp files, which can improve parallel compilation.
Tune Analysis for Large Binaries
Generated Output
The codegen command generates several types of files in the output directory:Configuration Header
Initialization Code
Function Implementation Files
CMake Integration
Integration with CMake
After running codegen, rebuild your CMake project to include the generated code:sources.cmake is automatically included by the project’s CMakeLists.txt.
Custom Codegen Target
Your project includes a custom CMake target for running codegen:rexglue codegen with the correct paths automatically.
Common Errors
Missing Config File
XEX File Not Found
file_path in your config matches the actual XEX location.
Validation Errors
--force to generate code despite errors, or fix the issues in your configuration.
Performance Tips
-
Use
--functions-per-fileto balance compilation parallelism:- Smaller values (250-500): More files, better parallelism, slower linking
- Larger values (1000+): Fewer files, slower compilation per file
-
Enable verbose logging only when debugging:
-
Tune iteration limits for very large binaries (>10MB XEX):
- Increase
--max-discovery-iterationsif function discovery doesn’t converge - Increase
--max-blocks-per-functionif you have very large functions
- Increase
Next Steps
- Learn about Configuration Options
- Understand Function Discovery
- Read about Exception Handling