1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 20:22:17 +00:00
nxdumptool/source/dumper.h

72 lines
4.9 KiB
C
Raw Permalink Normal View History

2018-05-15 17:00:19 +01:00
#pragma once
#ifndef __DUMPER_H__
#define __DUMPER_H__
2018-05-15 17:00:19 +01:00
#include <switch.h>
2019-06-05 23:44:18 +01:00
#include "util.h"
2018-05-15 17:00:19 +01:00
2019-10-17 21:15:35 +01:00
#define FAT32_FILESIZE_LIMIT (u64)0xFFFFFFFF // 4 GiB - 1 (4294967295 bytes)
2019-05-01 21:24:13 +01:00
2019-10-17 21:15:35 +01:00
#define SPLIT_FILE_XCI_PART_SIZE (u64)0xFFFF8000 // 4 GiB - 0x8000 (4294934528 bytes) (based on XCI-Cutter)
#define SPLIT_FILE_NSP_PART_SIZE (u64)0xFFFF0000 // 4 GiB - 0x10000 (4294901760 bytes) (based on splitNSP.py)
2019-08-15 06:21:51 +01:00
#define SPLIT_FILE_GENERIC_PART_SIZE SPLIT_FILE_NSP_PART_SIZE
2019-10-17 21:15:35 +01:00
#define SPLIT_FILE_SEQUENTIAL_SIZE (u64)0x40000000 // 1 GiB (used for sequential dumps when there's not enough storage space available)
2019-04-21 17:27:33 +01:00
#define CERT_OFFSET 0x7000
#define CERT_SIZE 0x200
2019-10-17 21:15:35 +01:00
typedef struct {
bool keepCert; // Original value for the "Keep certificate" option. Overrides the selected setting in the current session
bool trimDump; // Original value for the "Trim output dump" option. Overrides the selected setting in the current session
bool calcCrc; // "CRC32 checksum calculation + dump verification" option
u8 partNumber; // Next part number
u32 partitionIndex; // IStorage partition index
u64 partitionOffset; // IStorage partition offset
u32 certCrc; // CRC32 checksum accumulator (XCI with cert). Only used if calcCrc == true and keepCert == true
u32 certlessCrc; // CRC32 checksum accumulator (certless XCI). Only used if calcCrc == true
} PACKED sequentialXciCtx;
2020-03-30 22:10:07 +01:00
// This struct is followed by 'ncaCount' SHA-256 checksums in the output file and 'programNcaModCount' modified + reencrypted Program NCA headers
// The modified NCA headers are only needed if their NPDM signature is replaced (it uses cryptographically secure random numbers). The RSA public key used in the ACID section from the main.npdm file is constant, so we don't need to keep track of that
2019-10-17 21:15:35 +01:00
typedef struct {
2020-03-30 22:10:07 +01:00
NcmStorageId storageId; // Source storage from which the data is dumped
2019-10-17 21:15:35 +01:00
bool removeConsoleData; // Original value for the "Remove console specific data" option. Overrides the selected setting in the current session
bool tiklessDump; // Original value for the "Generate ticket-less dump" option. Overrides the selected setting in the current session. Ignored if removeConsoleData == false
2019-11-06 18:22:40 +00:00
bool npdmAcidRsaPatch; // Original value for the "Change NPDM RSA key/sig in Program NCA" option. Overrides the selected setting in the current session
bool preInstall; // Indicates if we're dealing with a preinstalled title - e.g. if the user already accepted the missing ticket prompt
2019-10-17 21:15:35 +01:00
u8 partNumber; // Next part number
2020-03-30 22:10:07 +01:00
u32 pfs0FileCount; // PFS0 file count
2019-10-17 21:15:35 +01:00
u32 ncaCount; // NCA count
2020-03-30 22:10:07 +01:00
u32 programNcaModCount; // Program NCA mod count
2019-10-17 21:15:35 +01:00
u32 fileIndex; // Current PFS0 file entry index
u64 fileOffset; // Current PFS0 file entry offset
Sha256Context hashCtx; // Current NCA SHA-256 checksum context. Only used when dealing with the same NCA between different parts
} PACKED sequentialNspCtx;
typedef struct {
bool enabled;
nspDumpType titleType;
u32 titleIndex;
2019-12-11 08:56:58 +00:00
u64 contentSize;
char *contentSizeStr;
2019-10-17 21:15:35 +01:00
char nspFilename[NAME_BUF_LEN];
char truncatedNspFilename[NAME_BUF_LEN];
} batchEntry;
2019-06-28 21:13:54 +01:00
2019-12-11 08:56:58 +00:00
bool dumpNXCardImage(xciOptions *xciDumpCfg);
int dumpNintendoSubmissionPackage(nspDumpType selectedNspDumpType, u32 titleIndex, nspOptions *nspDumpCfg, bool batch);
int dumpNintendoSubmissionPackageBatch(batchOptions *batchDumpCfg);
2019-06-09 02:36:21 +01:00
bool dumpRawHfs0Partition(u32 partition, bool doSplitting);
2019-06-28 21:13:54 +01:00
bool dumpHfs0PartitionData(u32 partition, bool doSplitting);
2019-12-11 08:56:58 +00:00
bool dumpFileFromHfs0Partition(u32 partition, u32 fileIndex, char *filename, bool doSplitting);
bool dumpExeFsSectionData(u32 titleIndex, bool usePatch, ncaFsOptions *exeFsDumpCfg);
bool dumpFileFromExeFsSection(u32 titleIndex, u32 fileIndex, bool usePatch, ncaFsOptions *exeFsDumpCfg);
bool dumpRomFsSectionData(u32 titleIndex, selectedRomFsType curRomFsType, ncaFsOptions *romFsDumpCfg);
bool dumpFileFromRomFsSection(u32 titleIndex, u32 file_offset, selectedRomFsType curRomFsType, ncaFsOptions *romFsDumpCfg);
bool dumpCurrentDirFromRomFsSection(u32 titleIndex, selectedRomFsType curRomFsType, ncaFsOptions *romFsDumpCfg);
2019-06-09 02:36:21 +01:00
bool dumpGameCardCertificate();
2019-11-06 18:22:40 +00:00
bool dumpTicketFromTitle(u32 titleIndex, selectedTicketType curTikType, ticketOptions *tikDumpCfg);
#endif