mirror of
https://github.com/switchbrew/libnx.git
synced 2025-08-05 16:09:24 +02:00
Added accountGetPreselectedUser.
This commit is contained in:
parent
41e75d0b7d
commit
f61e9237e6
@ -63,3 +63,7 @@ Result accountProfileGetImageSize(AccountProfile* profile, size_t* image_size);
|
||||
Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, size_t* image_size);
|
||||
|
||||
void accountProfileClose(AccountProfile* profile);
|
||||
|
||||
/// Gets the userID which was selected by the profile-selector applet (if any), prior to launching the currently running Application title. This can only be used once under the current process, under an Application title.
|
||||
Result accountGetPreselectedUser(u128 *userID);
|
||||
|
||||
|
@ -87,6 +87,7 @@ Result appletCreateManagedDisplayLayer(u64 *out);
|
||||
* @param s Output storage.
|
||||
* @param kind See \ref AppletLaunchParameterKind.
|
||||
* @note Can only be used in Applications.
|
||||
* @note See also acc.h \ref accountGetPreselectedUser (wrapper for appletPopLaunchParameter etc).
|
||||
*/
|
||||
Result appletPopLaunchParameter(AppletStorage *s, AppletLaunchParameterKind kind);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "arm/atomics.h"
|
||||
#include "services/acc.h"
|
||||
#include "services/sm.h"
|
||||
#include "services/applet.h"
|
||||
|
||||
static Service g_accSrv;
|
||||
static u64 g_refCnt;
|
||||
@ -325,3 +326,38 @@ void accountProfileClose(AccountProfile* profile) {
|
||||
serviceClose(&profile->s);
|
||||
}
|
||||
|
||||
Result accountGetPreselectedUser(u128 *userID) {
|
||||
Result rc=0;
|
||||
AppletStorage storage;
|
||||
s64 tmpsize=0;
|
||||
|
||||
struct {
|
||||
u32 magicnum;//These two fields must match fixed values.
|
||||
u8 unk_x4;
|
||||
u8 pad[3];
|
||||
u128 userID;
|
||||
u8 unk_x18[0x70];//unused
|
||||
} PACKED storagedata;
|
||||
|
||||
memset(&storagedata, 0, sizeof(storagedata));
|
||||
|
||||
rc = appletPopLaunchParameter(&storage, AppletLaunchParameterKind_PreselectedUser);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
rc = appletStorageGetSize(&storage, &tmpsize);
|
||||
if (R_SUCCEEDED(rc) && tmpsize < sizeof(storagedata))
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
|
||||
if (R_SUCCEEDED(rc)) rc = appletStorageRead(&storage, 0, &storagedata, sizeof(storagedata));
|
||||
|
||||
appletStorageClose(&storage);
|
||||
|
||||
if (R_SUCCEEDED(rc) && (storagedata.magicnum!=0xc79497ca || storagedata.unk_x4!=1))
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||
|
||||
if (R_SUCCEEDED(rc) && userID) *userID = storagedata.userID;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user