So is there a way to decompile a .pex file into a .psc file so that it could be corrected and recompiled?
From what you've said, the .pex files are only for something we can read to better understand what the script is doing. There is no way to recompile them.
Your program is the first decompile program I have tried that worked! I have already endorsed it. But I need a decompiler that will create a .psc file.
Most scripts you can rebuild from the information decompiled, especially if you wrote the original script. If you didn't now's a good time to learn the ins and outs of scripting so you can understand what's decompiled!
This unfinished tool has been obsolete since 2013. Use Champollion: Skyrim release here, Fallout 4 release here, source at GitHub here. It seems to do a good job, though it has a few issues that need manual tweaking. E.g., it exports Event/EndEvent as Function/EndFunction, so you need to be able to identify on your own what should be coded as an Event not a regular Function. It generally helps if you have source to some version of what you want to work on, or something very similar to it, or just a lot of general familarity with Papyrus scripting. One thing that will help is taking PEX files for which you already have PSC, and exporting new PSCs with it from the PEX, then comparing the results to the original PSC. Regardless, it'll still be much easier than trying to translate this old application's pseudo-Assembly into Papyrus source. I'm sure it was of great value in its day, but it has clearly been surpassed.
I managed to install it on my WX-64 machine. Installed to a non-protected directory (i.e. not Program Files x86), didn't run as admin, let it sit for a minute or so then hit cancel - at that point the security popup to grant the app permissions to install itself came up so I clicked yes for permissions and no for "do you really want to close the installer". Running as administrator may bypass that initial hiccup.
I'm trying to use this but something is going wrong.
If I take a working pex file as confirmed in-game then Decompile and then Compile the pex file (without even editing it) that pex file no longer works. (the script functions don't happen)
TL; DR: This tool is not meant to restore the original .psc source code from a compiled .pex script. Rather it's meant to provide you with something human-readable for you to better understand the behavior of the examined script.
A year late, and I haven't tested the download here yet. But from a technical perspective, .psc is compiled into a .pex file. The word compiled here is extremely important. It usually doesn't only mean it's translated into byte code or even binary code, but also that a lot of information is lost. Some things may be optimized to increase performance. Take c++ binaries, for example. It's impossible to decompile a C++ application and get the exact same source code back, if even something close to reality. The safest in looking at the behavior of an executable is to reverse engineer it and browse through its assembler code.
Java, for example, can be fairly easily decompiled as its byte code is quite lossless - it even keeps the fully qualified names of classes, methods and fields, unlike C++. Names of fields are completely irrelevant to the CPU. All it needs to know is their location in memory, which usually is the start address of the object plus a specific offset. Thus all field names of C++ classes are lost. Looking at the function names, they get quite mutilated into something of the following format: __1486@myfunction@@moregibberishhere
31 comments
From what you've said, the .pex files are only for something we can read to better understand what the script is doing. There is no way to recompile them.
Your program is the first decompile program I have tried that worked! I have already endorsed it. But I need a decompiler that will create a .psc file.
Yes, the path is correct. It still won't let me.
If I take a working pex file as confirmed in-game then Decompile and then Compile the pex file (without even editing it) that pex file no longer works. (the script functions don't happen)
Am I doing something wrong here?
A year late, and I haven't tested the download here yet. But from a technical perspective, .psc is compiled into a .pex file. The word compiled here is extremely important. It usually doesn't only mean it's translated into byte code or even binary code, but also that a lot of information is lost. Some things may be optimized to increase performance. Take c++ binaries, for example. It's impossible to decompile a C++ application and get the exact same source code back, if even something close to reality. The safest in looking at the behavior of an executable is to reverse engineer it and browse through its assembler code.
Java, for example, can be fairly easily decompiled as its byte code is quite lossless - it even keeps the fully qualified names of classes, methods and fields, unlike C++. Names of fields are completely irrelevant to the CPU. All it needs to know is their location in memory, which usually is the start address of the object plus a specific offset. Thus all field names of C++ classes are lost. Looking at the function names, they get quite mutilated into something of the following format: __1486@myfunction@@moregibberishhere
Thanks you for this utility it's perfect!!
"undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined undefined, undefined "
Edit: maybe update your mod description and provide a link to the compiler?