IAppletResource.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel.Common;
  3. using Ryujinx.HLE.HOS.Kernel.Memory;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.HLE.HOS.Services.Hid
  7. {
  8. class IAppletResource : IpcService
  9. {
  10. private Dictionary<int, ServiceProcessRequest> _commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  12. private KSharedMemory _hidSharedMem;
  13. public IAppletResource(KSharedMemory hidSharedMem)
  14. {
  15. _commands = new Dictionary<int, ServiceProcessRequest>
  16. {
  17. { 0, GetSharedMemoryHandle }
  18. };
  19. _hidSharedMem = hidSharedMem;
  20. }
  21. public long GetSharedMemoryHandle(ServiceCtx context)
  22. {
  23. if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success)
  24. {
  25. throw new InvalidOperationException("Out of handles!");
  26. }
  27. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  28. return 0;
  29. }
  30. }
  31. }