IServiceCreator.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using LibHac;
  2. using LibHac.Common;
  3. using Ryujinx.Common;
  4. using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator;
  5. using Ryujinx.HLE.HOS.Services.Arp;
  6. namespace Ryujinx.HLE.HOS.Services.Bcat
  7. {
  8. [Service("bcat:a", "bcat:a")]
  9. [Service("bcat:m", "bcat:m")]
  10. [Service("bcat:u", "bcat:u")]
  11. [Service("bcat:s", "bcat:s")]
  12. class IServiceCreator : DisposableIpcService
  13. {
  14. private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _base;
  15. public IServiceCreator(ServiceCtx context, string serviceName)
  16. {
  17. var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
  18. applicationClient.Sm.GetService(ref _base, serviceName).ThrowIfFailure();
  19. }
  20. protected override void Dispose(bool isDisposing)
  21. {
  22. if (isDisposing)
  23. {
  24. _base.Destroy();
  25. }
  26. }
  27. [CommandHipc(0)]
  28. // CreateBcatService(pid) -> object<nn::bcat::detail::ipc::IBcatService>
  29. public ResultCode CreateBcatService(ServiceCtx context)
  30. {
  31. // TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
  32. // Add an instance of nn::bcat::detail::service::core::PassphraseManager.
  33. // Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
  34. // Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin".
  35. // If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400.
  36. MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context)));
  37. // NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
  38. // return ResultCode.NullObject;
  39. return ResultCode.Success;
  40. }
  41. [CommandHipc(1)]
  42. // CreateDeliveryCacheStorageService(pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
  43. public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
  44. {
  45. ulong pid = context.RequestData.ReadUInt64();
  46. using var serv = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
  47. Result rc = _base.Get.CreateDeliveryCacheStorageService(ref serv.Ref(), pid);
  48. if (rc.IsSuccess())
  49. {
  50. MakeObject(context, new IDeliveryCacheStorageService(context, ref serv.Ref()));
  51. }
  52. return (ResultCode)rc.Value;
  53. }
  54. [CommandHipc(2)]
  55. // CreateDeliveryCacheStorageServiceWithApplicationId(nn::ApplicationId) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
  56. public ResultCode CreateDeliveryCacheStorageServiceWithApplicationId(ServiceCtx context)
  57. {
  58. ApplicationId applicationId = context.RequestData.ReadStruct<ApplicationId>();
  59. using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
  60. Result rc = _base.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref service.Ref(), applicationId);
  61. if (rc.IsSuccess())
  62. {
  63. MakeObject(context, new IDeliveryCacheStorageService(context, ref service.Ref()));
  64. }
  65. return (ResultCode)rc.Value;
  66. }
  67. }
  68. }