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

70 lines
4.7 KiB
C
Raw 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;
typedef struct {
2019-12-11 08:56:58 +00: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
u32 nspFileCount; // PFS0 file count
u32 ncaCount; // NCA count
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
u8 programNcaHeaderMod[NCA_FULL_HEADER_LENGTH]; // Modified + reencrypted Program NCA header. Only needed if the NPDM signature in the Program NCA header 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
} 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