patterns/lua5.1: Fixed a bug in the Lua 5.1 bytecode pattern (#298)

* Fixed a bug in the Lua 5.1 bytecode pattern

Lua 5.1 bytecode upvalue fields were incorrectly defined as a `Vector<u32>` instead of `Vector<LuaString>`.

* Fixed another bug in the lua 5.1 bytecode pattern

Lua 5.1 bytecode string sizes were incorrectly parsed as a 64-bit integer, instead of a 32-bit integer.

* Updated the Lua 5.1 bytecode pattern for 32-bit compilers.

Updated the pattern to allow for 32-bit and 64-bit integers for the size of the string length field.
This commit is contained in:
Guest257351
2024-11-17 23:25:00 +10:30
committed by GitHub
parent abbd25e7f6
commit 323898d083

View File

@@ -36,8 +36,15 @@ struct LuaBinaryHeader {
u8 lua_Number;
u8 is_lua_Number_integral;
};
LuaBinaryHeader header @ 0;
struct LuaString {
u64 size;
if (header.size_of_size_t == 4) {
u32 size;
} else {
u64 size;
}
if (size > 0) {
char data[size];
}
@@ -72,7 +79,7 @@ struct LocalVar {
struct LuaDebugInfo {
Vector<u32> lineInfo;
Vector<LocalVar> localVar;
Vector<u32> upvalues;
Vector<LuaString> upvalues;
};
struct LuaConstants{
@@ -96,9 +103,4 @@ struct LuaFunction {
LuaDebugInfo debugInfo;
};
struct LuaFile {
LuaBinaryHeader header;
LuaFunction func;
};
LuaFile file @ 0;
LuaFunction toplevelFunction @ 12; // Lua header size is always 12 bytes