Skip to main content

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.

Release files for hlbc 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hlbc 0.5.0
File Size Uploaded
hlbc-0.5.0.tar.gz 28.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hlbc 0.5.0
File Interpreter ABI Platform
hlbc-0.5.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details

Total release size: 318.9 kB

Release files / hlbc-0.5.0.tar.gz

Download URL hlbc-0.5.0.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
21c8b0a3bdde506b588094e61ee51789c8e5485b72b70544da6504936f73f815
BLAKE2b-256 checksum
How to use checksums
279d357b9d2a8848308455725066f8e08e4d27e678616171226ddfa812dd03d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release files / hlbc-0.5.0-cp310-none-win_amd64.whl

Download URL hlbc-0.5.0-cp310-none-win_amd64.whl
Size 290.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5feed59051c95c8a7a959c9915f23b2cd50865a29167906a766dc25b2940e300
BLAKE2b-256 checksum
How to use checksums
cce50be193cacfe2e4f8e918b45b6cde02dabfa52ce78eef213cd3a48a595584
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.7.0

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page