mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Use InitializeApplicationInfo in accountInitialize when initializing with acc:u0. Handle cleanup on failure in accountInitialize.
This commit is contained in:
parent
b896b33e3e
commit
c484b33995
@ -5,10 +5,13 @@
|
|||||||
#include "services/acc.h"
|
#include "services/acc.h"
|
||||||
#include "services/sm.h"
|
#include "services/sm.h"
|
||||||
#include "services/applet.h"
|
#include "services/applet.h"
|
||||||
|
#include "runtime/hosversion.h"
|
||||||
|
|
||||||
static Service g_accSrv;
|
static Service g_accSrv;
|
||||||
static u64 g_refCnt;
|
static u64 g_refCnt;
|
||||||
|
|
||||||
|
static Result _accountInitializeApplicationInfo(void);
|
||||||
|
|
||||||
Result accountInitialize(void)
|
Result accountInitialize(void)
|
||||||
{
|
{
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
@ -19,7 +22,12 @@ Result accountInitialize(void)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rc = smGetService(&g_accSrv, "acc:u1");
|
rc = smGetService(&g_accSrv, "acc:u1");
|
||||||
if (R_FAILED(rc)) rc = smGetService(&g_accSrv, "acc:u0");
|
if (R_FAILED(rc)) {
|
||||||
|
rc = smGetService(&g_accSrv, "acc:u0");
|
||||||
|
if (R_SUCCEEDED(rc)) rc = _accountInitializeApplicationInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R_FAILED(rc)) accountExit();
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -34,6 +42,42 @@ Service* accountGetServiceSession(void) {
|
|||||||
return &g_accSrv;
|
return &g_accSrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _accountInitializeApplicationInfo(void) {
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u64 pid_placeholder;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
ipcSendPid(&c);
|
||||||
|
|
||||||
|
raw = serviceIpcPrepareHeader(&g_accSrv, &c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = hosversionBefore(6,0,0) ? 100 : 140;
|
||||||
|
raw->pid_placeholder = 0;
|
||||||
|
|
||||||
|
Result rc = serviceIpcDispatch(&g_accSrv);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
IpcParsedCommand r;
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 result;
|
||||||
|
} *resp;
|
||||||
|
|
||||||
|
serviceIpcParse(&g_accSrv, &r, sizeof(*resp));
|
||||||
|
resp = r.Raw;
|
||||||
|
|
||||||
|
rc = resp->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result accountGetUserCount(s32* user_count)
|
Result accountGetUserCount(s32* user_count)
|
||||||
{
|
{
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
|
Loading…
Reference in New Issue
Block a user