1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.HLE.Utilities;
using System.Collections.Generic;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Acc
{
class IAccountService : IpcService
{
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
public IAccountService()
{
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, GetUserCount },
{ 1, GetUserExistence },
{ 2, ListAllUsers },
{ 3, ListOpenUsers },
{ 4, GetLastOpenedUser },
{ 5, GetProfile },
{ 50, IsUserRegistrationRequestPermitted },
{ 51, TrySelectUserWithoutInteraction },
{ 100, InitializeApplicationInfo },
{ 101, GetBaasAccountManagerForApplication }
};
}
// GetUserCount() -> i32
public long GetUserCount(ServiceCtx context)
{
context.ResponseData.Write(context.Device.System.State.GetUserCount());
return 0;
}
// GetUserExistence(nn::account::Uid) -> bool
public long GetUserExistence(ServiceCtx context)
{
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
context.ResponseData.Write(context.Device.System.State.TryGetUser(uuid, out _));
return 0;
}
// ListAllUsers() -> array<nn::account::Uid, 0xa>
public long ListAllUsers(ServiceCtx context)
{
return WriteUserList(context, context.Device.System.State.GetAllUsers());
}
// ListOpenUsers() -> array<nn::account::Uid, 0xa>
public long ListOpenUsers(ServiceCtx context)
{
return WriteUserList(context, context.Device.System.State.GetOpenUsers());
}
private long WriteUserList(ServiceCtx context, IEnumerable<UserProfile> profiles)
{
long outputPosition = context.Request.RecvListBuff[0].Position;
long outputSize = context.Request.RecvListBuff[0].Size;
long offset = 0;
foreach (UserProfile profile in profiles)
{
if ((ulong)offset + 16 > (ulong)outputSize)
{
break;
}
context.Memory.WriteInt64(outputPosition, profile.Uuid.Low);
context.Memory.WriteInt64(outputPosition + 8, profile.Uuid.High);
}
return 0;
}
// GetLastOpenedUser() -> nn::account::Uid
public long GetLastOpenedUser(ServiceCtx context)
{
UserProfile lastOpened = context.Device.System.State.LastOpenUser;
lastOpened.Uuid.Write(context.ResponseData);
return 0;
}
// GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
public long GetProfile(ServiceCtx context)
{
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
if (!context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
{
Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{uuid} not found!");
return MakeError(ErrorModule.Account, AccErr.UserNotFound);
}
MakeObject(context, new IProfile(profile));
return 0;
}
// IsUserRegistrationRequestPermitted(u64, pid) -> bool
public long IsUserRegistrationRequestPermitted(ServiceCtx context)
{
long unknown = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAcc, new { unknown });
context.ResponseData.Write(false);
return 0;
}
// TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
public long TrySelectUserWithoutInteraction(ServiceCtx context)
{
bool unknown = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAcc, new { unknown });
UserProfile profile = context.Device.System.State.LastOpenUser;
profile.Uuid.Write(context.ResponseData);
return 0;
}
// InitializeApplicationInfo(u64, pid)
public long InitializeApplicationInfo(ServiceCtx context)
{
long unknown = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAcc, new { unknown });
return 0;
}
// GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
public long GetBaasAccountManagerForApplication(ServiceCtx context)
{
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
MakeObject(context, new IManagerForApplication(uuid));
return 0;
}
}
}
|