PKG files

From PS3 Developer wiki
Jump to navigation Jump to search

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

File Header

All values are in big endian format.

 typedef struct {
   u32 magic;
   u32 pkg_type;
   u32 pkg_info_offset;
   u32 pkg_info_size;
   u32 header_size;
   u32 item_count;
   u64 total_size;
   u64 data_offset;
   u64 data_size;
   char contentid[0x30];
   u8 digest[0x10];
   u8 k_licensee[0x10];
 } PKG_HEADER;


field offset type notes
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

 typedef struct {
   u32 filename_offset;
   u32 filename_size;
   u64 data_offset;
   u64 data_size;
   u32 flags;
   u32 padding;
 } PKG_FILE_HEADER;
field offset type notes
filename_offset 0x0 u32
filename_size 0x4 u32
data_offset 0x8 u64
data_size 0x10 u64
flags 0x18 u32 The file type
padding 0x1C u32 zero