luadec
A Lua 5.1 bytecode decompiler library written in Rust, originated from the lbcdec project.
Installation
Add this to your Cargo.toml:
[]
= "0.2.0"
Usage
As a Library
Basic Decompilation
use LuaDecompiler;
// Read bytecode from file
let bytecode = read?;
// Create decompiler and decompile
let decompiler = new;
let source_code = decompiler.decompile?;
println!;
With Custom Options
use ;
let options = DecompileOptions ;
let decompiler = with_options;
let result = decompiler.decompile?;
Batch Processing
use ;
let batch_options = BatchOptions ;
// Decompile all .luac files in a directory
let results = decompile_bytecode_files?;
File Operations
use LuaDecompiler;
let decompiler = new;
// Decompile file to file
decompiler.decompile_file_to_file?;
// Decompile file to string
let source = decompiler.decompile_file?;
Configuration Options
DecompileOptions
BatchOptions
Error Handling
The library provides detailed error information:
use ;
match decompiler.decompile
Performance
- Memory Efficient: Processes bytecode without loading entire files into memory
- Parallel Processing: Batch operations can utilize multiple CPU cores
- Optimized Parsing: Efficient bytecode parsing with minimal allocations
Limitations
- Lua 5.1 Only: Currently supports Lua 5.1 bytecode format only
- Debug Information: Some debug information may be lost during compilation
- Variable Names: Local variable names may be generic if debug info is stripped
- Comments: Original source comments are not preserved in bytecode
Development
Building from Source
Running Tests
Generating Documentation
Related Projects
- lbcdec: The original project this library is based on
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Acknowledgments
- Original
lbcdecproject by Dwayne Slater
Changelog
Version 0.2.0
- Initial Release