28

There are bunch of interesting files accessible via chrome://resources/* using google chrome.

On linux That the content is in /opt/google/chrome/resources.pak. I know I can get the whole sources from http://chromium.googlecode.com/svn/trunk/ but I would like to unpack the resource.pak file.

file resources.pak reports just junk.

Just to be clear, the question is NOT where to get those resources from. The question is what is the resources.pak file format and how to unpack it?

4 Answers 4

27

taken from https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-dev/agGjTt4Dmcw

4 byte version number
4 byte number of resources
1 byte encoding

For each resource:
2 byte resource id
4 byte resource offset in file

There is an extra resource entry at the end with ID 0 giving the end of the last resource (which is essentially the length of the file)

This python module can unpack and repack files:
data_pack.py from grit-i18n

10
  • 3
    Just replace line 160 in data_pack.py from: print "%s: %s" % (resource_id, text) to: with open(str(resource_id), "wb") as file: file.write(text), then run: python data_pack.py yourfile.pak and you will get files extracted in the current directory.
    – niutech
    Commented Mar 8, 2014 at 15:17
  • 1
    @niutech, you make it sound like you only have to download that one file, but in fact, you have to download the entire project or data_pack.py won't have its dependencies. :-P Commented Jun 4, 2016 at 6:06
  • 2
    @pileofrocks I found this github.com/myfreeer/chrome-pak-customizer and it can unpack and pack it, but Opera doesn't seem to accept the repacked file.
    – MrU
    Commented Dec 14, 2018 at 7:20
  • 1
    @MrU I couldn't get that to work (Windows-only?), but this github.com/shuax/ChromePAK was at the bottom of the Github page. This one worked and Brave accepts the repacked file. Commented Dec 14, 2018 at 21:26
  • 1
    @MrU This might be too obscure for an answer... But on top of the Github page there's a link another page and in the middle of that page under "ChromePAK V5" there's a link to "pak_tools_v5.7z", it contains command line tool for all platforms. You'll see usage examples when you call "pak_tools(.exe)". Commented Dec 17, 2018 at 2:28
4

The chrome-pak-customizer (pointed out by MrU in the comments above) seems to work well to unpack Chrome's .pak files. If you're on Windows, you can download and unzip chrome-pak.7z from the releases page. Then drop the .pak file on the unpack.bat script to unpack it.

For other platforms, it looks like you'll need to build the tool from the source.

2
  • Turns out chrome-pak-customizer isn't compatible with the latest Chrome versions (tested by unpacking and repacking without modifying the pak file) ChromePAK seems to work though!
    – MrU
    Commented Dec 18, 2018 at 12:45
  • I tried unpacking a pak file in Chrome 70 or 71 on Windows, and the assets were unpacked correctly. I didn't try repacking the files.
    – jdunning
    Commented Dec 29, 2018 at 2:46
2

I found resource.pak V5 has a new format:

struct header {
    // 5 is the latest version
    uint32_t version;
    // 0 = BINARY, 1 = UTF8, 2 = UTF16
    uint8_t encoding;
    // 3 bytes padding
    uint8_t padding[3];
    uint16_t resource_count;
    uint16_t alias_count;
};

Which is followed by resource_count resources, and alias_count aliases.

struct resource {
    uint16_t resource_id;
    uint32_t file_offset;
};
struct alias {
    uint16_t resource_id;
    uint16_t entry_index;
};

Where uint32_t = 4 bytes, uint16_t = 2 bytes, uint8_t = 1, all little endian integers.

The source is available at https://github.com/chromium/chromium/blob/master/ui/base/resource/data_pack.cc.

2

This python file in chromium could help. https://source.chromium.org/chromium/chromium/src/+/main:tools/grit/pak_util.py

You need to download the whole directory, and then run it.

example:

pak_util.py extract resources.pak -o /tmp/rescources.out/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.