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