Service/APT: Fixed a regression, PreloadLibraryApplet should also start an applet when called.

master
Subv 2015-07-23 21:09:43 +07:00
parent ce31184557
commit 599744921d
6 changed files with 36 additions and 5 deletions

@ -91,7 +91,7 @@ ResultCode Applet::Start(const Service::APT::AppletStartupParameter& parameter)
bool IsLibraryAppletRunning() { bool IsLibraryAppletRunning() {
// Check the applets map for instances of any applet // Check the applets map for instances of any applet
for (auto& itr = applets.begin(); itr != applets.end(); ++itr) for (auto itr = applets.begin(); itr != applets.end(); ++itr)
if (itr->second != nullptr) if (itr->second != nullptr)
return true; return true;
return false; return false;

@ -334,7 +334,26 @@ void GetAppCpuTimeLimit(Service::Interface* self) {
void PrepareToStartLibraryApplet(Service::Interface* self) { void PrepareToStartLibraryApplet(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer(); u32* cmd_buff = Kernel::GetCommandBuffer();
AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
cmd_buff[1] = RESULT_SUCCESS.raw;
} else {
cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
}
LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
}
void PreloadLibraryApplet(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
AppletId applet_id = static_cast<AppletId>(cmd_buff[1]);
auto applet = HLE::Applets::Applet::Get(applet_id);
if (applet) {
LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
cmd_buff[1] = RESULT_SUCCESS.raw;
} else {
cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw;
}
LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
} }

@ -302,6 +302,17 @@ void GetAppCpuTimeLimit(Service::Interface* self);
*/ */
void PrepareToStartLibraryApplet(Service::Interface* self); void PrepareToStartLibraryApplet(Service::Interface* self);
/**
* APT::PreloadLibraryApplet service function
* Inputs:
* 0 : Command header [0x00160040]
* 1 : Id of the applet to start
* Outputs:
* 0 : Return header
* 1 : Result of function, 0 on success, otherwise error code
*/
void PreloadLibraryApplet(Service::Interface* self);
/** /**
* APT::StartLibraryApplet service function * APT::StartLibraryApplet service function
* Inputs: * Inputs:

@ -21,6 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x000D0080, ReceiveParameter, "ReceiveParameter"}, {0x000D0080, ReceiveParameter, "ReceiveParameter"},
{0x000E0080, GlanceParameter, "GlanceParameter"}, {0x000E0080, GlanceParameter, "GlanceParameter"},
{0x000F0100, CancelParameter, "CancelParameter"}, {0x000F0100, CancelParameter, "CancelParameter"},
{0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x001E0084, StartLibraryApplet, "StartLibraryApplet"}, {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
{0x003B0040, nullptr, "CancelLibraryApplet?"}, {0x003B0040, nullptr, "CancelLibraryApplet?"},

@ -32,9 +32,9 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00130000, nullptr, "GetPreparationState"}, {0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"}, {0x00140040, nullptr, "SetPreparationState"},
{0x00150140, nullptr, "PrepareToStartApplication"}, {0x00150140, nullptr, "PrepareToStartApplication"},
{0x00160040, nullptr, "PreloadLibraryApplet"}, {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, nullptr, "PrepareToStartLibraryApplet"}, {0x00180040, PrepareToStartLibraryApplet,"PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"}, {0x00190040, nullptr, "PrepareToStartSystemApplet"},
{0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"}, {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
{0x001B00C4, nullptr, "StartApplication"}, {0x001B00C4, nullptr, "StartApplication"},

@ -33,7 +33,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00130000, nullptr, "GetPreparationState"}, {0x00130000, nullptr, "GetPreparationState"},
{0x00140040, nullptr, "SetPreparationState"}, {0x00140040, nullptr, "SetPreparationState"},
{0x00150140, nullptr, "PrepareToStartApplication"}, {0x00150140, nullptr, "PrepareToStartApplication"},
{0x00160040, nullptr, "PreloadLibraryApplet"}, {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
{0x00170040, nullptr, "FinishPreloadingLibraryApplet"}, {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
{0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"}, {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
{0x00190040, nullptr, "PrepareToStartSystemApplet"}, {0x00190040, nullptr, "PrepareToStartSystemApplet"},