IAccountServiceForApplication.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. [CommandHipc(160)] // 13.0.0+
  72. // InitializeApplicationInfo(u64 pid_placeholder, pid)
  73. public ResultCode InitializeApplicationInfo(ServiceCtx context)
  74. {
  75. // NOTE: In call 100, account service use the pid_placeholder instead of the real pid, which is wrong, call 140 fix that.
  76. /*
  77. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
  78. // For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.
  79. if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // ResultCode.InvalidProcessId
  80. {
  81. return ResultCode.InvalidArgument;
  82. }
  83. */
  84. // TODO: Determine where ApplicationLaunchProperty is used.
  85. ApplicationLaunchProperty applicationLaunchProperty = ApplicationLaunchProperty.GetByPid(context);
  86. Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { applicationLaunchProperty.TitleId });
  87. return ResultCode.Success;
  88. }
  89. [CommandHipc(101)]
  90. // GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
  91. public ResultCode GetBaasAccountManagerForApplication(ServiceCtx context)
  92. {
  93. ResultCode resultCode = _applicationServiceServer.CheckUserId(context, out UserId userId);
  94. if (resultCode != ResultCode.Success)
  95. {
  96. return resultCode;
  97. }
  98. MakeObject(context, new IManagerForApplication(userId));
  99. // Doesn't occur in our case.
  100. // return ResultCode.NullObject;
  101. return ResultCode.Success;
  102. }
  103. [CommandHipc(110)]
  104. // StoreSaveDataThumbnail(nn::account::Uid, buffer<bytes, 5>)
  105. public ResultCode StoreSaveDataThumbnail(ServiceCtx context)
  106. {
  107. return _applicationServiceServer.StoreSaveDataThumbnail(context);
  108. }
  109. [CommandHipc(111)]
  110. // ClearSaveDataThumbnail(nn::account::Uid)
  111. public ResultCode ClearSaveDataThumbnail(ServiceCtx context)
  112. {
  113. return _applicationServiceServer.ClearSaveDataThumbnail(context);
  114. }
  115. [CommandHipc(131)] // 6.0.0+
  116. // ListOpenContextStoredUsers() -> array<nn::account::Uid, 0xa>
  117. public ResultCode ListOpenContextStoredUsers(ServiceCtx context)
  118. {
  119. ulong outputPosition = context.Request.RecvListBuff[0].Position;
  120. ulong outputSize = context.Request.RecvListBuff[0].Size;
  121. MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
  122. // TODO: This seems to write stored userids of the OpenContext in the buffer. We needs to determine them.
  123. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  124. return ResultCode.Success;
  125. }
  126. [CommandHipc(141)] // 6.0.0+
  127. // ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
  128. public ResultCode ListQualifiedUsers(ServiceCtx context)
  129. {
  130. return _applicationServiceServer.ListQualifiedUsers(context);
  131. }
  132. [CommandHipc(150)] // 6.0.0+
  133. // IsUserAccountSwitchLocked() -> bool
  134. public ResultCode IsUserAccountSwitchLocked(ServiceCtx context)
  135. {
  136. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationControlProperty() with the current Pid and store the result (NACP file) internally.
  137. // But since we use LibHac and we load one Application at a time, it's not necessary.
  138. context.ResponseData.Write((byte)context.Device.Application.ControlData.Value.UserAccountSwitchLock);
  139. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  140. return ResultCode.Success;
  141. }
  142. }
  143. }