hlbc

Crates.iohlbc
lib.rshlbc
version0.7.0
sourcesrc
created_at2022-05-21 15:22:01.421137
updated_at2023-11-16 21:23:47.589525
descriptionHashlink bytecode disassembler and analyzer
homepage
repositoryhttps://github.com/Gui-Yom/hlbc
max_upload_size
id590761
size120,409
(Gui-Yom)

documentation

README

hlbc Crates.io

Hashlink bytecode disassembler and analyzer.

This crate is a library, see hlbc-cli for an actual program to use.


Features

  • Parse the whole bytecode file or any bytecode element
  • Display any bytecode element
  • Restore all possible names
  • Link elements between them (with manual references for flexibility)
  • Link elements with their debug information
  • Serialize bytecode back to bytes
  • Decompiler to haxe source code for classes and functions
  • Commandline interface to use the features of this library (hlbc-cli)

Planned features

  • Properly test serialization, ensure we get a byte-to-byte equivalent.
  • Integrate with the Haxe/Hashlink standard library to restore more names, exclude them from analysis and such
  • C API to integrate with other tools
  • Text search engine to search for strings and names
  • Assemble and inject bytecode or inject haxe source code directly

Changelog

See CHANGELOG.md.

Decompiler

The decompiler is present in the hlbc-decompiler crate and is currently incomplete (and might never be 100% complete). See the wiki for examples of decompilation output.

Wiki

A wiki detailing the specifics of Hashlink bytecode is available here. The wiki also details the specifics of Haxe to hashlink compilation and decompilation.

Alternatives

This library is made in Rust, a C API is in the works which could permit using this lib in many other projects, but for now it is only Rust friendly.

Other alternatives include :

  • Tinkering directly with the hashlink source code in C (my first attempt was doing this, but it turned out that everything in C is pain in the ass)
  • Using the in-progress dashlink made in Haxe but probably compilable to many other languages.

Macros

There are 98 different bytecode instructions, there is no way I manually write code for them. Most of the serialization code for these opcodes is generated through a proc macro (see hlbc-derive). Making that a declarative macro would probably turn out really hard. The only time I needed to write 98 different branches was for the formatting used when displaying the instructions (src/fmt.rs).

Commit count: 165

cargo fmt