Jump to content
Sign in to follow this  
v00d00

VC2010 - Luadec / Luac - Prepatched for PD2 *UPDATED*

Recommended Posts

v00d00

As stated in the title, here is pre-patched Luac/Luadec source code for VC2010. Builds correctly when set to "Release", untested with "Debug" (project was modified from the base Luadec one, to include Luac)

*** Changes (May 26): Now based on Luadec v2.1 (link below), new opcodes added to the decompiler (for loops work!), shortened numbers( ie: 0.68000000715256 shows as 0.68 now ), if available locals/upvalues/line#'s are displayed in the disassembly (-dis), some tweaks to several opcodes in the disassembly.

Stripped .luac files have trouble being decompiled, and may crash, use the -dg option to assist, or the -dis to get a complete "asm" dump.

To generate exact binary matches to the original decrypted .luac files, use *IX style paths, such as in the example (and test) below:

>luac lib/tweak_data/gageassignmenttweakdata.lua

>fc /b luac.out lib/tweak_data/gageassignmenttweakdata.luac

Comparing files luac.out and lib/tweak_data/gageassignmenttweakdata.luac

FC: no differences encountered
To compare a .lua and .luac (without caring about variable names, line #'s, etc), try the following:

First, it disassembles (-s = strip, -dg = disable local guessing) the original .luac file. Then it compiles the original .lua file, then disassembles that. Finally, a binary compare is done. If they match, the code in the lua is functionally identical to the code in the .luac. Sure, you may not have the same variables, or line numbering, but the bytecode is the same.

Have the same lua code, but want to fix line#'s or locals, do the same as above, but remove the "-s -dg" options from both instances of luadec. Then, instead of fc, use a program such as WinMerge to compare the 2 files, and make your changes to the .lua source.

>luadec -s -dg -dis filename.luac > temp1.txt

>luac -o temp.luac filename.lua

>luadec -s -dg -dis temp.luac > temp2.txt

>fc /b temp1.txt temp2.txt

FC: no differences encountered

Had several requests for information about this, so it's just easier to supply this vs explaining all of the required patches each time :)

Code used:

  • Please login or register to see this link.
  • Please login or register to see this link. (v2.1 r119)
  • Please login or register to see this link.
  • My own patches to handle the new opcodes, several improvements, number shortening, local listings, etc..

Please login or register to see this link.

Share this post


Link to post
Share on other sites
PirateCaptain

Please login or register to see this link.

insta-sticky :popcorn:

Share this post


Link to post
Share on other sites
v00d00

Nice job, I have my own copy on VC2013 though :-)

And about opcodes, they aren't necessary to fix but the whole decompiler needs to be fixed from dumb errors.

Yeah. This one fixes some issues: Please login or register to see this link.

Fixes and Improvements:

1.compelete table support

2.improved loop support

3.more clear disassembled results

4.read lua source files directly

5.options to decompile only specific nested function

6.process lua script with 255 or more functions

7.more stable and less memory leaks

8.can process consecutive 255 or more variable assignments

Still has problems with complex if/else logic (inline or otherwise), but it's better than the current one. v3 of the SztupY branch is supposed to handle the logic updates, but no word on any progress since he announced he was starting it.

Share this post


Link to post
Share on other sites
Sandman

So, does this let us decrypt the lua files whenever a patch comes out? Or is it just support for it? Either way, always nice to see stuff from you v00d00! :)

Share this post


Link to post
Share on other sites
v00d00

The program for extracting/decrypting the .luac files (which are contained in the .bundles) is in many places.. This however, is what I use to write the .lua source code from the .luac files. Think of the .luac files like .exe's. To figure out the .exe, you need a disassembler.. That is what this can fully do. It can also decompile a few of the PD2 .luac's back to source code completely, and a few others partially.

And finally, it can perfectly compile .lua files back into the .luac's used by the game (using luac.exe). I use luadec.exe to see the "luasm" (English formatted internal code), and based on that I write it back into .lua's by hand. Then I use luac.exe to compile my own .lua I've written into a luac, to make sure mine is a match for the original. If the 2 .luac's are identical, then the lua source is valid.

Share this post


Link to post
Share on other sites
Sandman

v00d00, could you maybe post a tutorial of an example on youtube? It doesn't need to have sound or anything, I am just having difficulties with the decompiling. Seeing exactly how you do it would probably help.

Share this post


Link to post
Share on other sites
Sandman

Ok, so I finally am able to decompile the luac files but only the ones in Captains PPv14 folder. If I try to do one from the actual game itself, I get this error:

luadec: [string "charactertweakdata.luac"]:1: '=' expected near '?'

Did I do something wrong, or leave out a step?

Share this post


Link to post
Share on other sites
DoubleDutch

@v00d00 The link to your luadec21.zip no longer works - can you repost a link?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Stop being a peeping tom and join the community.... we got cookies

Join the crew now

Sign in

Already part of the crew? Board right here

Sign In Now
Sign in to follow this  

×