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: | ||
[[Category:Software]] | |||
= 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 | |||
} | |||
= 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 == | ||
All values are in big endian format. | |||
All | |||
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 !! type !! notes | |||
! | |||
|- | |- | ||
| | ! colspan="4"| Unencrypted header | ||
|- | |- | ||
| | | magic || 0x0 || u32 || Magic value of 0x7f504b47 "\x7fPKG" | ||
|- | |- | ||
| | | pkg_type || 0x4 || u32 || The package type is 1 for PS3 pkg and 2 for PSP/Vita packages. the flag 0x80000000 is used for retail. | ||
|- | |- | ||
| | | pkg_info_offset || 0x8 || u32 || offset of the pkg_info structure | ||
|- | |- | ||
| | | pkg_info_size || 0xC || u32 || pkg_info_size*8 = size of the pkg_info structure | ||
|- | |- | ||
| | | header_size || 0x10 || u32 || Size of the header | ||
|- | |- | ||
| | | item_count || 0x14 || u32 || | ||
|- | |- | ||
| | | total_size || 0x18 || u64 || | ||
|- | |- | ||
| | | data_offset || 0x20 || u64 || | ||
|- | |- | ||
| | | data_size || 0x28 || u64 || | ||
|- | |- | ||
| | | contentid|| 0x30 || u8[48] || | ||
|- | |- | ||
| | | digest || 0x60 || u8[16] || | ||
|- | |- | ||
| | | k_licensee || 0x70 || u8[16] || | ||
|- | |- | ||
|} | |} | ||
=== File Entry === | |||
All values are in big endian format | |||
== File | |||
= | |||
All values are in big endian format | |||
typedef struct { | typedef struct { | ||
Line 696: | Line 82: | ||
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 96: | ||
| 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 | ||
|- | |- | ||
|} | |} | ||