From 1fd5cf2b4a6f592cc8df945e540ea523a799bb97 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 27 Sep 2022 21:24:52 -0300 Subject: [PATCH] Fix ListOpenContextStoredUsers and stub LoadOpenContext (#3718) * Fix ListOpenContextStoredUsers and stub LoadOpenContext * Remove nonsensical comment --- .../Services/Account/Acc/AccountManager.cs | 18 ++++++++++++--- .../Acc/AccountService/ManagerServer.cs | 2 +- .../Account/Acc/ApplicationServiceServer.cs | 5 +++++ .../Acc/IAccountServiceForApplication.cs | 22 +++++++++---------- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs index 9d9cb6ff88..41d5028fbf 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs @@ -22,7 +22,8 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc // outside of the AccountManager. private readonly HorizonClient _horizonClient; - private ConcurrentDictionary _profiles; + private readonly ConcurrentDictionary _profiles; + private UserProfile[] _storedOpenedUsers; public UserProfile LastOpenedUser { get; private set; } @@ -31,6 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc _horizonClient = horizonClient; _profiles = new ConcurrentDictionary(); + _storedOpenedUsers = Array.Empty(); _accountSaveDataManager = new AccountSaveDataManager(_profiles); @@ -44,9 +46,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc } else { - UserId commandLineUserProfileOverride = default; + UserId commandLineUserProfileOverride = default; if (!string.IsNullOrEmpty(initialProfileName)) - { + { commandLineUserProfileOverride = _profiles.Values.FirstOrDefault(x => x.Name == initialProfileName)?.UserId ?? default; if (commandLineUserProfileOverride.IsNull) Logger.Warning?.Print(LogClass.Application, $"The command line specified profile named '{initialProfileName}' was not found"); @@ -221,6 +223,16 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc return _profiles.Values.Where(x => x.AccountState == AccountState.Open); } + internal IEnumerable GetStoredOpenedUsers() + { + return _storedOpenedUsers; + } + + internal void StoreOpenedUsers() + { + _storedOpenedUsers = _profiles.Values.Where(x => x.AccountState == AccountState.Open).ToArray(); + } + internal UserProfile GetFirst() { return _profiles.First().Value; diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs index d74f5ecf2e..011accd28b 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs @@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService public ResultCode StoreOpenContext(ServiceCtx context) { - Logger.Stub?.PrintStub(LogClass.ServiceAcc); + context.Device.System.AccountManager.StoreOpenedUsers(); return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs index aa6873604d..7b474f0e7f 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/ApplicationServiceServer.cs @@ -201,6 +201,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc return ResultCode.Success; } + public ResultCode ListOpenContextStoredUsers(ServiceCtx context) + { + return WriteUserList(context, context.Device.System.AccountManager.GetStoredOpenedUsers()); + } + public ResultCode ListQualifiedUsers(ServiceCtx context) { // TODO: Determine how users are "qualified". We assume all users are "qualified" for now. diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs index 4de0b34bbb..9208232299 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/IAccountServiceForApplication.cs @@ -1,5 +1,4 @@ using Ryujinx.Common.Logging; -using Ryujinx.Cpu; using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService; using Ryujinx.HLE.HOS.Services.Arp; @@ -139,20 +138,21 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc return _applicationServiceServer.ClearSaveDataThumbnail(context); } + [CommandHipc(130)] // 5.0.0+ + // LoadOpenContext(nn::account::Uid) + public ResultCode LoadOpenContext(ServiceCtx context) + { + Logger.Stub?.PrintStub(LogClass.ServiceAcc); + + return ResultCode.Success; + } + + [CommandHipc(60)] // 5.0.0-5.1.0 [CommandHipc(131)] // 6.0.0+ // ListOpenContextStoredUsers() -> array public ResultCode ListOpenContextStoredUsers(ServiceCtx context) { - ulong outputPosition = context.Request.RecvListBuff[0].Position; - ulong outputSize = context.Request.RecvListBuff[0].Size; - - MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize); - - // TODO: This seems to write stored userids of the OpenContext in the buffer. We needs to determine them. - - Logger.Stub?.PrintStub(LogClass.ServiceAcc); - - return ResultCode.Success; + return _applicationServiceServer.ListOpenContextStoredUsers(context); } [CommandHipc(141)] // 6.0.0+