Beispiel #1
0
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;
}
Beispiel #2
0
static bool __handle_incoming_parameter() {
	u8 type;

	aptOpenSession();
	APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &type);
	aptCloseSession();

	switch(type)
	{
	case 0x1: // Application just started.
		aptAppStarted();
		return true;

	case 0x3: // "Launched library applet finished loading"
		aptSetStatus(APP_APPLETSTARTED);
		return true;
	case 0xA: // "Launched library applet closed"
		if(__apt_launchapplet_parambuf && __apt_launchapplet_parambufsize)memcpy(__apt_launchapplet_parambuf, aptParameters, __apt_launchapplet_parambufsize);
		aptSetStatus(APP_APPLETCLOSED);
		return true;
	case 0xB: // Just returned from menu.
		GSPGPU_AcquireRight(NULL, 0x0);
		GSPGPU_RestoreVramSysArea(NULL);
		aptAppletUtility_Exit_RetToApp(0);
		aptSetStatus(APP_RUNNING);
		return true;

	case 0xC: // Exiting application.
		aptSetStatus(APP_EXITING);
		return false;
	}

	return true;
}
Beispiel #3
0
void aptAppletClosed()
{
	aptAppletUtility_Exit_RetToApp(1);

	GSPGPU_AcquireRight(NULL, 0x0);
	GSPGPU_RestoreVramSysArea(NULL);

	svcClearEvent(aptStatusEvent);
	aptSetStatus(APP_RUNNING);
}
Beispiel #4
0
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;
}