]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add APT:ReceiveDeliverArg
authorJeffrey Pfau <jeffrey@endrift.com>
Wed, 28 Dec 2016 02:49:58 +0000 (18:49 -0800)
committerfincs <fincs.alt1@gmail.com>
Thu, 29 Dec 2016 18:28:59 +0000 (19:28 +0100)
libctru/include/3ds/services/apt.h
libctru/source/services/apt.c

index 1dad9de30d721bc5f02bc8e9486718ed33c27620..e8026d54ccb59d730c39b145b40e0c50a7b6d72e 100644 (file)
@@ -497,3 +497,13 @@ Result APT_StartSystemApplet(NS_APPID appID, const void* param, size_t paramSize
  * @brief mapAddr Pointer to write the mapping address of the system font memory block to.
  */
 Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr);
+
+/**
+ * @brief Receives the deliver (launch) argument
+ * @param param Parameter buffer.
+ * @param paramSize Size of parameter buffer.
+ * @param hmac HMAC buffer (should be 0x20 bytes long).
+ * @param sender Pointer to output the sender's AppID to.
+ * @param received Pointer to output whether an argument was received to.
+ */
+Result APT_ReceiveDeliverArg(const void* param, size_t paramSize, const void* hmac, u64* sender, bool* received);
index b7b9163e388e6492578a7eaa256044f841c02d1f..c7088f6bdf8bff8245719d42ea5b8e2b519bdf86 100644 (file)
@@ -1079,3 +1079,36 @@ Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr)
 
        return ret;
 }
+
+Result APT_ReceiveDeliverArg(const void* param, size_t paramSize, const void* hmac, u64* sender, bool* received)
+{
+       u32 cmdbuf[16];
+       cmdbuf[0]=IPC_MakeHeader(0x35,2,0); // 0x350080
+       cmdbuf[1]=paramSize;
+       cmdbuf[2]=hmac ? 0x20 : 0;
+
+       u32 saved_threadstorage[4];
+       u32* staticbufs = getThreadStaticBuffers();
+       saved_threadstorage[0]=staticbufs[0];
+       saved_threadstorage[1]=staticbufs[1];
+       saved_threadstorage[2]=staticbufs[2];
+       saved_threadstorage[3]=staticbufs[3];
+       staticbufs[0]=IPC_Desc_StaticBuffer(cmdbuf[1],0);
+       staticbufs[1]=(u32)param;
+       staticbufs[2]=IPC_Desc_StaticBuffer(cmdbuf[2],2);
+       staticbufs[3]=(u32)hmac;
+
+       Result ret = aptSendCommand(cmdbuf);
+       staticbufs[0]=saved_threadstorage[0];
+       staticbufs[1]=saved_threadstorage[1];
+       staticbufs[2]=saved_threadstorage[2];
+       staticbufs[3]=saved_threadstorage[3];
+
+       if (R_SUCCEEDED(ret))
+       {
+               if (sender)     *sender    =cmdbuf[2] | ((u64)cmdbuf[3]<<32);
+               if (received)   *received  =cmdbuf[4] & 0xFF;
+       }
+
+       return ret;
+}