Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

.LUB Decompilation

Featured Replies

  • Author
  • Localization

lllsondowlll, posted Sat Oct 21, 2017 4:46 pm (27516)


About 10 years ago, a friend and I discovered how to decompile the attached lub files. Since then I had a hard drive crash and lost my backups in the move on how to perform this. I've been trying based on memory to hex edit the lub files into a format luadec could read but I keep getting stuck on how we were generating the stripped table.

From what I can remember, we were converting this luac 5.0 header to a luac 5.1 that luacdec 51 could read by changing the header, and cutting some of the data (namely the size code) near " C63E" (which can be found in every lub) and pasting it under the 51 header. There were some other steps needed such as generating a checksum which my memory is hazy on, and the data at the footer of the luac51 file which I simply cannot find out how to generate.

Luckily, I am in possession of SOME of the unpacked lubs which I've been trying to use as a comparison. I simply just need to modify this file back to a format where a decompiler can read. This is why I am reaching out as this has been taking up a LOT of my time and figured someone here could point me in the right direction. I've attached two sample files with four formats: Lub, Lua, Luac50, and Luac51.

Please, if anyone could shed some light on to this so I can get decompilers to read the original, I would be extremely grateful.
  • Author
  • Localization

lllsondowlll, posted Sun Oct 22, 2017 5:33 am (27581)


Nevermind I got it figured out
  • Author
  • Localization

Acewell, posted Sun Oct 22, 2017 5:38 am (27583)


what was your solution? i would like to try what worked for you. :)
i've seen lub files from other games before and i wondered if they could be converted back to lua.
  • Author
  • Localization

aluigi, posted Sun Oct 22, 2017 9:35 am (27593)


@lllsondowlll
feel free to post your code on github so other people (and you if you have another hdd crash :) ) don't have to reinvent the wheel
  • Author
  • Localization

lllsondowlll, posted Tue Oct 24, 2017 4:29 am (27654)


By the time I figured out how to do it by hand, I stumbled on some source code a few days later for a patchy unluac50. I made some modifications to the code (in particular fixed a loop issue as well) to target this native luac50 format. This may be more help for people to sift through than me explaining how to do it by hand :lol:

https://sourceforge.net/u/tomy/unluac/ci/default/tree/

Here is one of the main issues with this source:
decompile\Registers.java

Code:
 public Target getTarget(int register, int line) {
    if(!isLocal(register, line)) {
      throw new IllegalStateException("No declaration exists in register " register " at line " line);
    }
    return new VariableTarget(decls[register][line]);
  }


and here is the "fix"

Code:
  public Target getTarget(int register, int line) {
    if(!isLocal(register, line)) {
      decls[register][line] = new Declaration("_TMP_", 0, 0);
    }
    return new VariableTarget(decls[register][line]);
  }
 
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.