ILibraryAppletCreator.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Kernel.Memory;
  3. using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletCreator;
  4. namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
  5. {
  6. class ILibraryAppletCreator : IpcService
  7. {
  8. public ILibraryAppletCreator() { }
  9. [Command(0)]
  10. // CreateLibraryApplet(u32, u32) -> object<nn::am::service::ILibraryAppletAccessor>
  11. public ResultCode CreateLibraryApplet(ServiceCtx context)
  12. {
  13. AppletId appletId = (AppletId)context.RequestData.ReadInt32();
  14. int libraryAppletMode = context.RequestData.ReadInt32();
  15. MakeObject(context, new ILibraryAppletAccessor(appletId, context.Device.System));
  16. return ResultCode.Success;
  17. }
  18. [Command(10)]
  19. // CreateStorage(u64) -> object<nn::am::service::IStorage>
  20. public ResultCode CreateStorage(ServiceCtx context)
  21. {
  22. long size = context.RequestData.ReadInt64();
  23. MakeObject(context, new IStorage(new byte[size]));
  24. return ResultCode.Success;
  25. }
  26. [Command(11)]
  27. // CreateTransferMemoryStorage(b8, u64, handle<copy>) -> object<nn::am::service::IStorage>
  28. public ResultCode CreateTransferMemoryStorage(ServiceCtx context)
  29. {
  30. bool unknown = context.RequestData.ReadBoolean();
  31. long size = context.RequestData.ReadInt64();
  32. int handle = context.Request.HandleDesc.ToCopy[0];
  33. KTransferMemory transferMem = context.Process.HandleTable.GetObject<KTransferMemory>(handle);
  34. if (transferMem == null)
  35. {
  36. Logger.Warning?.Print(LogClass.ServiceAm, $"Invalid TransferMemory Handle: {handle:X}");
  37. return ResultCode.Success; // TODO: Find correct error code
  38. }
  39. var data = new byte[transferMem.Size];
  40. transferMem.Creator.CpuMemory.Read(transferMem.Address, data);
  41. context.Device.System.KernelContext.Syscall.CloseHandle(handle);
  42. MakeObject(context, new IStorage(data));
  43. return ResultCode.Success;
  44. }
  45. }
  46. }