Chromium ships a lot of stuff in resources.pak files
currently, when opening these files in 7-zip, it finds a gzip header in the middle of the file, and then fails to extract it due to garbage data
Chromium .pak files are generated with this python script: https://github.com/chromium/chromium/blob/main/tools/grit/pak_util.py#L76 (standalone grit if you don't want to clone the entire codebase)
- you can run
python3 pak_util.py -h to use the cli
https://github.com/chromium/chromium/blob/main/tools/grit/grit/format/data_pack.py#L135 is where most of the work is done
"spec": https://www.chromium.org/developers/design-documents/linuxresourcesandlocalizedstrings/#data-file-format-version-4
file-format from me reading the code, so it might not be super accurate (see the document above):
- everything is little-endian
- header:
- first 4 bytes are the version: can only be
4 or 5
- on version 4:
- uint32, resource entry count
- next byte is the encoding for all text resources:
- 0: binary (no text resources)
- 1: UTF-8
- 2: UTF-16
- on version 5:
- next byte is the encoding for all text resources (same definition)
- next 3 bytes are ignored
- uint16, resource entry count
- uint16, alias count
- next are resource count + 1 entry headers, 6 bytes each:
- uint16, resource id
- uint32, file offset
- each resource data goes from the current file offset to the next entry's file offset
- that means the last entry header doesn't refer to any data (I think, fact check this)
- next are aliases, 4 bytes each (there are 'alias count' alias entries)
- uint16, alias resource id
- uint16, index of the resource that the alias is pointing to
- rest is the actual data
- if a resource's data starts with
1f 8b, the data should be decompressed with gzip
- if a resource's data starts with
1e 9b, then the next 6 bytes are the size of the uncompressed data, and the data should be decompressed with brotli (excluding those first 8 bytes of course)
so basically, header summary:
05 00 00 00 uu ?? ?? ?? nn nn mm mm or 04 00 00 00 nn nn nn nn uu
- everything is little endian
us are the encoding:
- 0: binary (no text resources)
- 1: UTF-8
- 2: UTF-16
ns are the resource_count
ms are the alias_count
an example pak file (inside a zip file because GitHub doesn't let me upload it directly)
- inside are two files: an image with resource id
1111 and a text file with resource id 2222
Chromium ships a lot of stuff in
resources.pakfilescurrently, when opening these files in 7-zip, it finds a gzip header in the middle of the file, and then fails to extract it due to garbage data
Chromium
.pakfiles are generated with this python script: https://github.com/chromium/chromium/blob/main/tools/grit/pak_util.py#L76 (standalonegritif you don't want to clone the entire codebase)python3 pak_util.py -hto use the clihttps://github.com/chromium/chromium/blob/main/tools/grit/grit/format/data_pack.py#L135 is where most of the work is done
"spec": https://www.chromium.org/developers/design-documents/linuxresourcesandlocalizedstrings/#data-file-format-version-4
file-format from me reading the code, so it might not be super accurate (see the document above):
4or51f 8b, the data should be decompressed with gzip1e 9b, then the next 6 bytes are the size of the uncompressed data, and the data should be decompressed with brotli (excluding those first 8 bytes of course)so basically, header summary:
05 00 00 00 uu ?? ?? ?? nn nn mm mmor04 00 00 00 nn nn nn nn uuus are the encoding:ns are theresource_countms are thealias_countan example pak file (inside a zip file because GitHub doesn't let me upload it directly)
1111and a text file with resource id2222