This commit is contained in:
wheremyfoodat 2023-08-13 18:20:46 +03:00
parent 2dd9933621
commit ca0b5755c0

View file

@ -2,9 +2,10 @@
#include <array>
#include <optional>
#include <vector>
#include "io_file.hpp"
#include "helpers.hpp"
#include "crypto/aes_engine.hpp"
#include "helpers.hpp"
#include "io_file.hpp"
#include "services/region_codes.hpp"
struct NCCH {
@ -27,10 +28,10 @@ struct NCCH {
u32 size = 0;
// Extract the code set info from the relevant header data
void extract(const u8* headerEntry) {
address = *(u32*)&headerEntry[0];
pageCount = *(u32*)&headerEntry[4];
size = *(u32*)&headerEntry[8];
void extract(const u8 *headerEntry) {
address = *(u32 *)&headerEntry[0];
pageCount = *(u32 *)&headerEntry[4];
size = *(u32 *)&headerEntry[8];
}
};
@ -66,7 +67,7 @@ struct NCCH {
// Returns true on success, false on failure
// Partition index/offset/size must have been set before this
bool loadFromHeader(Crypto::AESEngine &aesEngine, IOFile& file, const FSInfo &info);
bool loadFromHeader(Crypto::AESEngine &aesEngine, IOFile &file, const FSInfo &info);
bool hasExtendedHeader() { return exheaderSize != 0; }
bool hasExeFS() { return exeFS.size != 0; }
@ -75,10 +76,10 @@ struct NCCH {
bool hasSaveData() { return saveData.size() != 0; }
// Parse SMDH for region info and such. Returns false on failure, true on success
bool parseSMDH(const std::vector<u8>& smdh);
bool parseSMDH(const std::vector<u8> &smdh);
std::pair<bool, Crypto::AESKey> getPrimaryKey(Crypto::AESEngine &aesEngine, const Crypto::AESKey &keyY);
std::pair<bool, Crypto::AESKey> getSecondaryKey(Crypto::AESEngine &aesEngine, const Crypto::AESKey &keyY);
std::pair<bool, std::size_t> readFromFile(IOFile& file, const FSInfo &info, u8 *dst, std::size_t offset, std::size_t size);
std::pair<bool, std::size_t> readFromFile(IOFile &file, const FSInfo &info, u8 *dst, std::size_t offset, std::size_t size);
};