Skip to main content

A (terrible) Python wrapper for hlbc

Project description

hlbc-python

A (terrible) Python wrapper for hlbc - A Hashlink bytecode disassembler and decompiler.

Installation

pip install hlbc

Usage

Before running this example, download either the prebuilt bytecode or the source code of the Clazz test file and place the compiled bytecode in the same directory as the script.

import hlbc

# Open and disassemble a file
code = hlbc.Bytecode("./Clazz.hl")

# Get the debug files
print(code.get_debug_files())
# > ['Clazz.hx', 'C:\\HaxeToolkit\\haxe\\std/hl/_std/Std.hx', 'C:\\HaxeToolkit\\haxe\\std/hl/_std/String.hx', ... '?']

# Get all functions from a specific debug file in the bytecode
print(code.get_functions("Clazz.hx"))
# > ['fn main@22 () -> void', 'fn method@23 (Clazz) -> i32', 'fn <none>@337 ((f64, f64) -> i32, i32, i32) -> i32', ...]

# Decompile a single function by index
print(code.decompile("23"))
# > static function method(_: Clazz): Int {
# >  return 42;
# > }

# Stub a function
print(code.stub("23"))
# > static function method(_: Clazz): Int {}

Notes

  • Any errors will be raised back to Python as simple Exceptions, but this is subject to change.
  • The Bytecode class is thread-safe. You can use the same instance multiple times in different threads. It also doesn't hold the file open, so you can create multiple instances of it with the same file.

Credits

  • Gui-Yom (Guillaume Anthouard) for creating hlbc, which this project is just a cheap repackaging of.

Project details


Download files

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

Source Distribution

hlbc-0.3.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

hlbc-0.3.0-cp310-none-win_amd64.whl (270.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

File details

Details for the file hlbc-0.3.0.tar.gz.

File metadata

  • Download URL: hlbc-0.3.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.0

File hashes

Hashes for hlbc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a80bb72972fdf5d09cb4f5ede3c011c8d7b6803285a5003489ce0779bf89a169
MD5 a69b71843b485fe80bc6dfcd6a8d011d
BLAKE2b-256 6945333d18c0203e938663eef3235a725b9617b87bde109588c922eaee0d7fff

See more details on using hashes here.

File details

Details for the file hlbc-0.3.0-cp310-none-win_amd64.whl.

File metadata

  • Download URL: hlbc-0.3.0-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 270.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.0

File hashes

Hashes for hlbc-0.3.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 35b3acd94407b73e6c8e09117c8fe43766df7d1ff593008074bbb9eebc4ad5a6
MD5 f7e3506d7cbb9c7d5b2b6386e47fac16
BLAKE2b-256 84c1629a97c6d713a644d122f1844b600383e0838b3943b2e611cb85691cef2e

See more details on using hashes here.

Supported by

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