SGA V5
Archive Header
| Start | Stop | Size | Type | Name |
|---|---|---|---|---|
| 0 | 7 | 8 | ASCII | Magic word |
| 8 | 9 | 2 | UInt-16 | Version major |
| 10 | 11 | 2 | UInt-16 | Version minor |
| 12 | 27 | 16 | MD5 Hash | File hash |
| 28 | 155 | 112 | String (utf-16-le) | Archive name |
| 156 | 171 | 16 | MD5 Hash | TOC hash |
| 172 | 175 | 4 | UInt-32 | TOC size |
| 176 | 179 | 4 | UInt-32 | Data offset |
| 180 | 183 | 4 | UInt-32 | TOC offset |
| 184 | 187 | 4 | UInt-32 | Unknown1 |
| 188 | 191 | 4 | UInt-32 | Unknown2 |
| 192 | 195 | 4 | raw | Unknown3 |
- Magic word - Used to identify a file as an SGA archive. Always contains an ASCII string with the value "ARCHIVE_".
- Version Major - Used to identify the exact version of sga archive. For SGA V4, it should always be 5.
- Version Minor - Sometimes called platform. Indemnify the patch version of the SGA archive.
- File hash - Used for error correction.
- Archive name - UTF-16-LE string with the name of the archive. This name does not need to be the same as the name of the file itself.
- TOC hash - Used for error correction.
- TOC size - Table of contents size in bytes.
- Data offset - The starting position of the data block.
- TOC offset - The starting position of the table of contents.
- Unknown1 - Unknown value, but is always 1.
- Unknown2 - Unknown value, but is always 0.
- Unknown3 - Unknown value, Seems to be only random padding on the end of the archive header.
Table of Contents (TOC)
The table of contents is located at the end of the archive after the data block. TOC is divided into 5 parts: TOC header, Drive definition list, Folder definition list, File definition list and name list.
TOC Header
| Start | Stop | Size | Type | Name |
|---|---|---|---|---|
| 0 | 3 | 4 | UInt-32 | Drive offset |
| 4 | 5 | 2 | UInt-16 | Drive count |
| 6 | 9 | 4 | UInt-32 | Folder offset |
| 10 | 11 | 2 | UInt-16 | Folder count |
| 12 | 15 | 4 | UInt-32 | File offset |
| 16 | 17 | 2 | UInt-16 | File count |
| 18 | 21 | 4 | UInt-32 | Name offset |
| 22 | 23 | 2 | UInt-16 | Name count |
- Drive offset - Relative offset to start of the drive definition list. (Always 24)
- Drive count - Count of drives(Root folders) in the archive.
- Folder offset - Relative offset to start of the folder's definition list.
- Folder count - Count of folders in the archive.
- File offset - Relative offset to the start of the file definitions list.
- File count - Count of files in archives.
- Name offset - Relative offset to the start of the name array.
- Name count - Count of names in the archive.
Offsets represent the count of bytes from the start of the TOC header. (Toc starts after the data offset field, at position 180.)
Drives definition
| Start | Stop | Size | Type | Name |
|---|---|---|---|---|
| 0 | 63 | 64 | String | Alias |
| 64 | 127 | 64 | String | Name |
| 128 | 129 | 2 | UInt-16 | First folder |
| 130 | 131 | 2 | UInt-16 | Last folder |
| 132 | 133 | 2 | UInt-16 | First file |
| 134 | 135 | 2 | UInt-16 | Last file |
| 136 | 137 | 2 | UInt-16 | Root folder |
- Alias - 64 characters long ASCII string representing the name of the drive.
- Name - 64 characters long ASCII string working as a name alias.
I'm not sure what the difference is between the Name and Alias fields. Some archives have these values the same, some have different values.
- First folder - Index into the folder definition list to the first folder in the drive.
- Last folder - Index into the folder definition list to the last folder in the drive.
- First file - Index into the file definition list to the first file in the drive.
- Last file - Index into the file definition list to the last file in the drive.
- Root folder - Index into the folder definition of this drive root folder.
File and folder definitions are indexed from 0. The root folder is generally the first folder in the folder list. The last file/folder index is the index of the first object that is not present in the folder. If the first and last indexes have the same value, that means the driver or folder does not contain any folders/files.
Folders definition
| Start | Stop | Size | Type | Name |
|---|---|---|---|---|
| 0 | 3 | 4 | UInt-32 | Name offset |
| 4 | 5 | 2 | UInt-16 | First folder |
| 5 | 6 | 2 | UInt-16 | Last folder |
| 7 | 8 | 2 | UInt-16 | First file |
| 8 | 9 | 2 | UInt-16 | Last file |
- Name offset - Byte offset to the beginning of the name of this folder in the name list.
- First folder - Index into the folder definition list to the first subfolder in the folder.
- Last folder - Index into the folder definition list to the last subfolder in the folder.
- First file - Index into the file definition list to the first file in the folder.
- Last file - Index into the file definition list to the last file in the folder.
File definition
| Start | Stop | Size | Type | Name |
|---|---|---|---|---|
| 0 | 3 | 4 | UInt-32 | Name offset |
| 4 | 7 | 4 | UInt-32 | Data Offset |
| 8 | 11 | 4 | UInt-32 | Compressed Size |
| 12 | 15 | 4 | UInt-32 | Decompressed Size |
| 16 | 19 | 4 | 32-bit Unix time | Modified |
| 20 | 20 | 1 | UInt-8 | Unused |
| 21 | 21 | 1 | UInt-8 | Storage type |
- Name offset - Byte offset to the beginning of the name of this folder in the name list.
- Data Offset - Relative byte offset to the beginning of the buffer containing the file data in the data block.
- Compressed Size - Size of the compressed data in the data block. (bytes)
- Decompressed Size - Size of the decompressed file. (bytes)
- Modified - Linux timestamp when the file was changed.
- Unused - unused in this version of the SGA archive.
- Storage type - type of compression used.
Storage type:
The storage type flag determines whether the file is compressed and, if so, which compression type was used. It can be one of three values:
- 0 - Uncompress
- 1 - Stream compress
- 2 - Buffer compress
Name list
Name list is an Array of ASCII null-terminated strings representing the names of all files and folders in the archive.
Data Block
The Data block remains the same between all SGA versions. For more info, see Data block.