fastman92

fastman92 enhanced GTA SA IMG archive

Jun 21st, 2015
591
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Test of archive:
  2.  
  3. All files have been compressed with specified compression type and fully rebuilt.
  4.  
  5. IMG_FASTMAN92_GTASA_COMPRESSION_TYPE_NONE - 915 MB archive
  6. IMG_FASTMAN92_GTASA_COMPRESSION_TYPE_ZLIB, highest compression level - 533 MB archive
  7. IMG_FASTMAN92_GTASA_COMPRESSION_TYPE_LZ4, highest compression level, LZ4 HC actually - 686 MB archive
  8.  
  9.  
  10. -----------------------------------------------------
  11.  
  12. Final specification.
  13. Structure of IMG archive.
  14.  
  15. beginning of IMG archive, first header:
  16.  
  17. #pragma pack(push, 1)
  18. struct tImgFastman92GTASAfirstHeader
  19. {
  20.     DWORD magicID;  // VERF
  21.     DWORD archiveFlags; // bits 0-3 archive version (should be 1), bits 4-7 metadata encryption type, bits 8-10 game
  22.     char authorName[12];    // constant value "fastman92" padded with zeros.
  23. };
  24. #pragma pack(pop)
  25.  
  26. VALIDATE_SIZE(tImgFastman92GTASAfirstHeader, 0x14);
  27.  
  28. ------------
  29.  
  30. Second header, could be encrypted:
  31.  
  32. #pragma pack(push, 1)
  33. struct tImgFastman92GTASAsecondHeader
  34. {
  35.     DWORD Check;    // constant value 1, after decryption it should have value 1. To check if decryption worked properly.
  36.     DWORD NumberOfEntries;
  37.  
  38.     char reserved[8];   // for future use, should be NULL now.
  39. };
  40. #pragma pack(pop)
  41.  
  42. VALIDATE_SIZE(tImgFastman92GTASAsecondHeader, 16);
  43.  
  44.  
  45. Now there comes a list of entries, each entry of type:
  46.  
  47. #define IMG_FASTMAN92_GTASA_MAX_FILENAME_LENGTH 39
  48.  
  49. #pragma pack(push, 1)
  50. class tImgFastman92GTASAdirectoryEntry
  51. {
  52. public:
  53.     unsigned __int32 PositionInSectors;
  54.     unsigned __int16 OriginalSizeInSectors;
  55.     unsigned __int16 NumberOfPaddedBytesInAlignedOriginalSize;
  56.     unsigned __int16 PackedSizeInSectors;
  57.     unsigned __int16 NumberOfPaddedBytesInAlignedPackedSize;
  58.     unsigned __int32 Flags;
  59.     char Name[IMG_FASTMAN92_GTASA_MAX_FILENAME_LENGTH + 1];
  60.     char Reserved[8];   // should have NULL values when reserved.
  61. };
  62. #pragma pack(pop)
  63.  
  64. VALIDATE_SIZE(tImgFastman92GTASAdirectoryEntry, 64);
  65.  
  66.  
  67. /////////////////
  68. Explanation of file flags:
  69. - bits 0-3, compression type
  70. - bits 4-7, encryption type
  71.  
  72. ///////////////////////////////////////////
  73.  
  74. Enumerations:
  75.  
  76. Game type (3 bits for this value)
  77.     - 0: GTA SA
  78.  
  79.  
  80. Compression type (4 bits for this value):
  81.     - 0: no compression
  82.     - 1: ZLIB compression
  83.     - 2: LZ4 / LZ4 HC compression
  84.    
  85. Encryption type (4 bits for this value):
  86.     - 0: no encryption
  87.     - 1: encryption of variation 1, discouraged
  88.     - 2: encryption of variation 2
  89.    
  90.  
  91.    
  92. That's all!
RAW Paste Data