hax0r31337 / denpk2

Unpacks the NXPK files from games with NetEase NeoX 2 Engine
6 stars 2 forks source link

PyTools #4

Open DasMoorhuhn opened 3 months ago

DasMoorhuhn commented 3 months ago

Ay^^

From where can I get the pytools lib which is linked in the Cargo.toml? pytools = { path = "../pytools" }

Alexander-Porter commented 3 months ago

I'm currently working on remapping opcodes using a modified version of the xdis library, which I thought may work as an alternative of pytools. I got the opcode mapping from the latest commit. I got pyc files from the last commit of this repo without pytools dependency. I fixed the magic number of the .pyc file and have the opcode remapped as shown below:

(
    filename,
    co,
    version,
    timestamp,
    magic_int,
    is_pypy,
    source_size,
    sip_hash,
) = xdis.disassemble_file(
    str(pyc_file), outstream=open(os.devnull, "w"), alternate_opmap=alternate_opmap #from src/opcode/mapping.rs
)

However, the output pyc file can't be decompiled. I have tried using both uncompyle6 and pycdc, and they both warned about an unsupported opcode. For pycdc, the specific unsupported opcode was MAKE_CELL.

I suspect there might be an issue with how the opcode is being remapped. To debug this further, the access to the pytools dependency should be helpful.

@hax0r31337 Could you please make the pytools public? This will greatly help in locating and fixing the error with decompiling, thanks!

hax0r31337 commented 3 months ago

I was planning to add decompiler to pytools library, but I having trouble analyzing dominator tree of python bytecode.
That's the reason I didn't made pytools available publicly.

btw both pycdc and uncompyle6 unable to decompile Python 3.11 bytecode, although pycdc claims the capability