From 323898d083a0dafcf07bc32d68287e1c1a8e99ae Mon Sep 17 00:00:00 2001 From: Guest257351 <57662212+Guest257351@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:25:00 +1030 Subject: [PATCH] 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` instead of `Vector`. * 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. --- patterns/lua51.hexpat | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/patterns/lua51.hexpat b/patterns/lua51.hexpat index 03319bb..b01e931 100644 --- a/patterns/lua51.hexpat +++ b/patterns/lua51.hexpat @@ -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 lineInfo; Vector localVar; - Vector upvalues; + Vector 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 \ No newline at end of file