IServiceForApplication.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.Cpu;
  4. using Ryujinx.HLE.HOS.Services.Account.Acc;
  5. namespace Ryujinx.HLE.HOS.Services.Mnpp
  6. {
  7. [Service("mnpp:app")] // 13.0.0+
  8. class IServiceForApplication : IpcService
  9. {
  10. public IServiceForApplication(ServiceCtx context) { }
  11. [CommandHipc(0)]
  12. // Initialize(pid)
  13. public ResultCode Initialize(ServiceCtx context)
  14. {
  15. // Pid placeholder
  16. context.RequestData.ReadInt64();
  17. ulong pid = context.Request.HandleDesc.PId;
  18. // TODO: Service calls set:sys GetPlatformRegion.
  19. // If the result == 1 (China) it calls arp:r GetApplicationInstanceId and GetApplicationLaunchProperty to get the title id and store it internally.
  20. // If not, it does nothing.
  21. Logger.Stub?.PrintStub(LogClass.ServiceMnpp, new { pid });
  22. return ResultCode.Success;
  23. }
  24. [CommandHipc(1)]
  25. // SendRawTelemetryData(nn::account::Uid user_id, buffer<bytes, 5> title_id)
  26. public ResultCode SendRawTelemetryData(ServiceCtx context)
  27. {
  28. ulong titleIdInputPosition = context.Request.SendBuff[0].Position;
  29. ulong titleIdInputSize = context.Request.SendBuff[0].Size;
  30. UserId userId = context.RequestData.ReadStruct<UserId>();
  31. // TODO: Service calls set:sys GetPlatformRegion.
  32. // If the result != 1 (China) it returns ResultCode.Success.
  33. if (userId.IsNull)
  34. {
  35. return ResultCode.InvalidArgument;
  36. }
  37. if (titleIdInputSize <= 64)
  38. {
  39. string titleId = MemoryHelper.ReadAsciiString(context.Memory, titleIdInputPosition, (long)titleIdInputSize);
  40. // TODO: The service stores the titleId internally and seems proceed to some telemetry for China, which is not needed here.
  41. Logger.Stub?.PrintStub(LogClass.ServiceMnpp, new { userId, titleId });
  42. return ResultCode.Success;
  43. }
  44. Logger.Stub?.PrintStub(LogClass.ServiceMnpp, new { userId });
  45. return ResultCode.InvalidBufferSize;
  46. }
  47. }
  48. }