Add CIA building

Quite a lot of code, yeah.

The built CIA is almost identical to GM9, with the following differences:
1. Paddings are zeroed out
2. Title key is not written (GM9 gets it from support data/ticket db)
3. Ticket content index is slightly different (GM9 likely takes it from the legit ticket, while we are building a fake one)

The 2, 3 points can be fixed probably.
This commit is contained in:
zhupengfei
2020-08-07 08:58:09 +08:00
parent 769162e95c
commit 49ddd86b7a
8 changed files with 514 additions and 41 deletions
+15
View File
@@ -12,6 +12,7 @@
namespace Core {
class CIABuilder;
class SDMCDecryptor;
/**
@@ -130,6 +131,19 @@ public:
*/
void AbortDumpCXI();
/**
* Builds a CIA from a content.
* Blocks, but can be aborted on another thread.
* @return true on success, false otherwise
*/
bool BuildCIA(const ContentSpecifier& specifier, const std::string& destination,
const ProgressCallback& callback = [](std::size_t, std::size_t) {});
/**
* Aborts current CIA building
*/
void AbortBuildCIA();
/**
* Deletes/Cleans up a content. Used for deleting contents that have
* not been fully imported.
@@ -172,6 +186,7 @@ private:
bool is_good{};
Config config;
std::unique_ptr<SDMCDecryptor> decryptor;
std::unique_ptr<CIABuilder> cia_builder;
// The NCCH used to dump CXIs.
std::unique_ptr<NCCHContainer> dump_cxi_ncch;