Horizon: Implement arp:r and arp:w services (#5802)

* Horizon: Implement arp:r and arp:w services

* Fix formatting

* Remove HLE arp services

* Revert "Remove HLE arp services"

This reverts commit c576fcccadb963db56b96bacabd1c1ac7abfb1ab.

* Keep LibHac impl since it's used in bcat

* Addresses gdkchan's feedback

* ArpApi in PrepoIpcServer and remove LmApi

* Fix 2

* Fixes ArpApi init

* Fix encoding

* Update PrepoService.cs

* Fix prepo
This commit is contained in:
Ac_K 2024-01-25 23:06:53 +01:00 committed by GitHub
parent 43705c2320
commit cd37c75b82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1415 additions and 37 deletions

View file

@ -5,6 +5,7 @@ using Ryujinx.Common.Utilities;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Prepo.Types;
using Ryujinx.Horizon.Sdk.Account;
using Ryujinx.Horizon.Sdk.Arp;
using Ryujinx.Horizon.Sdk.Prepo;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
@ -22,14 +23,16 @@ namespace Ryujinx.Horizon.Prepo.Ipc
System,
}
private readonly ArpApi _arp;
private readonly PrepoServicePermissionLevel _permissionLevel;
private ulong _systemSessionId;
private bool _immediateTransmissionEnabled;
private bool _userAgreementCheckEnabled = true;
public PrepoService(PrepoServicePermissionLevel permissionLevel)
public PrepoService(ArpApi arp, PrepoServicePermissionLevel permissionLevel)
{
_arp = arp;
_permissionLevel = permissionLevel;
}
@ -165,7 +168,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc
return PrepoResult.PermissionDenied;
}
private static Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, ApplicationId applicationId = default)
private Result ProcessPlayReport(PlayReportKind playReportKind, ReadOnlySpan<byte> gameRoomBuffer, ReadOnlySpan<byte> reportBuffer, ulong pid, Uid userId, bool withUserId = false, ApplicationId applicationId = default)
{
if (withUserId)
{
@ -199,8 +202,8 @@ namespace Ryujinx.Horizon.Prepo.Ipc
builder.AppendLine("PlayReport log:");
builder.AppendLine($" Kind: {playReportKind}");
// NOTE: The service calls arp:r using the pid to get the application id, if it fails PrepoResult.InvalidPid is returned.
// Reports are stored internally and an event is signaled to transmit them.
// NOTE: Reports are stored internally and an event is signaled to transmit them.
if (pid != 0)
{
builder.AppendLine($" Pid: {pid}");
@ -210,6 +213,16 @@ namespace Ryujinx.Horizon.Prepo.Ipc
builder.AppendLine($" ApplicationId: {applicationId}");
}
Result result = _arp.GetApplicationInstanceId(out ulong applicationInstanceId, pid);
if (result.IsFailure)
{
return PrepoResult.InvalidPid;
}
_arp.GetApplicationLaunchProperty(out ApplicationLaunchProperty applicationLaunchProperty, applicationInstanceId).AbortOnFailure();
builder.AppendLine($" ApplicationVersion: {applicationLaunchProperty.Version}");
if (!userId.IsNull)
{
builder.AppendLine($" UserId: {userId}");