IPurchaseEventManager.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Threading;
  5. using System;
  6. namespace Ryujinx.HLE.HOS.Services.Ns.Aoc
  7. {
  8. class IPurchaseEventManager : IpcService
  9. {
  10. private readonly KEvent _purchasedEvent;
  11. public IPurchaseEventManager(Horizon system)
  12. {
  13. _purchasedEvent = new KEvent(system.KernelContext);
  14. }
  15. [CommandHipc(0)]
  16. // SetDefaultDeliveryTarget(pid, buffer<bytes, 5> unknown)
  17. public ResultCode SetDefaultDeliveryTarget(ServiceCtx context)
  18. {
  19. ulong inBufferPosition = context.Request.SendBuff[0].Position;
  20. ulong inBufferSize = context.Request.SendBuff[0].Size;
  21. byte[] buffer = new byte[inBufferSize];
  22. context.Memory.Read(inBufferPosition, buffer);
  23. // NOTE: Service uses the pid to call arp:r GetApplicationLaunchProperty and store it in internal field.
  24. // Then it seems to use the buffer content and compare it with a stored linked instrusive list.
  25. // Since we don't support purchase from eShop, we can stub it.
  26. Logger.Stub?.PrintStub(LogClass.ServiceNs);
  27. return ResultCode.Success;
  28. }
  29. [CommandHipc(2)]
  30. // GetPurchasedEventReadableHandle() -> handle<copy, event>
  31. public ResultCode GetPurchasedEventReadableHandle(ServiceCtx context)
  32. {
  33. if (context.Process.HandleTable.GenerateHandle(_purchasedEvent.ReadableEvent, out int purchasedEventReadableHandle) != KernelResult.Success)
  34. {
  35. throw new InvalidOperationException("Out of handles!");
  36. }
  37. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(purchasedEventReadableHandle);
  38. return ResultCode.Success;
  39. }
  40. [CommandHipc(3)]
  41. // PopPurchasedProductInfo(nn::ec::detail::PurchasedProductInfo)
  42. public ResultCode PopPurchasedProductInfo(ServiceCtx context)
  43. {
  44. byte[] purchasedProductInfo = new byte[0x80];
  45. context.ResponseData.Write(purchasedProductInfo);
  46. // NOTE: Service finds info using internal array then convert it into nn::ec::detail::PurchasedProductInfo.
  47. // Returns 0x320A4 if the internal array size is null.
  48. // Since we don't support purchase from eShop, we can stub it.
  49. Logger.Debug?.PrintStub(LogClass.ServiceNs); // NOTE: Uses Debug to avoid spamming.
  50. return ResultCode.Success;
  51. }
  52. }
  53. }