From: fincs Date: Sun, 17 Jul 2016 22:26:52 +0000 (+0200) Subject: Fix lingering parameter bug with APTREINIT (aka hax 2.x) X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=24b9341c992ec884a3c486e2b441c7092e23b595;p=corbenik%2Fctrulib.git Fix lingering parameter bug with APTREINIT (aka hax 2.x) --- diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index da939eb..625527d 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -129,6 +129,20 @@ Result aptSendCommand(u32* aptcmdbuf) return res; } +static void aptClearParamQueue(void) +{ + // Check for parameters? + for (;;) + { + APT_Command cmd; + Result res = APT_GlanceParameter(envGetAptAppId(), aptParameters, sizeof(aptParameters), NULL, &cmd, NULL, NULL); + if (R_FAILED(res) || cmd==APTCMD_NONE) break; + _aptDebug(2, cmd); + svcClearEvent(aptEvents[2]); + APT_CancelParameter(APPID_NONE, envGetAptAppId(), NULL); + } +} + static void aptInitCaptureInfo(aptCaptureBufInfo* capinfo) { GSPGPU_CaptureInfo gspcapinfo; @@ -265,7 +279,10 @@ void aptExit(void) closeAptLock = false; srvInit(); // Keep srv initialized } else + { APT_Finalize(envGetAptAppId()); + aptClearParamQueue(); + } svcSignalEvent(aptEvents[0]); threadJoin(aptEventHandlerThread, U64_MAX); @@ -400,20 +417,6 @@ APT_Command aptWaitForWakeUp(APT_Transition transition) return cmd; } -static void aptClearParamQueue(void) -{ - // Check for parameters? - for (;;) - { - APT_Command cmd; - Result res = APT_GlanceParameter(envGetAptAppId(), aptParameters, sizeof(aptParameters), NULL, &cmd, NULL, NULL); - if (R_FAILED(res) || cmd==APTCMD_NONE) break; - _aptDebug(2, cmd); - svcClearEvent(aptEvents[2]); - APT_CancelParameter(APPID_NONE, envGetAptAppId(), NULL); - } -} - static void aptScreenTransfer(NS_APPID appId, bool sysApplet) { aptCallHook(APTHOOK_ONSUSPEND);