Table format conversion/decompression

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
lorak
Posts: 36
Joined: Wed Aug 31, 2016 6:12 pm

Table format conversion/decompression

Post by lorak »

I have access to game saves and game files from a video game.
At this moment I am interested in editing certain tables form game files. Some of those game files tables also appear in game saves.
The problem is that the table formats in both ends look a bit different.

Table example from game saves:

Code: Select all

xx xx xx xx 03 00 02 00 00 00 FF FF 04 00 00 00 
00 00 00 00 EC 4B 2C 66 03 00 00 00 B0 00 00 00
43 47 49 44 02 00 00 00 03 00 00 00 B2 00 00 00
4C 47 49 44 02 00 00 00 00 00 00 00 10 00 00 00
43 4E 41 4D A0 00 00 00 03 00 00 00 00 00 00 00
4E 43 63 6C 10 00 00 00 22 00 4E 46 43 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 41 00
23 00 41 46 43 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 61 74 61 62 61 73 65 5C
67 61 6D 65 6D 6F 64 65 73 5C 67 61 6D 65 6D 6F
98 14 67 3F 06 00 00 00 08 00 00 00 3F 00 00 00
00 00 00 00 xx xx xx xx xx xx xx xx xx xx xx xx


Table example from game files:

Code: Select all

xx xx xx xx xx xx xx xx xx xx xx xx 03 00 02 00 
00 FF FF 04 00 00 00 00 00 00 00 B0 57 1E 7C 00
00 00 03 00 00 00 B0 44 49 47 43 00 00 00 02 00
00 00 03 00 00 00 B2 44 49 47 4C 00 00 00 02 00
00 00 00 00 00 00 10 4D 41 4E 43 00 00 00 A0 00
00 00 03 00 00 00 00 6C 63 43 4E 00 00 00 10 00
22 4E 46 43 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 40 00 00 23 41 46 43 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61
73 65 5C 67 61 6D 65 6D 6F 64 65 73 5C 67 61 6D
65 6D 6F 64 65 2E 64 BE 49 5C B0 00 00 00 02 00
00 00 08 00 00 00 xx xx xx xx xx xx xx xx xx xx


What I already know from the tables above:
  • Both tables contain the same elements (information).
  • 1st two bytes in each table refer to maximum number of elements the table can hold (0003).
  • Next 2 bytes refer to current number of elements in the table (0002).
  • Byte 9 in game saves and (8 in game files) with hex-value 04 is the number of fields in the table (FFFF04).
  • In the first table (from game saves), the first field name is in bytes 28-31, byte 32 is the number of bits to allocate a value in that field. On the other hand, in the second table (from game files), the first field name is also in bytes 28-31, but byte 35 (not 32) is the number of bits to allocate a value in that field.
  • The first element of the game saves table starts at hex-value 22 in row 6 until hex-value 41 in row 7. In a similar way we can identify the first element in the game files table.
  • The second and last element of the game saves table starts at hex-value 23 in row 8 until byte 7 in row 9. In a similar way we can identify the first element in the game files table. Similar for the game files table.
  • We have some text from hex-value 61 in row 9 until byte 5 in row 11 in game saves table. For game file table this text starts in the last byte of row 9 until byte 11 in row 11.
  • Do not know about the rest of the bytes.

Below is the information stored in the tables above in a human friendly format:

Code: Select all

CGID    LGID   CNAM    NCcl
 1       0      NFC    35
 0       0      AFC    34

It looks like an endianness related, decompression issue or something similar, in my humble opinion. I have an editor that can deal with game saves tables but cannot do it with game files tables. For that reason I would like to be able to swap between both "formats".

I have tried

Code: Select all

quickbms -E
(to swap endianness) trying to convert from game saves to game files format and vice versa with no luck, the format is still incorrect in the end. Both files (tables) above can be downloaded from this link.

Thanks in advance.

Edit: Many thanks for moving this thread to Game archive sub-forum.