Jump to content


Photo

SUN.EXE Source Code


  • Please log in to reply
15 replies to this topic

#1 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 18 January 2015 - 09:50 PM

The title says it all, the link contains a solution file with the source code of SUN.EXE 
 
I'm new to this forum and I'm a big fan of the Westwood games. Since I like coding and I wanted to expand my field of knowledge I started to decompile tiberian sun. I started with the executable SUN.EXE since that's the main entry point of the whole game. 
 
Short summary of executable: 
- It reads NameOfExe.lcf, where NameOfExe is SUN 
- Tries to apply patches if any by invoking patchget.dat, whilst using information from the file above 
- Runs game.exe and waits until that returns 
 
PLEASE NOTE: 
All naming in the source code was up to my own interpretations, this also counts for the layout of the source files. 
This executable that comes out of the source code when compiled should behave exactly the same as the original SUN.EXE with only one exception: 
The original SUN.EXE could be given arguments when ran (for example: trough cmd.exe and adding arguments). Some parsing of these arguments was going on in the original code which I haven't been able to identify yet. Also I was unable to test some methods, I have flagged these with a macro SUN_UNTESTEDA, however it's very unlikely that they will not function, since I'm pretty sure I decompiled them properly and last: when reading launcher.txt when there's a patch applied it shows the patch notes. I couldn't completly test the parsing of this file, however I think the result is still the same. 
 
COPYRIGHT STUFF: 
I do not care what you do with this source as long as you don't claim that you are the creator of it. If you modify it in such a way that it's completly different it would be nice if there's a reference to me. 
 
COMPILATION: 
I wrote and test compiled this in Visual Studio 2013 Ultimate. I'm unsure what version the original exe is but the last modification date is: 18-05-1999 12:18 and size 80kb
 
LINK:
 
This zip does not contain any executables, I'm not trying to scam anybody. This website wouldn't let me upload the zip/rar as an attachment. I'm just trying to share good stuff about old Westwood games.

Edited by Neijwiert, 19 January 2015 - 07:32 PM.


#2 rumblesom

rumblesom

    Captain

  • Strike Team
  • PipPipPipPipPipPip
  • 4992 posts

Posted 18 January 2015 - 10:17 PM

wow! any interest in trying the same for ra2 ???



#3 FunkyFr3sh

FunkyFr3sh

    Corporal

  • Members
  • PipPip
  • 17 posts

Posted 18 January 2015 - 10:18 PM

May I know why you chose sun.exe? The file is not really used anymore these days :) If you wanna start to reverse engineer the main executable (game.exe) then you should get in contact with me

#4 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 18 January 2015 - 11:03 PM

wow! any interest in trying the same for ra2 ???

Not yet, maybe in the future

 

 

May I know why you chose sun.exe? The file is not really used anymore these days  :) If you wanna start to reverse engineer the main executable (game.exe) then you should get in contact with me

 

Becouse this is my first time actually trying it. SUN.EXE is the main entry point for Tiberian Sun and it's a simple executable. I already started with Game.exe today, So far I have a WinMain function and all the resource files extracted lol.


Edited by Neijwiert, 18 January 2015 - 11:15 PM.


#5 rumblesom

rumblesom

    Captain

  • Strike Team
  • PipPipPipPipPipPip
  • 4992 posts

Posted 18 January 2015 - 11:06 PM

please do ra2,exe or game.exe of red alert 2 !!!



#6 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 18 January 2015 - 11:14 PM

please do ra2,exe or game.exe of red alert 2 !!!

I appreciate your enthousiasm, but Game.exe of tiberian sun will take alot of time to decompile aswell. I might not even finish it. I'm going to focus on this first and then I'll start looking for other things. And like I said, I'm doing this to expand my knowledge. As much as I like Westood games, some things can take up too much time hehe



#7 Sean3z

Sean3z

    Captain

  • ST Retirees
  • PipPipPipPipPipPip
  • 1740 posts
  • Location:Corona, CA
  • XWIS Name: sean3z

Posted 19 January 2015 - 12:40 PM

This is pretty awesome! And while FunkyFr3sh is spot on, most people bypass SUN.exe, it doesn't make this project any less admirable. These kind of undertakings are always positive IMO. Have you considered throwing this on GitHub or something for others to contribute?

#8 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 19 January 2015 - 03:35 PM

This is pretty awesome! And while FunkyFr3sh is spot on, most people bypass SUN.exe, it doesn't make this project any less admirable. These kind of undertakings are always positive IMO. Have you considered throwing this on GitHub or something for others to contribute?


I was actually consedring going to github already. I might put it there, we'll see how things go. However I will not release the ida database file (I'm using Ida pro with hex rays 1,5) for reasons. So if I were to put it on github only the already decompiled sources will be there.

For people interested, the current progress:
Decompiled some initial mutexes that are created to check if the game is alteady running and stuff. Identified some debug functions. I am currently on holdup on a function that seems to get a translated string from languages.dll. I think i might need to look in that file first before continueing, or i could ignore all messageboxes or anything else that uses that file. Im not sure yet.

#9 zzattack

zzattack

    Colonel

  • Members
  • PipPipPipPipPipPipPip
  • 5357 posts
  • Location:Eindhoven, Netherlands
  • XWIS Name: zzattack

Posted 19 January 2015 - 03:48 PM

might be the csf file, that's a format that has been reverse engineered



#10 JonasAKAFaze

JonasAKAFaze

    The BH Master

  • Bounty Hunters
  • PipPipPipPipPipPip
  • 1251 posts
  • Location:Denmark
  • XWIS Name: Faze

Posted 19 January 2015 - 04:47 PM

I don't know what the heck I'm reading...



#11 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 19 January 2015 - 05:48 PM

might be the csf file, that's a format that has been reverse engineered


No I'm 100% sure its looking for strings inside language.dll. Haven't seen or looked at the file you mentioned.

#12 rumblesom

rumblesom

    Captain

  • Strike Team
  • PipPipPipPipPipPip
  • 4992 posts

Posted 19 January 2015 - 06:56 PM

Such a shame this is for ts 😢😩

#13 Olaf

Olaf

    Commander

  • XWIS Admin
  • PipPipPipPipPipPipPipPip
  • 13498 posts
  • XWIS Name: XTF

Posted 19 January 2015 - 07:03 PM

Such a shame this is for ts

Why?

#14 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 19 January 2015 - 07:29 PM

Updated link. It now points to a folder with 2 archives (both hold the same data). One with format .zip other with .rar. I now have included the projects Game and Language. The language dll is completly decompiled with the exception of 2 entries I haven't figured out yet. They have ID 192 and 193. I haven't named (macro definitions) the strings yet (Too many entries lol, I have a life). I will name them when I go along the source code when they point to the strings. I did name however all the dialog presets, but I'm a bit rusty with tiberian sun so I might have named some wrong. Feel free to name them properly and hand me an updated version. 

But other than the 2 entries, the output language.dll should behave exactly the same as the original (english) version. The version entry in the source says it's version 2.0.

 

EDIT:

Your webbrowser might remember where the previous link went to (atleast mine does, its Chrome) and still bring you to the old link. Check the link in your address bar and verify its the same as posted above.


Edited by Neijwiert, 19 January 2015 - 07:33 PM.


#15 fir3w0rx

fir3w0rx

    Xwis Was Initially Striketeam

  • XWIS Buddies
  • PipPipPipPipPipPip
  • 2159 posts
  • Location:Out with your wife
  • XWIS Name: fir3w0rx

Posted 20 January 2015 - 11:12 AM

Does 'reverse engineer' mean when you try to capture an enemy base, then you see a drone?

 

BA BOOM CCHHH!



#16 Neijwiert

Neijwiert

    New Conscript

  • Members
  • Pip
  • 7 posts

Posted 22 January 2015 - 05:35 PM

Change of plans; I'm going to assist CCHyper as he is very far in the process of decompiling. The progress will not be open-source because of his terms.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users