ILibraryAppletCreator.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. context.Memory.Read(transferMem.Address, data);
  41. MakeObject(context, new IStorage(data));
  42. return ResultCode.Success;
  43. }
  44. }
  45. }