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
40 changed files with 1415 additions and 37 deletions

View File

@@ -19,6 +19,7 @@ using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.Loaders.Executables;
using Ryujinx.HLE.Loaders.Processes.Extensions;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Arp;
using System;
using System.Linq;
using System.Runtime.InteropServices;
@@ -229,6 +230,7 @@ namespace Ryujinx.HLE.Loaders.Processes
bool allowCodeMemoryForJit,
string name,
ulong programId,
byte programIndex,
byte[] arguments = null,
params IExecutable[] executables)
{
@@ -421,7 +423,7 @@ namespace Ryujinx.HLE.Loaders.Processes
// Once everything is loaded, we can load cheats.
device.Configuration.VirtualFileSystem.ModLoader.LoadCheats(programId, tamperInfo, device.TamperMachine);
return new ProcessResult(
ProcessResult processResult = new(
metaLoader,
applicationControlProperties,
diskCacheEnabled,
@@ -431,6 +433,25 @@ namespace Ryujinx.HLE.Loaders.Processes
meta.MainThreadPriority,
meta.MainThreadStackSize,
device.System.State.DesiredTitleLanguage);
// Register everything in arp service.
device.System.ServiceTable.ArpWriter.AcquireRegistrar(out IRegistrar registrar);
registrar.SetApplicationControlProperty(MemoryMarshal.Cast<byte, Horizon.Sdk.Ns.ApplicationControlProperty>(applicationControlProperties.ByteSpan)[0]);
// TODO: Handle Version and StorageId when it will be needed.
registrar.SetApplicationLaunchProperty(new ApplicationLaunchProperty()
{
ApplicationId = new Horizon.Sdk.Ncm.ApplicationId(programId),
Version = 0x00,
Storage = Horizon.Sdk.Ncm.StorageId.BuiltInUser,
PatchStorage = Horizon.Sdk.Ncm.StorageId.None,
ApplicationKind = ApplicationKind.Application,
});
device.System.ServiceTable.ArpReader.GetApplicationInstanceId(out ulong applicationInstanceId, process.Pid);
device.System.ServiceTable.ArpWriter.AcquireApplicationProcessPropertyUpdater(out IUpdater updater, applicationInstanceId);
updater.SetApplicationProcessProperty(process.Pid, new ApplicationProcessProperty() { ProgramIndex = programIndex });
return processResult;
}
public static Result LoadIntoMemory(KProcess process, IExecutable image, ulong baseAddress)