IPurchaseEventManager.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 use 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. }
  41. }