mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-11 05:10:05 +00:00
core: Detect and return error if GBA virtual console is loaded. (#6257)
This commit is contained in:
parent
d704c6a3ac
commit
84e54a52a6
6 changed files with 33 additions and 6 deletions
|
@ -75,6 +75,7 @@ enum class ResultStatus {
|
|||
ErrorAlreadyLoaded,
|
||||
ErrorMemoryAllocationFailed,
|
||||
ErrorEncrypted,
|
||||
ErrorGbaTitle,
|
||||
};
|
||||
|
||||
constexpr u32 MakeMagic(char a, char b, char c, char d) {
|
||||
|
|
|
@ -85,6 +85,11 @@ ResultStatus AppLoader_NCCH::LoadExec(std::shared_ptr<Kernel::Process>& process)
|
|||
u64_le program_id;
|
||||
if (ResultStatus::Success == ReadCode(code) &&
|
||||
ResultStatus::Success == ReadProgramId(program_id)) {
|
||||
if (IsGbaVirtualConsole(code)) {
|
||||
LOG_ERROR(Loader, "Encountered unsupported GBA Virtual Console code section.");
|
||||
return ResultStatus::ErrorGbaTitle;
|
||||
}
|
||||
|
||||
std::string process_name = Common::StringFromFixedZeroTerminatedBuffer(
|
||||
(const char*)overlay_ncch->exheader_header.codeset_info.name, 8);
|
||||
|
||||
|
@ -177,6 +182,12 @@ void AppLoader_NCCH::ParseRegionLockoutInfo() {
|
|||
}
|
||||
}
|
||||
|
||||
bool AppLoader_NCCH::IsGbaVirtualConsole(const std::vector<u8>& code) {
|
||||
const u32* gbaVcHeader = reinterpret_cast<const u32*>(code.data() + code.size() - 0x10);
|
||||
return code.size() >= 0x10 && gbaVcHeader[0] == MakeMagic('.', 'C', 'A', 'A') &&
|
||||
gbaVcHeader[1] == 1;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCCH::Load(std::shared_ptr<Kernel::Process>& process) {
|
||||
u64_le ncch_program_id;
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ private:
|
|||
/// Reads the region lockout info in the SMDH and send it to CFG service
|
||||
void ParseRegionLockoutInfo();
|
||||
|
||||
/// Detects whether the NCCH contains GBA Virtual Console.
|
||||
bool IsGbaVirtualConsole(const std::vector<u8>& code);
|
||||
|
||||
FileSys::NCCHContainer base_ncch;
|
||||
FileSys::NCCHContainer update_ncch;
|
||||
FileSys::NCCHContainer* overlay_ncch;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue