Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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