void aptExit() { if (!aptInitialised) return; if(!(__system_runflags&RUNFLAG_APTWORKAROUND))aptAppletUtility_Exit_RetToApp(0); // This is only executed when application-termination was triggered via the home-menu power-off screen. if(aptGetStatusPower() == 1) { aptOpenSession(); APT_ReplySleepQuery(NULL, currentAppId, 0x0); aptCloseSession(); } if(!(__system_runflags&RUNFLAG_APTWORKAROUND)) { aptOpenSession(); APT_PrepareToCloseApplication(NULL, 0x1); aptCloseSession(); aptOpenSession(); APT_CloseApplication(NULL, 0x0, 0x0, 0x0); aptCloseSession(); } svcCloseHandle(aptSleepSync); svcCloseHandle(aptStatusMutex); svcCloseHandle(aptLockHandle); svcCloseHandle(aptStatusEvent); aptInitialised = false; }
void aptExit() { if (!aptInitialised) return; if(!aptIsCrippled())aptAppletUtility_Exit_RetToApp(0); // This is only executed when application-termination was triggered via the home-menu power-off screen. if(aptGetStatusPower() == 1) { aptOpenSession(); APT_ReplySleepQuery(NULL, currentAppId, 0x0); aptCloseSession(); } if(!aptIsCrippled()) { bool isReinit = aptIsReinit(); if (aptGetStatus() == APP_EXITING || !isReinit) { aptOpenSession(); APT_PrepareToCloseApplication(NULL, 0x1); aptCloseSession(); aptOpenSession(); APT_CloseApplication(NULL, 0x0, 0x0, 0x0); aptCloseSession(); if (isReinit) { extern void (*__system_retAddr)(void); __system_retAddr = NULL; } } else if (isReinit) { aptOpenSession(); APT_Finalize(NULL, currentAppId); aptCloseSession(); } } svcSignalEvent(aptEvents[2]); svcWaitSynchronization(aptEventHandlerThread, U64_MAX); svcCloseHandle(aptEventHandlerThread); svcCloseHandle(aptEvents[2]); svcCloseHandle(aptSleepSync); svcCloseHandle(aptStatusMutex); svcCloseHandle(aptLockHandle); svcCloseHandle(aptStatusEvent); aptInitialised = false; }