zrax / pycdc

C++ python bytecode disassembler and decompiler
GNU General Public License v3.0
2.95k stars 591 forks source link

Added support for `LOAD_CLASSDEREF` #458

Closed TiZCrocodile closed 3 months ago

TiZCrocodile commented 3 months ago

The opcode itself is exactly the same as LOAD_DEREF.

  1. The problem is when the class is a closure (e.g. defined inside a function body) then there is a BUILD_TUPLE after the LOAD_BUILD_CLASS which makes problems. In this case I just added a check in the BUILD_TUPLE opcode to break if the TOS is NODE_LOADBUILDCLASS.

  2. There is another problem which makes the code->name() of the class to be part of the function locals. (e.g. func.<locals>.my_class instead of my_class) which makes the check srcString->isEqual(code->name().cast<PycObject>()) be invalid. Here I removed this check and another one that checks if the srcString != nullptr