Skip to content

Fix incorrect OP_CLOSURE decompilation (register C -> Bx)#73

Open
jalbert-dev wants to merge 1 commit intoviruscamp:masterfrom
jalbert-dev:fix/closure-operand-decompiler
Open

Fix incorrect OP_CLOSURE decompilation (register C -> Bx)#73
jalbert-dev wants to merge 1 commit intoviruscamp:masterfrom
jalbert-dev:fix/closure-operand-decompiler

Conversation

@jalbert-dev
Copy link

@jalbert-dev jalbert-dev commented Aug 16, 2020

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 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OP_CLOSURE decompiles incorrectly if Lua uses non-standard opcode order

1 participant