From c9d2593c2cb4ad8e45df7abe7e02c1b42e2f260e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B3pez=20Guimaraes?= <112760654+DaniElectra@users.noreply.github.com> Date: Fri, 19 Jun 2026 22:56:06 +0100 Subject: [PATCH] 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. --- src/core/hle/service/apt/applet_manager.cpp | 6 ++++-- src/core/hle/service/apt/applet_manager.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index a6cc6f254..535b970dc 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -154,11 +154,13 @@ static u64 ConvertTitleID(Core::System& system, u64 base_title_id) { } static bool IsSystemAppletId(AppletId applet_id) { - return (static_cast(applet_id) & static_cast(AppletId::AnySystemApplet)) != 0; + return (static_cast(applet_id) & static_cast(AppletId::TypeMask)) == + static_cast(AppletId::AnySystemApplet); } static bool IsApplicationAppletId(AppletId applet_id) { - return (static_cast(applet_id) & static_cast(AppletId::Application)) != 0; + return (static_cast(applet_id) & static_cast(AppletId::TypeMask)) == + static_cast(AppletId::Application); } AppletManager::AppletSlot AppletManager::GetAppletSlotFromId(AppletId id) { diff --git a/src/core/hle/service/apt/applet_manager.h b/src/core/hle/service/apt/applet_manager.h index 5e7f69040..eea184b74 100644 --- a/src/core/hle/service/apt/applet_manager.h +++ b/src/core/hle/service/apt/applet_manager.h @@ -101,6 +101,7 @@ enum class AppletId : u32 { Mint2 = 0x407, Extrapad2 = 0x408, Memolib2 = 0x409, + TypeMask = 0xF00, }; /// Application Old/New 3DS target platforms