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 · 8 comments
Open
14 of 41 tasks

Support Python 3.12 decompilation #453

zrax opened this issue Feb 21, 2024 · 8 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.

@rockingdice
Copy link

rockingdice commented Jul 22, 2024

pycdc crashes for some pyc files when parsing JUMP_BACKWARD_A(140) in python 3.11, could you examine what the error is?

@greenozon
Copy link
Contributor

JUMP_BACKWARD is still not in main branch, you could try to play with this PR: #472

@rockingdice
Copy link

rockingdice commented Jul 22, 2024

JUMP_BACKWARD is still not in main branch, you could try to play with this PR: #472

Thanks for the pr!

@DEMON1A
Copy link

DEMON1A commented Jul 29, 2024

Anything new about LOAD_FAST_AND_CLEAR?

@jsrcode
Copy link

jsrcode commented Dec 1, 2024

JUMP_BACKWARD

JUMP_BACKWARD_A与JUMP_BACKWARD是否有区别

@jsrcode
Copy link

jsrcode commented Dec 1, 2024

POP_JUMP_IF_NONE

合并后依旧报错Unsupported opcode: POP_JUMP_IF_NONE (239)

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

7 participants
@zrax @greenozon @rockingdice @Seneral @DEMON1A @jsrcode and others