aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Acc
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-08-16 20:47:36 -0300
committerGitHub <noreply@github.com>2018-08-16 20:47:36 -0300
commit521751795a1c97c0d97f6f8904a3be69b13d3a9d (patch)
tree942a05899c40e2de6d92a38b93a494bd96ee64b8 /Ryujinx.HLE/HOS/Services/Acc
parent182d716867ae477c2b15a5332430dc2641fa1cc3 (diff)
Code style fixes and nits on the HLE project (#355)
* Some style fixes and nits on ITimeZoneService * Remove some unneeded usings * Remove the Ryujinx.HLE.OsHle.Handles namespace * Remove hbmenu automatic load on process exit * Rename Ns to Device, rename Os to System, rename SystemState to State * Move Exceptions and Utilities out of OsHle * Rename OsHle to HOS * Rename OsHle folder to HOS * IManagerDisplayService and ISystemDisplayService style fixes * BsdError shouldn't be public * Add a empty new line before using static * Remove unused file * Some style fixes on NPDM * Exit gracefully when the application is closed * Code style fixes on IGeneralService * Add 0x prefix on values printed as hex * Small improvements on finalization code * Move ProcessId and ThreadId out of AThreadState * Rename VFs to FileSystem * FsAccessHeader shouldn't be public. Also fix file names casing * More case changes on NPDM * Remove unused files * Move using to the correct place on NPDM * Use properties on KernelAccessControlMmio * Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Acc')
-rw-r--r--Ryujinx.HLE/HOS/Services/Acc/AccErr.cs7
-rw-r--r--Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs125
-rw-r--r--Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs38
-rw-r--r--Ryujinx.HLE/HOS/Services/Acc/IProfile.cs58
4 files changed, 228 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Acc/AccErr.cs b/Ryujinx.HLE/HOS/Services/Acc/AccErr.cs
new file mode 100644
index 00000000..144d6680
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Acc/AccErr.cs
@@ -0,0 +1,7 @@
+namespace Ryujinx.HLE.HOS.Services.Acc
+{
+ static class AccErr
+ {
+ public const int UserNotFound = 100;
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs b/Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs
new file mode 100644
index 00000000..36dfd9ef
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs
@@ -0,0 +1,125 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.SystemState;
+using Ryujinx.HLE.Logging;
+using System.Collections.Generic;
+
+using static Ryujinx.HLE.HOS.ErrorCode;
+
+namespace Ryujinx.HLE.HOS.Services.Acc
+{
+ class IAccountServiceForApplication : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IAccountServiceForApplication()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, GetUserCount },
+ { 1, GetUserExistence },
+ { 2, ListAllUsers },
+ { 3, ListOpenUsers },
+ { 4, GetLastOpenedUser },
+ { 5, GetProfile },
+ { 100, InitializeApplicationInfo },
+ { 101, GetBaasAccountManagerForApplication }
+ };
+ }
+
+ public long GetUserCount(ServiceCtx Context)
+ {
+ Context.ResponseData.Write(Context.Device.System.State.GetUserCount());
+
+ return 0;
+ }
+
+ public long GetUserExistence(ServiceCtx Context)
+ {
+ UserId Uuid = new UserId(
+ Context.RequestData.ReadInt64(),
+ Context.RequestData.ReadInt64());
+
+ Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _) ? 1 : 0);
+
+ return 0;
+ }
+
+ public long ListAllUsers(ServiceCtx Context)
+ {
+ return WriteUserList(Context, Context.Device.System.State.GetAllUsers());
+ }
+
+ 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;
+ }
+
+ byte[] Uuid = Profile.Uuid.Bytes;
+
+ for (int Index = Uuid.Length - 1; Index >= 0; Index--)
+ {
+ Context.Memory.WriteByte(OutputPosition + Offset++, Uuid[Index]);
+ }
+ }
+
+ return 0;
+ }
+
+ public long GetLastOpenedUser(ServiceCtx Context)
+ {
+ UserProfile LastOpened = Context.Device.System.State.LastOpenUser;
+
+ LastOpened.Uuid.Write(Context.ResponseData);
+
+ return 0;
+ }
+
+ public long GetProfile(ServiceCtx Context)
+ {
+ UserId Uuid = new UserId(
+ Context.RequestData.ReadInt64(),
+ Context.RequestData.ReadInt64());
+
+ if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
+ {
+ Context.Device.Log.PrintWarning(LogClass.ServiceAcc, $"User 0x{Uuid} not found!");
+
+ return MakeError(ErrorModule.Account, AccErr.UserNotFound);
+ }
+
+ MakeObject(Context, new IProfile(Profile));
+
+ return 0;
+ }
+
+ public long InitializeApplicationInfo(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+
+ return 0;
+ }
+
+ public long GetBaasAccountManagerForApplication(ServiceCtx Context)
+ {
+ MakeObject(Context, new IManagerForApplication());
+
+ return 0;
+ }
+ }
+}
diff --git a/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs b/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs
new file mode 100644
index 00000000..813a1b17
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs
@@ -0,0 +1,38 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.Logging;
+using System.Collections.Generic;
+
+namespace Ryujinx.HLE.HOS.Services.Acc
+{
+ class IManagerForApplication : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ public IManagerForApplication()
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, CheckAvailability },
+ { 1, GetAccountId }
+ };
+ }
+
+ public long CheckAvailability(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+
+ return 0;
+ }
+
+ public long GetAccountId(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+
+ Context.ResponseData.Write(0xcafeL);
+
+ return 0;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
new file mode 100644
index 00000000..960cc49c
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
@@ -0,0 +1,58 @@
+using ChocolArm64.Memory;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.SystemState;
+using Ryujinx.HLE.Logging;
+using Ryujinx.HLE.Utilities;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Ryujinx.HLE.HOS.Services.Acc
+{
+ class IProfile : IpcService
+ {
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
+
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+
+ private UserProfile Profile;
+
+ public IProfile(UserProfile Profile)
+ {
+ m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ {
+ { 0, Get },
+ { 1, GetBase }
+ };
+
+ this.Profile = Profile;
+ }
+
+ public long Get(ServiceCtx Context)
+ {
+ Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+
+ long Position = Context.Request.ReceiveBuff[0].Position;
+
+ AMemoryHelper.FillWithZeros(Context.Memory, Position, 0x80);
+
+ Context.Memory.WriteInt32(Position, 0);
+ Context.Memory.WriteInt32(Position + 4, 1);
+ Context.Memory.WriteInt64(Position + 8, 1);
+
+ return GetBase(Context);
+ }
+
+ public long GetBase(ServiceCtx Context)
+ {
+ Profile.Uuid.Write(Context.ResponseData);
+
+ Context.ResponseData.Write(Profile.LastModifiedTimestamp);
+
+ byte[] Username = StringUtils.GetFixedLengthBytes(Profile.Name, 0x20, Encoding.UTF8);
+
+ Context.ResponseData.Write(Username);
+
+ return 0;
+ }
+ }
+} \ No newline at end of file