fs: add indirection to raw storage open, for hac2l

This commit is contained in:
Michael Scire
2022-03-13 20:58:02 -07:00
committed by SciresM
parent 9866285f0e
commit 32d443977e
6 changed files with 70 additions and 20 deletions

View File

@@ -51,6 +51,8 @@ namespace ams::fssrv::fscreator {
#if !defined(ATMOSPHERE_BOARD_NINTENDO_NX)
Result CreateWithContext(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::IAsynchronousAccessSplitter> *out_splitter, fssystem::NcaFsHeaderReader *out_header_reader, void *ctx, std::shared_ptr<fssystem::NcaReader> nca_reader, s32 index);
Result CreateWithPatchWithContext(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::IAsynchronousAccessSplitter> *out_splitter, fssystem::NcaFsHeaderReader *out_header_reader, void *ctx, std::shared_ptr<fssystem::NcaReader> original_nca_reader, std::shared_ptr<fssystem::NcaReader> current_nca_reader, s32 index);
Result CreateByRawStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::IAsynchronousAccessSplitter> *out_splitter, const fssystem::NcaFsHeaderReader *header_reader, std::shared_ptr<fs::IStorage> raw_storage, void *ctx, std::shared_ptr<fssystem::NcaReader> nca_reader);
#endif
};

View File

@@ -58,6 +58,10 @@ namespace ams::fssystem {
DecryptAesCtrFunction decrypt_aes_ctr;
DecryptAesCtrFunction decrypt_aes_ctr_external;
bool is_plaintext_header_available;
#if !defined(ATMOSPHERE_BOARD_NINTENDO_NX)
bool is_unsigned_header_available_for_host_tool;
#endif
};
static_assert(util::is_pod<NcaCryptoConfiguration>::value);
@@ -103,6 +107,7 @@ namespace ams::fssystem {
DecryptAesCtrFunction m_decrypt_aes_ctr_external;
bool m_is_software_aes_prioritized;
NcaHeader::EncryptionType m_header_encryption_type;
bool m_is_header_sign1_signature_valid;
GetDecompressorFunction m_get_decompressor;
IHash256GeneratorFactory *m_hash_generator_factory;
public:
@@ -149,8 +154,10 @@ namespace ams::fssystem {
GetDecompressorFunction GetDecompressor() const;
IHash256GeneratorFactory *GetHashGeneratorFactory() const;
void GetHeaderSign2(void *dst, size_t size);
void GetHeaderSign2TargetHash(void *dst, size_t size);
bool GetHeaderSign1Valid() const;
void GetHeaderSign2(void *dst, size_t size) const;
void GetHeaderSign2TargetHash(void *dst, size_t size) const;
};
class NcaFsHeaderReader : public ::ams::fs::impl::Newable {
@@ -252,6 +259,13 @@ namespace ams::fssystem {
/* Open the storage. */
R_RETURN(OpenStorageWithContext(out, out_splitter, out_header_reader, fs_index, std::addressof(ctx)));
}
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
private:
#else
public:
#endif
Result CreateStorageByRawStorage(std::shared_ptr<fs::IStorage> *out, const NcaFsHeaderReader *header_reader, std::shared_ptr<fs::IStorage> raw_storage, StorageContext *ctx);
private:
Result OpenStorageImpl(std::shared_ptr<fs::IStorage> *out, NcaFsHeaderReader *out_header_reader, s32 fs_index, StorageContext *ctx);