Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c);
Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent);
Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent);
+Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);//*Application and *System use APT commands 0x01010000 and 0x01020000. Using APT_CheckNew3DS() is recommended, this determines which of those two funcs to use automatically.
+Result APT_CheckNew3DS_System(Handle* handle, u8 *out);
+Result APT_CheckNew3DS(Handle* handle, u8 *out);
+
NS_APPID currentAppId;
+static char *__apt_servicestr = NULL;
+static char *__apt_servicenames[3] = {"APT:U", "APT:S", "APT:A"};
+
Handle aptLockHandle;
Handle aptuHandle;
Handle aptEvents[3];
static void aptAppStarted(void);
+static Result __apt_initservicehandle()
+{
+ Result ret=0;
+ u32 i;
+
+ if(__apt_servicestr)
+ {
+ return srvGetServiceHandle(&aptuHandle, __apt_servicestr);
+ }
+
+ for(i=0; i<3; i++)
+ {
+ ret = srvGetServiceHandle(&aptuHandle, __apt_servicenames[i]);
+ if(ret==0)
+ {
+ __apt_servicestr = __apt_servicenames[i];
+ return ret;
+ }
+ }
+
+ return ret;
+}
+
void aptInitCaptureInfo(u32 *ns_capinfo)
{
u32 tmp=0;
Result ret=0;
// Initialize APT stuff, escape load screen.
- srvGetServiceHandle(&aptuHandle, "APT:U");
+ ret = __apt_initservicehandle();
+ if(ret!=0)return ret;
if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
svcCloseHandle(aptuHandle);
void aptOpenSession()
{
+ //Result ret;
+
svcWaitSynchronization(aptLockHandle, U64_MAX);
- srvGetServiceHandle(&aptuHandle, "APT:U");
+ __apt_initservicehandle();
}
void aptCloseSession()
return cmdbuf[1];
}
+
+Result APT_CheckNew3DS_Application(Handle* handle, u8 *out)
+{
+ if(!handle)handle=&aptuHandle;
+
+ u32* cmdbuf=getThreadCommandBuffer();
+ cmdbuf[0]=0x01010000;
+
+ Result ret=0;
+ if((ret=svcSendSyncRequest(*handle)))return ret;
+
+ if(out)*out=cmdbuf[2];
+
+ return cmdbuf[1];
+}
+
+Result APT_CheckNew3DS_System(Handle* handle, u8 *out)
+{
+ if(!handle)handle=&aptuHandle;
+
+ u32* cmdbuf=getThreadCommandBuffer();
+ cmdbuf[0]=0x01020000;
+
+ Result ret=0;
+ if((ret=svcSendSyncRequest(*handle)))return ret;
+
+ if(out)*out=cmdbuf[2];
+
+ return cmdbuf[1];
+}
+
+Result APT_CheckNew3DS(Handle* handle, u8 *out)
+{
+ if(currentAppId==APPID_APPLICATION)return APT_CheckNew3DS_Application(NULL, out);
+ return APT_CheckNew3DS_System(NULL, out);
+}
+