Skip to content

Instantly share code, notes, and snippets.

@smealum
Created September 18, 2015 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smealum/528dbb10d90c1577bdc4 to your computer and use it in GitHub Desktop.
Save smealum/528dbb10d90c1577bdc4 to your computer and use it in GitHub Desktop.
aptExit
void _aptExit()
{
Handle _srvHandle;
Handle* srvHandle = &_srvHandle;
Handle aptLockHandle = 0;
Handle aptuHandle=0x00;
_initSrv(srvHandle);
_aptSessionInit();
#ifndef OTHERAPP
aptLockHandle=*((Handle*)CN_APTLOCKHANDLE_ADR);
#else
_aptOpenSession();
_APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle);
_aptCloseSession();
#endif
_aptOpenSession();
_APT_CancelLibraryApplet(&aptuHandle, 0x1);
_aptCloseSession();
_aptOpenSession();
_APT_NotifyToWait(&aptuHandle, 0x300);
_aptCloseSession();
u32 buf1;
u8 buf2[4];
_aptOpenSession();
buf1 = 0x00;
_APT_AppletUtility(&aptuHandle, NULL, 0x4, 0x1, (u8*)&buf1, 0x1, buf2);
_aptCloseSession();
u8 out = 1;
while(out)
{
_aptOpenSession();
_APT_IsRegistered(&aptuHandle, 0x401, &out); // wait until swkbd is dead
_aptCloseSession();
}
_aptOpenSession();
buf1 = 0x10;
_APT_AppletUtility(&aptuHandle, NULL, 0x7, 0x4, (u8*)&buf1, 0x1, buf2);
_aptCloseSession();
_aptOpenSession();
buf1 = 0x00;
_APT_AppletUtility(&aptuHandle, NULL, 0x4, 0x1, (u8*)&buf1, 0x1, buf2);
_aptCloseSession();
_aptOpenSession();
_APT_PrepareToCloseApplication(&aptuHandle, 0x1);
_aptCloseSession();
_aptOpenSession();
_APT_CloseApplication(&aptuHandle, 0x0, 0x0, 0x0);
_aptCloseSession();
svc_closeHandle(aptLockHandle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment