0 of 0

File information

Last updated

Original upload

Created by


Uploaded by


Virus scan

Safe to use

About this mod

Decompiler for compiled PEX scripts.

Permissions and credits
A utility that decompiles PEX files into human-readable format similar to assembly languages with a touch of C syntax.

Windows version uploaded only. Tested only on Windows 7 x64 so far. Untested Linux and OSX versions are available and will upload if there are requests.

I hope to make a compiler for the decompiled script syntax by the end of this week or at the beginning of the next week.

Version 0.99a:
  • Fixed float decoding for 0 and subnormal numbers.

Version 0.99
  • Switched positions of type and name for PROP headers to make it consistent with variable declarations.
  • Moved property flags to PROP headers, between the property name and user flags.
  • Converted user flags from hexadecimal number to character-based flags inspired by linux file permission flags.
  • Properly writing DEFAULT state in debug info.
  • Made the strings double-quoted to differentiate them from the identifiers.
  • Added .00 to whole number floats to clearly distinguish them from integers.
  • Fixed broken property handlers.
  • Object parent class not written if there is none.
  • Replaced newlines in a string with whitespaces to make it easier on the compiler.

Windows: Unpack the MSI file from the RAR archive and then install it.

The utility is very simple, with a single 'Decompile...' button which allows selection of file(s) to be decompiled. One or more selected scripts will be decompiled and saved as .dpex files in the same directory as the source .pex scripts. Optionally, the string table and debug info may be written into the decompiled script by checking the appropriate checkboxes.

The decompiler assumes that the source .pex script is valid and will not check its format except for the magic signature at the beginning of the file. Attempts to decompile an invalid script may produce garbage results or even crash the program.

The utility should display a 'Done' message when it finishes decompilation. Any other message or no message at all means that an error has occurred.

Syntax of the decompiled scripts will be most familiar to those familiar with assembly languages or at least the format of the binary .pex scripts. Declarations starting with a dot (.) declare a 'segment' of the script. Mandatory segments are .FLAGS, which contains definitions of global user flags, and .OBJECTS which contains the scripts objects (the main code). Optionally, a .STRINGS segment may contain the string table and .DEBUG segment may contain debug info.

Curved brackets ({}) are used to define user flags for various entities. For example, variables are declared with the following syntax:
type name = value {user_flags}
Similarly, function headers are in the following format:
return_type FUNCTION name(arugments) {user_flags}

@doc keyword is used for documentation comments, inspired by the Docblock syntax.

Instruction mnemonics have been taken from the PEX format specification on the wiki:

  • Properly write DEFAULT state in debug info
  • Convert property flags to more human-readable format and move them to PROP header
  • More useful error messages.
  • Recursive directory decompilation
  • Command line invocation
  • Nicer interface, maybe