diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 1a1e644..9377c0b 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -67,3 +67,5 @@ 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); diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index bda13b6..d2f65d9 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -743,3 +743,35 @@ Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c) return cmdbuf[1]; } + +//See http://3dbrew.org/APT:SetApplicationCpuTimeLimit +Result APT_SetAppCpuTimeLimit(Handle* handle, 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; + + return cmdbuf[1]; +} + +Result APT_GetAppCpuTimeLimit(Handle* handle, 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(percent)*percent=cmdbuf[2]; + + return cmdbuf[1]; +}