diff --git a/stratosphere/loader/source/ldr_npdm.cpp b/stratosphere/loader/source/ldr_npdm.cpp index 2bb9eb669..8d7eb0f37 100644 --- a/stratosphere/loader/source/ldr_npdm.cpp +++ b/stratosphere/loader/source/ldr_npdm.cpp @@ -190,7 +190,7 @@ Result NpdmUtils::LoadNpdm(u64 tid, NpdmInfo *out) { info->acid->flags = (info->acid->flags & 0xFFFFFFC3) | (original_info->acid->flags & 0x0000003C); } /* Fix application type. */ - const u32 original_application_type = GetApplicationType((u32 *)original_info->aci0_kac, original_info->aci0->kac_size/sizeof(u32)) & 7; + const u32 original_application_type = GetApplicationTypeRaw((u32 *)original_info->aci0_kac, original_info->aci0->kac_size/sizeof(u32)) & 7; u32 *caps = (u32 *)info->aci0_kac; for (unsigned int i = 0; i < info->aci0->kac_size/sizeof(u32); i++) { if ((caps[i] & 0x3FFF) == 0x1FFF) { @@ -489,4 +489,15 @@ u32 NpdmUtils::GetApplicationType(u32 *caps, size_t num_caps) { } } return application_type; +} + +/* Like GetApplicationType, except this returns the raw kac descriptor value. */ +u32 NpdmUtils::GetApplicationTypeRaw(u32 *caps, size_t num_caps) { + u32 application_type = 0; + for (unsigned int i = 0; i < num_caps; i++) { + if ((caps[i] & 0x3FFF) == 0x1FFF) { + return (caps[i] >> 14) & 7; + } + } + return application_type; } \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_npdm.hpp b/stratosphere/loader/source/ldr_npdm.hpp index 3a7e721ee..b04606046 100644 --- a/stratosphere/loader/source/ldr_npdm.hpp +++ b/stratosphere/loader/source/ldr_npdm.hpp @@ -96,6 +96,7 @@ class NpdmUtils { static_assert(sizeof(NpdmAci0) == 0x40, "Incorrectly defined NpdmAci0!"); static u32 GetApplicationType(u32 *caps, size_t num_caps); + static u32 GetApplicationTypeRaw(u32 *caps, size_t num_caps); static Result ValidateCapabilityAgainstRestrictions(u32 *restrict_caps, size_t num_restrict_caps, u32 *&cur_cap, size_t &caps_remaining); static Result ValidateCapabilities(u32 *acid_caps, size_t num_acid_caps, u32 *aci0_caps, size_t num_aci0_caps);