The decompiler currently handles OP_CLOSURE improperly, and looks for the function index in register C, when Lua uses combined register Bx. This will actually work as expected with vanilla Lua implementations that use the typical Op-A-C-B opcode-operand ordering, as C happens to be the lower 9 bits of Bx, but will fail with Lua implementations that use a different ordering.
This patch makes some tiny changes to ProcessCode so that it reads the function index from Bx instead.
(The disassembler part of luadec already reads from Bx instead of C, so no changes are necessary there.)
Fix #74.
The decompiler currently handles
OP_CLOSURE
improperly, and looks for the function index in register C, when Lua uses combined register Bx. This will actually work as expected with vanilla Lua implementations that use the typicalOp-A-C-B
opcode-operand ordering, as C happens to be the lower 9 bits of Bx, but will fail with Lua implementations that use a different ordering.This patch makes some tiny changes to
ProcessCode
so that it reads the function index from Bx instead.(The disassembler part of luadec already reads from Bx instead of C, so no changes are necessary there.)