mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-03 00:39:14 +00:00
124 lines
1.8 KiB
C
124 lines
1.8 KiB
C
#pragma once
|
|
|
|
// 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;
|
|
|
|
/* 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];
|
|
} content;
|
|
|
|
struct{
|
|
buffer_struct ciaHdr;
|
|
|
|
u32 certChainOffset;
|
|
buffer_struct certChain;
|
|
|
|
u32 tikOffset;
|
|
buffer_struct tik;
|
|
|
|
u32 tmdOffset;
|
|
buffer_struct tmd;
|
|
|
|
u32 metaOffset;
|
|
buffer_struct meta;
|
|
|
|
u64 contentOffset;
|
|
buffer_struct content;
|
|
} ciaSections;
|
|
} cia_settings;
|
|
|
|
// Public Prototypes
|
|
int build_CIA(user_settings *usrset); |