Map Database  •  FAQ  •  RSS  •  Login

Main TPR EXE Decompiled

<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Aug 2008, 10:19

Main TPR EXE Decompiled

Hi Guys,
I found a C decompiler called RecStudio and tried decoding the main TPR EXE.
Well, it sat there are decompiled it and displayed it as C code. Due to the nature of things, none of the procedures/variables had names, making it difficult to do anything.
As of yet, I haven't don't anything with it. I tried looking through it, but there are thousands of procedures and I doubt that you could do anything practical with it. Still, I don't know C very well and so maybe it would make more sense if I did? Harold: Do you think you could take a quick look at it?
Still, I thought I might as well let people know, and maybe someone else will do better than me?
Download the decompiled EXE
Lewin.
Edit: Corrected link.
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 08 Aug 2008, 10:32

Aren't those the normal exes of The Shattered Kingdom? Might be an interesting idea though.
<<

Merchator

Sword Fighter

Posts: 336

Joined: 27 Dec 2006, 23:00

Location: Germany

Post 08 Aug 2008, 10:33

Wow, I tried much decompiler, but noone really managed to handle this. But this tool get it!
The Code is quite confusing for me, but it's interesting to look through.
Maybe this is the first step?
Anyway, nice job!
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Aug 2008, 10:38

Oops! The link was wrong. Corrected now. Now it is a TXT file of the EXE. Note: This is my EXE, so things could be changed a bit (I have been doing some experimenting) So I'd recommend you decompile your own EXE with the tool I linked to. You can also see stuff better from in RecStudio.
Lewin.
<<

Merchator

Sword Fighter

Posts: 336

Joined: 27 Dec 2006, 23:00

Location: Germany

Post 08 Aug 2008, 10:41

Hm, somehow looks like assembler code merged with another scriptinglanguage. I never saw a C-Source code, so I can't judge this.

Your message is too short!
:roll:
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 08 Aug 2008, 10:47

Doesn't look at all like assembly to me. Still, decompiling exes always creates one huge mess of the source code... :(
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Aug 2008, 10:56

Hm, somehow looks like common assembler code. I never saw a C-Source code, so I can't judge this.

Your message is too short!
:roll:
You mean that the stuff shown in RecStudio is assembler code? You might need to click to view it in C. On the menu click Decompile -> View Decompiled Code and it should be displayed in C. Double click on one of the procedures to view it. Remember that it won't look neat as none of the names are known, so it just makes up random stuff.
What do you mean my message is too short?
Lewin.
<<

Merchator

Sword Fighter

Posts: 336

Joined: 27 Dec 2006, 23:00

Location: Germany

Post 08 Aug 2008, 11:00

Oh, thanks for the hint! Still looks odd for me :D

About my last sentence...it's nothing important. I said to myself that my message is too short. Just for fun :wink:

Hm, this tool often crashes. I got the Win 98 Version cause I hadn't found a XP Version. Is any XP Version out there?
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 08 Aug 2008, 11:07

Yeah crashes here too.
Anyways, I wonder how hard it would be to get the code to compile and work as supposed.
<<

harold

Knight

Posts: 562

Joined: 19 Nov 2007, 23:00

Post 23 Oct 2008, 15:47

So.. I took a look at it
However, since all structure is lost, and it's a mess of goto's etc - not many people could do something useful with this I'm afraid
Variables named after registers make sense of course (what else could it use?) but it doesn't make it much easier either :lol:
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 24 Oct 2008, 02:17

Hey Harold, great to see you still come here once in a while. :wink:

This topic is kind of out of date, because I haven't told people the latest EXE hacking news. I've found a much, much better program than RecStudio.
It's called IDA (the Interactive Dis-Assembler) and it is AWESOME!!!! The only problem is that is cost money, but I found a way around that. :lol: I'll leave that to you. (PM me if you can't find it)

Almost all of the EXE changes in SR3 have been thanks to this program, it's extremely good for locating stuff. Why didn't I mention it before? Well, I've been lazy and I thought Litude might object to using it for the patch. (although I've only used it to locate values so far) Don't be angry with me Litude...
It can also export as C code, and it's much neater than the C code exported by RecStudio. It give data pointers intelligent names, making it easy to locate stuff. It also puts comments explaining what it thinks stuff is doing or just referencing pointers to a piece of code. It can also give you the index into the EXE from the disassembly code meaning it's easy to change values. (how else do you think we changed the memory mapping to allow for more buildings in the statistics menu?)
By using a combination of IDA, the C code from IDA and a hex editor view of the EXE you can do some quite powerful stuff.


@Litude: I spent ages trying to make it recompile but it doesn't seem to work. As far as I can see we can just use programs like these to locate values and then change them. Writing complex code is too hard.
Lewin.
<<

harold

Knight

Posts: 562

Joined: 19 Nov 2007, 23:00

Post 24 Oct 2008, 10:44

Ah I know IDA

What did you use to recompile it?
<<

Litude

User avatar

King Karolus

Posts: 1233

Joined: 01 May 2006, 22:00

Website: http://www.knightsandmerchants.net

Location: Finland

Post 24 Oct 2008, 12:53

It's called IDA (the Interactive Dis-Assembler) and it is AWESOME!!!! The only problem is that is cost money, but I found a way around that. :lol: I'll leave that to you.
Sounds awesome, need to take a look :)
Almost all of the EXE changes in SR3 have been thanks to this program, it's extremely good for locating stuff. Why didn't I mention it before? Well, I've been lazy and I thought Litude might object to using it for the patch. (although I've only used it to locate values so far) Don't be angry with me Litude...
Huh, why would I object using it?
It can also export as C code, and it's much neater than the C code exported by RecStudio. It give data pointers intelligent names, making it easy to locate stuff. It also puts comments explaining what it thinks stuff is doing or just referencing pointers to a piece of code.
Hmm... Apparently Knights and Merchants was coded in C++ so I wonder if a C decompile would be useful at all.
It can also give you the index into the EXE from the disassembly code meaning it's easy to change values. (how else do you think we changed the memory mapping to allow for more buildings in the statistics menu?)
By using a combination of IDA, the C code from IDA and a hex editor view of the EXE you can do some quite powerful stuff.
Heh, we still haven't found that blasted fish... :evil:
@Litude: I spent ages trying to make it recompile but it doesn't seem to work. As far as I can see we can just use programs like these to locate values and then change them. Writing complex code is too hard.
I guess this is what we're stuck with.
<<

harold

Knight

Posts: 562

Joined: 19 Nov 2007, 23:00

Post 24 Oct 2008, 16:20

Hmm... Apparently Knights and Merchants was coded in C++ so I wonder if a C decompile would be useful at all.
It should be. You obviously lose the structure (it isn't really OO anymore)
And you have to keep in mind that member methods take a this pointer as first argument - and things like that, but that's not too hard
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 24 Oct 2008, 23:02

@Harold: I'm not recompiling it. I've used it to get indexes for single byte values. (like the maximum number of songs) Then I edit those indexes in the EXE with a hex editor.
Sounds awesome, need to take a look.
Yeah, you should. Only really useful if you have somewhere to start from though.
To get the index into the EXE, change to the hex view tab and look at the index in the status bar. Then drop the first number in the index, like we do for moving stuff around.
Huh, why would I object using it?
Well I'm using a pirated copy and as far as I could tell you disliked piracy.
Hmm... Apparently Knights and Merchants was coded in C++ so I wonder if a C decompile would be useful at all.
That might be an issue if we were recompiling it. However the code is easy to read because C and C++ are very similar. Anyway, as far as I understand it can turn any EXE into C. It just converts it from assemblly which should be similar through all languages.
I use the C code because it's easier to understand. Then I look at the assembelly to find the value I want to change.
Heh, we still haven't found that blasted fish... :evil:
I have tried, but we have no index to search from. The only idea I have is to look for a random number from 0 to 2 and add one to it.
I've also tried making the tutorial button say battle tutorial and it run a different DAT file (so we can have another EXE that let's you play it) but that's hard too because once you've won it tries to start the next number mission unless it's mission 0.

If anyone can find anything useful then give me the index and I'll see if I can make anything of it.
I guess this is what we're stuck with.
Still, we can do a lot as is.

I'm taking a holiday from EXE hacking for a while, so I can do my editor and such.
Lewin.

Return to “Other Creations”

Who is online

Users browsing this forum: No registered users and 10 guests