Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

Lua Bytecode Parser

This is a basic lua 5.1 bytecode parser written C++.
Usage:
Open the solution file in visual studio make sure you're building with C++17.
Parser.exe <file> (luac file)
Example:
-- This is to demonstrate the parser's ability to parse multiple nested prototypes.
(function()
print("Hello, World!");
(function()
print(1);
end)();
end)();
Output:
-- Header Info --Signature: 'Lua'Version: 81Format: 0Endianness: BigEndianIntSize: 4Size_tSize: 4InstructionSize: 4LuaNumberSize: 8IntegralFlag: 0functionmain(...)
-- Prototype Info --Source='@test.lua'LineDefined=0LastLineDefined=0NumUpvalues=0NumParameters=0IsVararg=trueMaxStackSize=2-- Constants ---- Instructions --Opcode: 36, A: 0, B: 0, C: 0, Mnemonic: CLOSUREOpcode: 28, A: 3, B: 1, C: 2, Mnemonic: CALLOpcode: 30, A: 2, B: 1, C: 1, Mnemonic: RETURN-- Nested Prototypes --functionproto_000001D6127E6B50(...)
-- Prototype Info --Source='(none)'LineDefined=1LastLineDefined=1NumUpvalues=0NumParameters=0IsVararg=falseMaxStackSize=2-- Constants --
[Constant] Type=String, Value="print"
[Constant] Type=String, Value="Hello, World!"-- Instructions --Opcode: 5, A: 0, B: 0, C: 0, Mnemonic: GETGLOBALOpcode: 1, A: 2, B: 1, C: 0, Mnemonic: LOADKOpcode: 28, A: 5, B: 2, C: 3, Mnemonic: CALLOpcode: 36, A: 0, B: 0, C: 0, Mnemonic: CLOSUREOpcode: 28, A: 3, B: 1, C: 2, Mnemonic: CALLOpcode: 30, A: 2, B: 1, C: 1, Mnemonic: RETURN-- Nested Prototypes --functionproto_000001D6127E8F30(...)
-- Prototype Info --Source='(none)'LineDefined=1LastLineDefined=1NumUpvalues=0NumParameters=0IsVararg=falseMaxStackSize=2-- Constants --
[Constant] Type=String, Value="print"
[Constant] Type=Number, Value=1-- Instructions --Opcode: 5, A: 0, B: 0, C: 0, Mnemonic: GETGLOBALOpcode: 1, A: 2, B: 1, C: 0, Mnemonic: LOADKOpcode: 28, A: 5, B: 2, C: 3, Mnemonic: CALLOpcode: 30, A: 2, B: 1, C: 1, Mnemonic: RETURNendendend
We output it in a lua like format. We got the idea from luac.nl.
Anyways, we plan to release a more dynamic version which will handle each and every Lua version.
See anything that could be improved on? Let us know! Logisec Contact Us
Creds:

About

A Lua Bytecode Parser written entirely in C++.

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages