2016-11-26 15:37:53 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
2016-11-28 01:19:12 +01:00
|
|
|
#define NCSD_MEDIA_UNIT 0x200
|
|
|
|
|
|
|
|
#define NCSD_CINFO_OFFSET 0x200
|
|
|
|
#define NCSD_CINFO_SIZE 0x1000
|
|
|
|
#define NCSD_DINFO_OFFSET 0x1200
|
|
|
|
#define NCSD_DINFO_SIZE 0x300
|
2016-12-19 01:33:30 +01:00
|
|
|
#define NCSD_CNT0_OFFSET 0x4000
|
2016-11-26 15:37:53 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
u32 offset;
|
|
|
|
u32 size;
|
|
|
|
} __attribute__((packed)) NcchPartition;
|
|
|
|
|
2016-11-28 01:19:12 +01:00
|
|
|
// see: https://www.3dbrew.org/wiki/NCSD#NCSD_header
|
2016-11-26 15:37:53 +01:00
|
|
|
typedef struct {
|
|
|
|
u8 signature[0x100];
|
|
|
|
u8 magic[4];
|
|
|
|
u32 size;
|
|
|
|
u64 mediaId;
|
|
|
|
u8 partitions_fs_type[8];
|
|
|
|
u8 partitions_crypto_type[8];
|
|
|
|
NcchPartition partitions[8];
|
|
|
|
u8 hash_exthdr[0x20];
|
|
|
|
u8 size_addhdr[0x4];
|
|
|
|
u8 sector_zero_offset[0x4];
|
|
|
|
u8 partition_flags[8];
|
|
|
|
u8 partitionId_table[8][8];
|
2017-01-14 12:41:34 +01:00
|
|
|
u8 reserved[0x30];
|
2016-11-28 01:19:12 +01:00
|
|
|
} __attribute__((packed)) NcsdHeader;
|
2016-11-26 15:37:53 +01:00
|
|
|
|
|
|
|
u32 ValidateNcsdHeader(NcsdHeader* header);
|
2017-01-13 14:20:42 +01:00
|
|
|
u64 GetNcsdTrimmedSize(NcsdHeader* header);
|
2016-12-13 00:20:00 +01:00
|
|
|
u32 DecryptNcsdSequential(u8* data, u32 offset_data, u32 size_data);
|