View Full Version : [APP][27-Dec-09] LuaTool 1.2 - Lua Decompiler, Compiler and Compare
Co0kieMonster
6th October 2009, 08:02 PM
Intro:
This is an all-in-one tool for decompiling, compiling and comparing lua scripts found in Manila (TouchFLO 3D / Sense).
All this is a continuation of sztupy's original work: Lua 5.1 tools (http://forum.xda-developers.com/showthread.php?t=479910).
General:
LuaTool consists of 4 parts: Lua decompiler, Lua compiler, Lua compare utility and a Manila file type detection utility.
LuaDec 3.2 - Lua decompiler
Notes on latest version:
Major overhaul of the local finding algorithm. Most lua scripts can now be fully decompiled without a problem.
Manila 2.5.1921 has a total of 703 scripts (including embedded scripts). LuaDec can fully decompile 663 files. That's a success rate of 94.31%.
General notes:
LuaDec automatically checks if the output file was decompiled successfully.
If it wasn't, LuaDec will also output the disassembly and compare file.
In case the decompile was 100% good, LuaDec will only output the standard .lua file as before.
LuaC 1.2 - Lua compiler
Binary function replacement:
LuaC can directly replace functions in compiled luac files. This can be useful if the luac file can't be fully decompiled, but only a small part of the file needs to be edited. Some more info on function replacement. (http://forum.xda-developers.com/showpost.php?p=5226480&postcount=38)
Continue statement:
The "continue" statement has been added to the Lua Compiler.
Lua doesn't officially support continue statements, but it looks like HTC added it for their needs, so I'm following their lead.
Usage and versions:
LuaTool 1.2 by Co0kieMonster
Usage: LuaTool <task_select> [task_options] <task_input>
Tasks:
/decompile (or /d) -- Lua Decompiler
/compile (or /c) -- Lua Compiler
/compare (or /cr) -- Lua Compare utility
/detect (or /dt) -- Manila file type detect utility
LuaDec 3.2
Usage: LuaTool /decompile [options] <inputfile>
Available Options:
-o <filename> specify output file name
-dis don't decompile, just disassemble
-f <number> decompile/disassemble only function number (0 = global block)
LuaC 1.2
Usage: LuaTool /compile [options] <inputfile>
Available Options:
-o <filename> specify output file name
-s strip debug information
-r <n> <luac_file> replace function <n> in <luac_file> with <inputfile>
LuaCompare 1.2.1
Usage: LuaTool /compare [options] <original.luac> <newfile.lua(c)>
Available Options:
-o <filename> specify output file name
-s side by side file comparison
-du disable underline
ManilaDetect
Usage: LuaTool /detect <inputfile>
LuaTool changelog:
# LuaTool v1.2
-updated LuaDec to v3.2, LuaC to v1.2 and LuaCompare to v1.2.1
# LuaTool v1.1
-updated LuaDec to v3.1, LuaC to v1.1 and LuaCompare to v1.2
LuaDec changelog:
# LuaDec v3.2
-Local guesser improvements
---major overhaul - gives much better results
-Conditionals handling improvements
---fixed elseif not being recognised in some cases
---added partial support for complex inline boolean assingment
-General improvements
---fixed single function decompile
---fixed table assignments where there are more then 16 values
---better error handling
# LuaDec v3.1
-Conditionals handling improvements
---wrote a brand new algorithm for handling complex logic expressions
---fixed falsely detected generic for loops
---fixed misplaced if end, because of end-to-break optimization
-Local guesser improvements
---declarations at CALL before RETURN
-General improvements
---fixed indents not behaving properly in some cases
---fixed LOADNIL assignments where the destinations are local variables
---decompiler now displays success rate after decompile
---added SETLIST handling
# LuaDec v3.0.4
-General improvements:
---added back error messages
---fixed variable arguments handling
---fixed multiple inline assignments
---fixed a rare if ending misplacement
-Local guesser improvements at:
---inline bool assignments
---table in table situations
---TAILCALLs
---CALLs which return multiple results
---locals declared just before TEST ops
---SETTABLE where b isn't a constant
# LuaDec v3.0
-core rewrite and cleanup
-more accurate especially with conditionals and loops
-some miscellaneous accuracy improvements
-added extra info to script header (date, time, file name and manila name)
-LuaCompare updated to v1.0.1 (compatibility)
# LuaDec v2.1
- Less crashing:
--- added a failsafe for crashing on bad registers
--- fixed crash on SETUPVAL
--- fixed crash on SETLIST
- Better conditional handling:
--- fixed handling of deeper nested else and elseif
--- fixed handling of empty if-end and else-end blocks
--- added break handling
- Better table handling:
--- fixed inline table assignments
--- fixed handling of numerically indexed tables
- Adjustments to local guesser:
--- fixed guessing for inline table assignments
--- fixed guessing for SETGLOBAL and SETUPVAL at PC 1
LuaC changelog:
# LuaC v1.2
-added binary function replacement
# LuaC v1.1
-added "continue" statement
LuaCompare changelog:
# LuaCompare v1.2.1
-small change to support single function decompile
# LuaCompare v1.2
-pre-compare disassembly is now done internally instead of writing to disk and reading
-added a console message with match percentage
# LuaCompare v1.1
-initial version integrated in LuaTool
12aon
6th October 2009, 08:36 PM
Go co0kiemonster! You da man! :D
6Fg8
6th October 2009, 11:56 PM
boy oh boy ... cant believe that, thanks :)
time to get back to the keyboard and do some hack0r's stuff
see you guys :D
12aon
7th October 2009, 05:32 PM
I like the new compare output a lot! Saves some lines in the manilatool.cmd as well. Do you plan on updating all the ruby tools or just the compare?
Muchos gracias ;)
Co0kieMonster
8th October 2009, 01:32 AM
Do you plan on updating all the ruby tools or just the compare?
Probably all (except luadecguess, which is redundant because luadec has an internal guesser since version 2.0). But I hadn't planned on doing it any time soon - right now, luadec is keeping me pretty busy. I'm doing a semi-rewrite of it in order to inject some OOP love :) (port to C++) and then hopefully make a proper conditionals and loops engine.
12aon
8th October 2009, 11:31 PM
I don't mind OOP love :). Hey I somebody came with this idea about luadec but as it turned out I misunderstood him. He was actually talking about the m9editor. Nevertheless the idea is good. You tell me if it's doable.
Wouldn't it be a good idea to include the full manila name in the lines of code as well (If known). Going a bit further might it not be an even better idea to include some more diagnostic info there.
Thing I can think of are manila version (although I can't imagine a foolproof method), date, full manila path name maybe some diagnostics.
You know I'm going to keep you occupied right? :p
Co0kieMonster
9th October 2009, 03:05 AM
Wouldn't it be a good idea to include the full manila name in the lines of code as well (If known). Going a bit further might it not be an even better idea to include some more diagnostic info there.
Thing I can think of are manila version (although I can't imagine a foolproof method), date, full manila path name maybe some diagnostics.
Full manila name and date aren't a problem. I'll add them in the next release.
Manila version would have to be set by the user so that's a bit problematic. But it would be great to have. I'll try to think of good way to add it.
As for diagnostics: Did you mean adding something other than the "-- DECOMPILER ERROR: ... " lines, or just making those lines a bit more useful?
You know I'm going to keep you occupied right? :p
I'm counting on it :D
12aon
9th October 2009, 03:29 AM
Full manila name and date aren't a problem. I'll add them in the next release.
Manila version would have to be set by the user so that's a bit problematic. But it would be great to have. I'll try to think of good way to add it.
As for diagnostics: Did you mean adding something other than the "-- DECOMPILER ERROR: ... " lines, or just making those lines a bit more useful?
I'm counting on it :D
The version number can be found in a package here:
[HKEY_LOCAL_MACHINE\Software\HTC\Manila]
"Version"="2.1.19193517.0"
That's either the .reg or .rgu file
It can also sometimes be found in the package name. But these things are very unpredictable. In that sense it could only be used as an extra. I don't know if any of the exe's in the package hold the info.
By diagnostics I was referring to my lack to come up with anything else. I hoped your developer instincts would lead you to add in the rest for me. But now that I think of it maybe something amount of errors in the script or amount of opcodes, maybe the number of functions. I don't know why, or how it would be useful so probably just leave out that part. Unless you disagree of course,
12
Asphyx
9th October 2009, 03:51 AM
You know I'm going to keep you occupied right? :p
LOL 12 has a new toy!
I guess it would be dumb to ask if you intend to use this in your Manila kitchen! LOL
12aon
9th October 2009, 03:57 AM
LOL 12 has a new toy!
I guess it would be dumb to ask if you intend to use this in your Manila kitchen! LOL
It is already part of the kitchen :), co0kie has been helping us for a while now. He is the one who added the lua scheme to notepad2 ;)
pentace
19th October 2009, 02:46 AM
Ive been trying to use this on the lua files in the sprint hero but no matter what i try i get the error "Bad header in precompiled chunk"
Any thoughts/ideas?
12aon
19th October 2009, 12:07 PM
You sure hero's got lua files? Would you mind sharing them?
12
Co0kieMonster
21st October 2009, 12:27 AM
Ive been trying to use this on the lua files in the sprint hero but no matter what i try i get the error "Bad header in precompiled chunk"
Any thoughts/ideas?
Might be a different encoding.
Can you upload a few of the files so I can check it out?
Co0kieMonster
22nd October 2009, 11:32 PM
Version 3.0 is up :)
Some info:
Version 3.0 is a complete rewrite of LuaDec. It's more accurate then 2.1, especially when large loops are involved. It might just need a little bit more tweaking but conditional and loop handling is almost perfect. The next big thing to tackle is local guessing, and that will come in a later version.
LuaDec has also generally been cleaned up, so no more obsolete command line switches or memory leaks.
It can also retrieve the full manila name and add it to the file header. E.g.: if you decompile 0bd9db81_manila, LuaDec will add \windows\htc\people\scripts\people\peoplegroupdeta il.luac to the decompiled script header for better reference. For this to work you need to have the m9editor.names.txt file in the same folder as LuaDec.
Now that I've done this rewrite I should be able to accelerate development. And there are some cool new feature coming in future versions.
skrollster
26th October 2009, 12:40 AM
Hi,
I just wondering if it is possible to use this to decompile any lua files, the one i'm looking for is decompiling lightroom plugins
Co0kieMonster
26th October 2009, 02:20 AM
Hi,
I just wondering if it is possible to use this to decompile any lua files, the one i'm looking for is decompiling lightroom plugins
LuaDec has been tuned specifically to HTC's Lua variant. Theoretically it should decompile any Lua 5.1 scripts, but it might be incompatible with the character and number encodings of non-HTC scripts. I'm not sure about the specifics, since those adaptation were done before my development efforts - see here for some of the details: http://forum.xda-developers.com/showpost.php?p=3466886&postcount=249
You can always give it a try and see what happens. It can't hurt :)
skrollster
26th October 2009, 10:33 AM
LuaDec has been tuned specifically to HTC's Lua variant. Theoretically it should decompile any Lua 5.1 scripts, but it might be incompatible with the character and number encodings of non-HTC scripts. I'm not sure about the specifics, since those adaptation were done before my development efforts - see here for some of the details: http://forum.xda-developers.com/showpost.php?p=3466886&postcount=249
You can always give it a try and see what happens. It can't hurt :)
It just gave me an almost blank file, the only thing in it was some stuff i guess you add to all files
Co0kieMonster
27th October 2009, 12:24 AM
It just gave me an almost blank file, the only thing in it was some stuff i guess you add to all files
Yeah, that's definitely because of the different encodings. Sorry, but I guess it's not going to work.
skrollster
29th October 2009, 02:52 PM
Too bad really, is it possible to create a decompiler for the encoding used for adobes applications? if so, is it much work to change it?
Co0kieMonster
29th October 2009, 11:06 PM
I'm not sure. Upload one or two lua files so I can take a look.
Co0kieMonster
2nd November 2009, 01:43 PM
LuaTool v1.0 has been released and is up in first post.
LuaTool is an all-in-one tool for decompiling, compiling and comparing lua files.
With LuaTool, LuaDec got an update as well - LuaDec 3.0.4:
In this version LuaDec has generally been improved for decompile accuracy (see full changelog below), but there are also some changes related to file output.
LuaDec now automatically checks if the output file was decompiled successfully.
If it wasn't, LuaDec will also output the disassembly and compare file.
In case the decompile was 100% good, LuaDec will only output the standard .lua file as before.
skrollster
3rd November 2009, 12:11 AM
One example is the LR plugin for facebook:
http://regex.info/LightroomPlugins2/releases/facebook-20091023.96.zip
kinnyfaifai
9th November 2009, 04:10 PM
I've just tried to decompile a script and I get the following:
l_0_0.InitializeIndexAnimation = function(l_15_0, l_15_1, l_15_2, l_15_3, l_15_4, l_15_5)
local l_15_6 = MultiGroup:GetItemY(l_15_1)
local l_15_7 = MultiGroup:GetItemRotation(l_15_1)
local l_15_8, l_15_9, l_15_10, l_15_11 = MultiGroup:GetItemOpacity(l_15_1)
if not l_15_2 or not l_15_8 then
end
if l_15_1 == 9 then
if _application.Orientation == ScreenOrientation_Landscape then
else
-- Overwrote pending register. (Assignments::assign)
StartWeatherAnimation(l_15_4 - 126, l_15_7, 0, 35)
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
end
end
if l_15_3 ~= nil then
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
l_15_3:InitializeAnimation(l_15_4, l_15_7, 0, l_15_2, l_15_5)
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
end
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
end
I'm getting quite a few:
-- Attempted to generate an assignment, but got confused about usage of registers. (Assignments::flushPending)
at the end of the script. I remember seeing a tutorial on the net teaching the basics of reading the disassembled code, but I can't find it, anyone got the link they can send me so i can try figure this out?!
Also, co0kiemoster, any good tips for solving the above errors?
Many thanks! :)
Co0kieMonster
10th November 2009, 01:29 AM
One example is the LR plugin for facebook:
http://regex.info/LightroomPlugins2/releases/facebook-20091023.96.zip
It looks like the files are in basic ascii but they're doing some kind of encryption over it. I don't think there's anything quick and easy that can be done to fix it and I don't have the time to decipher it further. Have to concentrate on HTC's lua.
I've just tried to decompile a script and I get the following:
I'm getting quite a few:
at the end of the script. I remember seeing a tutorial on the net teaching the basics of reading the disassembled code, but I can't find it, anyone got the link they can send me so i can try figure this out?!
Also, co0kiemoster, any good tips for solving the above errors?
Many thanks! :)
Here is the link to sztupy's decompiling tutorial: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial
Those errors are pretty much the most complicated to fix. It means a local was misguessed somewhere - either too many locals were declared or too little. Unfortunately, it also means that you have to reconstruct most of the function manually :( (Because the first wrong local affects everything that follows.)
Some major improvements to the LuaDec local guesser are in the works, but it won't be too soon (my current plan is to have it done for LuaDec 3.2). As for the immediate future: LuaDec 3.1 will have much better complex logic expression handling as well as have some miscellaneous tweaks. That should be done some time this week.
12aon
10th November 2009, 06:30 AM
It looks like the files are in basic ascii but they're doing some kind of encryption over it. I don't think there's anything quick and easy that can be done to fix it and I don't have the time to decipher it further. Have to concentrate on HTC's lua.
Here is the link to sztupy's decompiling tutorial: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial
Those errors are pretty much the most complicated to fix. It means a local was misguessed somewhere - either too many locals were declared or too little. Unfortunately, it also means that you have to reconstruct most of the function manually :( (Because the first wrong local affects everything that follows.)
Some major improvements to the LuaDec local guesser are in the works, but it won't be too soon (my current plan is to have it done for LuaDec 3.2). As for the immediate future: LuaDec 3.1 will have much better complex logic expression handling as well as have some miscellaneous tweaks. That should be done some time this week.
K00l ;) good to hear you are back in town, curious about the misc tweaks ;)
kinnyfaifai
10th November 2009, 08:07 AM
Here is the link to sztupy's decompiling tutorial: http://msdn.winmo.sztupy.hu/manilasd...iling_Tutorial
I found it in the end, thanks for posting. Looking forward to the next version of LuaDec. In the meantime I must put sometime in learning this. Been putting it off for a while.
K00l ;) good to hear you are back in town, curious about the misc tweaks ;)
+1 here on that! :)
I have one question, when the compare log contains:
1> 75 [-]: SETTABLE R0 K39 K24 ; R0["GroupAppointment1"] := nil
2> 75 [-]: SETTABLE R0 K38 K24 ; R0["GroupAppointment1"] := nil
I know the Rx are registers, what does the Kxx tags mean? If the difference in bytecode is the Kxx parts I'm not sure what that means and how to even start fixing it!
Thanks!
Co0kieMonster
10th November 2009, 01:46 PM
K00l ;) good to hear you are back in town, curious about the misc tweaks ;)
The misc category would be: fixes to some mishandled breaks and loop endings, indents not behaving properly in some cases, and I'm still looking to fix anything left wrong with conditionals and loops so that should all be close to 100% good by with v3.1.
I'm also modifying the compiler a bit. yozgatg found a loop that seems to use a continue statement. Lua doesn't officially support continue statements, but HTC probably added it for their needs. So I'm adding the same thing to our compiler.
I have one question, when the compare log contains:
1> 75 [-]: SETTABLE R0 K39 K24 ; R0["GroupAppointment1"] := nil
2> 75 [-]: SETTABLE R0 K38 K24 ; R0["GroupAppointment1"] := nil
I know the Rx are registers, what does the Kxx tags mean? If the difference in bytecode is the Kxx parts I'm not sure what that means and how to even start fixing it!
Thanks!
"K" represents a constant. The right part of the disassembly decodes the constant automatically. In your case:
SETTABLE R0 K39 K24 ; R0["GroupAppointment1"] := nil
K39 == GroupAppointment1
K24 == nil
The K values are numbered as they appear in the source lua file. E.g.:
Source:
PeopleFrom = {All = 1, Device = 2, SIM = 3, Updated = 4}
Compiled:
0 [-]: NEWTABLE R0 0 4 ; R0 := {}
1 [-]: SETTABLE R0 K1 K2 ; R0["All"] := 1
2 [-]: SETTABLE R0 K3 K4 ; R0["Device"] := 2
3 [-]: SETTABLE R0 K5 K6 ; R0["SIM"] := 3
4 [-]: SETTABLE R0 K7 K8 ; R0["Updated"] := 4
5 [-]: SETGLOBAL R0 K0 ; PeopleFrom := R0
Even though "PeopleFrom" is mentioned last in the compiled opcodes it's aliased as the first constant K0. That's because it's first in the uncompiled source code.
Now, if we change the source to something like this:
local l_0_0 = {All = 1, Device = 2, SIM = 3, Updated = 4}
PeopleFrom = l_0_0
The compiled opcodes become this:
0 [-]: NEWTABLE R0 0 4 ; R0 := {}
1 [-]: SETTABLE R0 K0 K1 ; R0["All"] := 1
2 [-]: SETTABLE R0 K2 K3 ; R0["Device"] := 2
3 [-]: SETTABLE R0 K4 K5 ; R0["SIM"] := 3
4 [-]: SETTABLE R0 K6 K7 ; R0["Updated"] := 4
5 [-]: SETGLOBAL R0 K8 ; PeopleFrom := R0
In this case "PeopleFrom" is the last constant K8, because it appears last in the uncompiled source. Local variable names ("l_0_0" in this case) are not saved as constants or anything else so you won't see then in the disassembly.
Oh, and the constants are assigned K values only the first time they are found, and after that the same K is reused. So:
PeopleFrom = {All = nil, Device = nil, SIM = nil, Updated = 938}
Compiled:
0 [-]: NEWTABLE R0 0 4 ; R0 := {}
1 [-]: SETTABLE R0 K1 K2 ; R0["All"] := nil
2 [-]: SETTABLE R0 K3 K2 ; R0["Device"] := nil
3 [-]: SETTABLE R0 K4 K2 ; R0["SIM"] := nil
4 [-]: SETTABLE R0 K5 K6 ; R0["Updated"] := 938
5 [-]: SETGLOBAL R0 K0 ; PeopleFrom := R0
kinnyfaifai
10th November 2009, 02:43 PM
@ co0kiemonster, many thanks for the explanation. :D
I got a long way to go yet then to be able to fix lua scripts. But i'll stick at it. :)
yozgatg
10th November 2009, 06:57 PM
cookiemonster, did you find a way to implement a continue function to be used for "for" loops in the upcoming release?
Co0kieMonster
10th November 2009, 07:18 PM
Yes, I just did that :)
I tested it with the file you sent me and with the "continue" it gets a 100% compare match.
I'm hoping to get 3.1 finalized and released later today. If by chance I don't make it I'll post a beta version in the Manila And XML GUI group.
miammiam
10th November 2009, 10:42 PM
hi all,
i try to edit this file (http://www.file-upload.net/download-2003403/3fb3a68c_manila.zip.html), for changing the bookmark target(Windows/opera9 to Windows/opera9/profile)
i had decompil with "luatool /d 3fb3a68c_manila"(55.8kb)
i have 3 files:
_3fb3a68c_manila.cmp.lua
_3fb3a68c_manila.dis.lua
_3fb3a68c_manila.lua
modified my target in 3 files and compile with "luatool /c 3fb3a68c_manila.lua"
a file "3fb3a68c_manila.luac"(56kb) are created, rename 3fb3a68c_manila in my kitchen; but when i flash my device=don't work the tab not start...
why?
ps: sorry for the bad english.
Co0kieMonster
11th November 2009, 02:46 AM
LuaTool v1.1 released.
Changes: updated LuaDec to v3.1, LuaC to v1.1 and LuaCompare to v1.2.
LuaDec 3.1: The main improvement for this version is a new way of handling complex logic expressions (e.g. "A and B and (C or D and E)"). It also has some minor conditional handling fixes, as well as general improvements - see full changelog.
LuaC 1.1: Added the "continue" statement to the Lua Compiler.
Lua doesn't officially support continue statements, but it looks like HTC added it for their needs, so I'm following their lead.
LuaCompare 1.2: Pre-compare disassembly is now done internally instead of writing to disk and reading (generally a better idea). Also added a console message with match percentage.
miammiam
11th November 2009, 02:53 AM
"decompile succes 94%"....?
Co0kieMonster
11th November 2009, 02:54 AM
hi all,
i try to edit this file (http://www.file-upload.net/download-2003403/3fb3a68c_manila.zip.html), for changing the bookmark target(Windows/opera9 to Windows/opera9/profile)
i had decompil with "luatool /d 3fb3a68c_manila"(55.8kb)
i have 3 files:
_3fb3a68c_manila.cmp.lua
_3fb3a68c_manila.dis.lua
_3fb3a68c_manila.lua
modified my target in 3 files and compile with "luatool /c 3fb3a68c_manila.lua"
a file "3fb3a68c_manila.luac"(56kb) are created, rename 3fb3a68c_manila in my kitchen; but when i flash my device=don't work the tab not start...
why?
ps: sorry for the bad english.
If you get 3 output files after decompile that means the decompile wasn't 100% correct and you have to manually fix it. The cmp.lua file is the compare output and dis.lua is the disassembly. See sztupy's tutorial for tips on manual decompiling: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial
miammiam
11th November 2009, 02:56 AM
If you get 3 output files after decompile that means the decompile wasn't 100% correct and you have to manually fix it. The cmp.lua file is the compare output and dis.lua is the disassembly. See sztupy's tutorial for tips on manual decompiling: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial
thanks... :)
kwbr
21st December 2009, 11:35 PM
If you get 3 output files after decompile that means the decompile wasn't 100% correct and you have to manually fix it. The cmp.lua file is the compare output and dis.lua is the disassembly. See sztupy's tutorial for tips on manual decompiling: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial
Hi, I am having the same problem with this manila file and luadec hangs / stops responding on my windows 7 machine. I can only get the disassembly file. So decompiling is a nogo for now.
Co0kieMonster
22nd December 2009, 12:57 AM
I've been working on LuaDec version 3.2 and it decompiles that file 100%. I still have a few things to finish up before I release it, but in the meanwhile I've attached a fully decompiled 3fb3a68c_manila.
Co0kieMonster
27th December 2009, 08:15 PM
LuaTool v1.2 released.
Changes: updated LuaDec to v3.2, LuaC to v1.2 and LuaCompare to v1.2.1.
LuaDec 3.2: Major overhaul of the local finding algorithm. Most lua scripts can now be fully decompiled without a problem.
The success rate on manila luac files is great: 94.31% (as tested on Manila 2.1.1921)
Manila 2.5.1921 has a total of 703 scripts (including embedded scripts). LuaDec can fully decompile 663 out of those 703 files => 94.31%.
LuaC 1.2: LuaC can now directly replace functions in compiled luac files. This can be useful if the luac file can't be fully decompiled, but only a small part of the file needs to be edited.
Example: You have a luac file that can't be completely decompiled, but the function you need can. You can decompile only that function using LuaDec -f switch, then edit the function, and finally inject the modified function back into the original file using the LuaC -r switch.
That can look like this:
1) LuaTool /decompile -f 7 -o myfunction.lua 09ab94f0_manila --- this will decompile only function #7 and store it in myfunction.lua
2) now edit myfunction.lua as required
3) LuaTool /compile -r 7 09ab94f0_manila myfunction.lua --- this will replace function #7 in 09ab94f0_manila with the modified myfunction.lua
The function replace syntax is:
LuaTool /c -r <n> <luac_file> <inputfile>
<n> is the function number that should be replaced
<luac_file> is the compiled luac file where the function should be replaced
<inputfile> is the single function that will replace function <n> - it should be an uncompiled lua file with just a single function in it
mwalt2
27th December 2009, 09:18 PM
LuaTool v1.2 released.
Changes: updated LuaDec to v3.2, LuaC to v1.2 and LuaCompare to v1.2.1.
LuaDec 3.2: Major overhaul of the local finding algorithm. Most lua scripts can now be fully decompiled without a problem.
The success rate on manila luac files is great: 94.31% (as tested on Manila 2.1.1921)
Manila 2.5.1921 has a total of 703 scripts (including embedded scripts). LuaDec can fully decompile 663 out of those 703 files => 94.31%.
LuaC 1.2: LuaC can now directly replace functions in compiled luac files. This can be useful if the luac file can't be fully decompiled, but only a small part of the file needs to be edited.
Wow, nice stuff. Good work.
santod040
12th January 2010, 08:10 PM
I have had some trouble trying to decompile the lua files in this zip file (http://fs03n4.sendspace.com/dl/42bf39c07a6b016c89df9dd3aef1026a/4b4cc8811bf7d13b/uw85y0/Alpha%201.rar). I'm not sure why it's crashing out on me, but if anyone could lend a hand I would be most grateful!
Co0kieMonster
12th January 2010, 08:29 PM
I have had some trouble trying to decompile the lua files in this zip file (http://fs03n4.sendspace.com/dl/42bf39c07a6b016c89df9dd3aef1026a/4b4cc8811bf7d13b/uw85y0/Alpha%201.rar). I'm not sure why it's crashing out on me, but if anyone could lend a hand I would be most grateful!
LuaDec 3.2 can fully decompile all the files except 652ae0f4_manila. Luckily, I've been working on a new beta version of LuaDec and it can decompile 652ae0f4_manila. I won’t be releasing the new LuaDec yet, but I have attached all the decompiled files.
santod040
12th January 2010, 08:31 PM
All the files except 652ae0f4_manila can be fully decompiled with LuaDec 3.2. Luckily, I've been working on a new beta version of LuaDec and it can decompile 652ae0f4_manila. I won’t be releasing the new LuaDec yet, but I have attached all the decompiled files.
You the man, Cookie Monster!!! :cool:
Jamrecords
3rd February 2010, 10:24 AM
LuaDec 3.2 can fully decompile all the files except 652ae0f4_manila. Luckily, I've been working on a new beta version of LuaDec and it can decompile 652ae0f4_manila. I won’t be releasing the new LuaDec yet, but I have attached all the decompiled files.
Excellent work! And why you do not want to release a new version?
I have to ask you. Please, decompiled file 652ae0f4_manila from Manila 2.5.2011.3030 for me)
And, may I ask a personal study?
276304
Fredz
5th February 2010, 01:13 PM
Hi CookieMonster,
I've got some problem decompiling favorite people tab (manila 2.5 2021). The remaining files are the followings :
7b64b476_manila
22c30cbf_manila
049ced00_manila
57a92846_manila
285d32bc_manila
when did you expect to release the new version ?
Thanks for all you work.:)
guenthar
5th February 2010, 01:31 PM
I used the luadec that is a part of manilla kitchen but it always gives me a bad header error with the scripts I'm trying to decompile. If I use luadec 2.1 though the scripts decompile correctly but the problem is that it always crashes on the larger scripts. I think the newer versions might have corrected the problem but they no longer work with my scripts.
EDIT: I was finally able to download luatool and when I use it to decompile one of the lua scripts it comes up with an error saying "not a valid luac file" and it does the same if I try to disassemble it. I forgot to mention before but I am trying to decompile the scripts from a new game called Venetica.
Co0kieMonster
5th February 2010, 02:13 PM
Excellent work! And why you do not want to release a new version?
I have to ask you. Please, decompiled file 652ae0f4_manila from Manila 2.5.2011.3030 for me)
And, may I ask a personal study?
276304
I've attached a beta version of LuaTool with LuaDec 3.2.2beta. It will decompile 652ae0f4_manila and a few other files better then 3.2.0, but it might mess up some other files that 3.2.0 got right. So keep both version, and try with one or the other.
That's the reason I didn't want to release it - the new version isn't always better than the old, and I wanted to fix it. But since it looks like I won't have time to perfect it anytime soon, here's the Beta, but use with caution.
Hi CookieMonster,
I've got some problem decompiling favorite people tab (manila 2.5 2021). The remaining files are the followings :
7b64b476_manila
22c30cbf_manila
049ced00_manila
57a92846_manila
285d32bc_manila
when did you expect to release the new version ?
Thanks for all you work.:)
I've attached a beta of the new version. I hope that helps. And the same cautionary message as above: keep the last stable version at hand, too. I have no idea when I'll be able to get a new final version out.
In the mean time, you can also try the function replacement feature - it can be quite useful for party decompiled scripts.
Co0kieMonster
5th February 2010, 02:14 PM
I used the luadec that is a part of manilla kitchen but it always gives me a bad header error with the scripts I'm trying to decompile. If I use luadec 2.1 though the scripts decompile correctly but the problem is that it always crashes on the larger scripts. I think the newer versions might have corrected the problem but they no longer work with my scripts.
EDIT: I was finally able to download luatool and when I use it to decompile one of the lua scripts it comes up with an error saying "not a valid luac file" and it does the same if I try to disassemble it. I forgot to mention before but I am trying to decompile the scripts from a new game called Venetica.
Upload one of the lua files, so I can take a look. If it's a regular ascii lua 5.1 script I can quickly recompile LuaTool for acsii. Manila uses unicode so the current LuaTool was adapted fot that.
guenthar
5th February 2010, 02:29 PM
Upload one of the lua files, so I can take a look. If it's a regular ascii lua 5.1 script I can quickly recompile LuaTool for acsii. Manila uses unicode so the current LuaTool was adapted fot that.
Here is one of the script files.
Co0kieMonster
5th February 2010, 03:10 PM
Here is one of the script files.
Here is LuaTool for ASCII. It recognizes the file.
Unfortunately, it looks like the script uses variable arguments, and I haven't really had a chance to properly work that out (hasn’t come up much in the manila scripts).
It does decompile most of the file, though.
Jamrecords
5th February 2010, 04:21 PM
I've attached a beta of the new version. I hope that helps. And the same cautionary message as above: keep the last stable version at hand, too. I have no idea when I'll be able to get a new final version out.
In the mean time, you can also try the function replacement feature - it can be quite useful for party decompiled scripts.
Best!!! Thank you! 652 ...._manila decompile excellent. But the problem with other scripts still there. I think that you will finish it before the final))))
I have an idea (position shortcuts to switch hours), but I can not get it done. Can you help me?
guenthar
5th February 2010, 06:20 PM
Even with this it couldn't be decompiled, edited, and recompiled correctly then?
Thank you for doing this.
santod040
6th February 2010, 02:27 PM
So I too have been fighting to get this file decompiled cleanly. Even with the new beta version.
Is there any chance someone could help me with this?
I am still getting my feet wet with some of this decompiling and recompiling of scripts. But I have learned a great deal from all the pros on here in these forums. You guys are great! Thanks Cookie for your great tool and all your efforts! :)
Co0kieMonster
7th February 2010, 12:32 AM
Best!!! Thank you! 652 ...._manila decompile excellent. But the problem with other scripts still there. I think that you will finish it before the final))))
I have an idea (position shortcuts to switch hours), but I can not get it done. Can you help me?
I'm willing to help, but I'm not sure I understand your idea.
Even with this it couldn't be decompiled, edited, and recompiled correctly then?
Thank you for doing this.
Yeah, it can't be recompiled.
But, it looks like only the variable argument messes it up. I've added the bug to my to-do list and I'll hopefully have it fixed by the next release.
So I too have been fighting to get this file decompiled cleanly. Even with the new beta version.
Is there any chance someone could help me with this?
I am still getting my feet wet with some of this decompiling and recompiling of scripts. But I have learned a great deal from all the pros on here in these forums. You guys are great! Thanks Cookie for your great tool and all your efforts! :)
Are you sure you tried it with the 1.2.2beta I posted on the last page?
Because I just try it and it decompiles perfectly.
santod040
7th February 2010, 12:53 AM
Yes, I did. Maybe my parameters are off?
Like I say, I am still a noob at this stuff.
I have decompiled it once before, but I don't recall what commands I used last time that worked.
All I really need to do is change one thing in the Rotate function, Home_PageListView.
Position.y there's a vector setting where Vector3(x, y, z)
I just need adjust x position to make this right.
As I have almost got this just how I want it now.
With landscape enabled as well. Thanks again for everything you do Cookie!
If you don't have time to help, I understand. :(
http://i649.photobucket.com/albums/uu212/santod_photos/20100206_034314_0245_111g.jpg?t=1265457324
http://i649.photobucket.com/albums/uu212/santod_photos/20100206_032810_0244_111g.jpg?t=1265500284
Co0kieMonster
7th February 2010, 01:03 AM
Yes, I did. Maybe my parameters are off?
Like I say, I am still a noob at this stuff.
I have decompiled it once before, but I don't recall what commands I used last time that worked.
All I really need to do is change one thing in the Rotate function, Home_PageListView.
Position.y there's a vector setting where Vector3(x, y, z)
I just need adjust x position to make this right.
As I have almost got this just how I want it now.
If you don't have time to help, I understand. :(
I'm not sure what you mean by parameters, there's really only one thing you should type in the command line:
luatool /d 652ae0f4_manila
What decompile success did that give you?
P.S. Here is the decompiled file, just in case that doesn't work.
santod040
7th February 2010, 01:13 AM
I'm not sure what you mean by parameters, there's really only one thing you should type in the command line:
luatool /d 652ae0f4_manila
What decompile success did that give you?
P.S. Here is the decompiled file, just in case that doesn't work.
I don't know why it acts different for me then the older version.
Thanks again Co0kie!
Fredz
9th February 2010, 01:32 PM
Hi CookieMonster,
The beta has only decompile successfully one file (57a92846_manila).
I've solve two other ones : I need to add do...end to limit propagation of local variables. Maybe this information can help you. The two files concerning are 22c30cbf_manila and 049ced00_manila.
So, it remains :
7b64b476_manila
285d32bc_manila
For the first one, the code missing is dead code.
For the second one, there is problem with local, but can't understand where is the problem.
Maybe you could solved them. So attached are the lua files.
Thanks
theShad
9th February 2010, 03:03 PM
Co0kieMonster,
Thanks a lot for LuaTool, it is really perfect!
But as santod040 I have problems with decomiling 652ae0f4_manila. I use the last beta, the command "luatool /d 652ae0f4_manila" gives me 75% success. At first I thought that it could be because I took this file from manila mod, but then I tried orginal one and got same 75%((
utopykzebulon
10th February 2010, 04:55 AM
hi all,
Someone knows where to find "_svc files" required in some lua script?
Co0kieMonster
10th February 2010, 12:24 PM
hi all,
Someone knows where to find "_svc files" required in some lua script?
The _svc files don't actually refer to any lua scripts, but to service .dlls: HomeService.dll, WorldClockService.dll, AppointmentService.dll, etc.
Co0kieMonster,
Thanks a lot for LuaTool, it is really perfect!
But as santod040 I have problems with decomiling 652ae0f4_manila. I use the last beta, the command "luatool /d 652ae0f4_manila" gives me 75% success. At first I thought that it could be because I took this file from manila mod, but then I tried orginal one and got same 75%((
Might depend on which manila version the 652ae0f4_manila is from.
I'll see what I can do when I get around to working on LuaTool.
Hi CookieMonster,
The beta has only decompile successfully one file (57a92846_manila).
I've solve two other ones : I need to add do...end to limit propagation of local variables. Maybe this information can help you. The two files concerning are 22c30cbf_manila and 049ced00_manila.
So, it remains :
7b64b476_manila
285d32bc_manila
For the first one, the code missing is dead code.
For the second one, there is problem with local, but can't understand where is the problem.
Maybe you could solved them. So attached are the lua files.
Thanks
I've corrected the 285d32bc_manila manually and attached it. It's a problem with complex assignments.
Generally if you see something like:
local l_22_12 = something
if something then
l_22_12 = something_else
-- Error: some decompiler error
end
That's a complex assignment and it should be:
local l_22_12 = something and something_else
or:
local l_22_12 = something or something_else
I was working on solving this problem in LuaTool, but it's getting harder to correctly solve these cases without breaking something else. However, I believe I will be able to make it work eventually.
There are some cases like that 7b64b476_manila, where I don't even know how to decompile it manually, let alone write a decompiler that can. I've seen that case from 7b64b476_manila before, but I really don't get what's going on there. If someone manages do manually decompile that, please post it.
Z!L0G80
15th February 2010, 09:53 PM
hi ,could you add luaj to your decompiler, description here >> http://sourceforge.net/projects/luaj/ i have found thiz compiled script on my htc hero in game :) attached sample
good work thnx
Co0kieMonster
19th February 2010, 09:21 PM
hi ,could you add luaj to your decompiler, description here >> http://sourceforge.net/projects/luaj/ i have found thiz compiled script on my htc hero in game :) attached sample
good work thnx
No, sorry, too much work.
TMartin
25th February 2010, 06:57 PM
Hey Co0kieMonster
Thanks for the great tool!!! 1.2.2 beta is working great so far!! Now if only I knew more about all this scripting.
rotastrain
3rd March 2010, 09:36 AM
hey cookie..
something slightly off topic
in ur great mod of the homescreen for manila 2.5..have u managed to decompile or find out how manila finds the icon of a exe?like when we choose the program it automatically finds the exe icon and sets it to the designated spot..do u know what lua code is written for that?
Co0kieMonster
3rd March 2010, 05:08 PM
hey cookie..
something slightly off topic
in ur great mod of the homescreen for manila 2.5..have u managed to decompile or find out how manila finds the icon of a exe?like when we choose the program it automatically finds the exe icon and sets it to the designated spot..do u know what lua code is written for that?
6c219600_manila - under LaunchIconMode function:
HomeManager:GetImage(l_14_3.ExePath)
akamustang
6th March 2010, 06:23 AM
Some things I have noticed
Recompiled scripts end up bigger than the originals even if /cr reports a 100% match
Would be nice if a recompiled script with no changes ended up byte for byte exactly the same as the original
Also uncompiling a recompiled script brings up even more errors
This wouldn't happen if the above suggestion could be implemented
i.e.
Decompile original to 1.lua, compile 1.lua to 1.luac, decompile 1.luac to 2.lua
Then compare 1.cmp.lua to 2.cmp.lua
On a related note
If your latest test/beta version has any improvements in these areas
Any chance you could upload it :D
Co0kieMonster
9th March 2010, 02:52 AM
Some things I have noticed
Recompiled scripts end up bigger than the originals even if /cr reports a 100% match
Would be nice if a recompiled script with no changes ended up byte for byte exactly the same as the original
When you recompile the files make sure you set the -s (remove debug info) switch. That way you will get byte for byte identical files.
The extra debug info is what makes the recompiled files bigger. (But it doesn't impact functionality.)
Also uncompiling a recompiled script brings up even more errors
This is related to the debug info. For the first decompile there was not debug info, but it was there for the second. It's actually a pretty rare case that files with debug info decompile worse than without. It should be the other way around.
The debug info contains information about local declarations. Without this information the decompiler has to go through a local mapping stage where it gathers the local declaration info. This mapping run might not always collect the right info -> decompile errors.
If a compiled file contains debug info, it has local declarations info (which is 100% correct), so there is no need to do separate local mapping, and no chance to get a wrong local map. Hence, the decompiling should be better in case the debug info is there.
There is one exception: around tables. I've built in some additional heuristics that help decompile some table situations. The tables are handled in a later stage but part of the detection had to be included in the local mapping stage. So when the local mapper is skipped because of the present debug info, the local map is OK, but some rare table cases may not be.
This is actually a very rare case. I'm surprised you found it.
On a related note
If your latest test/beta version has any improvements in these areas
Any chance you could upload it :D
Sadly I haven't done any additional work on the decompiler since 3.2.2, so the latest is uploaded.
akamustang
9th March 2010, 04:25 AM
Ahh, if there is debug info being added that would most likely be my issue
Thanks for the -s tip, I'll give it a go
ElCondor
11th April 2010, 02:28 PM
I'm pretty new to all this stuff, but I'm having a problem.
When running the tool, I can see the ms-dos like screen for one moment then it disappears.
I'm running Windows 7 64-bit.
Anyone know what to do?
Co0kieMonster
11th April 2010, 04:38 PM
It's a command line tool.
You'd have to run it from the command prompt.
But if you have never used that before, I think the best way to get started would be to use the Manila CMD Kitchen: http://forum.xda-developers.com/showthread.php?t=528548
It has a very well written guide.
ElCondor
12th April 2010, 08:30 AM
OK I'll do some more research, learn more. Thanks!:)
Silco
16th April 2010, 01:12 AM
is there a decompiler for lua 5.0.3 (I could only find 5.0.2 one and that returns an error on my file, 5.1.x decompiler also returns an error)
betitomiller
23rd April 2010, 12:28 PM
when i decompiling 1.7.1 , it does not go to decompile: 2E587A9A_manila, 5DED22E8_manila, 652ae0f4_manila
ask for advice, or decompile the file, and better and then another ...
and 22DC24C8_manila ... please
cnzqy1
23rd April 2010, 04:10 PM
when i decompiling 1.7.1 , it does not go to decompile: 2E587A9A_manila, 5DED22E8_manila, 652ae0f4_manila
ask for advice, or decompile the file, and better and then another ...
and 22DC24C8_manila ... please
You'd better see the thread more carefully, see:http://forum.xda-developers.com/showpost.php?p=5493910&postcount=2, the attachment.
sentinel80
12th May 2010, 09:36 PM
Hi alls!
I cant decompile/compile this manila file, pls help me.
thanks
Jaro72
11th June 2010, 11:44 AM
Hi i'm intersted in porting your great mod to HVGA resolution but i need some help to get started. Maybe you can explaihn some things to me or what i need to do.
I have the .lua files and noticed some coordinates in there thes should be changes i assume. Anything else is also?
J!
lyiann
2nd July 2010, 08:29 AM
I can't decompile this manila file, help!!
lyiann
2nd July 2010, 08:34 AM
Hi alls!
I cant decompile/compile this manila file, pls help me.
thanks
C:\manila>luatool /d 53cc1e4f_manila
Decompile success: 86%
IoDa00
13th August 2010, 03:32 PM
Hi,
i need some help,
I decompiler this file successfully but when I try to compile, it gives me always the message permission denied.
I use this command
LuaTool /compile -s -r 28 5fa4d4b7_manila 5fa4d4b7_manila.lua
I attached file of version 2017 (Home Tab), and its changed lua file, to compile.
I Use the Windows 7 with administrator permissions and execute the files as administrator.
Thanks for the help
Cumps
ai6908
15th August 2010, 11:17 PM
This is the first time I am using this tool...thanks for this co0kie...:)
Co0kieMonster
15th August 2010, 11:27 PM
Hi,
i need some help,
I decompiler this file successfully but when I try to compile, it gives me always the message permission denied.
I use this command
LuaTool /compile -s -r 28 5fa4d4b7_manila 5fa4d4b7_manila.lua
I attached file of version 2017 (Home Tab), and its changed lua file, to compile.
I Use the Windows 7 with administrator permissions and execute the files as administrator.
Thanks for the help
Cumps
You need to remove the system and read-only flags from the file 5fa4d4b7_manila.
Use the command "attrib -s -r".
IoDa00
16th August 2010, 04:37 PM
Thanks
solved
You need to remove the system and read-only flags from the file 5fa4d4b7_manila.
Use the command "attrib -s -r".
plopper
29th December 2010, 10:39 PM
short question but big impact: any possibilety to port this toolset to linux?
plopper
poorgrad
1st February 2011, 06:18 AM
I tried to run LuaTool with wine 1.3.10 on Fedora 14 and it failed with an call to an unimplemented function in msvcp90.dll.
This probably means it may not be simple to port.
poorgrad
27th March 2011, 10:39 PM
I did some more experimentation. Luatool works in wine if you install the Visual Studio 2008 runtime using winetricks vcrun2008. I was able to use it to disable the clock animation following the instructions in http://forum.xda-developers.com/showthread.php?t=703579.
sharkie405
18th June 2011, 07:02 PM
I'm having a bit of trouble compiling this .lua file. Here is a screenie of the error:
http://i981.photobucket.com/albums/ae293/Sharkie405/luatoolerror.jpg
Does anyone know why I'm getting this error and/or can anyone compile the attached file for me? :D
poyensa
18th June 2011, 07:30 PM
as i said in CHT thread, i think the problem is in the decompilation process. That file looks like is not correctly decompiled, but its not necessary to decompile as co0kie provided the open source. So work on the original file, then compilation should not be a problem.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.