]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fix lingering parameter bug with APTREINIT (aka hax 2.x)
authorfincs <fincs.alt1@gmail.com>
Sun, 17 Jul 2016 22:26:52 +0000 (00:26 +0200)
committerfincs <fincs.alt1@gmail.com>
Sun, 17 Jul 2016 22:26:52 +0000 (00:26 +0200)
libctru/source/services/apt.c

index da939eb71640611e66f38f9de4d1058d61e33590..625527dd85035ac7a5bdeda51686b39c45c976cc 100644 (file)
@@ -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);