Forum: Archive RSS
Lua 5.1 decompiler

Announcement

2008-11-05, 14:54 by Keshire
Rules for posting on this site.
Follow them or have your posting rights removed or be banned.

[cut=Full List Of Rules]*  If a topic makes no sense to you, do not ask broad questions about it.  We have a lot of developer posts that will make no sense to someone who doesn't know how to program or has not taken the time to explore the game files.


*  All modifications we release for the xbox will require a modified xbox.  Ask for instruction and then tell us you don't have one will result in banning/deletion of all posts for failure to read instructions.  THERE WILL BE NO SAVES ON THIS SITE SO DO NOT REQUEST THEM.


*  We do not endorse pirating.  Suggesting or asking for such will get you banned.  If you like a game BUY IT.  People worked hard to make something to entertain you, it's the least you can do.  If you are caught without one of these you will be banned.


*  Posting of original game files is strictly prohibited.  If you have code to share post just the code you have made.  Only attach files if you have created an application or something similar that requires the attachment.  If you made many changes to a file but did not change ALL of it then post a PPF or something similar to avoid posting any original code at all.  Do not link to original files either.  Either way it's just the same as posting them here.


*  Harassing admins/moderators through PM/Email because of your own inability to work things out with other people in the forums will result in loss of PM an removal of ability to post.


*  Harassing admins/moderators through PM/Email because of your own inability to read posts and stickies in the forums with any compitence will result in loss of PM an removal of ability to post.


*  Harassing or just flooding a topic/person because you are too lazy to use search will get your posting rights removed.  Search exists for a reason and we won't deal with people that constantly ask for things that are easy to find with search.


*  Public bashing of other members will get your posts removed.  If it is done repeatedly you will get your account banned.


*  Posting a reply to merely say you don't know or you also want to know something is a waste of space and all of our collective time (assuming you weren't asked directly, but if you were it probably should have been done in PM).  Repeated offenders will get their posting rights removed.

*  Do not cross post questions/requests in forums.  Pick the appropriate forum and post it there.  People read in all of the forums and don't need to see the extra spam.


*  Everything on this site is provided AS IS.  If you use a tool that someone wrote here and it crashes your computer, we don't care.  The programmer should be informed with as much information as you can provide in order to prevent that from happening again though.

*  Being an open forum, try to contribute to it.  As in by helping crack file formats or developing new tools or game modifications.  Leeches are never appreciated.  Especially when they are ungrateful for the work that other people put into doing something for them.  Being ungrateful is a very quick path to being banned.


*  Lack of acting like a mature person or inability to type in proper english or something close to it will not be tolerated (i.e. l33t,ALL CAPS, or IM shorthand).


Basically, this is a technically based Fable modding site.  This is NOT a playground. [/cut]

If you have a problem with these rules, don't come here.

Failure to not read the stickies on forums (like this one) is not an excuse.  Failure to read this post is also not an excuse.
LittleCodingFox #1
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
Subject: Lua 5.1 decompiler
For those of you looking for a Lua 5.1 decompiler, on the LuaAddons wiki, it says that ChunkSpy can decompile chunks (probably even full scripts) from Lua 5.0.2 and 5.1 files.

Here's the link

EDIT: Nevermind, i didnt read the homepage itself but the LuaAddon Wiki page, and apparently it decompiles to assembly. I'll see if i can find an alternative

I apologise for a useless thread.
This post was edited on 2008-11-14, 09:36 by LittleCodingFox.
LittleCodingFox #2
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
Well, it's not like i'm Mr. Super Duper Smart Person Guy, but i'm trying to write a decompiler for Lua. So far, got headers working OK, hopefully i'll be successful though. Wish me luck, i'll need it.
LittleCodingFox #3
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
Now isnt that interesting. I just found out that Fable 2 LUA files dont use the same lua_Number as regular lua, which uses doubles as lua_Number. Looks like the sizeof of lua_Number on the Fable 2 Scripts is 4 instead of 8, so i'm guessing it's using floats, which also explains why i'm getting some weird stuff when scanning the files.

EDIT: Just fixed my scan. Whoop-dee-doo. I'll take care of translating OPCodes and stuff now.
Avatar
Keshire Administrator #4
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Ya. Being able to test scripts would be great. If they are using a non standard compiling method. Floats instead of doubles, we may need to write our own compiler, correct?

Scripts would give instant satisfaction. :D
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
LittleCodingFox #5
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
We just need to modify a #define on lua that defines lua_Number as Double, and a few related #defines, to float, that should work, or we just have to follow their guides to know what to do exactly, since lua explicitly specifies that you can change it.

Also, did you notice there's actually one decompressed script on gamescripts.bnk? gameflow.txt has a decompiled gameflow.lua, if i aint mistaken.

Did i mention this is hard work since i hardly used Lua in my life?
This post was edited on 2008-12-13, 10:37 by LittleCodingFox.
Avatar
Keshire Administrator #6
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Yep noticed the plain text gameflow first thing. There's also some uncompiled .lua scripts that contain enumerations. Makes me wonder if the game can use both compiled and uncompiled.

And ditto. Never used LUA once in my life. But I'm pretty good at picking up on new languages pretty quick.
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
LittleCodingFox #7
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
Ditto at being pretty good at picking up new languages pretty quick.

The game can interpret both compiled and decompiled, that's for sure. From the code i saw, it uses the same function to load LUA files, so there's really no difference.
LittleCodingFox #8
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
I'm really sorry guys, but i'm having trouble either finding time or skill to complete this (OP codes deal with bitwise operations, which i'm not so good at).

Attached is the source code for what i've been able to do so far.

There's no comments, but the code should be half-readable. Also remember, it's quite experimental.

You can find FragmentLib's most recent release here.
LittleCodingFox #9
Member since Nov 2008 · 34 posts
Group memberships: Members
Show profile · Link to this post
I checked out ChunkSpy, wrote a modified Lua binary and ChunkSpy script, and i can decompile stuff to ASM-style.

I'm not sure if i did anything wrong while modifying it, but it's working for now. Plus, it should be pretty easy to convert to regular code now, even if kinda ugly styled.

There be binaries attached.
The author has attached one file to this post:
FableIILua.zip | Save   218.6 kBytes, downloaded 280 times
Avatar
JohnDoe Moderator #10
User title: Community Pet
Member since Nov 2008 · 19 posts · Location: Texas
Group memberships: Global Moderators, Members
Show profile · Link to this post
Cool stuff. Nice work. :)
An optimist is a pessimist in the making.
Avatar
Keshire Administrator #11
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Just as an update to this:

Pluto for Lua (Used in Saving the game)
http://luaforge.net/projects/pluto/

LuaPlus (Used to expose C++ functions to LUA)
http://luaplus.org

Fable 3 will be using
Kore
http://www.kore.net

5.1 decompiler: http://luadec51.luaforge.net/
Includes Source code
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
This post was edited on 2010-07-17, 07:36 by Keshire.
Avatar
Keshire Administrator #12
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Recompiled luadec to use floats instead of doubles.

It crashed on the compiled gameflow. I'm guessing it's due to luaplus or pluto. I haven't had time to look into too much.

luadec script.lua >> output.txt

You'll be able to download this if and when Pe fixes downloads. :P
Otherwise PM me or hit me up on IRC.
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
The author has attached one file to this post:
LuaDec51.zip | Save   69.4 kBytes, downloaded 590 times
Avatar
Keshire Administrator #13
Member since Nov 2008 · 29 posts
Group memberships: Administrators, Members
Show profile · Link to this post
Here is a LuaPlus Compiler for Fable 2 Lua.

It gave me a 1 to 1 compile of the gameflow so you can modify the gameflow and then recompile it. ;)
Apathy Cannot Inspire.
Ambivalence cannot lead.
Loved me. Feared me.
Changed me. Killed me.
Anything would be something.
But nothing is worst of all.
The author has attached one file to this post:
LuaCPlus.zip | Save   56.5 kBytes, downloaded 619 times
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Not logged in. · Lost password · Registration disabled
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Page created in 303 ms (91.6 ms) · 72 database queries in 254.7 ms
Current time: 2024-11-25, 07:25:22 (UTC -07:00)