From 1a6bdc38a99e4a9dff7e91539c8077c20fc55a2a Mon Sep 17 00:00:00 2001 From: profi200 Date: Sat, 7 Mar 2015 18:37:43 +0100 Subject: [PATCH] Implemented functions to start system applets. --- libctru/include/3ds/services/am.h | 2 +- libctru/include/3ds/services/apt.h | 2 ++ libctru/source/services/apt.c | 33 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/libctru/include/3ds/services/am.h b/libctru/include/3ds/services/am.h index 3eb1501..eaf7379 100644 --- a/libctru/include/3ds/services/am.h +++ b/libctru/include/3ds/services/am.h @@ -8,7 +8,7 @@ typedef struct { u64 titleID; - u64 unknown; + u64 size; u16 titleVersion; u8 unknown2[6]; } TitleList; diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 15db7b7..368731c 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -82,4 +82,6 @@ Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0P Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID); Result APT_StartLibraryApplet(Handle* handle, 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); diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index 9560c79..036b097 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -1155,3 +1155,36 @@ Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u return 0; } +Result APT_PrepareToStartSystemApplet(Handle* handle, 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; + + return cmdbuf[1]; +} + +Result APT_StartSystemApplet(Handle* handle, 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[2] = bufSize; + cmdbuf[3] = 0; + cmdbuf[4] = applHandle; + cmdbuf[5] = (bufSize<<14) | 2; + cmdbuf[6] = (u32)buf; + + Result ret=0; + if((ret=svcSendSyncRequest(*handle)))return ret; + + return cmdbuf[1]; +} +