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

Support Python 3.12 decompilation #453

Open
14 of 41 tasks
zrax opened this issue Feb 21, 2024 · 2 comments
Open
14 of 41 tasks

Support Python 3.12 decompilation #453

zrax opened this issue Feb 21, 2024 · 2 comments

Comments

@zrax
Copy link
Owner

zrax commented Feb 21, 2024

Tasks

  • Bytecode support (pycdas)
  • Handle new opcodes in AST builder
    • INTERPRETER_EXIT
    • END_FOR
    • END_SEND
    • RESERVED
    • BINARY_SLICE
    • STORE_SLICE
    • CLEANUP_THROW
    • POP_JUMP_IF_FALSE
    • POP_JUMP_IF_TRUE
    • RETURN_CONST
    • LOAD_FAST_CHECK
    • POP_JUMP_IF_NOT_NONE
    • POP_JUMP_IF_NONE
    • LOAD_SUPER_ATTR
    • LOAD_FAST_AND_CLEAR
    • YIELD_VALUE
    • CALL_INTRINSIC_1
    • CALL_INTRINSIC_2
    • LOAD_FROM_DICT_OR_GLOBALS
    • LOAD_FROM_DICT_OR_DEREF
    • INSTRUMENTED_LOAD_SUPER_ATTR
    • INSTRUMENTED_POP_JUMP_IF_NONE
    • INSTRUMENTED_POP_JUMP_IF_NOT_NONE
    • INSTRUMENTED_RESUME
    • INSTRUMENTED_CALL
    • INSTRUMENTED_RETURN_VALUE
    • INSTRUMENTED_YIELD_VALUE
    • INSTRUMENTED_CALL_FUNCTION_EX
    • INSTRUMENTED_JUMP_FORWARD
    • INSTRUMENTED_JUMP_BACKWARD
    • INSTRUMENTED_RETURN_CONST
    • INSTRUMENTED_FOR_ITER
    • INSTRUMENTED_POP_JUMP_IF_FALSE
    • INSTRUMENTED_POP_JUMP_IF_TRUE
    • INSTRUMENTED_END_FOR
    • INSTRUMENTED_END_SEND
    • INSTRUMENTED_INSTRUCTION
    • INSTRUMENTED_LINE
  • All jumps are now relative
@Seneral
Copy link

Seneral commented Apr 25, 2024

Added support for the following
POP_JUMP_IF_NOT_NONE
POP_JUMP_IF_NONE
CALL_INTRINSIC_1 (only INTRINSIC_IMPORT_STAR)

patch.txt

EDIT: Fixed logging for unsupported intrinsic_1

I have no idea how to implement the other intrinsics, I found no obvious mapping to prior opcodes like with IMPORT_STAR and since I have no code to test it against either, this is all I can do rn. The script I wanted decompiled is successfully decompiled now, so thanks a lot for this project!

@Seneral
Copy link

Seneral commented May 26, 2024

Warning: In my test file, it seems it's inverted - POP_JUMP_IF_NOT_NONE_A needed to be come if xxx is None: for the decompiled behaviour to match the original. No occurences of POP_JUMP_IF_NONE_A to double-check sadly. Not sure if this is a general error, cpython seems to treat POP_JUMP_IF_NOT_NONE_A as expected, and the opcodes also match the ones found here.
This will need proper verification.

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

No branches or pull requests

3 participants
@zrax @Seneral and others