From 520332e49e36d5381de6eb059f7ead03f7658892 Mon Sep 17 00:00:00 2001 From: smea Date: Sun, 27 Sep 2015 21:34:47 -0700 Subject: [PATCH 1/6] Update apt.h --- libctru/include/3ds/services/apt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 56ae418..9035b08 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -97,7 +97,7 @@ 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_GetAppletInfo(Handle* handle, NS_APPID appID); +Result APT_GetAppletInfo(Handle* handle, NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes); Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion); Result APT_PrepareToJumpToHomeMenu(Handle* handle); Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c); From 2dc74a81ab7e7171fe4cff897de299d484330b9a Mon Sep 17 00:00:00 2001 From: suloku Date: Thu, 1 Oct 2015 17:18:17 +0200 Subject: [PATCH 2/6] Update apt.h --- libctru/include/3ds/services/apt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 9035b08..4378299 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -99,6 +99,7 @@ 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_GetAppletInfo(Handle* handle, NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes); Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion); +Result APT_GetProgramID(Handle* handle, u64* pProgramID); Result APT_PrepareToJumpToHomeMenu(Handle* handle); Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c); Result APT_PrepareToJumpToApplication(Handle* handle, u32 a); From 76e3cb0721f3beffe6ee0ea2307e2a0e78e8dc87 Mon Sep 17 00:00:00 2001 From: suloku Date: Thu, 1 Oct 2015 17:19:13 +0200 Subject: [PATCH 3/6] Implement APT_GetProgramID --- libctru/source/services/apt.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index 1d01d4d..2b3c97b 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -833,6 +833,28 @@ Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titlever return cmdbuf[1]; } +Result APT_GetProgramID(Handle* handle, u64* pProgramID) +{ + if(!handle)handle=&aptuHandle; + + u32* cmdbuf=getThreadCommandBuffer(); + cmdbuf[0] = 0x00580002; //request header code + cmdbuf[1] = 0x20; + + Result ret=0; + if((ret=svcSendSyncRequest(*handle)))return ret; + + if(ret==0)ret = cmdbuf[1]; + + if(pProgramID) + { + *pProgramID = 0; + if(ret==0) *pProgramID=((u64)cmdbuf[3]<<32)|cmdbuf[2]; + } + + return ret; +} + Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out) { if(!handle)handle=&aptuHandle; From b6817008acac521c0085d7e8d095fa826c260c8e Mon Sep 17 00:00:00 2001 From: suloku Date: Thu, 1 Oct 2015 19:01:31 +0200 Subject: [PATCH 4/6] Update apt.c --- libctru/source/services/apt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index 2b3c97b..95283bd 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -848,7 +848,6 @@ Result APT_GetProgramID(Handle* handle, u64* pProgramID) if(pProgramID) { - *pProgramID = 0; if(ret==0) *pProgramID=((u64)cmdbuf[3]<<32)|cmdbuf[2]; } From 87b9d1302aebd43e0128dbf09296c8992a72c5ae Mon Sep 17 00:00:00 2001 From: smea Date: Fri, 2 Oct 2015 23:05:30 -0700 Subject: [PATCH 5/6] Added FSUSER_GetMediaType --- libctru/include/3ds/services/fs.h | 1 + libctru/source/services/fs.c | 43 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/libctru/include/3ds/services/fs.h b/libctru/include/3ds/services/fs.h index 2f7b4dd..acac55a 100644 --- a/libctru/include/3ds/services/fs.h +++ b/libctru/include/3ds/services/fs.h @@ -150,6 +150,7 @@ Result FSUSER_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clust Result FSUSER_GetNandArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters); Result FSUSER_IsSdmcDetected(Handle *handle, u8 *detected); Result FSUSER_IsSdmcWritable(Handle *handle, u8 *writable); +Result FSUSER_GetMediaType(Handle *handle, u8* mediatype); Result FSFILE_Close(Handle handle); Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size); diff --git a/libctru/source/services/fs.c b/libctru/source/services/fs.c index 157583e..8043fcd 100644 --- a/libctru/source/services/fs.c +++ b/libctru/source/services/fs.c @@ -1051,6 +1051,49 @@ FSUSER_IsSdmcDetected(Handle *handle, return cmdbuf[1]; } +/*! Close an open file + * + * @param[in] handle fs:USER handle + * @param[out] mediatype Output curent process mediatype + * + * @returns error + * + * @internal + * + * #### Request + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code [0x08680000] + * + * #### Response + * + * Index Word | Description + * -----------|------------------------- + * 0 | Header code + * 1 | Result code + */ +Result +FSUSER_GetMediaType(Handle *handle, + u8* mediatype) +{ + if(!handle) + handle = &fsuHandle; + + u32* cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = 0x08680000; + + Result ret = 0; + if((ret = svcSendSyncRequest(*handle))) + return ret; + + if(mediatype) + *mediatype = cmdbuf[2]; + + return cmdbuf[1]; +} + /*! Check if SD card is writable * * @param[in] handle fs:USER handle From c765e3b559f1b38012e3fd4e98d3d450f64aba3d Mon Sep 17 00:00:00 2001 From: smea Date: Fri, 2 Oct 2015 23:10:38 -0700 Subject: [PATCH 6/6] Update fs.c --- libctru/source/services/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libctru/source/services/fs.c b/libctru/source/services/fs.c index 8043fcd..04f93ad 100644 --- a/libctru/source/services/fs.c +++ b/libctru/source/services/fs.c @@ -1051,7 +1051,7 @@ FSUSER_IsSdmcDetected(Handle *handle, return cmdbuf[1]; } -/*! Close an open file +/*! Get curent process mediatype * * @param[in] handle fs:USER handle * @param[out] mediatype Output curent process mediatype