2018-04-24 05:24:20 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
2018-04-24 07:51:29 +00:00
|
|
|
#include <fnd/IFile.h>
|
2018-09-23 03:29:22 +00:00
|
|
|
#include <fnd/SharedPtr.h>
|
2018-06-24 15:01:16 +00:00
|
|
|
#include <fnd/List.h>
|
2018-10-27 06:13:53 +00:00
|
|
|
#include <nn/hac/GameCardHeader.h>
|
2018-08-21 12:03:19 +00:00
|
|
|
#include "KeyConfiguration.h"
|
2018-04-24 05:24:20 +00:00
|
|
|
#include "PfsProcess.h"
|
|
|
|
|
2018-09-13 11:06:48 +00:00
|
|
|
#include "common.h"
|
2018-04-24 05:24:20 +00:00
|
|
|
|
2018-10-27 06:13:53 +00:00
|
|
|
class GameCardProcess
|
2018-04-24 05:24:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-10-27 06:13:53 +00:00
|
|
|
GameCardProcess();
|
2018-04-24 05:24:20 +00:00
|
|
|
|
|
|
|
void process();
|
|
|
|
|
|
|
|
// generic
|
2018-09-23 03:29:22 +00:00
|
|
|
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
2018-08-21 12:03:19 +00:00
|
|
|
void setKeyCfg(const KeyConfiguration& keycfg);
|
2018-06-18 15:30:19 +00:00
|
|
|
void setCliOutputMode(CliOutputMode type);
|
2018-04-24 05:24:20 +00:00
|
|
|
void setVerifyMode(bool verify);
|
|
|
|
|
|
|
|
// xci specific
|
2018-06-03 07:10:47 +00:00
|
|
|
void setPartitionForExtract(const std::string& partition_name, const std::string& extract_path);
|
2018-04-24 05:24:20 +00:00
|
|
|
void setListFs(bool list_fs);
|
|
|
|
|
|
|
|
private:
|
2018-10-27 06:13:53 +00:00
|
|
|
const std::string kModuleName = "GameCardProcess";
|
2018-04-24 05:24:20 +00:00
|
|
|
const std::string kXciMountPointName = "gamecard:/";
|
|
|
|
|
2018-09-23 03:29:22 +00:00
|
|
|
fnd::SharedPtr<fnd::IFile> mFile;
|
2018-08-21 12:03:19 +00:00
|
|
|
KeyConfiguration mKeyCfg;
|
2018-06-18 15:30:19 +00:00
|
|
|
CliOutputMode mCliOutputMode;
|
2018-04-24 05:24:20 +00:00
|
|
|
bool mVerify;
|
2019-11-17 06:26:23 +00:00
|
|
|
bool mListFs;
|
2018-04-24 05:24:20 +00:00
|
|
|
|
2018-06-03 07:10:47 +00:00
|
|
|
struct sExtractInfo
|
2018-04-24 05:24:20 +00:00
|
|
|
{
|
2018-06-03 07:10:47 +00:00
|
|
|
std::string partition_name;
|
|
|
|
std::string extract_path;
|
2018-06-24 15:01:16 +00:00
|
|
|
|
|
|
|
void operator=(const sExtractInfo& other)
|
|
|
|
{
|
|
|
|
partition_name = other.partition_name;
|
|
|
|
extract_path = other.extract_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const std::string& name) const
|
|
|
|
{
|
|
|
|
return name == partition_name;
|
|
|
|
}
|
2018-06-03 07:10:47 +00:00
|
|
|
};
|
2018-04-24 05:24:20 +00:00
|
|
|
|
2019-11-17 06:26:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool mIsTrueSdkXci;
|
|
|
|
bool mIsSdkXciEncrypted;
|
|
|
|
size_t mGcHeaderOffset;
|
|
|
|
bool mProccessExtendedHeader;
|
|
|
|
byte_t mHdrSignature[fnd::rsa::kRsa2048Size];
|
|
|
|
fnd::sha::sSha256Hash mHdrHash;
|
2018-10-27 06:13:53 +00:00
|
|
|
nn::hac::GameCardHeader mHdr;
|
2019-11-17 06:26:23 +00:00
|
|
|
|
2018-06-03 07:10:47 +00:00
|
|
|
PfsProcess mRootPfs;
|
2018-06-24 15:01:16 +00:00
|
|
|
fnd::List<sExtractInfo> mExtractInfo;
|
2018-04-24 05:24:20 +00:00
|
|
|
|
2018-08-13 17:14:21 +00:00
|
|
|
void importHeader();
|
2018-04-24 05:24:20 +00:00
|
|
|
void displayHeader();
|
2020-05-17 04:30:14 +00:00
|
|
|
bool validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash, bool use_salt, byte_t salt);
|
2018-04-24 05:24:20 +00:00
|
|
|
bool validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash);
|
|
|
|
void validateXciSignature();
|
|
|
|
void processRootPfs();
|
|
|
|
void processPartitionPfs();
|
|
|
|
};
|