Skip to main content

Python bindings for the xex2 crate: parse, inspect, and patch Xbox 360 XEX2 executables.

Project description

xex2 (Python)

Python bindings for the xex2 crate via diplomat + nanobind. Parse Xbox 360 XEX2 executables and extract the inner PE from Python.

Build pipeline

The pipeline is intentionally small; everything below the src/xex2.cpp glue file is auto-generated or stock tooling.

┌─────────────────────────────┐
│ crates/xex2-ffi/src/lib.rs  │  #[diplomat::bridge] — hand-written
└────────────┬────────────────┘
             │ diplomat-tool cpp
             ▼
┌─────────────────────────────────────────────┐
│ crates/xex2-ffi/bindings/cpp/*.hpp          │  auto-generated C++
│ (Xex2.hpp, Xex2Bytes.hpp, Xex2Error.hpp,    │  (gitignored)
│  diplomat_runtime.hpp, ...)                 │
└────────────┬────────────────────────────────┘
             │ #include
             ▼
┌─────────────────────────────┐
│ bindings/python/src/xex2.cpp│  nanobind glue — hand-written
└────────────┬────────────────┘
             │ nanobind + scikit-build-core
             ▼
┌─────────────────────────────┐
│ xex2.cpython-<ver>-<abi>.so │  final Python extension module
└─────────────────────────────┘

Install

From PyPI (once published):

pip install xex2
# or
uv add xex2

Pre-built wheels cover CPython 3.10–3.13 on Linux (manylinux_2_28 x86_64), macOS (arm64 + x86_64), and Windows x86_64. The extension is statically linked to libxex2_ffi.a, so wheels have no dependency on a separately installed native library.

Building from source

Source builds need the full Rust workspace available; they're only intended for local development.

# From the workspace root:
cargo build -p xex2-ffi --release
diplomat-tool cpp crates/xex2-ffi/bindings/cpp \
    --entry crates/xex2-ffi/src/lib.rs

# Then:
cd bindings/python
uv pip install -e . --no-build-isolation

Use

import xex2

data = open("game.xex", "rb").read()
x = xex2.Xex2.parse(data)

# Always-present fields (from SecurityInfo / ImageInfo / Xex2Header).
print(f"load_address:  {x.load_address:#010x}")
print(f"image_size:    {x.image_size:#x}")
print(f"module_flags:  {x.module_flags:#x}")
print(f"image_flags:   {x.image_flags:#x}")

# Optional-header-backed fields raise RuntimeError when absent —
# `xex2`'s `Option<T>` is propagated as a typed error rather than a
# silent default. Catch or use .get-style wrappers yourself.
try:
    print(f"entry_point:   {x.entry_point:#010x}")
except RuntimeError:
    print("no entry point set")

# ExecutionInfo-derived fields.
for field in ("title_id", "version", "disc_number", "disc_count"):
    try:
        print(f"{field:14s} {getattr(x, field)!r}")
    except RuntimeError:
        pass

# Fixed-size byte fields come back as `bytes`.
print(f"image_hash:    {x.image_hash.hex()}")
print(f"rsa_signature: {len(x.rsa_signature)} bytes")

# Imports / resources are iterable.
for lib in (x.imports()[i] for i in range(len(x.imports()))):
    print(f"import: {lib.name} v{lib.version:#010x} ({len(lib)} records)")

# Modify: strip restrictions, get a re-signed XEX back as bytes.
limits = xex2.Xex2RemoveLimits.all()
open("game-unlocked.xex", "wb").write(x.modify(limits))

# Extract the decrypted / decompressed PE.
open("game.pe", "wb").write(x.extract_basefile())

Surface

  • Always present: load_address, image_size, header_size, page_descriptor_count, info_size, image_flags, import_table_count, export_table_address, game_regions, allowed_media_types, module_flags, data_offset, security_offset, optional_header_count.
  • Optional scalars (raise on absence): entry_point, original_base_address, default_stack_size, default_heap_size, default_fs_cache_size, date_range_not_before, date_range_not_after, bounding_path.
  • ExecutionInfo (raise on absence): title_id, exec_media_id, version, base_version, platform, executable_table, disc_number, disc_count, savegame_id.
  • FileFormatInfo (raise on absence): compression_type, encryption_type, window_size.
  • Fixed-size bytes: image_hash (20), import_table_hash (20), header_hash (20), media_id (16), file_key (16), rsa_signature (256).
  • Collections: imports()Xex2Imports, resources()Xex2Resources. Both support len(), [i], and get(i); OOB indices raise RuntimeError.
  • Operations: extract_basefile()bytes (decrypted/decompressed PE); modify(Xex2RemoveLimits)bytes (re-signed XEX with the requested restrictions stripped).

Tests

cd bindings/python
uv run pytest

Tests that need a real fixture (xex_files/afplayer.xex) skip when the file isn't present so a fresh clone still runs the suite.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xex2-0.2.0-cp313-cp313-win_amd64.whl (276.9 kB view details)

Uploaded CPython 3.13Windows x86-64

xex2-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

xex2-0.2.0-cp313-cp313-macosx_11_0_universal2.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ universal2 (ARM64, x86-64)

xex2-0.2.0-cp312-cp312-win_amd64.whl (277.0 kB view details)

Uploaded CPython 3.12Windows x86-64

xex2-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

xex2-0.2.0-cp312-cp312-macosx_11_0_universal2.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ universal2 (ARM64, x86-64)

xex2-0.2.0-cp311-cp311-win_amd64.whl (277.4 kB view details)

Uploaded CPython 3.11Windows x86-64

xex2-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

xex2-0.2.0-cp311-cp311-macosx_11_0_universal2.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ universal2 (ARM64, x86-64)

xex2-0.2.0-cp310-cp310-win_amd64.whl (277.7 kB view details)

Uploaded CPython 3.10Windows x86-64

xex2-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

xex2-0.2.0-cp310-cp310-macosx_11_0_universal2.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file xex2-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: xex2-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 276.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xex2-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 526ef8fc319ff28a4cca58fabe7eff8d9120eef947cbb98c2025716ada5d8a65
MD5 0f6fea61bd05ac1bf2fbe451a4ae081f
BLAKE2b-256 c82cf15c26452d9736d4aacece097aca3d128097c7d68a29d93be54af82df197

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp313-cp313-win_amd64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4a77c8287be0eafac3012bc7b6bd03d421426b09b3aa76ec43d52ec47884d359
MD5 3e34a0ed31757c7567945ef9c92e37af
BLAKE2b-256 1bc91b6ad407c3693840b84a46ca3206839b2a86fa710d52c1f5045446f5917b

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp313-cp313-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp313-cp313-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 7579d677b64961fef25daaeefb8d37bb55d7eabf8da85449394167f8dc47f40b
MD5 1694fd9c84051a034b3b4ddc9e4b6d30
BLAKE2b-256 e059a977631cf9b057e9b5e7bccd2469acda9b97696df05f534c28f464d49bd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp313-cp313-macosx_11_0_universal2.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: xex2-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 277.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xex2-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f410b8dfd958591ae3b9f8384ac46cfac2c15b4094e7de18171ca84d04dcc147
MD5 a3557797ea3cb804a1a55484fb14b3c5
BLAKE2b-256 c41314b8a172a8d4a6797bffb487101b232743bc626525ce506ec08edc8f6de6

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp312-cp312-win_amd64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fe4303d836d74f4d68342cf86b349b5b31a02518687415b3e4402bc5d267059
MD5 52d6dd487f7b1862ec56610c5d31147f
BLAKE2b-256 caf5691e0240253f1e45b00e9232bce3d7ada0f2109c1caa413dafc881f8c46b

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp312-cp312-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp312-cp312-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 1ab0c2ed83f819eeb6049fbdbd4ef1534a205cf8e7e70ee045cdf165205958e4
MD5 9c53af744d4b0642f50e77daee83757c
BLAKE2b-256 2723c6dc0badec47b5adcdfa1a856a3d2c63e88695834cc555d4747e19156015

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp312-cp312-macosx_11_0_universal2.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: xex2-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 277.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xex2-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 18f22037887ecd3f4e1c39daa051ee01914b1d436ddf6e79aceae9d1d9a9fcd8
MD5 1cfd15e50b52d5f6cac561e10e084cc1
BLAKE2b-256 8dbdbe72a5f46f7802390ade136ec5b8d0a88b439cc8a4d5f93c25cedc5b7417

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9179d26a2a45a4477c900a09da1bebb33e86978d3916bd0cdc5a746d22420d60
MD5 f30cd258276540beb1e00e4dcbc21a4f
BLAKE2b-256 5bb7c1be304503bb7d6fe4577199598aeb1eaa39dc4cda7209d864052cd26f16

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp311-cp311-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 194a615b113c4292d33c1b0cf2a8b92358262c32327ebb002f818542770028c6
MD5 7e673ea966e75735dcf4810657299513
BLAKE2b-256 3f595174d8e19463709fda5ad1e944de2aac9cf65ef8ad148a7fb67143ec5539

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp311-cp311-macosx_11_0_universal2.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: xex2-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 277.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xex2-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 152c2e8c80b52fe302e2ddc2b551390e2a3285bab194d0cd07a7ec1ffe6bb8c6
MD5 7d8571f6e78d62802ac6fa1dc24f8545
BLAKE2b-256 e603da4d025efb8ccd18649a98e4fac28e4732313c79dfd44d5f926e98454698

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp310-cp310-win_amd64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae50593700815d4c65b5da248b2b1247bbfb6ae7e81687eaa61ec086b883751d
MD5 bf5a056c1f45cc41700904fea0e6ff9c
BLAKE2b-256 49ec4327a7c79898ed5eab964f4c480d77b96e573bc564d6234f66d30719b710

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xex2-0.2.0-cp310-cp310-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for xex2-0.2.0-cp310-cp310-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 61ab0f1d00d907cde7fce8f168aaa1d5ec5c79d52f95f052207949ba94e03ba4
MD5 a0e25bb2bdd22093f2f0731640f72966
BLAKE2b-256 b4742b399877ca296407e45980f9e68f65848274a8532904cd8a087137912c84

See more details on using hashes here.

Provenance

The following attestation bundles were made for xex2-0.2.0-cp310-cp310-macosx_11_0_universal2.whl:

Publisher: pypi.yml on landaire/acceleration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page