Tuesday, July 2, 2013

Desperados : Wanted Dead or Alive - BTTN Resource

Inside .res file there is 'BTTN' entry resources.
Those resources can be managed like PICC, this type is like TOLG but notice the loop iteration (4 <> 5)

Pseudo-Code

  magic_number = read(4)   
  unknow = read(4)   
  if (magic_number == 0x4654504E):   
   a = read(4)  
   b = read(4)  
   for i in xrange(0, 4):  
     if ((1 << i) & b):  
       width = read(4)   
       height = read(4)   
       is_compressed = read(4)   
       size = read(4)   
       data = read(size)   
       if is_compressed == 1:   
         data = zlib.decompress(data)   
Data is still 16bits image.
Few extracted images :




Desperados : Wanted Dead or Alive - TOGL Resource

Inside .res file there is 'TOGL' entry resources.
Those resources can be managed like PICC, but with few differences.

Pseudo-code

  magic_number = read(4)   
  unknow = read(4)   
  if (magic_number == 0x4C474F54):   
   a = read(4)  
   b = read(4)  
   for i in xrange(0, 5):  
     if ((1 << i) & b):  
       width = read(4)   
       height = read(4)   
       is_compressed = read(4)   
       size = read(4)   
       data = read(size)   
       if is_compressed == 1:   
         data = zlib.decompress(data)   
Data is still 16 bits image.
Few extracted images :




Desperados : Wanted Dead or Alive - PIC Resource

Inside .res file there is 'PIC ' (notice the space at the end) entry resources.
Those resources can be managed like PICC.
The only difference is this resource got only one entry.

Pseudo-code

  magic_number = read(4)   
  unknow = read(4)   
  if (magic_number == 0x20434950):   
   unknow = read(4)   
   width = read(4)   
   height = read(4)   
   is_compressed = read(4)   
   size = read(4)   
   data = read(size)   
   if is_compressed == 1:   
     data = zlib.decompress(data)   
Data is still 16 bits image.
Few extracted images :







Desperados : Wanted Dead or Alive - PICC Resource

Inside .res file there is 'PICC' entry resources.

PICC specification

 +0x00 : Unknow  
 +0x04 : Nb PICC entry  
 +0x08 : Entry Data (view class CResEntry)  

CResEntry

An entry can be represented by this structure :
 00000000 CResEntry    struc ; (sizeof=0xC)  
 00000000 Width      dw ?  
 00000002 Height     dw ?  
 00000004 IsCompressed  dd ?  
 00000008 SizeFile    dd ?  
 0000000C CResEntry    ends  
If the field IsCompressed is set to 1, data are compressed using zlib version 1.1.3.

Pseudo-Code to read PICC

 magic_number = read(4)  
 unknow = read(4)  
 if (magic_number == 0x43434950):  
   unknow = read(4)  
   nb_PICC_entry = read(4)  
   for i in xrange(0, nb_PICC_entry):  
     width = read(4)  
     height = read(4)  
     is_compressed = read(4)  
     size = read(4)  
     data = read(size)  
     if is_compressed == 1:  
       data = zlib.decompress(data)  
Then the data are simply image in 16 bits format, you can convert it into 24 bits, with the following pseudo-code :
 void setRGB(png_byte *ptr, unsigned char r,   
                unsigned char g, unsigned char b)  
 {  
     ptr[0] = r;  
     ptr[1] = g;  
     ptr[2] = b;  
 }  
 ...  
 int x, y;  
 for (y = 0 ; y < height ; y++)  
 {  
     for (x = 0 ; x < width ; x++)  
     {  
         int a;  
         unsigned short *tab;  
         unsigned short color;  
         a = = (x + (y * width)) * 2;  
         tab = (unsigned short*)(buffer + a);  
         color = *tab;  
         setRGB(&(row[x * 3]),   
                     (color >> 11 << 8) / 32,   
                     (((color >> 5) & 0x3F) << 8) / 64,   
                     ((color & 0x1F) << 8) / 32);  
     }  
     png_write_row(png_ptr, row);  
 }  

Monday, July 1, 2013

Desperados : Wanted Dead or Alive - Extracted Resources

Some randoms resources that I managed to extract :





more info coming soon...

Desperados : Wanted Dead or Alive - .res / .RES files

List of files with extension .res or .RES :
 PS F:\> $Dir = get-childitem -recurse F:\Game\Infogrames\Desperados\Game  
 PS F:\> $List = $Dir | where {$_.extension -eq ".res"}  
 PS F:\> $List | ft fullname | Format-Table  
 FullName  
 --------  
 F:\Game\Infogrames\Desperados\Game\Data\Interface\DEFAULT.RES  
 F:\Game\Infogrames\Desperados\Game\Data\Interface\Texts.res  
 F:\Game\Infogrames\Desperados\Game\Data\Sounds\Expressions\Expressions.res  

Method to open .res file :
 005D8270 ReadResFile proc near  

File format specification

 +0x00 : Magic Number  
 +0x04 : Archive Version  
 +0x08 : Nb Entry  
 +0x0C : Format  
 +0x10 : Unknow_0  
 ....
Magic number must be equal to 0x53455253 ('SERS').
ArchiveVersion must be equal to 0x100 (256).
Format can be equal to :

  • 0x45564157 ('EVAW') : 0x005D96A0 WaveResFile proc near
  • 0x43434950 ('CCIP') : 0x005D8D50 PiccResFile proc near
  • 0x44494C53 ('DILS') : 0x005DA0E0 SlidResFile proc near
  • 0x20525543 (' RUC') : 0x005D9CA0 CurResFile proc near
  • 0x20434950 (' CIP') : 0x005D8A10 PicResFile proc near
  • 0x204F4452 (' ODR') : 0x005DA800 RdoResFile proc near
  • 0x4E545442 ('NTTB') : 0x005DA470 BttnResFile proc near
  • 0x4654504E ('FTPN') : 0x005D8630 NptfResFile proc near
  • 0x4C474F54 ('LGOT') : 0x005DAB90 ToglResFile proc near
  • 0x54584554 ('TXET') : 0x005D90B0 TextResFile proc near
Refer to other articles to understand each entry type.

Sunday, June 30, 2013

Desperados : Wanted Dead or Alive - Files Extension

All files extensions find inside game folder :

 PS > Get-ChildItem -recurse F:\Game\Infogrames\Desperados\Game\* | Select-Object Extension | Sort-Object Extension | Get-Unique -asString  
 Extension  
 ---------  
 .cfg  
 .cpg  
 .dat  
 .dll  
 .dvd  
 .dvf  
 .dvm  
 .exe  
 .fnt  
 .fxg
 .log  
 .map  
 .pak  
 .res  
 .RES  
 .sbk  
 .scb  
 .stf  
 .sxt  
 .tmp  
 .wav