Clean up smdh getting

This commit is contained in:
offtkp 2023-12-27 23:05:21 +02:00
parent 74e8f7d4eb
commit 3aa977c6c5
9 changed files with 45 additions and 52 deletions

View file

@ -6,10 +6,6 @@
#include "loader/ncch.hpp"
#include "memory.hpp"
#ifdef __ANDROID__
#include "jni_driver.hpp"
#endif
#include <iostream>
bool NCCH::loadFromHeader(Crypto::AESEngine &aesEngine, IOFile& file, const FSInfo &info) {
@ -30,6 +26,7 @@ bool NCCH::loadFromHeader(Crypto::AESEngine &aesEngine, IOFile& file, const FSIn
codeFile.clear();
saveData.clear();
smdh.clear();
partitionInfo = info;
size = u64(*(u32*)&header[0x104]) * mediaUnit; // TODO: Maybe don't type pun because big endian will break
@ -223,11 +220,10 @@ bool NCCH::loadFromHeader(Crypto::AESEngine &aesEngine, IOFile& file, const FSIn
}
} else if (std::strcmp(name, "icon") == 0) {
// Parse icon file to extract region info and more in the future (logo, etc)
std::vector<u8> tmp;
tmp.resize(fileSize);
readFromFile(file, exeFS, tmp.data(), fileOffset + exeFSHeaderSize, fileSize);
smdh.resize(fileSize);
readFromFile(file, exeFS, smdh.data(), fileOffset + exeFSHeaderSize, fileSize);
if (!parseSMDH(tmp)) {
if (!parseSMDH(smdh)) {
printf("Failed to parse SMDH!\n");
}
}
@ -259,11 +255,6 @@ bool NCCH::parseSMDH(const std::vector<u8>& smdh) {
return false;
}
// In the Android version, notify the application that we're loading an SMDH file, to extract data for the title list
#ifdef __ANDROID__
Pandroid::onSmdhLoaded(smdh);
#endif
// Bitmask showing which regions are allowed.
// https://www.3dbrew.org/wiki/SMDH#Region_Lockout
const u32 regionMasks = *(u32*)&smdh[0x2018];