A faithful Python port of Ghidra's C++ decompiler core. SLEIGH instruction decoding is provided via a pybind11 native module (sleigh_native.pyd); everything else — IR, data-flow analysis, SSA construction, optimization rules, control-flow structuring, and C output — is pure Python.
- Canonical repository:
https://github.com/fjqisba/GhidraX.git - Documentation:
https://github.com/fjqisba/GhidraX/tree/main/docs
git clone https://github.com/fjqisba/GhidraX.git
cd GhidraXGhidraX/
├── src/ # Python decompiler package (src-layout)
│ └── ghidra/
│ ├── analysis/ # Heritage (SSA), flow, data-flow
│ ├── arch/ # Architecture abstraction
│ ├── block/ # Control-flow structuring
│ ├── core/ # Address, AddrSpace, opcodes, marshal
│ ├── database/ # Symbol database, variable mapping
│ ├── fspec/ # Function signatures, calling conventions
│ ├── ir/ # Varnode, PcodeOp, Funcdata
│ ├── output/ # PrintC / PrintLanguage emission
│ ├── sleigh/ # SLEIGH engine + native .pyd modules
│ ├── transform/ # Action/Rule optimization chain
│ └── types/ # Type system, casts
├── native/ # C++ source (Ghidra decompiler + pybind11)
│ ├── CMakeLists.txt
│ ├── build.bat # One-click Windows build
│ ├── sleigh_bind.cpp # sleigh_native.pyd binding
│ └── decompiler_bind.cpp # decompiler_native.pyd binding
├── specs/ # Ghidra processor specifications
│ └── Processors/x86/data/languages/
├── tools/ # Utilities, comparison, and deployment helpers
│ ├── deploy.bat # IDA plugin deployer
│ ├── console.py # CLI utility
│ └── action_compare.py # Python/native staged action comparison
├── docs/ # Documentation
│ ├── ARCHITECTURE.md # Porting roadmap & design
│ ├── AUDIT.md # Code audit notes
│ └── progress.md # Module porting progress
├── pyproject.toml # Build config + pytest settings
├── LICENSE
└── README.md
cd native
build.batAuto-detects MSVC 2022, CMake, Ninja, Python, pybind11, and zlib. Outputs are copied to src/ghidra/sleigh/.
Prerequisites
| Tool | Install |
|---|---|
| Visual Studio 2022 | "Desktop development with C++" workload |
| CMake ≥ 3.15 | winget install Kitware.CMake |
| Ninja | winget install Ninja-build.Ninja |
| Python ≥ 3.10 | python.org |
| pybind11 | pip install pybind11 |
| zlib (static) | vcpkg install zlib:x64-windows-static |
from ghidra.sleigh.decompiler_python import DecompilerPython
dp = DecompilerPython()
dp.use_python_heritage = True
dp.use_python_rules = True
dp.use_python_printc = True
dp.initialize()
code = dp.decompile(
sla_path="specs/Processors/x86/data/languages/x86-64.sla",
target="x86:LE:64:default",
image=binary_bytes,
base_addr=0x140000000,
entry=0x140001000,
)
print(code)from ghidra.sleigh.decompiler_native import DecompilerNative
dn = DecompilerNative()
dn.add_spec_path("specs/Processors/x86/data/languages")
dn.initialize()
code = dn.decompile(
"specs/Processors/x86/data/languages/x86-64.sla",
"x86:LE:64:default",
binary_bytes, 0x140000000, 0x140001000, 0,
)
print(code)| Layer | Implementation | Purpose |
|---|---|---|
| SLEIGH Engine | C++ pybind11 .pyd |
Instruction decode & P-code lifting |
| Decompiler Core | Pure Python | IR, SSA, optimization, structuring, C output |
| Native Baseline | C++ pybind11 .pyd |
Full C++ Ghidra decompiler for comparison |
The C++ source under native/ is the ground truth — Python must produce semantically equivalent output. See docs/ARCHITECTURE.md for the full porting plan.
Processor specs live under specs/Processors/. The SLA search order:
- Paths added via
arch_map.add_sla_search_dir() PYGHIDRA_SLA_DIRenvironment variable<project_root>/specs/Processors/<arch>/data/languages/
To add architectures, copy .sla + .pspec + .cspec from your Ghidra install and add an entry in src/ghidra/sleigh/arch_map.py.
pip install -e ".[dev]"
python -m pytest tests -v --timeout=120