Files
Project_CTR/cia.h
T
2014-04-01 14:08:00 +08:00

125 lines
1.9 KiB
C

// Enums
typedef enum
{
CIA_NO_NCCH0 = -1,
CIA_INVALID_NCCH0 = -2,
CIA_CONFILCTING_CONTENT_IDS = -3,
CIA_BAD_VERSION = -4,
} cia_errors;
// Structs
typedef struct
{
u8 hdrSize[4];
u8 type[2];
u8 version[2];
u8 certChainSize[4];
u8 tikSize[4];
u8 tmdSize[4];
u8 metaSize[4];
u8 contentSize[8];
u8 contentIndex[0x2000];
} cia_hdr;
typedef struct
{
u8 dependencyList[0x30*0x8];
u8 padding0[0x180];
u8 coreVersion[4];
u8 padding1[0xfc];
} cia_metadata;
typedef struct
{
u8 *inFile;
u64 inFileSize;
FILE *out;
keys_struct *keys;
struct{
u8 titleId[8];
u16 titleVersion[4];
u8 titleKey[16];
} common;
struct{
u8 caCrlVersion;
u8 signerCrlVersion;
} cert;
struct{
u8 issuer[0x40];
u8 formatVersion;
u16 version;
u8 ticketId[8];
u8 deviceId[8];
u8 licenceType;
u8 audit;
u8 eshopAccId[4];
} tik;
struct{
u8 issuer[0x40];
u8 formatVersion;
u16 version;
u8 titleType[4];
u8 savedataSize[4];
u8 privSavedataSize[4];
u8 twlFlag;
} tmd;
struct{
bool IsCfa;
bool IsDlc;
bool encryptCia;
char *overrideSaveDataSize;
bool keyNotFound;
FILE **contentFilePtrs;
u64 cciContentOffsets[CCI_MAX_CONTENT];
/* Misc Records */
u16 contentCount;
u64 contentOffset[CIA_MAX_CONTENT];
u64 totalContentSize;
/* Content Chunk Records */
u64 contentSize[CIA_MAX_CONTENT];
u16 contentIndex[CIA_MAX_CONTENT];
u16 contentFlags[CIA_MAX_CONTENT];
u32 contentId[CIA_MAX_CONTENT];
u8 contentHash[CIA_MAX_CONTENT][0x20];
u8 contentTitleId[CIA_MAX_CONTENT][8];
} content;
struct{
COMPONENT_STRUCT ciaHdr;
u32 certChainOffset;
COMPONENT_STRUCT certChain;
u32 tikOffset;
COMPONENT_STRUCT tik;
u32 tmdOffset;
COMPONENT_STRUCT tmd;
u32 metaOffset;
COMPONENT_STRUCT meta;
u64 contentOffset;
} ciaSections;
} cia_settings;
// Public Prototypes
int build_CIA(user_settings *usrset);