IPurchaseEventManager.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.HLE.HOS.Ipc;
  4. using Ryujinx.HLE.HOS.Kernel.Common;
  5. using Ryujinx.HLE.HOS.Kernel.Threading;
  6. using System;
  7. namespace Ryujinx.HLE.HOS.Services.Ns
  8. {
  9. class IPurchaseEventManager : IpcService
  10. {
  11. private readonly KEvent _purchasedEvent;
  12. public IPurchaseEventManager(Horizon system)
  13. {
  14. _purchasedEvent = new KEvent(system.KernelContext);
  15. }
  16. [Command(0)]
  17. // SetDefaultDeliveryTarget(pid, buffer<bytes, 5> unknown)
  18. public ResultCode SetDefaultDeliveryTarget(ServiceCtx context)
  19. {
  20. long inBufferPosition = context.Request.SendBuff[0].Position;
  21. long inBufferSize = context.Request.SendBuff[0].Size;
  22. byte[] buffer = new byte[inBufferSize];
  23. context.Memory.Read((ulong)inBufferPosition, buffer);
  24. // NOTE: Service use the pid to call arp:r GetApplicationLaunchProperty and store it in internal field.
  25. // Then it seems to use the buffer content and compare it with a stored linked instrusive list.
  26. // Since we don't support purchase from eShop, we can stub it.
  27. Logger.Stub?.PrintStub(LogClass.ServiceNs);
  28. return ResultCode.Success;
  29. }
  30. [Command(2)]
  31. // GetPurchasedEventReadableHandle() -> handle<copy, event>
  32. public ResultCode GetPurchasedEventReadableHandle(ServiceCtx context)
  33. {
  34. if (context.Process.HandleTable.GenerateHandle(_purchasedEvent.ReadableEvent, out int handle) != KernelResult.Success)
  35. {
  36. throw new InvalidOperationException("Out of handles!");
  37. }
  38. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  39. return ResultCode.Success;
  40. }
  41. }
  42. }