From 7cf3ce7ed2dc4af4ed1ae9ba8d67d0941c847d76 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Wed, 23 Jun 2021 22:41:44 +0200 Subject: [PATCH] prepo: Implement SaveSystemReport and SaveSystemReportWithUser (#2379) --- .../HOS/Services/Prepo/IPrepoService.cs | 34 ++++++++++++++++--- .../Types/PrepoServicePermissionLevel.cs | 4 +-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs index 4f36d4014..3fa1182db 100644 --- a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs +++ b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs @@ -31,7 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo // SaveReport(u64, pid, buffer, buffer) public ResultCode SaveReport(ServiceCtx context) { - if (((int)_permission & 1) == 0) + if ((_permission & PrepoServicePermissionLevel.User) == 0) { return ResultCode.PermissionDenied; } @@ -46,7 +46,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo // SaveReportWithUser(nn::account::Uid, u64, pid, buffer, buffer) public ResultCode SaveReportWithUser(ServiceCtx context) { - if (((int)_permission & 1) == 0) + if ((_permission & PrepoServicePermissionLevel.User) == 0) { return ResultCode.PermissionDenied; } @@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo // GetSystemSessionId() -> u64 public ResultCode GetSystemSessionId(ServiceCtx context) { - if (((int)_permission & 1) == 0) + if ((_permission & PrepoServicePermissionLevel.User) == 0) { return ResultCode.PermissionDenied; } @@ -99,6 +99,32 @@ namespace Ryujinx.HLE.HOS.Services.Prepo return ResultCode.Success; } + [CommandHipc(20100)] + // SaveSystemReport(u64, pid, buffer, buffer) + public ResultCode SaveSystemReport(ServiceCtx context) + { + if ((_permission & PrepoServicePermissionLevel.System) != 0) + { + return ResultCode.PermissionDenied; + } + + // We don't care about the differences since we don't use the play report. + return ProcessReport(context, withUserID: false); + } + + [CommandHipc(20101)] + // SaveSystemReportWithUser(nn::account::Uid, u64, pid, buffer, buffer) + public ResultCode SaveSystemReportWithUser(ServiceCtx context) + { + if ((_permission & PrepoServicePermissionLevel.System) != 0) + { + return ResultCode.PermissionDenied; + } + + // We don't care about the differences since we don't use the play report. + return ProcessReport(context, withUserID: true); + } + private ResultCode ProcessReport(ServiceCtx context, bool withUserID) { UserId userId = withUserID ? context.RequestData.ReadStruct() : new UserId(); @@ -136,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo private string ReadReportBuffer(byte[] buffer, string room, UserId userId) { - StringBuilder builder = new StringBuilder(); + StringBuilder builder = new StringBuilder(); MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(buffer); builder.AppendLine(); diff --git a/Ryujinx.HLE/HOS/Services/Prepo/Types/PrepoServicePermissionLevel.cs b/Ryujinx.HLE/HOS/Services/Prepo/Types/PrepoServicePermissionLevel.cs index 624c3fde3..35774707d 100644 --- a/Ryujinx.HLE/HOS/Services/Prepo/Types/PrepoServicePermissionLevel.cs +++ b/Ryujinx.HLE/HOS/Services/Prepo/Types/PrepoServicePermissionLevel.cs @@ -1,6 +1,4 @@ -using System; - -namespace Ryujinx.HLE.HOS.Services.Prepo +namespace Ryujinx.HLE.HOS.Services.Prepo { enum PrepoServicePermissionLevel {