2020-03-24 16:26:37 -06:00
|
|
|
using MsgPack;
|
2020-01-30 09:39:05 -07:00
|
|
|
using MsgPack.Serialization;
|
2020-02-01 20:24:17 -07:00
|
|
|
using Ryujinx.Common;
|
2018-10-17 11:15:50 -06:00
|
|
|
using Ryujinx.Common.Logging;
|
2020-03-25 15:33:18 -06:00
|
|
|
using Ryujinx.Common.Utilities;
|
2020-02-01 20:24:17 -07:00
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
2019-11-24 16:45:54 -07:00
|
|
|
using Ryujinx.HLE.Utilities;
|
|
|
|
using System.Text;
|
2018-04-21 17:04:43 -06:00
|
|
|
|
2018-08-16 17:47:36 -06:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Prepo
|
2018-04-21 17:04:43 -06:00
|
|
|
{
|
2019-07-10 09:59:54 -06:00
|
|
|
[Service("prepo:a")]
|
2019-09-18 18:45:11 -06:00
|
|
|
[Service("prepo:a2")]
|
2019-07-10 09:59:54 -06:00
|
|
|
[Service("prepo:u")]
|
2018-04-21 17:04:43 -06:00
|
|
|
class IPrepoService : IpcService
|
|
|
|
{
|
2019-07-11 19:13:43 -06:00
|
|
|
public IPrepoService(ServiceCtx context) { }
|
2018-05-17 12:25:42 -06:00
|
|
|
|
2019-11-24 16:45:54 -07:00
|
|
|
[Command(10100)] // 1.0.0-5.1.0
|
|
|
|
// SaveReport(u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
|
|
|
public ResultCode SaveReportOld(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
|
return ProcessReport(context, withUserID: false);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(10101)] // 1.0.0-5.1.0
|
|
|
|
// SaveReportWithUserOld(nn::account::Uid, u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
|
|
|
public ResultCode SaveReportWithUserOld(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
|
return ProcessReport(context, withUserID: true);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(10102)] // 6.0.0+
|
|
|
|
// SaveReport(u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
|
|
|
public ResultCode SaveReport(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
|
return ProcessReport(context, withUserID: false);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(10103)] // 6.0.0+
|
2019-07-11 19:13:43 -06:00
|
|
|
// SaveReportWithUser(nn::account::Uid, u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
2019-11-24 16:45:54 -07:00
|
|
|
public ResultCode SaveReportWithUser(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
|
return ProcessReport(context, withUserID: true);
|
|
|
|
}
|
|
|
|
|
2020-03-25 05:28:15 -06:00
|
|
|
[Command(10200)]
|
|
|
|
// RequestImmediateTransmission()
|
|
|
|
public ResultCode RequestImmediateTransmission(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// It signals an event of nn::prepo::detail::service::core::TransmissionStatusManager that requests the transmission of the report.
|
|
|
|
// Since we don't use reports it's fine to do nothing.
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command(10300)]
|
|
|
|
// GetTransmissionStatus() -> u32
|
|
|
|
public ResultCode GetTransmissionStatus(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// It returns the transmission result of nn::prepo::detail::service::core::TransmissionStatusManager.
|
|
|
|
// Since we don't use reports it's fine to return ResultCode.Success.
|
|
|
|
context.ResponseData.Write((int)ResultCode.Success);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2019-11-24 16:45:54 -07:00
|
|
|
private ResultCode ProcessReport(ServiceCtx context, bool withUserID)
|
2018-05-17 12:25:42 -06:00
|
|
|
{
|
2020-02-01 20:24:17 -07:00
|
|
|
UserId userId = withUserID ? context.RequestData.ReadStruct<UserId>() : new UserId();
|
2019-11-24 16:45:54 -07:00
|
|
|
string gameRoom = StringUtils.ReadUtf8String(context);
|
|
|
|
|
|
|
|
if (withUserID)
|
|
|
|
{
|
|
|
|
if (userId.IsNull)
|
|
|
|
{
|
|
|
|
return ResultCode.InvalidArgument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gameRoom == string.Empty)
|
|
|
|
{
|
|
|
|
return ResultCode.InvalidState;
|
|
|
|
}
|
|
|
|
|
|
|
|
long inputPosition = context.Request.SendBuff[0].Position;
|
|
|
|
long inputSize = context.Request.SendBuff[0].Size;
|
|
|
|
|
|
|
|
if (inputSize == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.InvalidBufferSize;
|
|
|
|
}
|
|
|
|
|
2020-05-03 16:54:50 -06:00
|
|
|
byte[] inputBuffer = new byte[inputSize];
|
|
|
|
|
|
|
|
context.Memory.Read((ulong)inputPosition, inputBuffer);
|
2019-11-24 16:45:54 -07:00
|
|
|
|
|
|
|
Logger.PrintInfo(LogClass.ServicePrepo, ReadReportBuffer(inputBuffer, gameRoom, userId));
|
2018-05-17 12:25:42 -06:00
|
|
|
|
2019-07-14 13:04:38 -06:00
|
|
|
return ResultCode.Success;
|
2018-05-17 12:25:42 -06:00
|
|
|
}
|
2019-11-24 16:45:54 -07:00
|
|
|
|
2020-02-01 20:24:17 -07:00
|
|
|
private string ReadReportBuffer(byte[] buffer, string room, UserId userId)
|
2019-11-24 16:45:54 -07:00
|
|
|
{
|
2020-03-24 16:26:37 -06:00
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(buffer);
|
2019-11-24 16:45:54 -07:00
|
|
|
|
2020-03-24 16:26:37 -06:00
|
|
|
builder.AppendLine();
|
|
|
|
builder.AppendLine("PlayReport log:");
|
2019-11-24 16:45:54 -07:00
|
|
|
|
|
|
|
if (!userId.IsNull)
|
|
|
|
{
|
2020-03-24 16:26:37 -06:00
|
|
|
builder.AppendLine($" UserId: {userId.ToString()}");
|
2019-11-24 16:45:54 -07:00
|
|
|
}
|
|
|
|
|
2020-03-24 16:26:37 -06:00
|
|
|
builder.AppendLine($" Room: {room}");
|
2020-03-25 15:33:18 -06:00
|
|
|
builder.AppendLine($" Report: {MessagePackObjectFormatter.Format(deserializedReport)}");
|
2019-11-24 16:45:54 -07:00
|
|
|
|
2020-03-24 16:26:37 -06:00
|
|
|
return builder.ToString();
|
2020-01-30 09:39:05 -07:00
|
|
|
}
|
2018-04-21 17:04:43 -06:00
|
|
|
}
|
2020-01-30 09:39:05 -07:00
|
|
|
}
|