IAppletResource.cs 877 B

12345678910111213141516171819202122232425262728293031
  1. using Ryujinx.HLE.HOS.Ipc;
  2. using Ryujinx.HLE.HOS.Kernel.Common;
  3. using Ryujinx.HLE.HOS.Kernel.Memory;
  4. using System;
  5. namespace Ryujinx.HLE.HOS.Services.Hid.HidServer
  6. {
  7. class IAppletResource : IpcService
  8. {
  9. private KSharedMemory _hidSharedMem;
  10. public IAppletResource(KSharedMemory hidSharedMem)
  11. {
  12. _hidSharedMem = hidSharedMem;
  13. }
  14. [Command(0)]
  15. // GetSharedMemoryHandle() -> handle<copy>
  16. public ResultCode GetSharedMemoryHandle(ServiceCtx context)
  17. {
  18. if (context.Process.HandleTable.GenerateHandle(_hidSharedMem, out int handle) != KernelResult.Success)
  19. {
  20. throw new InvalidOperationException("Out of handles!");
  21. }
  22. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  23. return ResultCode.Success;
  24. }
  25. }
  26. }