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.4.0.tar.gz (28.7 kB view hashes)

Uploaded Source

Built Distribution

hlbc-0.4.0-cp310-none-win_amd64.whl (282.6 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

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