IAccountServiceForApplication.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService;
  3. using Ryujinx.HLE.HOS.Services.Arp;
  4. namespace Ryujinx.HLE.HOS.Services.Account.Acc
  5. {
  6. [Service("acc:u0", AccountServiceFlag.Application)] // Max Sessions: 4
  7. class IAccountServiceForApplication : IpcService
  8. {
  9. private ApplicationServiceServer _applicationServiceServer;
  10. public IAccountServiceForApplication(ServiceCtx context, AccountServiceFlag serviceFlag)
  11. {
  12. _applicationServiceServer = new ApplicationServiceServer(serviceFlag);
  13. }
  14. [CommandHipc(0)]
  15. // GetUserCount() -> i32
  16. public ResultCode GetUserCount(ServiceCtx context)
  17. {
  18. return _applicationServiceServer.GetUserCountImpl(context);
  19. }
  20. [CommandHipc(1)]
  21. // GetUserExistence(nn::account::Uid) -> bool
  22. public ResultCode GetUserExistence(ServiceCtx context)
  23. {
  24. return _applicationServiceServer.GetUserExistenceImpl(context);
  25. }
  26. [CommandHipc(2)]
  27. // ListAllUsers() -> array<nn::account::Uid, 0xa>
  28. public ResultCode ListAllUsers(ServiceCtx context)
  29. {
  30. return _applicationServiceServer.ListAllUsers(context);
  31. }
  32. [CommandHipc(3)]
  33. // ListOpenUsers() -> array<nn::account::Uid, 0xa>
  34. public ResultCode ListOpenUsers(ServiceCtx context)
  35. {
  36. return _applicationServiceServer.ListOpenUsers(context);
  37. }
  38. [CommandHipc(4)]
  39. // GetLastOpenedUser() -> nn::account::Uid
  40. public ResultCode GetLastOpenedUser(ServiceCtx context)
  41. {
  42. return _applicationServiceServer.GetLastOpenedUser(context);
  43. }
  44. [CommandHipc(5)]
  45. // GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
  46. public ResultCode GetProfile(ServiceCtx context)
  47. {
  48. ResultCode resultCode = _applicationServiceServer.GetProfile(context, out IProfile iProfile);
  49. if (resultCode == ResultCode.Success)
  50. {
  51. MakeObject(context, iProfile);
  52. }
  53. return resultCode;
  54. }
  55. [CommandHipc(50)]
  56. // IsUserRegistrationRequestPermitted(pid) -> bool
  57. public ResultCode IsUserRegistrationRequestPermitted(ServiceCtx context)
  58. {
  59. // NOTE: pid is unused.
  60. return _applicationServiceServer.IsUserRegistrationRequestPermitted(context);
  61. }
  62. [CommandHipc(51)]
  63. // TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
  64. public ResultCode TrySelectUserWithoutInteraction(ServiceCtx context)
  65. {
  66. return _applicationServiceServer.TrySelectUserWithoutInteraction(context);
  67. }
  68. [CommandHipc(100)]
  69. [CommandHipc(140)] // 6.0.0+
  70. [CommandHipc(160)] // 13.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(130)] // 5.0.0+
  115. // LoadOpenContext(nn::account::Uid)
  116. public ResultCode LoadOpenContext(ServiceCtx context)
  117. {
  118. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  119. return ResultCode.Success;
  120. }
  121. [CommandHipc(60)] // 5.0.0-5.1.0
  122. [CommandHipc(131)] // 6.0.0+
  123. // ListOpenContextStoredUsers() -> array<nn::account::Uid, 0xa>
  124. public ResultCode ListOpenContextStoredUsers(ServiceCtx context)
  125. {
  126. return _applicationServiceServer.ListOpenContextStoredUsers(context);
  127. }
  128. [CommandHipc(141)] // 6.0.0+
  129. // ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
  130. public ResultCode ListQualifiedUsers(ServiceCtx context)
  131. {
  132. return _applicationServiceServer.ListQualifiedUsers(context);
  133. }
  134. [CommandHipc(150)] // 6.0.0+
  135. // IsUserAccountSwitchLocked() -> bool
  136. public ResultCode IsUserAccountSwitchLocked(ServiceCtx context)
  137. {
  138. // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationControlProperty() with the current Pid and store the result (NACP file) internally.
  139. // But since we use LibHac and we load one Application at a time, it's not necessary.
  140. context.ResponseData.Write((byte)context.Device.Application.ControlData.Value.UserAccountSwitchLock);
  141. Logger.Stub?.PrintStub(LogClass.ServiceAcc);
  142. return ResultCode.Success;
  143. }
  144. }
  145. }