diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 4a4276e70a..3e6d6b2007 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -971,7 +971,20 @@ void GetAppletInfo(Service::Interface* self) { IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 1, 0); // 0x60040 auto app_id = static_cast(rp.Pop()); - if (auto applet = HLE::Applets::Applet::Get(app_id)) { + LOG_DEBUG(Service_APT, "called appid=%u", static_cast(app_id)); + + const auto* slot = GetAppletSlotData(app_id); + + if (slot == nullptr || !slot->registered) { + // See if there's an HLE applet and try to use it before erroring out. + auto hle_applet = HLE::Applets::Applet::Get(app_id); + if (hle_applet == nullptr) { + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, + ErrorSummary::NotFound, ErrorLevel::Status)); + return; + } + // TODO(Subv): Get the title id for the current applet and write it in the response[2-3] IPC::RequestBuilder rb = rp.MakeBuilder(7, 0); rb.Push(RESULT_SUCCESS); @@ -981,12 +994,27 @@ void GetAppletInfo(Service::Interface* self) { rb.Push(true); // Registered rb.Push(true); // Loaded rb.Push(0); // Applet Attributes - } else { + LOG_WARNING(Service_APT, "Using HLE applet info for applet %03X", static_cast(app_id)); + return; + } + + if (app_id == AppletId::Application) { + // TODO(Subv): Implement this once Application launching is implemented + LOG_ERROR(Service_APT, "Unimplemented GetAppletInfo(Application)"); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound, ErrorLevel::Status)); + return; } - LOG_WARNING(Service_APT, "(stubbed) called appid=%u", static_cast(app_id)); + + IPC::RequestBuilder rb = rp.MakeBuilder(7, 0); + rb.Push(RESULT_SUCCESS); + rb.Push(GetTitleIdForApplet(app_id)); + // Note: The NS service hardcodes this to NAND for all applets except the Application applet. + rb.Push(static_cast(Service::FS::MediaType::NAND)); + rb.Push(slot->registered); + rb.Push(slot->loaded); + rb.Push(slot->attributes.raw); } void GetStartupArgument(Service::Interface* self) {