IAccountServiceForApplication.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.Cpu;
  3. using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService;
  4. using Ryujinx.HLE.HOS.Services.Arp;
  5. namespace Ryujinx.HLE.HOS.Services.Account.Acc
  6. {
  7. [Service("acc:u0", AccountServiceFlag.Application)] // Max Sessions: 4
  8. class IAccountServiceForApplication : IpcService
  9. {
  10. private ApplicationServiceServer _applicationServiceServer;
  11. public IAccountServiceForApplication(ServiceCtx context, AccountServiceFlag serviceFlag)
  12. {
  13. _applicationServiceServer = new ApplicationServiceServer(serviceFlag);
  14. }
  15. [CommandHipc(0)]
  16. // GetUserCount() -> i32
  17. public ResultCode GetUserCount(ServiceCtx context)
  18. {
  19. return _applicationServiceServer.GetUserCountImpl(context);
  20. }
  21. [CommandHipc(1)]
  22. // GetUserExistence(nn::account::Uid) -> bool
  23. public ResultCode GetUserExistence(ServiceCtx context)
  24. {
  25. return _applicationServiceServer.GetUserExistenceImpl(context);
  26. }
  27. [CommandHipc(2)]
  28. // ListAllUsers() -> array<nn::account::Uid, 0xa>
  29. public ResultCode ListAllUsers(ServiceCtx context)
  30. {
  31. return _applicationServiceServer.ListAllUsers(context);
  32. }
  33. [CommandHipc(3)]
  34. // ListOpenUsers() -> array<nn::account::Uid, 0xa>
  35. public ResultCode ListOpenUsers(ServiceCtx context)
  36. {
  37. return _applicationServiceServer.ListOpenUsers(context);
  38. }
  39. [CommandHipc(4)]
  40. // GetLastOpenedUser() -> nn::account::Uid
  41. public ResultCode GetLastOpenedUser(ServiceCtx context)
  42. {
  43. return _applicationServiceServer.GetLastOpenedUser(context);
  44. }
  45. [CommandHipc(5)]
  46. // GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
  47. public ResultCode GetProfile(ServiceCtx context)
  48. {
  49. ResultCode resultCode = _applicationServiceServer.GetProfile(context, out IProfile iProfile);
  50. if (resultCode == ResultCode.Success)
  51. {
  52. MakeObject(context, iProfile);
  53. }
  54. return resultCode;
  55. }
  56. [CommandHipc(50)]
  57. // IsUserRegistrationRequestPermitted(pid) -> bool
  58. public ResultCode IsUserRegistrationRequestPermitted(ServiceCtx context)
  59. {
  60. // NOTE: pid is unused.
  61. return _applicationServiceServer.IsUserRegistrationRequestPermitted(context);
  62. }
  63. [CommandHipc(51)]
  64. // TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
  65. public ResultCode TrySelectUserWithoutInteraction(ServiceCtx context)
  66. {
  67. return _applicationServiceServer.TrySelectUserWithoutInteraction(context);
  68. }
  69. [CommandHipc(100)]
  70. [CommandHipc(140)] // 6.0.0+
  71. // InitializeApplicationInfo(u64 pid_placeholder, pid)
  72. public ResultCode InitializeApplicationInfo(ServiceCtx context)
  73. {
  74. // NOTE: In call 100, account service use the pid_placeholder instead of the real pid, which is wrong, call 140 fix that.
  75. /*
  76. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
  77. // For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.
  78. if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // ResultCode.InvalidProcessId
  79. {
  80. return ResultCode.InvalidArgument;
  81. }
  82. */
  83. // TODO: Determine where ApplicationLaunchProperty is used.
  84. ApplicationLaunchProperty applicationLaunchProperty = ApplicationLaunchProperty.GetByPid(context);
  85. Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { applicationLaunchProperty.TitleId });
  86. return ResultCode.Success;
  87. }
  88. [CommandHipc(101)]
  89. // GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
  90. public ResultCode GetBaasAccountManagerForApplication(ServiceCtx context)
  91. {
  92. ResultCode resultCode = _applicationServiceServer.CheckUserId(context, out UserId userId);
  93. if (resultCode != ResultCode.Success)
  94. {
  95. return resultCode;
  96. }
  97. MakeObject(context, new IManagerForApplication(userId));
  98. // Doesn't occur in our case.
  99. // return ResultCode.NullObject;
  100. return ResultCode.Success;
  101. }
  102. [CommandHipc(110)]
  103. // StoreSaveDataThumbnail(nn::account::Uid, buffer<bytes, 5>)
  104. public ResultCode StoreSaveDataThumbnail(ServiceCtx context)
  105. {
  106. return _applicationServiceServer.StoreSaveDataThumbnail(context);
  107. }
  108. [CommandHipc(111)]
  109. // ClearSaveDataThumbnail(nn::account::Uid)
  110. public ResultCode ClearSaveDataThumbnail(ServiceCtx context)
  111. {
  112. return _applicationServiceServer.ClearSaveDataThumbnail(context);
  113. }
  114. [CommandHipc(131)] // 6.0.0+
  115. // ListOpenContextStoredUsers() -> array<nn::account::Uid, 0xa>
  116. public ResultCode ListOpenContextStoredUsers(ServiceCtx context)
  117. {
  118. ulong outputPosition = context.Request.RecvListBuff[0].Position;
  119. ulong outputSize = context.Request.RecvListBuff[0].Size;
  120. MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
  121. // TODO: This seems to write stored userids of the OpenContext in the buffer. We needs to determine them.
  122. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  123. return ResultCode.Success;
  124. }
  125. [CommandHipc(141)] // 6.0.0+
  126. // ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
  127. public ResultCode ListQualifiedUsers(ServiceCtx context)
  128. {
  129. return _applicationServiceServer.ListQualifiedUsers(context);
  130. }
  131. [CommandHipc(150)] // 6.0.0+
  132. // IsUserAccountSwitchLocked() -> bool
  133. public ResultCode IsUserAccountSwitchLocked(ServiceCtx context)
  134. {
  135. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationControlProperty() with the current Pid and store the result (NACP file) internally.
  136. // But since we use LibHac and we load one Application at a time, it's not necessary.
  137. context.ResponseData.Write(context.Device.Application.ControlData.Value.UserAccountSwitchLock);
  138. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  139. return ResultCode.Success;
  140. }
  141. }
  142. }