Editing PKG files
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
See also {{talk}} page | See also {{talk}} page | ||
= Firmware Packages = | |||
== File Header == | |||
All values are in big endian format. | |||
typedef struct { | |||
u32 0x00, 0x53434500// magic | |||
u32 0x04, 2 // version | |||
u16 0x08, 0 // sdk type? | |||
u16 0x0a, 3 // SCE header type; pkg | |||
u32 0x0c, 0 // meta offset | |||
u64 0x10, // size of sce_hdr + sizeof meta_hdr | |||
u64 0x18, 0x80 // + content_size_real | |||
} | |||
typedef struct | |||
// | |||
} | |||
= Game Packages = | |||
All game packages are signed with the ECDSA signature. The public key for it can be found in '''download_plugin.prx''' or in '''nas_plugin.prx''' (this also applies to NPDRM SELFs). Usually game packages are signed with two signatures - one for the header and the other for the entry table. | |||
== | == File Header == | ||
=== Retail PS3 .pkg === | |||
*Example: Scott Pilgrim VS. The World Unlock .pkg [http://zeus.dl.playstation.net/cdn/UP0001/NPUB30162_00/bG751I62Aych0U2E7hsxD5vKS28NurYg8CmJln6oQV4LUDAfXGSOyQHE45reFxIuwD5Qjo1xnQleHqulmmx9HmjNnXX8P5O5jcXlD.pkg file]: | *Example: Scott Pilgrim VS. The World Unlock .pkg [http://zeus.dl.playstation.net/cdn/UP0001/NPUB30162_00/bG751I62Aych0U2E7hsxD5vKS28NurYg8CmJln6oQV4LUDAfXGSOyQHE45reFxIuwD5Qjo1xnQleHqulmmx9HmjNnXX8P5O5jcXlD.pkg file]: | ||
'''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F''' | '''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F''' | ||
Line 179: | Line 35: | ||
'''00000090''' <span style="background-color:#3f48cc; color:#FFFFFF">0C 85 45 95 A8 D4 A3 9B 62 44 68 C1 38 CE D7 63</span> .…E•ЁФЈ›bDhБ8ОЧc | '''00000090''' <span style="background-color:#3f48cc; color:#FFFFFF">0C 85 45 95 A8 D4 A3 9B 62 44 68 C1 38 CE D7 63</span> .…E•ЁФЈ›bDhБ8ОЧc | ||
'''000000A0''' <span style="background-color:#3f48cc; color:#FFFFFF">0D FF 0C C5 3A 77 C6 E6 E4 62 AD 05 F3 93 D0 7A</span> .я.Е:wЖждb..у“Рz | '''000000A0''' <span style="background-color:#3f48cc; color:#FFFFFF">0D FF 0C C5 3A 77 C6 E6 E4 62 AD 05 F3 93 D0 7A</span> .я.Е:wЖждb..у“Рz | ||
'''000000B0''' <span style="background-color:#3f48cc; color:#FFFFFF">CC 02 B4 35 2B 70 47 D6</span> <span style="background-color:#a349a4 | '''000000B0''' <span style="background-color:#3f48cc; color:#FFFFFF">CC 02 B4 35 2B 70 47 D6</span> <span style="background-color:#a349a4;">EC 61 40 39 A6 5B DC BD</span> М.ґ5+pGЦмa@9¦[ЬЅ | ||
{| class="wikitable sortable" | |||
{| class="wikitable" | |||
|- | |- | ||
| style="background-color:#515243; color:#FFFFFF;" |'''Name''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Offset''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Size''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Example''' | |||
| style="background-color:#515243; color:#FFFFFF;" |'''Remark''' | |||
|- | |- | ||
| <span style="background:#ff0000;">magic || 0x00 || 0x04 || 7F 50 4B 47 || | | <span style="background:#ff0000;">magic || 0x00 || 0x04 || 7F 50 4B 47 || '.PKG' | ||
|- | |- | ||
| <span style="background-color:#008000; color:#FFFFFF;">pkg_revision || 0x04 || 0x02 || 80 00 || 80 00 for finalized | | <span style="background-color:#008000; color:#FFFFFF;">pkg_revision || 0x04 || 0x02 || 80 00 || 80 00 for retail (finalized), 00 00 for debug (non finalized) | ||
|- | |- | ||
| <span style="background-color:#3F48CC; color:#FFFFFF;">pkg_type | | <span style="background-color:#3F48CC; color:#FFFFFF;">pkg_type || 0x06 || 0x02 || 00 01 || 00 01 for ps3, 00 02 for psp | ||
|- | |- | ||
| <span style="background-color:#B5E61D;"> | | <span style="background-color:#B5E61D;">pkg_info_offset || 0x08 || 0x04 || 00 00 00 C0 || 0xC0 | ||
|- | |- | ||
| <span style="background-color:#B97A57;"> | | <span style="background-color:#B97A57;">pkg_info_size || 0x0C || 0x04 || 00 00 00 08 || pkg_info_size=0x00000008*8=0x40 | ||
|- | |- | ||
| <span style="background-color:#ff7f27;"> | | <span style="background-color:#ff7f27;">header_size || 0x10 || 0x04 || 00 00 00 C0 || 0xC0 | ||
|- | |- | ||
| <span style="background-color:#fff200;">item_count | | <span style="background-color:#fff200;">item_count || 0x14 || 0x04 || 00 00 00 02 || files and folders into the encrypted data | ||
|- | |- | ||
| <span style="background-color:#7f7f7f;">total_size | | <span style="background-color:#7f7f7f;">total_size || 0x18 || 0x08 || 00 00 00 00 00 00 17 C0 || 0x17C0 - total pkg file size | ||
|- | |- | ||
| <span style="background-color:#00a2e8;">data_offset || 0x20 || 0x08 || 00 00 00 00 00 00 01 80 || 0x0180 - encrypted data offset | | <span style="background-color:#00a2e8;">data_offset || 0x20 || 0x08 || 00 00 00 00 00 00 01 80 || 0x0180 - encrypted data offset | ||
Line 209: | Line 65: | ||
| <span style="background-color:#00ff00;">data_size || 0x28 || 0x08 || 00 00 00 00 00 00 15 E0 || 0x15E0 - encrypted data size | | <span style="background-color:#00ff00;">data_size || 0x28 || 0x08 || 00 00 00 00 00 00 15 E0 || 0x15E0 - encrypted data size | ||
|- | |- | ||
| <span style="background-color:#d52bd0;">contentid || 0x30 || 0x24 || | | <span style="background-color:#d52bd0;">contentid || 0x30 || 0x24 || || 'UP0001-NPUB30162_00-SCOTTPILGRIM0002' pkg content id | ||
|- | |- | ||
| padding | | padding || 0x54 || 0x0C || 00 00 00 00 00 00 00 00 00 00 00 00 || 0x0C bytes padding | ||
|- | |- | ||
| <span style="background-color:#000000; color:#ffffff;">digest || 0x60 || 0x10 || 09 8B A2 CA 2D 30 30 1F 8B 5B 82 79 C6 70 35 F3 || sha1 from debug files and attributes together merged in one block | | <span style="background-color:#000000; color:#ffffff;">digest || 0x60 || 0x10 || 09 8B A2 CA 2D 30 30 1F 8B 5B 82 79 C6 70 35 F3 || sha1 from debug files and attributes together merged in one block | ||
|- | |- | ||
| <span style="background-color:#ed1c24;">pkg_data_riv | | <span style="background-color:#ed1c24;">pkg_data_riv || 0x70 || 0x10 || D5 FA 15 9E 7F AC 82 70 BB 3E 0C EB 97 3D 30 11 || aes-128-ctr iv. uses with gpkg_key for decrypt data | ||
|- | |||
| <span style="background-color:#808000;">header_cmac_hash || 0x80 || 0x10 || 48 0D 86 60 9F 26 8E 7F 4F B4 DA A4 33 1E 9A A1 || cmac omac hash from 0x00-0x7F, gpkg_key used as key | |||
|- | |||
| <span style="background-color:#3f48cc; color:#FFFFFF;">header_npdrm_signature || 0x90 || 0x28 || || Header NPDRM ECDSA (R_sig, S_sig) | |||
|- | |||
| <span style="background-color:#a349a4;">header_sha1_hash || 0xB8 || 0x08 || EC 61 40 39 A6 5B DC BD || last 8 bytes of sha1 hash from 0x00-0x7F | |||
|- | |- | ||
|} | |} | ||
All values are in big endian format. | |||
typedef struct { | typedef struct { | ||
u32 magic; | u32 magic; | ||
u32 pkg_type; | |||
u32 pkg_info_offset; | |||
u32 | u32 pkg_info_size; | ||
u32 | u32 header_size; | ||
u32 | |||
u32 item_count; | u32 item_count; | ||
u64 total_size; | u64 total_size; | ||
u64 data_offset; | u64 data_offset; | ||
u64 data_size; | u64 data_size; | ||
char contentid[0x30]; | |||
u8 digest[0x10]; | u8 digest[0x10]; | ||
u8 | u8 k_licensee[0x10]; | ||
} PKG_HEADER; | } PKG_HEADER; | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! field !! offset !! size!! type !! notes | |||
|- | |- | ||
| | ! colspan="5"| Unencrypted header | ||
|- | |- | ||
| | | magic || 0x0 || 4 || u32 || Magic value of 0x7f504b47 "\x7fPKG" | ||
|- | |- | ||
| | | pkg_type || 0x4 || 4 || u32 || The package type is 1 for PS3 pkg and 2 for PSP (minis also)/Vita packages. the flag 0x80000000 is used for retail. | ||
|- | |- | ||
| | | pkg_info_offset||0x8 || 4 || u32 || offset of the pkg_info structure | ||
|- | |- | ||
| | | pkg_info_size || 0xC || 4 ||u32 || pkg_info_size*8 = size of the pkg_info structure | ||
|- | |- | ||
| | | header_size || 0x10 || 4 || u32 || Size of the header | ||
|- | |- | ||
| | | item_count || 0x14 || 4 || u32 || Variable (0x**) | ||
|- | |- | ||
| | | total_size || 0x18 || 8 || u64 || | ||
|- | |- | ||
| | | data_offset || 0x20 || 8 || u64 || | ||
|- | |- | ||
| | | data_size || 0x28 || 8 || u64 || | ||
|- | |- | ||
| | | contentid || 0x30 || 48 ||u8[48] || See [[PARAM.SFO#CONTENT_ID]] | ||
|- | |- | ||
| | | digest || 0x60 || 16 ||u8[16] || | ||
|- | |- | ||
| | | k_licensee || 0x70 || 16 ||u8[16] || | ||
|- | |- | ||
|} | |} | ||
typedef struct { | |||
u32 unk; | |||
u32 unk; | |||
u32 unk; | |||
u32 unk; | |||
u32 unk; | |||
u32 content type | |||
... | |||
} PKG_INFO; | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! content type !! notes !! install path (on ps3) | |||
|- | |- | ||
| | |0x04 || Patch/GameData || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x05 || Game_Exec || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x06 || PS1emu || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x07 || PSP || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x09 || Theme || /dev_hdd0/theme | ||
|- | |- | ||
| | |0x0A || Widget || /dev_hdd0/widget | ||
|- | |- | ||
| | |0x0B || License || /dev_hdd0/home/<current user>/exdata | ||
|- | |- | ||
| | |0x0C || VSH Module || /dev_hdd0/vsh/modules/ | ||
|- | |- | ||
| | |0x0D || PSN Avatar || /dev_hdd0/home/<current user>/psn_avatar | ||
|- | |- | ||
| | |0x0E || PSPgo || | ||
|- | |- | ||
| | |0x0F || Minis || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x10 || NEOGEO || | ||
|- | |- | ||
| | |0x11 || VMC || /dev_hdd0/tmp/vmc/ | ||
|- | |- | ||
| | |0x12 || Seen on PS2 classic || /dev_hdd0/game/ | ||
|- | |- | ||
| | |0x14 || || | ||
|- | |- | ||
| | |0x15 || PSVita (PSP2GD) || | ||
|- | |- | ||
| | |0x16 || PSVita (PSP2AC) || | ||
|- | |- | ||
| | |0x17 || PSVita (PSP2LA) || | ||
|} | |} | ||
= | === File Entry === | ||
All values are in big endian format | |||
== File | |||
= | |||
All values are in big endian format | |||
typedef struct { | typedef struct { | ||
Line 696: | Line 195: | ||
u32 flags; | u32 flags; | ||
u32 padding; | u32 padding; | ||
} | } PKG_FILE_HEADER; | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |||
! field !! offset !! type !! notes | ! field !! offset !! type !! notes | ||
|- | |- | ||
Line 709: | Line 209: | ||
| data_size || 0x10 || u64 || | | data_size || 0x10 || u64 || | ||
|- | |- | ||
| flags || 0x18 || u32 || The file type | | flags || 0x18 || u32 || The file type | ||
|- | |- | ||
| padding || 0x1C || u32 || zero | | padding || 0x1C || u32 || zero | ||
|- | |- | ||
|} | |} | ||
=== | === Misc/Note === | ||
== | |||
From FW 4.00, install PKG from root device (but not as "bubble") for PS1 classic if not containing [[EDAT_files|.EDAT files]] license type Free will abort or install directly as bubble according to the cfw. | |||
{{File Formats}}<noinclude>[[Category:Main]]</noinclude> | {{File Formats}}<noinclude>[[Category:Main]]</noinclude> |