apt: Properly implement app ID checks (#2225)

The IsSystemAppletId and IsApplicationAppletId checks were prone to
collisions due to the way they were implemented. For example, the
application app ID would pass IsSystemAppletId since 0x300 & 0x100 != 0

To account for masking collisions, add a generic `TypeMask` enum value
used to mask the app ID type correctly, and then match the masked value
with the app ID we're looking for.

Fixes issues with system applets that use objects from the caller
applications, since the edge case for sysapplet parameters being sent to
applications was also passing the other way around.
This commit is contained in:
Daniel López Guimaraes 2026-06-19 22:56:06 +01:00 committed by GitHub
parent 9e43e451d1
commit c9d2593c2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -154,11 +154,13 @@ static u64 ConvertTitleID(Core::System& system, u64 base_title_id) {
}
static bool IsSystemAppletId(AppletId applet_id) {
return (static_cast<u32>(applet_id) & static_cast<u32>(AppletId::AnySystemApplet)) != 0;
return (static_cast<u32>(applet_id) & static_cast<u32>(AppletId::TypeMask)) ==
static_cast<u32>(AppletId::AnySystemApplet);
}
static bool IsApplicationAppletId(AppletId applet_id) {
return (static_cast<u32>(applet_id) & static_cast<u32>(AppletId::Application)) != 0;
return (static_cast<u32>(applet_id) & static_cast<u32>(AppletId::TypeMask)) ==
static_cast<u32>(AppletId::Application);
}
AppletManager::AppletSlot AppletManager::GetAppletSlotFromId(AppletId id) {

View file

@ -101,6 +101,7 @@ enum class AppletId : u32 {
Mint2 = 0x407,
Extrapad2 = 0x408,
Memolib2 = 0x409,
TypeMask = 0xF00,
};
/// Application Old/New 3DS target platforms