.RES file format

a place to discuss it

Moderators: Deathifier, Sukayo

domingo
Fighter pilot
Posts: 21
Joined: Tue Sep 06, 2005 1:01 am
Location: BA, SVK

.RES file format

Postby domingo » Thu Oct 20, 2005 10:28 am

I've playing a bit with .RES files.

Here is what I've found (something is probably old info, because it was used in NOVA patch). All numbers are stored in IBM format (lowest byte first).

.RES file begins with 16 bytes header:

Code: Select all

struct res_file_header_t {
   char signature[16];
 };
signature is always

Code: Select all

"(C) H.D.I. V1.0\x1a"
Then there are definitions of 'resource group' (it's my term).

Code: Select all

struct res_file_group_t {
    char name[12];
    unsigned __int32 offset;
 };
where name is (I think) standard C zero-terminated string and offset is position in file where the data starts.

Last (terminator, again my term) group has empty name (all characters set to zero = '\0'), and offset equals to length of file.

There are several resource group types, but their type is not stored in .RES file, it is probably hardcoded in efs.exe. So far I've been able to fully decode only 'string table' group, but there are at least 2 more types (dialog and menu).


So let's speak about string table then (at least some info about this is used in NOVA).

String table starts with 2 bytes, which combined in number gets number of strings in table.
After these bytes, strings follows.

One string has 4 bytes header - 2 bytes as string identifier/index (I think this is most important for EFS to know which string to use) and then 2 bytes means string length. After the header follows string characters (take length from header).


Another resource group type is dialog, so far I've decoded only beginning:
2 bytes - x pos
2 bytes - y pos
2 bytes - x size
2 bytes - y size
2 bytes - unknown
2 bytes - number of objects in dialog
then there are some yet undecoded data - buttons, labels, images ... (I can see some strings here, also path to bin files ...).


Last resource group type is menu, but I've not decoded anything yet - I just see there are strings used in menus.

domingo
Fighter pilot
Posts: 21
Joined: Tue Sep 06, 2005 1:01 am
Location: BA, SVK

Re: .RES file format

Postby domingo » Thu Oct 20, 2005 11:25 am

There are .res files and their groups and types:
COMPSTR.RES - contains messages used by computer players

Code: Select all

string table glCompStr // 17 strings
DIPLO.RES - diplomacy related dialogs

Code: Select all

dialog SectsDlg
 dialog Manowitz // when browsing manowitz files
 dialog Diplomacy // choose diplomacy target ... there are 2 resources with this name !!!
 dialog Byz2Dlg // byzantium 2 dialog - where regents & ministries are assigned
 dialog VoteDlg // dialog for regent voting
 dialog SendMessDlg // to send message to another human player ?
 dialog HouseDlg // 'house' dialog, where your house potrait, standings, tax, etc are displayed
 dialog DiploDlg // 'other house diplomacy' dialog - other house info + diplomacy
 dialog HouseCon1 // house diplomacy - requests
 dialog HouseCon2 // house diplomacy - promises
 dialog HouseCon3 // house diplomacy - threats
 dialog ChurchCon1 // church diplomacy - requests
 dialog ChurchCon2 // church diplomacy - promises
 dialog ChurchCon3 // church diplomacy - threats
 dialog LeagueCon1 // league diplomacy - requests
 dialog LeagueCon2 // league diplomacy - promises
 dialog LeagueCon3 // league diplomacy - threats
 dialog Ministry // ministry assignment ???
 dialog CreditsDlg // ???
 dialog TechDlg // technology dialog for church diplomacy
 dialog TreatyDlg // ???
 dialog VotesDlg // ask for votes (there were probably plans to give only some votes, not all as it is now)
 dialog LoanDlg // to ask for loan
 dialog AskExcomDlg // to ask for excommunicate
 dialog BuyLeagDlg // agora dialog - to buy resources
 dialog SellLeagDlg // to sell resources ???
 dialog Diplomacy // second Diplomacy dialog
 dialog Choose // ???
 dialog LeagDipDlg // league status screen
 dialog ChuDipDlg // church status screen
 dialog TextPCX // ???
 dialog DispConDlg // accept / reject diplomacy options
 dialog MessTextDlg // message from another player ???
 dialog Tutorial // tutorial dialog ?
 dialog Advisor // advisor ???
 dialog GraphDlg // the power graph
DIPLOSTR.RES - strings used in diplomacy dialogs

Code: Select all

string table glDiploStr // 52 strings
EFS.RES - most of the important resources

Code: Select all

menu FileMenu // main menu
 dialog HexDlg // main planet view dialog ???
 dialog StarDlg // main galaxy view dialog ???
 dialog WorldDlg // world view dialog (right click on planet minimap) ???
 dialog GalaxyDlg // galaxy view dialog (right click on galaxy minimap) ???
 dialog EditStrDlg // ???
 dialog EditSect // button on cathedrals to change planet sect ???
 dialog StartDlg // starting dialog (load game, start new game, ...)
 dialog OptionsDlg // options dialog
 dialog MessToggle // ???
 dialog UnitInfoDlg // unit view dialog (right click on unit stack) ???
 dialog BuildStruct // button to build ?
 dialog BuildUnit // dialog to choose unit to build
 dialog Archive // technology archive dialog (maintenance cost, strike button, ...)
 dialog LabDlg // choose tech to research dialog
 dialog CargoDlg // for merging cargo pods ???
 dialog PickDlg // seems to be empty
 dialog OrdersDlg // attack type choose (normal, assault, feint)
 dialog UnitStatDlg // unit statistics
 dialog CombatDlg // planetary bombing dialog ?
 dialog SpAttDlg // space landing chooser (attack or land)
 dialog PlrTurnDlg // player turn dialog in PBEM games ?
 dialog MapOptions // choose historical / random galaxy
 dialog HouseCon // house control dialog - choose human/computer, etc ... at the start of game
 dialog GameOpt // game starting options dialog - also "difficulty" chooser
 dialog Portrait // choose your portrait dialog
 dialog ChName // choose your name
 dialog TraitDlg // trait chooser
 dialog MvToLeague // movement to league agora dialog (attack or sell)
 dialog PauseDlg // ???
 dialog ResDlg // ???
 dialog EmptyCity // dialog for empty city
 dialog SideHelp // ???
 dialog RebelPic // ???
 dialog AutoBuy // ???
 dialog MyFileOpen // ???
 dialog Cheat // for cheating ?
 dialog CityInfo // city info dialog
MAPEDIT.RES - for map editing application

Code: Select all

menu HexMenu // planet menu
 dialog HexDlg // main planet dialog
 dialog UnitEditDlg // unit editing
 menu StarMenu // galaxy menu
 dialog StarDlg // main galaxy dialog
 dialog EditPlanDlg // edit / change planet
 dialog ChngPlanDlg // change planet type ???
 dialog DeleteUnits // for deleting units
STRINGS.RES - most of the strings used in game

Code: Select all

string table glButtons // 10 strings
 string table glStrings // 482 strings
TUTSTR.RES - all tutorial strings (advisor when you have tutorial messages turned on)

Code: Select all

string table glTutorial // 64 strings
WIN.RES - non-gameplay related strings - load, save, options, etc ...

Code: Select all

string table WindowMess // 22 strings

domingo
Fighter pilot
Posts: 21
Joined: Tue Sep 06, 2005 1:01 am
Location: BA, SVK

Re: .RES file format

Postby domingo » Thu Oct 20, 2005 11:28 am

I've also created small application to decode .res files to .txt format (and back).
For now it decodes only string tables though (menu + dialogs only as 'unknown' streams of hex numbers), as others resource types are not yet decoded to my satisfaction - if anyone could give me hints, I'd appreciate it ...

But I have no web place to place this application ...

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Thu Oct 20, 2005 10:53 pm

The output of this decoder is VERY neat.

Does this need DOS, i.e., Windows 98 to run? How to run it on XP?

Is "CreditsDlg" maybe for the game credits?

domingo
Fighter pilot
Posts: 21
Joined: Tue Sep 06, 2005 1:01 am
Location: BA, SVK

Re: .RES file format

Postby domingo » Fri Oct 21, 2005 10:15 am

Thanks.

It runs ok on XP (well, it was created for XP).

I don't think it will run on DOS, as it is win32 console application ...

For help (options), start it in command console (either start->run->"cmd" or start->all programs->accessories->command prompt).

In fact there are only 2 options:

to decode .res file into text file:

Code: Select all

res2txt.exe decode <res_file> <decoded_file>
to encode (modified) text file into .res file:

Code: Select all

res2txt.exe encode <decoded_file> <res_file>
CreditsDlg - maybe, it is more-or-less all my guesses.

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Sun Oct 23, 2005 12:17 am

Hey! It works!

:D :D :D :D :D

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Wed Oct 26, 2005 4:25 pm

Does anybody have a Web site they can post Domingo's resource coder on, and link to it from here?

Some of you modders must have space . . . :)

domingo
Fighter pilot
Posts: 21
Joined: Tue Sep 06, 2005 1:01 am
Location: BA, SVK

Re: .RES file format

Postby domingo » Fri Oct 28, 2005 10:15 am

Well, if anybody wants it (while I still don't have webplace), he can drop me a PM with e-mail.

That way I will at least know how wanted / useful the tool will be :-)

User avatar
cy387_lk
Vau Ambassador
Posts: 236
Joined: Mon Jan 21, 2002 2:01 am
Location: Mexico City, Land of Drunk Mariachis
Contact:

Re: .RES file format

Postby cy387_lk » Sat Oct 29, 2005 6:02 am

what's up guys!
(finally got some free time to check out the forums)

Nice work! At last someone is decompilling the files.

Btw, if you need webspace just mail it to cy387_lk@yahoo.com.mx. Last few months I was completely remaking my web sites, and I'm looking forward to release new version of EFS fansite this/next week, where I'll put all the stuff I had before, plus some recent updates and FS books stuff.
Do I like science fiction? Sure! But only a bad one!...
("Tales of Pirx The Pilot" after Stanislaw Lem)

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Sat Oct 29, 2005 8:18 pm

Cool! Cy, would you be open to hosting a zipfile of my mod? I don't have a Web site either!

Also, you should include a link to tools like AXE, 010 Editor, Bink and Smacker, EFS Loader, and http://www.backerstreet.com., where the Watcom-capable REC decompiler lives. And which, as far as I know, no one here has yet tried to use. I have run it and I know it works, I just don't know how to read the output.

User avatar
cy387_lk
Vau Ambassador
Posts: 236
Joined: Mon Jan 21, 2002 2:01 am
Location: Mexico City, Land of Drunk Mariachis
Contact:

Re: .RES file format

Postby cy387_lk » Sun Oct 30, 2005 3:39 am

Sounds good, throw me all the stuff to mentioned mail.

AXE, 010 Editor, Bink and Smacker, EFS Loader, and http://www.backerstreet.com.
Yep, that's exactly what I meant saying "updates" :p
Do I like science fiction? Sure! But only a bad one!...

("Tales of Pirx The Pilot" after Stanislaw Lem)

User avatar
cy387_lk
Vau Ambassador
Posts: 236
Joined: Mon Jan 21, 2002 2:01 am
Location: Mexico City, Land of Drunk Mariachis
Contact:

Re: .RES file format

Postby cy387_lk » Mon Oct 31, 2005 5:16 am

btw about REC...
Well I tried it out yesterday, and found the code it produces quite readable. The problem is what are you going to do with it :D because it's not real C code and you couldn't compile it again even if you would replace all unknown variables with some real ones. Or better say, yes you could do it, but it wouldn't work as it supposed to. As I see this tool is good only for one thing - too see what actually happens inside the executable.
Do I like science fiction? Sure! But only a bad one!...

("Tales of Pirx The Pilot" after Stanislaw Lem)

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Wed Nov 02, 2005 1:58 am

Exactly.

You could s l o w l y reverse engineer it to build a new facsimile of the existing EXE. But the first step would be understanding the processes. the inputs and outputs. Which is what I'm interested in---exactly how does the AI decide what to build, etc?

But after that, you'd be writing your own program. And in that case, you may as well just write your own program!

User avatar
cy387_lk
Vau Ambassador
Posts: 236
Joined: Mon Jan 21, 2002 2:01 am
Location: Mexico City, Land of Drunk Mariachis
Contact:

Re: .RES file format

Postby cy387_lk » Wed Nov 02, 2005 4:46 am

hehe, actually that's what I'm thinking about, but not now.. First I'm waiting for Studio.NET2, and second I'm already busy with other coding things this Christmass, so maybe next year =)

A question btw:
Who made Reality mod? May its author forgive me for not knowing him :D I found no info about who did it in related website.
Do I like science fiction? Sure! But only a bad one!...

("Tales of Pirx The Pilot" after Stanislaw Lem)

Grimly Fiendish 2
Assault Legionnaire
Posts: 89
Joined: Wed Jun 15, 2005 1:01 am

Re: .RES file format

Postby Grimly Fiendish 2 » Wed Nov 02, 2005 5:45 pm

Looks like Archangel.


Return to “Fixing it ourself”

Who is online

Users browsing this forum: No registered users and 29 guests