|
|
@@ -5,16 +5,25 @@ using Ryujinx.Common.Logging;
|
|
|
using Ryujinx.Common.Utilities;
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
|
using Ryujinx.HLE.Utilities;
|
|
|
+using System;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Prepo
|
|
|
{
|
|
|
- [Service("prepo:a")]
|
|
|
- [Service("prepo:a2")]
|
|
|
- [Service("prepo:u")]
|
|
|
+ [Service("prepo:a", PrepoServicePermissionLevel.Admin)] // 1.0.0-5.1.0
|
|
|
+ [Service("prepo:a2", PrepoServicePermissionLevel.Admin)] // 6.0.0+
|
|
|
+ [Service("prepo:m", PrepoServicePermissionLevel.Manager)]
|
|
|
+ [Service("prepo:u", PrepoServicePermissionLevel.User)]
|
|
|
+ [Service("prepo:s", PrepoServicePermissionLevel.System)]
|
|
|
class IPrepoService : IpcService
|
|
|
{
|
|
|
- public IPrepoService(ServiceCtx context) { }
|
|
|
+ private PrepoServicePermissionLevel _permission;
|
|
|
+ private ulong _systemSessionId;
|
|
|
+
|
|
|
+ public IPrepoService(ServiceCtx context, PrepoServicePermissionLevel permission)
|
|
|
+ {
|
|
|
+ _permission = permission;
|
|
|
+ }
|
|
|
|
|
|
[Command(10100)] // 1.0.0-5.1.0
|
|
|
[Command(10102)] // 6.0.0-9.2.0
|
|
|
@@ -22,6 +31,11 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
|
|
|
// SaveReport(u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
|
|
public ResultCode SaveReport(ServiceCtx context)
|
|
|
{
|
|
|
+ if (((int)_permission & 1) == 0)
|
|
|
+ {
|
|
|
+ return ResultCode.PermissionDenied;
|
|
|
+ }
|
|
|
+
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
return ProcessReport(context, withUserID: false);
|
|
|
}
|
|
|
@@ -32,6 +46,11 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
|
|
|
// SaveReportWithUser(nn::account::Uid, u64, pid, buffer<u8, 9>, buffer<bytes, 5>)
|
|
|
public ResultCode SaveReportWithUser(ServiceCtx context)
|
|
|
{
|
|
|
+ if (((int)_permission & 1) == 0)
|
|
|
+ {
|
|
|
+ return ResultCode.PermissionDenied;
|
|
|
+ }
|
|
|
+
|
|
|
// We don't care about the differences since we don't use the play report.
|
|
|
return ProcessReport(context, withUserID: true);
|
|
|
}
|
|
|
@@ -57,6 +76,29 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
|
|
|
return ResultCode.Success;
|
|
|
}
|
|
|
|
|
|
+ [Command(10400)] // 9.0.0+
|
|
|
+ // GetSystemSessionId() -> u64
|
|
|
+ public ResultCode GetSystemSessionId(ServiceCtx context)
|
|
|
+ {
|
|
|
+ if (((int)_permission & 1) == 0)
|
|
|
+ {
|
|
|
+ return ResultCode.PermissionDenied;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_systemSessionId == 0)
|
|
|
+ {
|
|
|
+ byte[] randomBuffer = new byte[8];
|
|
|
+
|
|
|
+ new Random().NextBytes(randomBuffer);
|
|
|
+
|
|
|
+ _systemSessionId = BitConverter.ToUInt64(randomBuffer, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ context.ResponseData.Write(_systemSessionId);
|
|
|
+
|
|
|
+ return ResultCode.Success;
|
|
|
+ }
|
|
|
+
|
|
|
private ResultCode ProcessReport(ServiceCtx context, bool withUserID)
|
|
|
{
|
|
|
UserId userId = withUserID ? context.RequestData.ReadStruct<UserId>() : new UserId();
|