From 44dbc21d18f1ee534c9ac3cf00466ed56c7b0983 Mon Sep 17 00:00:00 2001 From: profi200 Date: Fri, 5 Sep 2014 04:01:51 +0200 Subject: [PATCH] Fixed the broken code for sysCore usage --- libctru/include/3ds/services/apt.h | 4 ++-- libctru/source/services/apt.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 9377c0b..b9b8794 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -67,5 +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); +Result APT_SetAppCpuTimeLimit(u32 percent); +Result APT_GetAppCpuTimeLimit(u32 *percent); diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index d2f65d9..0028424 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -745,9 +745,9 @@ Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c) } //See http://3dbrew.org/APT:SetApplicationCpuTimeLimit -Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent) +Result APT_SetAppCpuTimeLimit(u32 percent) { - if(!handle)handle=&aptuHandle; + aptOpenSession(); u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=0x4F0080; @@ -755,23 +755,33 @@ Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent) cmdbuf[2]=percent; Result ret=0; - if((ret=svcSendSyncRequest(*handle)))return ret; + if((ret=svcSendSyncRequest(aptuHandle))) + { + aptCloseSession(); + return ret; + } + aptCloseSession(); return cmdbuf[1]; } -Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent) +Result APT_GetAppCpuTimeLimit(u32 *percent) { - if(!handle)handle=&aptuHandle; + aptOpenSession(); u32* cmdbuf=getThreadCommandBuffer(); cmdbuf[0]=0x500040; cmdbuf[1]=1; Result ret=0; - if((ret=svcSendSyncRequest(*handle)))return ret; + if((ret=svcSendSyncRequest(aptuHandle))) + { + aptCloseSession(); + return ret; + } if(percent)*percent=cmdbuf[2]; + aptCloseSession(); return cmdbuf[1]; }