Name | hlbc JSON |
Version |
0.5.0
JSON |
| download |
home_page | None |
Summary | A (terrible) Python wrapper for hlbc |
upload_time | 2024-08-14 23:49:36 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | None |
keywords |
haxe
hashlink
decompiler
disassembler
hlbc
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# hlbc-python
A (terrible) Python wrapper for [hlbc](https://github.com/Gui-Yom/hlbc) - A Hashlink bytecode disassembler and decompiler.
## Installation
```bash
pip install hlbc
```
## Usage
Before running this example, download either the [prebuilt bytecode](https://github.com/N3rdL0rd/hlbc-python/raw/main/test/Clazz.hl) or the [source code](https://github.com/N3rdL0rd/hlbc-python/blob/main/test/Clazz.hx) of the `Clazz` test file and place the compiled bytecode in the same directory as the script.
```python
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 `Exception`s, 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](https://github.com/Gui-Yom) (Guillaume Anthouard) for creating [hlbc](https://github.com/Gui-Yom/hlbc), which this project is just a cheap repackaging of.
<!-- TODO: actual docs? pdoc3? who the hell knows... -->
Raw data
{
"_id": null,
"home_page": null,
"name": "hlbc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "N3rdL0rd <n3rdl0rd@proton.me>",
"keywords": "haxe, hashlink, decompiler, disassembler, hlbc",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/27/9d/357b9d2a8848308455725066f8e08e4d27e678616171226ddfa812dd03d7/hlbc-0.5.0.tar.gz",
"platform": null,
"description": "# hlbc-python\r\n\r\nA (terrible) Python wrapper for [hlbc](https://github.com/Gui-Yom/hlbc) - A Hashlink bytecode disassembler and decompiler.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install hlbc\r\n```\r\n\r\n## Usage\r\n\r\nBefore running this example, download either the [prebuilt bytecode](https://github.com/N3rdL0rd/hlbc-python/raw/main/test/Clazz.hl) or the [source code](https://github.com/N3rdL0rd/hlbc-python/blob/main/test/Clazz.hx) of the `Clazz` test file and place the compiled bytecode in the same directory as the script.\r\n\r\n```python\r\nimport hlbc\r\n\r\n# Open and disassemble a file\r\ncode = hlbc.Bytecode(\"./Clazz.hl\")\r\n\r\n# Get the debug files\r\nprint(code.get_debug_files())\r\n# > ['Clazz.hx', 'C:\\\\HaxeToolkit\\\\haxe\\\\std/hl/_std/Std.hx', 'C:\\\\HaxeToolkit\\\\haxe\\\\std/hl/_std/String.hx', ... '?']\r\n\r\n# Get all functions from a specific debug file in the bytecode\r\nprint(code.get_functions(\"Clazz.hx\"))\r\n# > ['fn main@22 () -> void', 'fn method@23 (Clazz) -> i32', 'fn <none>@337 ((f64, f64) -> i32, i32, i32) -> i32', ...]\r\n\r\n# Decompile a single function by index\r\nprint(code.decompile(\"23\"))\r\n# > static function method(_: Clazz): Int {\r\n# > return 42;\r\n# > }\r\n\r\n# Stub a function\r\nprint(code.stub(\"23\"))\r\n# > static function method(_: Clazz): Int {}\r\n```\r\n\r\n## Notes\r\n\r\n- Any errors will be raised back to Python as simple `Exception`s, but this is subject to change.\r\n- 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.\r\n\r\n## Credits\r\n\r\n- [Gui-Yom](https://github.com/Gui-Yom) (Guillaume Anthouard) for creating [hlbc](https://github.com/Gui-Yom/hlbc), which this project is just a cheap repackaging of.\r\n\r\n<!-- TODO: actual docs? pdoc3? who the hell knows... -->\n",
"bugtrack_url": null,
"license": null,
"summary": "A (terrible) Python wrapper for hlbc",
"version": "0.5.0",
"project_urls": {
"homepage": "https://github.com/N3rdL0rd/hlbc-python",
"repository": "https://github.com/N3rdL0rd/hlbc-python"
},
"split_keywords": [
"haxe",
" hashlink",
" decompiler",
" disassembler",
" hlbc"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cce50be193cacfe2e4f8e918b45b6cde02dabfa52ce78eef213cd3a48a595584",
"md5": "3bee5f6c829e7c2c105ec8d2d09e2eec",
"sha256": "5feed59051c95c8a7a959c9915f23b2cd50865a29167906a766dc25b2940e300"
},
"downloads": -1,
"filename": "hlbc-0.5.0-cp310-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "3bee5f6c829e7c2c105ec8d2d09e2eec",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 290328,
"upload_time": "2024-08-14T23:49:34",
"upload_time_iso_8601": "2024-08-14T23:49:34.544916Z",
"url": "https://files.pythonhosted.org/packages/cc/e5/0be193cacfe2e4f8e918b45b6cde02dabfa52ce78eef213cd3a48a595584/hlbc-0.5.0-cp310-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "279d357b9d2a8848308455725066f8e08e4d27e678616171226ddfa812dd03d7",
"md5": "9fa42d154731130ae16ca7e89472bb30",
"sha256": "21c8b0a3bdde506b588094e61ee51789c8e5485b72b70544da6504936f73f815"
},
"downloads": -1,
"filename": "hlbc-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "9fa42d154731130ae16ca7e89472bb30",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 28539,
"upload_time": "2024-08-14T23:49:36",
"upload_time_iso_8601": "2024-08-14T23:49:36.113190Z",
"url": "https://files.pythonhosted.org/packages/27/9d/357b9d2a8848308455725066f8e08e4d27e678616171226ddfa812dd03d7/hlbc-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-14 23:49:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "N3rdL0rd",
"github_project": "hlbc-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "hlbc"
}