yashsingh1/xdaforums huggingface dataset:
[Windows Mobile Development and Hacking General] smotrs:
12, yep, doesn't appear to be seeing the 2nd file correctly. What happens if you do a standard command line compare rather then use the batch script?
[Windows Mobile Development and Hacking General] 12aon:
Well I made the batch script so I wouldn't know what to do different when I do it from within cmd.

I will attach my setup here maybe its the files or maybe it's where they are at the moment I run compare (do they need to be in the same folder as compare.exe because when I tried with or without it gave me the same output). I also have an error log which I don't understand yet (probably the reason it's still not working). I'll attach the error, but you can see it when you run it from what will become my decompiling kitchen :) (I got some great and hard to implement ideas (especially for someone that just started scripting)). You find two other scripts in there that, that work but are meant for other use.

Error:

luadec: ..\test.lua:151: 'end' expected (to close 'function' at line 108) near '<eof>'

My Decomp kitchen
[Windows Mobile Development and Hacking General] smotrs:
Files can be anywhere, just as long as you point to it relative to where your at or supply a direct path.

compare test\file.luac ..\original\files.luac

It appears you have an error on line 151 of your ..\test.lua file. Looks like it's missing an 'end' at around that location. I'll grab the files now to take a look.
[Windows Mobile Development and Hacking General] smotrs:
12, I see the problem, look at around line 112-115, your missing an end statement. It should look like this,

DialNumber = function()
local l_10_0, l_10_2, l_10_3 = nil
if ThumbnailList:GetGenerator().SelectedIndex == 0 then
local l_10_1 = ThumbnailList:GetGenerator().Collection:GetCount()
if l_10_1 < MaxFavorites then
l_10_1 = AddFavorite
return l_10_1()
// missing the following end
end
end
if ThumbnailList:GetGenerator().SelectedIndex > -1 then
l_10_0 = ThumbnailList:GetGenerator():GetData(ThumbnailList:GetGenerator().SelectedIndex)
end
if l_10_0 ~= nil then
l_10_0:ConnectVia(l_10_0.DefaultContactMethodID)
end
end

When you run it a second time it then reports that your missing another 'end' to close the function at line 56, that function should look like this,

ViewContactCard = function()
local l_6_0, l_6_2, l_6_3 = nil
if ThumbnailList:GetGenerator().SelectedIndex == 0 then
local l_6_1 = ThumbnailList:GetGenerator().Collection:GetCount()
if l_6_1 < MaxFavorites then
l_6_1 = AddFavorite
return l_6_1()
// missing the following end
end
end
if ThumbnailList:GetGenerator().SelectedIndex > -1 then
l_6_0 = ThumbnailList:GetGenerator():GetData(ThumbnailList:GetGenerator().SelectedIndex)
l_6_0:ShowDetails()
end
end

At that point the compare runs correctly and you can start fixing things.
[Windows Mobile Development and Hacking General] 12aon:
So simple how can I have missed it!!!!!!!! Does show the importance of my error log :). Wow this looks so much better :) Now the only thing I'm trying to do is to throw any file in the folder have it compare and come out with the original name, and I'm almost there, I just gotta figure out how to rename a filename ;). You want an update when I finish this?
[Windows Mobile Development and Hacking General] smotrs:
BTW, note sure if you needed it or not, but here's the correct test.lua file correctly restructured.

Yeah, when you figure it out, send me an update. :)
[Windows Mobile Development and Hacking General] 12aon:
Nice I did need it, and I'm not really up to speed on redoing the scripts after i created the output but quoting a famous kyphur post it's also about the journey :)

I intend to make every step automated without haven to rename any file just click a few bats and then doing what we came to do. Maybe I'll even give it a UI if it's finished :) (yeah I know how about learning to correct scripts first...)
[Windows Mobile Development and Hacking General] smotrs:
I can picture what your describing, sounds pretty good even without a GUI for it. Keep us updated with your progress, I'd love to check it out when you get it where you want it. :)
[Windows Mobile Development and Hacking General] 12aon:
Ok I did it the dumb way around, for this script it doesn't really matter but for the other ones I need a way to rename the file names from this command: for %%G in (*.lua) do echo %%G (which will show the original manila name, in the cmd window) and redirect it to a file name. If anybody understands my gibberish and knows of a way to accomplish me... Do enlighten me, 12

@echo off

copy Original\*.luaU Tools\*.luaU

pushd Original

attrib -s -h -r -a *.* /s /d

ren *.* original.luaU

popd

copy Original\original.luaU original.luaU

del Original\original.luaU

copy Test\*.lua Tools\*.lua

pushd Test

attrib -s -h -r -a *.* /s /d

ren *.* test.lua

popd

copy Test\test.lua test.lua

del Test\test.lua

cd tools
compare.exe ..\original.luaU ..\test.lua 1> ..\Log.txt 2> ..\Error.txt

cd..

copy Tools\*.luaU Original\*.luaU
del Tools\*.luaU
copy Tools\*.lua Test\*.lua
del Tools\*.lua

del original.luaU
del test.lua

pause
[Windows Mobile Development and Hacking General] 12aon:
Ok I finished my decomp kitchen I can't think anymore:) I included your tools Sztup I hope that's ok.

I couldn't do it by batch so I had to learn powershell instead so that will be needed to run the scripts. But I think most of the guys and girls that do mess with this are already running windows 7 (comes with that) or you can dl it for free at the microsoft site.

If the check the scripts you find some rudimentary code in there that was for getting the guessed string into the file as well, but that didn't work out but I kept it in for later change.

Then there are two recompile scripts one relies on the version.txt created when you decompile the script. So only run that one when you are recompiling the same file that you decompiled (that changes the decompiled file to xxxxxxx_manila instead of xxxxxxxx_manila.lua)

Ok Smotrs (I think you and Sztup might be the only ones testing this), let me know what you think,

- Download -

Later, 12
[Windows Mobile Development and Hacking General] smotrs:
Darn, now I have to download power shell. :)

Soon as I get a chance, I'll grab PS and give it a play, already downloaded your RAR file.

What are the chances you can include the batch files you were originally trying. I can use PS to figure out what you were trying to do with the batch files and see if I can get the batch version working for you. Then you can offer up both if I can get it to work.

In the meantime, I'm off to download PS.
[Windows Mobile Development and Hacking General] 12aon:
Yeah sure, attached are the batch for compare (the dumb way and the unfixed way v2) and to others you might like like, later 12

Ok new version of the kitchen:

I made some changes to simplify the process.

A little guide

Make sure the kitchen looks like this

Put any untouched manila file in the manila folder. Don't put anything else anywhere else.

1 -

Decompile.ps1

Right click on the file and choose 'run with powershell', this will decompile the manila file after that it will do an compare of the file before and after it's decompiled to see if there the same (luadec is not perfect yet). When you run the script you might see an error in the screen about missing an end statement in line... (I did not find a way to put that in a log file yet). You need to create the end statements untill compare.exe no longer gives the error. The output of decompile.ps1 will be four files:

- version.txt in manila folder -> This contains the manila file name and is used for later retrieval of the name

- Log.txt in the root folder -> this will contain compare.exe's output and will show in which way the untouched and the decompiled file differ. For more info check Sztupy's tutorial on decompiling.

- the decompiled file in the Test folder ("manilaname".lua)

- the undecompiled file in the Original folder (this is done so compare.exe can compare the files)

2 -

Compare.ps1

This step is included in the decompile.ps1 but as I just explained you often get missing end statements somewhere in the decompiled files after which you will have add the missing statements and recompare. The output is the same except for the version.txt in the manila folder which will not be created.

3 -

Recompile.ps1

This will recompile the lua file after you successfully decompiled it and made your custom changes to it. This step will do several things you need to know before you decide do it. First it relies on the version.txt in the manila folder to give the files it's name, if you stepped in half way with an already decompiled script make sure that you create a text file called version.txt with the manila name inside and put it in the manila folder. Next it will delete all projects with the same name (manila name) so if you are doing some changes on the same script and don't want to lose the old make sure you do a backup or change the folder name in the product folder. After you decompiled you will find a folder with the original manila name in the product folder. In the folder are the recompiled lua script file and the decompiled source script. You will find that the file in the Test is no longer there. You can now delete the file in the Original folder as well.

- Download -

if you have questions or can think of thing the kitchen could do more efficient be sure to let me know, later, 12
[Windows Mobile Development and Hacking General] Ameet:
Great job buddy :D

But tell me something, how to correct the errors found in some scripts in the mode9 files? :(

Take for instance from the home.mode9 file there's a big script (I dont remember the instance no), if you decompile and save that script from mode9 editor and try to recompile and insert the same, unedited script it shows errors :( How to correct that?
[Windows Mobile Development and Hacking General] 12aon:
I hope some one will correct me if I'm wrong but first I think you got to delete the error messages from the script because they mess up the compare even more. from there on you have to find out what's wrong and try to correct if you understand what the script is trying to say. I'm really not as good in doing that and you are much better of with the tutorial. The only guys I know that are good at decompiling and smotrs and sztupy (of course there's mun_rus and D-mann). Just try to do basic and small scripts first. Can't run before you walk :)
[Windows Mobile Development and Hacking General] Ameet:
Still no luck brother :( The decompile.ps1 file doesnt run :( I put this file in the Manila folder and ran the ps1 file :( It crashes with some red lines and doesnt do anything :(
[Windows Mobile Development and Hacking General] 12aon:
That's a lot of :(. Bugger I don't understand what version of powershell do you run? It does work on my computer, why won't it work on yours.... Anybody else having the same probs? For the record Ameet is on XP and I'm on Win7. Well Ameet I guess you need to upgrade... :D just kidding.

Edit: after a qiuck google I think you have powershell 1.0 where as I have version 2.0. You can download it here. See what it does, and report back what you find. btw I heard some people have trouble uninstalling powershell if this is the case knoe that a lot of people have the same problem so google should provide a sollution, cheers
[Windows Mobile Development and Hacking General] Ameet:
I had version 1 :D I'll try this one tonight and report :D
[Windows Mobile Development and Hacking General] smotrs:
Version 2.0 works allot better then 1.0 version of powershell, you get further along.

I do know that it doesn't like paths with spaces in it, had to move it out of my profile directory to the root directory. Trying the manila file you posted up, 25d04412_manila, I end up with the following

PS C:\Decomp_Kitchen> .\decompile.ps1
-- Decompiled using luadec 2.0 UNICODE by sztupy (http://winmo.sztupy.hu)
-- Command line was: -pg ..\Manila\25d04412_manila

;0-13;0-357;Cannot index into a null array.
At C:\Decomp_Kitchen\Decompile.ps1:14 char:54
+ $Guessstring = (get-content Guess.txt -totalcount 4)[ <<<< -1]
-- Decompiled using luadec 2.0 UNICODE by sztupy (http://winmo.sztupy.hu)
-- Command line was: ..\Manila\25d04412_manila

Which makes me think it's something to do with the scripts since I can disassemble and compare by hand without any problems.

C:\Decomp_Kitchen\Tools>compare ..\manila\25d04412_manila ..\manila\25d04412_manila.lua
Main block:
Same
Function 1:
Same
Function 2:
Same

Global:
Opcodes in original: 382
Same lines in both files: 382 100%
Same opcodes in files: 382 100%

In any case, that manila file decompiles fine.
[Windows Mobile Development and Hacking General] Ameet:
Ok. I downloaded the version 2. Used it on the Decompile.ps1 file but got nothing out of it. Am attaching all the file that I used for decompiling and the error.log file too

The below is the error which was seen in the DOS window :( I simply want to know how to add and which script to get the dynamic call history link in my existing layout :(

E:\Diamond\Kitchens\12aon\12aon_Decomp_Kitchen_v1.1\Tools\luadec.exe: cannot ope
n ..\Manila\: No such file or directory
Cannot index into a null array.
At E:\Diamond\Kitchens\12aon\12aon_Decomp_Kitchen_v1.1\Decompile.ps1:14 char:54
+ $Guessstring = (get-content Guess.txt -totalcount 4)[ <<<< -1]
Copy-Item : Cannot bind argument to parameter 'Path' because it is null.
At E:\Diamond\Kitchens\12aon\12aon_Decomp_Kitchen_v1.1\Decompile.ps1:19 char:10
+ copy-item <<<< $manilaname -destination ..\Tools\$manilaname
E:\Diamond\Kitchens\12aon\12aon_Decomp_Kitchen_v1.1\Tools\luadec.exe: no input f
iles given
LuaDec by Hisham Muhammad
Ongoing port to Lua 5.1 by Zsolt Sz. Sztupak ([URL="http://winmo.sztupy.hu/"]http://winmo.sztupy.hu[/URL])
usage: E:\Diamond\Kitchens\12aon\12aon_Decomp_Kitchen_v1.1\Tools\luadec.exe [opt
ions] [filename]. Available options are:
- process stdin
-d output information for debugging the decompiler
-dis don't decompile, just disassemble
-f num decompile only num-th function (0=main block)
-l LDS declare locals as defined by LDS
-l2 LDS2 declare locals as defined by LDS2
-dg disable built-in local guessing
-pg don't run just print out the LDS2 string used
-a always declare all register as locals
-- stop handling options
Press any key to win a Million dollars...:
[Windows Mobile Development and Hacking General] 12aon:
Ok since Powershell is tricky I redid the kitchen in batch file format. I hope it now works for everyone else too :D. Have fun

Put any untouched manila file in the manila folder. Don't put anything else anywhere else.

1 - Decompile.bat

Double click on the script , this will decompile the manila file after that it will do an compare of the file before and after it's decompiled to see if there the same (luadec is not perfect yet). After you run the script check the error.txt in the root folder for errors about missing end statements (in line x). You need to create the missing end statements until compare.exe no longer gives the error. The output of decompile.bat will be three files:

- Log.txt in the root folder -> this will contain compare.exe's output and will show in which way the untouched and the decompiled file differ. For more info check Sztupy's tutorial on decompiling at http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial.

- Error.txt which will hold information about where the missing end statements are and possibly other errors

- The decompiled file in the Test folder ("manilaname".lua)

2 - Compare.bat

This step is included in the decompile.bat but as I just explained you often get missing 'end statements' somewhere in the decompiled files after which you will have add the missing statements and recompare. The output is the same except for the version.txt in the manila folder which will not be created.

3 - Recompile.bat

This will recompile the lua file after you successfully decompiled it and made your custom changes to it. This step will do several things you need to know before you decide do it. First it relies on the original manila file in the manila folder to give the files their name, if you stepped in half way with an already decompiled script make sure that you put the original file in the manila folder. After you decompiled you will find a folder with the original manila name in the product folder. In the folder are the recompiled lua script file and the decompiled source script. You will find that the file in the Test folder is no longer there. You can now delete the file in the Manila folder as well.

4 – Disassemble

This is the disassembly output which according to Sztupy you will need when decompiling really big scripts. More info: http://msdn.winmo.sztupy.hu/manilasdk/show/Lua_Decompiling_Tutorial.

- Download V2 -
[Windows Mobile Development and Hacking General] Ameet:
It gave me errors at start :( But I figured out myself it works if "r s h" attribs are removed from the file ;)

Now getting back to work, here's the attached script and the log from 1c684cd8_manila file (which has the most errors :() (I had renamed that luac script file to "1c684cd8_manila"

How to correct those errors. The msdn is too complex for someone like me who is not from a software background, but still interested to learn :D Please help
[Windows Mobile Development and Hacking General] 12aon:
Check your error log, you still have missing end statements I think because the [1] or the original file and [2] is the new file and the differ completely, 12
[Windows Mobile Development and Hacking General] Ameet:
Dont know how to correct them :(:(:(:(:(

Surprisingly the error log is 0 bytes :( Also disassembled the manila file, here's the dis log too

Please help :( I want the dynamic call history link in my home layout and also want to know how to add analog clock from scratch :(
[Windows Mobile Development and Hacking General] 12aon:
I decompiled the file and I find this in the error log:

luadec: ..\02_Decompiled\1c684cd8_manila.lua:21: '<eof>' expected near 'end'

There is something wrong in line 21, not sure what but if you check I will too

There are too many end statements if you check the file at the lines where the first decompile and the after that compare gives you the error, you'll find double 'end' statements. I found three already, but there are a lot of other errors in the lua file itself. Which you can start resolving as soon as you get a semi decent log file, (when the end statements are fixed). You can use the files Sztupy decompiled as a guide to what the files should look like.
[Windows Mobile Development and Hacking General] smotrs:
12, Not sure if it's different in Vista, but in XP for some reason, compare returns an error level of 0 when it runs. Because there is no error, the redirection fails to write anything to the error.txt file. So the standard error information isn't written with the below code.

1> ..\Log.txt 2> ..\Error.txt

To get around this, since you have a "pause" command at the end of each file, is to remove the redirection to the error file so that it reads like this instead.

1>..\Log.txt

This will let the error display on the screen in the DOS window that opens, just before the "Press any key to continue" message.

Also, not sure what the reason is, but I'm thinking you may want to change the last 4 lines of the batch files

cd..
cd tools
compare.exe ..\01_Manila\%MYVAR% ..\02_Decompiled\%MYVAR2%.lua 1>..\Log.txt

pause

to read similarly to this

cd..
pushd tools
compare.exe ..\01_Manila\%MYVAR% ..\02_Decompiled\%MYVAR2%.lua 1>..\Log.txt

popd
pause

In the event some moron (me) runs the commands at the command line within the directory itself rather then double click as you instruct. If you double click the files, it's not an issue, but I've gotten in the habit of running the commands at the command line.
[Windows Mobile Development and Hacking General] 12aon:
Right, will do. Thanks for the tips. See you around :)
[Windows Mobile Development and Hacking General] Ameet:
I tried doing that but then after 7-8 "end" errors it shows some funny error about some variable :(

Tried going by Sztupy's guide but that is too complex for someone like me :(:(:(:(:(

Can you post a link to his decompiled scripts? I'll compare those both
[Windows Mobile Development and Hacking General] smotrs:
Ok, here's one I haven't seen before,

16 [-]: EQ 1 R8 K5 ; if R8 == 0 then PC := 19
17 [-]: JMP 19 ; PC := 19
18 [-]: LOADBOOL R8 0 1 ; R8 := false; PC := %d
19 [-]: LOADBOOL R8 1 0 ; R8 := true
20 [-]: LOADBOOL R9 1 0 ; R9 := true
21 [-]: LOADK R10 K5 ; R10 := 0

any ideas what it's conveying on opcode 18?

The chunk would be something like this, I think

if l_15_8 ~= 0 then
l_15_8 = false
end
l_15_8 = true
l_15_9 = true
l_15_10 = 0

but the %d thing is a mystery to me, haven't seen it before.
[Windows Mobile Development and Hacking General] smotrs:
BTW, figured it out. The resulting code should look like this,

l_15_8 = l_15_8 == 0
local l_15_9 = true
local l_15_10 = 0

Only figured it out because I saw something similar later in the LUA file. Still don't understand the %d though. :)
[Windows Mobile Development and Hacking General] :
okay so the the Mode9 files do nothing.

and when resizing from WVGA to VGA, everything is done via the lua, is this correct?

I am working on decompiling the latest tachi files. and yeah, used the Manila kitchen, and its just being a pain.

Lots of work doing all of this. but yeah, can somone clearify that for me. That all resizing and everything is done via the Lua and not the mode9.

Also does anyone have a batch file or something that will be able to do multiple lua conversions at once, I try using 12aon kitchen, but it seems to only be able to handle one file at a time. and looking for more, also would be nice if it could do the luac to lua, but i might be just hoping here.
[Windows Mobile Development and Hacking General] 12aon:
WORK! Everytime &%@#$... never enough #$%&@... no time &%@#& good work 12 &%$@#...

:D
[Windows Mobile Development and Hacking General] :
sorry i spoke to soon, i went bak to everything, and yes, it works great.
[Windows Mobile Development and Hacking General] 12aon:
I don't understand, you went back to everything? Was just researching to make it decompile multiple Lua files, but I will have to crack my brain a bit more to make it work :) TTYL, 12
[Windows Mobile Development and Hacking General] sztupy:
Yep, these are the tricky ones. Whenever you see a LOADBOOL where the second operator is 1 (like in LOADBOOL R8 0 1 ), then it's an inline boolean assingment. Hopefully the manila developers didn't use this construct too much, but there were a lot of people working on this project, and it can be clearly seen that some of the lua files have different coding conventions, then some of the others. It seems the guy, who likes the inline boolean assignments didn't got too much work. This is of course good... for us :)
[Windows Mobile Development and Hacking General] smotrs:
Yep, this particular routine has a few of them inline rather then the conventional way. It was definitely bugging for a while. :)
[Windows Mobile Development and Hacking General] B4PJS:
Aaargh!! Have been trying to decompile the internetportal.luac (3fb3a68c_manilla) to try and make it work with Opera9.7 folder paths, but with m9editor 3.3.0.1 when i try to recompile i get errors about a missing "untill" clause and cant work out what the prob is, so tried again with 12aon's decompiler but ludec keeps crashing and not producing anything :(