Add APT:ReceiveDeliverArg

This commit is contained in:
Jeffrey Pfau 2016-12-27 18:49:58 -08:00 committed by fincs
parent 66d1f7c957
commit 635d3e6640
2 changed files with 43 additions and 0 deletions

View 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);

View 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;
}