2014-03-03 05:48:07 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
// Constants
|
2015-04-19 15:19:24 +02:00
|
|
|
enum
|
|
|
|
|
{
|
2015-08-06 01:59:41 +02:00
|
|
|
PKG_HEADER_SIZE = 0xC0, //sizeof(pkg_header) + sizeof(pkg_unk_checksum)
|
|
|
|
|
PKG_HEADER_SIZE2 = 0x280,
|
2015-04-19 15:19:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum : u16
|
|
|
|
|
{
|
|
|
|
|
PKG_RELEASE_TYPE_RELEASE = 0x8000,
|
|
|
|
|
PKG_RELEASE_TYPE_DEBUG = 0x0000,
|
|
|
|
|
|
|
|
|
|
PKG_PLATFORM_TYPE_PS3 = 0x0001,
|
|
|
|
|
PKG_PLATFORM_TYPE_PSP = 0x0002,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum : u32
|
|
|
|
|
{
|
|
|
|
|
PKG_FILE_ENTRY_NPDRM = 1,
|
|
|
|
|
PKG_FILE_ENTRY_NPDRMEDAT = 2,
|
|
|
|
|
PKG_FILE_ENTRY_REGULAR = 3,
|
|
|
|
|
PKG_FILE_ENTRY_FOLDER = 4,
|
2015-08-06 01:59:41 +02:00
|
|
|
PKG_FILE_ENTRY_UNK1 = 6,
|
2015-04-19 15:19:24 +02:00
|
|
|
PKG_FILE_ENTRY_SDAT = 9,
|
|
|
|
|
|
|
|
|
|
PKG_FILE_ENTRY_OVERWRITE = 0x80000000,
|
2015-08-06 01:59:41 +02:00
|
|
|
PKG_FILE_ENTRY_PSP = 0x10000000,
|
2015-04-19 15:19:24 +02:00
|
|
|
};
|
2014-03-03 05:48:07 +01:00
|
|
|
|
|
|
|
|
// Structs
|
|
|
|
|
struct PKGHeader
|
|
|
|
|
{
|
2016-04-25 12:49:12 +02:00
|
|
|
nse_t<u32> pkg_magic; // Magic (0x7f504b47)
|
2014-03-03 05:48:07 +01:00
|
|
|
be_t<u16> pkg_type; // Release type (Retail:0x8000, Debug:0x0000)
|
|
|
|
|
be_t<u16> pkg_platform; // Platform type (PS3:0x0001, PSP:0x0002)
|
2017-02-28 10:22:50 +01:00
|
|
|
be_t<u32> pkg_info_off;
|
|
|
|
|
be_t<u32> pkg_info_num;
|
|
|
|
|
be_t<u32> header_size; // Header size
|
2014-03-03 05:48:07 +01:00
|
|
|
be_t<u32> file_count; // Number of files
|
|
|
|
|
be_t<u64> pkg_size; // PKG size in bytes
|
|
|
|
|
be_t<u64> data_offset; // Encrypted data offset
|
|
|
|
|
be_t<u64> data_size; // Encrypted data size in bytes
|
|
|
|
|
char title_id[48]; // Title ID
|
2015-09-13 00:37:57 +02:00
|
|
|
be_t<u64> qa_digest[2]; // This should be the hash of "files + attribs"
|
|
|
|
|
be_t<u128> klicensee; // Nonce
|
2014-03-03 05:48:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PKGEntry
|
|
|
|
|
{
|
|
|
|
|
be_t<u32> name_offset; // File name offset
|
|
|
|
|
be_t<u32> name_size; // File name size
|
|
|
|
|
be_t<u64> file_offset; // File offset
|
|
|
|
|
be_t<u64> file_size; // File size
|
|
|
|
|
be_t<u32> type; // File type
|
|
|
|
|
be_t<u32> pad; // Padding (zeros)
|
|
|
|
|
};
|
|
|
|
|
|
2017-11-22 22:04:25 +01:00
|
|
|
bool pkg_install(const std::string& path, atomic_t<double>&);
|