libapplet: Added the new 11.0 funcs.

This commit is contained in:
yellows8 2020-12-15 22:10:28 -05:00
parent 55179074cc
commit 06d38571b4
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 56 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#pragma once
#include "../types.h"
#include "../services/applet.h"
#include "../services/acc.h"
/// CommonArguments
typedef struct {
@ -114,3 +115,22 @@ Result libappletRequestHomeMenu(void);
/// Equivalent to entering "System Update" under System Settings. When leaving this, it returns to the main Home Menu.
Result libappletRequestJumpToSystemUpdate(void);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] application_id ApplicationId
* @param[in] uid \ref AccountUid
* @param[in] buffer Input buffer.
* @param[in] size Input buffer size.
* @param[in] sender LaunchApplicationRequestSender
*/
Result libappletRequestToLaunchApplication(u64 application_id, AccountUid uid, const void* buffer, size_t size, u32 sender);
/**
* @brief Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
* @note Only available on [11.0.0+].
* @param[in] uid \ref AccountUid
* @param[in] application_id Optional ApplicationId, can be 0.
*/
Result libappletRequestJumpToStory(AccountUid uid, u64 application_id);

View File

@ -1,6 +1,7 @@
#include <string.h>
#include "libapplet_internal.h"
#include "arm/counter.h"
#include "runtime/hosversion.h"
static bool g_libappletJumpFlag;
@ -171,3 +172,38 @@ Result libappletRequestJumpToSystemUpdate(void) {
return _libappletQlaunchRequest(storagedata, sizeof(storagedata));
}
Result libappletRequestToLaunchApplication(u64 application_id, AccountUid uid, const void* buffer, size_t size, u32 sender) {
if (hosversionBefore(11,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
Result rc=0;
u32 tmp=size;
AppletStorage s={0};
u8 storagedata[0x10] = {0x53, 0x41, 0x4d, 0x53, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
rc = appletCreateStorage(&s, 0x800);
if (R_FAILED(rc)) return rc;
rc = appletStorageWrite(&s, 0, &storagedata, sizeof(storagedata));
if (R_SUCCEEDED(rc)) rc = appletStorageWrite(&s, sizeof(storagedata), &sender, sizeof(sender));
if (R_SUCCEEDED(rc)) rc = appletStorageWrite(&s, sizeof(storagedata)+sizeof(u32), &application_id, sizeof(application_id));
if (R_SUCCEEDED(rc)) rc = appletStorageWrite(&s, sizeof(storagedata)+sizeof(u32)+sizeof(u64), &uid, sizeof(AccountUid));
if (R_SUCCEEDED(rc)) rc = appletStorageWrite(&s, sizeof(storagedata)+sizeof(u32)+sizeof(u64)+sizeof(AccountUid), &tmp, sizeof(tmp));
if (R_SUCCEEDED(rc)) rc = appletStorageWrite(&s, sizeof(storagedata)+sizeof(u32)+sizeof(u64)+sizeof(AccountUid)+sizeof(tmp), buffer, tmp);
if (R_FAILED(rc)) {
appletStorageClose(&s);
return rc;
}
return appletPushToGeneralChannel(&s);
}
Result libappletRequestJumpToStory(AccountUid uid, u64 application_id) {
if (hosversionBefore(11,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
u8 storagedata[0x28] = {0x53, 0x41, 0x4d, 0x53, 0x01, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
memcpy(&storagedata[0x10], &uid, sizeof(uid));
memcpy(&storagedata[0x20], &application_id, sizeof(application_id));
return _libappletQlaunchRequest(storagedata, sizeof(storagedata));
}