extern Handle aptEvents[3];
-Result aptInit();
-void aptExit();
-void aptOpenSession();
-void aptCloseSession();
+Result aptInit(void);
+void aptExit(void);
+void aptOpenSession(void);
+void aptCloseSession(void);
void aptSetStatus(APP_STATUS status);
-APP_STATUS aptGetStatus();
-u32 aptGetStatusPower();//This can be used when the status is APP_SUSPEND* to check how the return-to-menu was triggered: 0 = home-button, 1 = power-button.
+APP_STATUS aptGetStatus(void);
+u32 aptGetStatusPower(void);//This can be used when the status is APP_SUSPEND* to check how the return-to-menu was triggered: 0 = home-button, 1 = power-button.
void aptSetStatusPower(u32 status);
-void aptReturnToMenu();//This should be called by the user application when aptGetStatus() returns APP_SUSPENDING, not calling this will result in return-to-menu being disabled with the status left at APP_SUSPENDING. This function will not return until the system returns to the application, or when the status was changed to APP_EXITING.
-void aptWaitStatusEvent();
-void aptSignalReadyForSleep();
-NS_APPID aptGetMenuAppID();
-bool aptMainLoop(); // Use like this in your main(): while (aptMainLoop()) { your code here... }
+void aptReturnToMenu(void);//This should be called by the user application when aptGetStatus() returns APP_SUSPENDING, not calling this will result in return-to-menu being disabled with the status left at APP_SUSPENDING. This function will not return until the system returns to the application, or when the status was changed to APP_EXITING.
+void aptWaitStatusEvent(void);
+void aptSignalReadyForSleep(void);
+NS_APPID aptGetMenuAppID(void);
+bool aptMainLoop(void); // Use like this in your main(): while (aptMainLoop()) { your code here... }
void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
void aptUnhook(aptHookCookie* cookie);
-Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
-Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
-Result APT_Finalize(Handle* handle, NS_APPID appId);
-Result APT_HardwareResetAsync(Handle* handle);
-Result APT_Enable(Handle* handle, u32 a);
-Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
-Result APT_PrepareToJumpToHomeMenu(Handle* handle);
-Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c);
-Result APT_PrepareToJumpToApplication(Handle* handle, u32 a);
-Result APT_JumpToApplication(Handle* handle, u32 a, u32 b, u32 c);
-Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out);
-Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType);
-Result APT_NotifyToWait(Handle* handle, NS_APPID appID);
-Result APT_AppletUtility(Handle* handle, u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
-Result APT_GlanceParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
-Result APT_ReceiveParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
-Result APT_SendParameter(Handle* handle, NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
-Result APT_SendCaptureBufferInfo(Handle* handle, u32 bufferSize, u32* buffer);
-Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a);
-Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID);
-Result APT_PrepareToCloseApplication(Handle* handle, u8 a);
-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);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication
-Result APT_CheckNew3DS_System(Handle* handle, u8 *out);
-Result APT_CheckNew3DS(Handle* handle, u8 *out);
-Result APT_PrepareToDoAppJump(Handle* handle, u8 flags, u64 programID, u8 mediatype);
-Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr);
-Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID);
-Result APT_StartLibraryApplet(Handle* handle, NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);
+Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
+Result APT_Initialize(NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
+Result APT_Finalize(NS_APPID appId);
+Result APT_HardwareResetAsync(void);
+Result APT_Enable(u32 a);
+Result APT_GetAppletManInfo(u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
+Result APT_PrepareToJumpToHomeMenu(void);
+Result APT_JumpToHomeMenu(u32 a, u32 b, u32 c);
+Result APT_PrepareToJumpToApplication(u32 a);
+Result APT_JumpToApplication(u32 a, u32 b, u32 c);
+Result APT_IsRegistered(NS_APPID appID, u8* out);
+Result APT_InquireNotification(u32 appID, u8* signalType);
+Result APT_NotifyToWait(NS_APPID appID);
+Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
+Result APT_GlanceParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
+Result APT_ReceiveParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
+Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
+Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer);
+Result APT_ReplySleepQuery(NS_APPID appID, u32 a);
+Result APT_ReplySleepNotificationComplete(NS_APPID appID);
+Result APT_PrepareToCloseApplication(u8 a);
+Result APT_CloseApplication(u32 a, u32 b, u32 c);
+Result APT_SetAppCpuTimeLimit(u32 percent);
+Result APT_GetAppCpuTimeLimit(u32 *percent);
+Result APT_CheckNew3DS_Application(u8 *out);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication
+Result APT_CheckNew3DS_System(u8 *out);
+Result APT_CheckNew3DS(u8 *out);
+Result APT_PrepareToDoAppJump(u8 flags, u64 programID, u8 mediatype);
+Result APT_DoAppJump(u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr);
+Result APT_PrepareToStartLibraryApplet(NS_APPID appID);
+Result APT_StartLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);
Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);//This should be used for launching library applets, this uses the above APT_StartLibraryApplet/APT_PrepareToStartLibraryApplet funcs + apt*Session(). parambuf is used for APT params input, when the applet closes the output param block is copied here. This is not usable from the homebrew launcher. This is broken: when the applet does get launched at all, the applet process doesn't actually get terminated when the applet gets closed.
-Result APT_PrepareToStartSystemApplet(Handle* handle, NS_APPID appID);
-Result APT_StartSystemApplet(Handle* handle, NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf);
+Result APT_PrepareToStartSystemApplet(NS_APPID appID);
+Result APT_StartSystemApplet(NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf);
return (__system_runflags & RUNFLAG_APTWORKAROUND) != 0 && !aptIsReinit();
}
-static Result __apt_initservicehandle()
+static Result __apt_initservicehandle(void)
{
Result ret=0;
u32 i;
ns_capinfo[0] = main_pixsz * 0x7000 + tmp;
}
-void aptWaitStatusEvent()
+void aptWaitStatusEvent(void)
{
svcWaitSynchronization(aptStatusEvent, U64_MAX);
svcClearEvent(aptStatusEvent);
buf1[0]=0x10;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x7, 0x4, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x7, 0x4, buf1, 0x1, buf2);
aptCloseSession();
buf1[0]=0x00;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
buf1[0]=0x01;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x7, 0x4, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x7, 0x4, buf1, 0x1, buf2);
aptCloseSession();
buf1[0]=0x00;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
if(type)
{
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
}
}
-NS_APPID aptGetMenuAppID()
+NS_APPID aptGetMenuAppID(void)
{
NS_APPID menu_appid;
aptOpenSession();
- APT_GetAppletManInfo(NULL, 0xff, NULL, NULL, &menu_appid, NULL);
+ APT_GetAppletManInfo(0xff, NULL, NULL, &menu_appid, NULL);
aptCloseSession();
return menu_appid;
}
-void aptReturnToMenu()
+void aptReturnToMenu(void)
{
NS_APPID menu_appid;
u32 tmp0 = 1, tmp1 = 0;
if(aptGetStatusPower() == 0)
{
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x6, 0x4, (u8*)&tmp0, 0x1, (u8*)&tmp1);
+ APT_AppletUtility(NULL, 0x6, 0x4, (u8*)&tmp0, 0x1, (u8*)&tmp1);
aptCloseSession();
}
// Prepare for return to menu
aptOpenSession();
- APT_PrepareToJumpToHomeMenu(NULL);
+ APT_PrepareToJumpToHomeMenu();
aptCloseSession();
// Save Vram
// Send capture-screen info to menu.
aptOpenSession();
- APT_SendParameter(NULL, currentAppId, menu_appid, 0x20, __ns_capinfo, 0x0, 0x10);
+ APT_SendParameter(currentAppId, menu_appid, 0x20, __ns_capinfo, 0x0, 0x10);
aptCloseSession();
aptOpenSession();
- APT_SendCaptureBufferInfo(NULL, 0x20, __ns_capinfo);
+ APT_SendCaptureBufferInfo(0x20, __ns_capinfo);
aptCloseSession();
// Release GSP module.
// Jump to menu!
aptOpenSession();
- APT_JumpToHomeMenu(NULL, 0x0, 0x0, 0x0);
+ APT_JumpToHomeMenu(0x0, 0x0, 0x0);
aptCloseSession();
// Wait for return to application.
aptOpenSession();
- APT_NotifyToWait(NULL, currentAppId);
+ APT_NotifyToWait(currentAppId);
aptCloseSession();
// This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
{
tmp0 = 0;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, (u8*)&tmp0, 0x1, (u8*)&tmp1);
+ APT_AppletUtility(NULL, 0x4, 0x1, (u8*)&tmp0, 0x1, (u8*)&tmp1);
aptCloseSession();
}
aptWaitStatusEvent();
}
-void aptAppletStarted()
+void aptAppletStarted(void)
{
u8 buf1[4], buf2[4];
aptSetStatus(APP_SUSPENDED);
aptOpenSession();
- APT_SendCaptureBufferInfo(NULL, 0x20, __ns_capinfo);
+ APT_SendCaptureBufferInfo(0x20, __ns_capinfo);
aptCloseSession();
aptOpenSession();
- APT_ReplySleepQuery(NULL, currentAppId, 0x0);
+ APT_ReplySleepQuery(currentAppId, 0x0);
aptCloseSession();
aptOpenSession();
- APT_StartLibraryApplet(NULL, __apt_launchapplet_appID, __apt_launchapplet_inhandle, __apt_launchapplet_parambuf, __apt_launchapplet_parambufsize);
+ APT_StartLibraryApplet(__apt_launchapplet_appID, __apt_launchapplet_inhandle, __apt_launchapplet_parambuf, __apt_launchapplet_parambufsize);
aptCloseSession();
buf1[0]=0x00;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
aptOpenSession();
- APT_NotifyToWait(NULL, currentAppId);
+ APT_NotifyToWait(currentAppId);
aptCloseSession();
buf1[0]=0x00;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
}
-void aptAppletClosed()
+void aptAppletClosed(void)
{
aptAppletUtility_Exit_RetToApp(1);
svcClearEvent(aptStatusEvent);
}
-static void __handle_notification() {
+static void __handle_notification(void) {
u8 type;
Result ret=0;
// Get notification type.
aptOpenSession();
- ret = APT_InquireNotification(NULL, currentAppId, &type);
+ ret = APT_InquireNotification(currentAppId, &type);
aptCloseSession();
if(ret!=0) return;
if(aptGetStatus() == APP_RUNNING)
{
aptOpenSession();
- APT_ReplySleepQuery(NULL, currentAppId, 0x0);
+ APT_ReplySleepQuery(currentAppId, 0x0);
aptCloseSession();
if(type == APTSIGNAL_HOMEBUTTON) aptSetStatusPower(0);
svcClearEvent(aptSleepSync);
aptOpenSession();
- APT_ReplySleepQuery(NULL, currentAppId, 0x1);
+ APT_ReplySleepQuery(currentAppId, 0x1);
aptCloseSession();
break;
aptSetStatus(APP_SLEEPMODE);
aptOpenSession();
- APT_ReplySleepNotificationComplete(NULL, currentAppId);
+ APT_ReplySleepNotificationComplete(currentAppId);
aptCloseSession();
}
break;
}
}
-static bool __handle_incoming_parameter() {
+static bool __handle_incoming_parameter(void) {
u8 type;
aptOpenSession();
- APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &type);
+ APT_ReceiveParameter(currentAppId, 0x1000, aptParameters, NULL, &type);
aptCloseSession();
_aptDebug(2, type);
// Initialize APT stuff, escape load screen.
ret = __apt_initservicehandle();
if(ret!=0)return ret;
- if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
+ if((ret=APT_GetLockHandle(0x0, &aptLockHandle)))return ret;
svcCloseHandle(aptuHandle);
currentAppId = __apt_appid;
if(!aptIsCrippled())
{
aptOpenSession();
- if((ret=APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
+ if((ret=APT_Initialize(currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
aptCloseSession();
aptOpenSession();
- if((ret=APT_Enable(NULL, 0x0)))return ret;
+ if((ret=APT_Enable(0x0)))return ret;
aptCloseSession();
// create APT close event
if (aptIsReinit())
{
aptOpenSession();
- APT_PrepareToJumpToApplication(NULL, 0x0);
+ APT_PrepareToJumpToApplication(0x0);
aptCloseSession();
aptOpenSession();
- APT_JumpToApplication(NULL, 0x0, 0x0, 0x0);
+ APT_JumpToApplication(0x0, 0x0, 0x0);
aptCloseSession();
}
aptOpenSession();
- if((ret=APT_NotifyToWait(NULL, currentAppId)))return ret;
+ if((ret=APT_NotifyToWait(currentAppId)))return ret;
aptCloseSession();
// create APT event handler thread
return 0;
}
-void aptExit()
+void aptExit(void)
{
if (!aptInitialised) return;
if(aptGetStatusPower() == 1)
{
aptOpenSession();
- APT_ReplySleepQuery(NULL, currentAppId, 0x0);
+ APT_ReplySleepQuery(currentAppId, 0x0);
aptCloseSession();
}
if (aptGetStatus() == APP_EXITING || !isReinit)
{
aptOpenSession();
- APT_PrepareToCloseApplication(NULL, 0x1);
+ APT_PrepareToCloseApplication(0x1);
aptCloseSession();
aptOpenSession();
- APT_CloseApplication(NULL, 0x0, 0x0, 0x0);
+ APT_CloseApplication(0x0, 0x0, 0x0);
aptCloseSession();
if (isReinit)
} else if (isReinit)
{
aptOpenSession();
- APT_Finalize(NULL, currentAppId);
+ APT_Finalize(currentAppId);
aptCloseSession();
}
}
aptInitialised = false;
}
-bool aptMainLoop()
+bool aptMainLoop(void)
{
while(1)
{
}
}
-void aptAppStarted()
+void aptAppStarted(void)
{
u8 buf1[4], buf2[4];
buf1[0] = 0x10;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x7, 0x4, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x7, 0x4, buf1, 0x1, buf2);
aptCloseSession();
buf1[0] = 0x00;
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
}
}
-APP_STATUS aptGetStatus()
+APP_STATUS aptGetStatus(void)
{
APP_STATUS ret;
svcWaitSynchronization(aptStatusMutex, U64_MAX);
svcReleaseMutex(aptStatusMutex);
}
-u32 aptGetStatusPower()
+u32 aptGetStatusPower(void)
{
u32 ret;
svcWaitSynchronization(aptStatusMutex, U64_MAX);
svcReleaseMutex(aptStatusMutex);
}
-void aptOpenSession()
+void aptOpenSession(void)
{
//Result ret;
__apt_initservicehandle();
}
-void aptCloseSession()
+void aptCloseSession(void)
{
svcCloseHandle(aptuHandle);
svcReleaseMutex(aptLockHandle);
}
-void aptSignalReadyForSleep()
+void aptSignalReadyForSleep(void)
{
svcSignalEvent(aptSleepSync);
}
-Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle)
+Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x10040; //request header code
cmdbuf[1]=flags;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(lockHandle)*lockHandle=cmdbuf[5];
return cmdbuf[1];
}
-Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2)
+Result APT_Initialize(NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x20080; //request header code
cmdbuf[1]=appId;
cmdbuf[2]=0x0;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(eventHandle1)*eventHandle1=cmdbuf[3]; //return to menu event ?
if(eventHandle2)*eventHandle2=cmdbuf[4];
return cmdbuf[1];
}
-Result APT_Finalize(Handle* handle, NS_APPID appId)
+Result APT_Finalize(NS_APPID appId)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x40040; //request header code
cmdbuf[1]=appId;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_HardwareResetAsync(Handle* handle)
+Result APT_HardwareResetAsync()
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x4E0000; //request header code
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_Enable(Handle* handle, u32 a)
+Result APT_Enable(u32 a)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x30040; //request header code
cmdbuf[1]=a;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid)
+Result APT_GetAppletManInfo(u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x00050040; //request header code
cmdbuf[1]=inval;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(outval8)*outval8=cmdbuf[2];
if(outval32)*outval32=cmdbuf[3];
return cmdbuf[1];
}
-Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out)
+Result APT_IsRegistered(NS_APPID appID, u8* out)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x90040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(out)*out=cmdbuf[2];
return cmdbuf[1];
}
-Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType)
+Result APT_InquireNotification(u32 appID, u8* signalType)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0xB0040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(signalType)*signalType=cmdbuf[2];
return cmdbuf[1];
}
-Result APT_PrepareToJumpToHomeMenu(Handle* handle)
+Result APT_PrepareToJumpToHomeMenu()
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x2b0000; //request header code
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c)
+Result APT_JumpToHomeMenu(u32 a, u32 b, u32 c)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x2C0044; //request header code
cmdbuf[1]=a;
cmdbuf[4]=(b<<14)|2;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_PrepareToJumpToApplication(Handle* handle, u32 a)
+Result APT_PrepareToJumpToApplication(u32 a)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x230040; //request header code
cmdbuf[1]=a;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_JumpToApplication(Handle* handle, u32 a, u32 b, u32 c)
+Result APT_JumpToApplication(u32 a, u32 b, u32 c)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x240044; //request header code
cmdbuf[1]=a;
cmdbuf[4]=(b<<14)|2;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_NotifyToWait(Handle* handle, NS_APPID appID)
+Result APT_NotifyToWait(NS_APPID appID)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x430040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_AppletUtility(Handle* handle, u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2)
+Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x4B00C2; //request header code
cmdbuf[1]=a;
cmdbuf[1+0x100/4]=(u32)buf2;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(out)*out=cmdbuf[2];
return cmdbuf[1];
}
-Result APT_GlanceParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType)
+Result APT_GlanceParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0xE0080; //request header code
cmdbuf[1]=appID;
cmdbuf[1+0x100/4]=(u32)buffer;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(signalType)*signalType=cmdbuf[3];
if(actualSize)*actualSize=cmdbuf[4];
return cmdbuf[1];
}
-Result APT_ReceiveParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType)
+Result APT_ReceiveParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType)
{
- if(!handle)handle=&aptuHandle;
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0xD0080; //request header code
cmdbuf[1]=appID;
cmdbuf[1+0x100/4]=(u32)buffer;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(signalType)*signalType=cmdbuf[3];
if(actualSize)*actualSize=cmdbuf[4];
return cmdbuf[1];
}
-Result APT_SendParameter(Handle* handle, NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType)
+Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType)
{
u32* cmdbuf=getThreadCommandBuffer();
- if(!handle)handle=&aptuHandle;
-
cmdbuf[0] = 0x000C0104; //request header code
cmdbuf[1] = src_appID;
cmdbuf[2] = dst_appID;
cmdbuf[8] = (u32)buffer;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_SendCaptureBufferInfo(Handle* handle, u32 bufferSize, u32* buffer)
+Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer)
{
u32* cmdbuf=getThreadCommandBuffer();
- if(!handle)handle=&aptuHandle;
-
cmdbuf[0] = 0x00400042; //request header code
cmdbuf[1] = bufferSize;
cmdbuf[2] = (bufferSize<<14) | 2;
cmdbuf[3] = (u32)buffer;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a)
+Result APT_ReplySleepQuery(NS_APPID appID, u32 a)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x3E0080; //request header code
cmdbuf[1]=appID;
cmdbuf[2]=a;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID)
+Result APT_ReplySleepNotificationComplete(NS_APPID appID)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x3F0040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_PrepareToCloseApplication(Handle* handle, u8 a)
+Result APT_PrepareToCloseApplication(u8 a)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x220040; //request header code
cmdbuf[1]=a;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c)
+Result APT_CloseApplication(u32 a, u32 b, u32 c)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x270044; //request header code
cmdbuf[1]=a;
cmdbuf[5]=c;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
//See http://3dbrew.org/APT:SetApplicationCpuTimeLimit
-Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent)
+Result APT_SetAppCpuTimeLimit(u32 percent)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x4F0080;
cmdbuf[1]=1;
cmdbuf[2]=percent;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent)
+Result APT_GetAppCpuTimeLimit(u32 *percent)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x500040;
cmdbuf[1]=1;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(percent)*percent=cmdbuf[2];
}
// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication
-Result APT_CheckNew3DS_Application(Handle* handle, u8 *out)
+Result APT_CheckNew3DS_Application(u8 *out)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x01010000;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(ret==0)ret = cmdbuf[1];
return ret;
}
-Result APT_CheckNew3DS_System(Handle* handle, u8 *out)
+Result APT_CheckNew3DS_System(u8 *out)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x01020000;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
if(ret==0)ret = cmdbuf[1];
return ret;
}
-Result APT_CheckNew3DS(Handle* handle, u8 *out)
+Result APT_CheckNew3DS(u8 *out)
{
Result ret=0;
}
aptOpenSession();
- ret = APT_CheckNew3DS_System(NULL, out);
+ ret = APT_CheckNew3DS_System(out);
aptCloseSession();
__apt_new3dsflag_initialized = 1;
return ret;
}
-Result APT_PrepareToDoAppJump(Handle* handle, u8 flags, u64 programID, u8 mediatype)
+Result APT_PrepareToDoAppJump(u8 flags, u64 programID, u8 mediatype)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x310100; //request header code
cmdbuf[1]=flags;
cmdbuf[4]=mediatype;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr)
+Result APT_DoAppJump(u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x320084; //request header code
cmdbuf[1]=NSbuf0Size;
cmdbuf[6]=(u32)NSbuf1Ptr;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID)
+Result APT_PrepareToStartLibraryApplet(NS_APPID appID)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x180040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_StartLibraryApplet(Handle* handle, NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize)
+Result APT_StartLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x1E0084; //request header code
cmdbuf[1]=appID;
cmdbuf[6]=(u32)parambuf;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
u8 buf2[4];
aptOpenSession();
- APT_ReplySleepQuery(NULL, currentAppId, 0);
+ APT_ReplySleepQuery(currentAppId, 0);
aptCloseSession();
aptOpenSession();
- ret=APT_PrepareToStartLibraryApplet(NULL, appID);
+ ret=APT_PrepareToStartLibraryApplet(appID);
aptCloseSession();
if(ret!=0)return ret;
memset(buf1, 0, 4);
aptOpenSession();
- APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
+ APT_AppletUtility(NULL, 0x4, 0x1, buf1, 0x1, buf2);
aptCloseSession();
while(1)
{
aptOpenSession();
- ret=APT_IsRegistered(NULL, appID, &tmp);
+ ret=APT_IsRegistered(appID, &tmp);
aptCloseSession();
if(ret!=0)return ret;
// Send capture-screen info to the library applet.
aptOpenSession();
- APT_SendParameter(NULL, currentAppId, appID, 0x20, __ns_capinfo, 0x0, 0x2);
+ APT_SendParameter(currentAppId, appID, 0x20, __ns_capinfo, 0x0, 0x2);
aptCloseSession();
// Release GSP module.
return 0;
}
-Result APT_PrepareToStartSystemApplet(Handle* handle, NS_APPID appID)
+Result APT_PrepareToStartSystemApplet(NS_APPID appID)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=0x00190040; //request header code
cmdbuf[1]=appID;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}
-Result APT_StartSystemApplet(Handle* handle, NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf)
+Result APT_StartSystemApplet(NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf)
{
- if(!handle)handle=&aptuHandle;
-
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0] = 0x001F0084; //request header code
cmdbuf[1] = appID;
cmdbuf[6] = (u32)buf;
Result ret=0;
- if((ret=svcSendSyncRequest(*handle)))return ret;
+ if((ret=svcSendSyncRequest(aptuHandle)))return ret;
return cmdbuf[1];
}