UserService.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Ryujinx.Horizon.Common;
  2. using Ryujinx.Horizon.Sdk.Sf;
  3. using Ryujinx.Horizon.Sdk.Sm;
  4. using Ryujinx.Horizon.Sm.Impl;
  5. namespace Ryujinx.Horizon.Sm.Ipc
  6. {
  7. partial class UserService : IUserService
  8. {
  9. private readonly ServiceManager _serviceManager;
  10. private ulong _clientProcessId;
  11. private bool _initialized;
  12. public UserService(ServiceManager serviceManager)
  13. {
  14. _serviceManager = serviceManager;
  15. }
  16. [CmifCommand(0)]
  17. public Result Initialize([ClientProcessId] ulong clientProcessId)
  18. {
  19. _clientProcessId = clientProcessId;
  20. _initialized = true;
  21. return Result.Success;
  22. }
  23. [CmifCommand(1)]
  24. public Result GetService([MoveHandle] out int handle, ServiceName name)
  25. {
  26. if (!_initialized)
  27. {
  28. handle = 0;
  29. return SmResult.InvalidClient;
  30. }
  31. return _serviceManager.GetService(out handle, _clientProcessId, name);
  32. }
  33. [CmifCommand(2)]
  34. public Result RegisterService([MoveHandle] out int handle, ServiceName name, int maxSessions, bool isLight)
  35. {
  36. if (!_initialized)
  37. {
  38. handle = 0;
  39. return SmResult.InvalidClient;
  40. }
  41. return _serviceManager.RegisterService(out handle, _clientProcessId, name, maxSessions, isLight);
  42. }
  43. [CmifCommand(3)]
  44. public Result UnregisterService(ServiceName name)
  45. {
  46. if (!_initialized)
  47. {
  48. return SmResult.InvalidClient;
  49. }
  50. return _serviceManager.UnregisterService(_clientProcessId, name);
  51. }
  52. }
  53. }