how to unpack resources.pak from google chrome?

眉间皱痕 提交于 2019-11-27 00:17:43

问题


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?


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/10633357/how-to-unpack-resources-pak-from-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!