mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-01-24 12:22:00 +00:00
Add cacheselector and allow PPTC with exefs mods
this is currently broken with Exlaunch mods that use hooks
This commit is contained in:
parent
0adaa4cb96
commit
2af9a33979
5 changed files with 33 additions and 11 deletions
|
@ -20,6 +20,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
private readonly string _titleIdText;
|
private readonly string _titleIdText;
|
||||||
private readonly string _displayVersion;
|
private readonly string _displayVersion;
|
||||||
private readonly bool _diskCacheEnabled;
|
private readonly bool _diskCacheEnabled;
|
||||||
|
private readonly string _diskCacheSelector;
|
||||||
private readonly ulong _codeAddress;
|
private readonly ulong _codeAddress;
|
||||||
private readonly ulong _codeSize;
|
private readonly ulong _codeSize;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
string titleIdText,
|
string titleIdText,
|
||||||
string displayVersion,
|
string displayVersion,
|
||||||
bool diskCacheEnabled,
|
bool diskCacheEnabled,
|
||||||
|
string diskCacheSelector,
|
||||||
ulong codeAddress,
|
ulong codeAddress,
|
||||||
ulong codeSize)
|
ulong codeSize)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +41,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
_titleIdText = titleIdText;
|
_titleIdText = titleIdText;
|
||||||
_displayVersion = displayVersion;
|
_displayVersion = displayVersion;
|
||||||
_diskCacheEnabled = diskCacheEnabled;
|
_diskCacheEnabled = diskCacheEnabled;
|
||||||
|
_diskCacheSelector = diskCacheSelector;
|
||||||
_codeAddress = codeAddress;
|
_codeAddress = codeAddress;
|
||||||
_codeSize = codeSize;
|
_codeSize = codeSize;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +117,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, "default"); //Ready for exefs profiles
|
DiskCacheLoadState = processContext.Initialize(_titleIdText, _displayVersion, _diskCacheEnabled, _codeAddress, _codeSize, _diskCacheSelector ?? "default"); //Ready for exefs profiles
|
||||||
|
|
||||||
return processContext;
|
return processContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using LibHac.FsSystem;
|
||||||
using LibHac.Loader;
|
using LibHac.Loader;
|
||||||
using LibHac.Tools.FsSystem;
|
using LibHac.Tools.FsSystem;
|
||||||
using LibHac.Tools.FsSystem.RomFs;
|
using LibHac.Tools.FsSystem.RomFs;
|
||||||
|
using LibHac.Util;
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
|
@ -18,6 +19,7 @@ using System.Collections.Specialized;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using LazyFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.LazyFile;
|
using LazyFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.LazyFile;
|
||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
|
|
||||||
|
@ -583,6 +585,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
public BitVector32 Stubs;
|
public BitVector32 Stubs;
|
||||||
public BitVector32 Replaces;
|
public BitVector32 Replaces;
|
||||||
public MetaLoader Npdm;
|
public MetaLoader Npdm;
|
||||||
|
public string Hash;
|
||||||
|
|
||||||
public bool Modified => (Stubs.Data | Replaces.Data) != 0;
|
public bool Modified => (Stubs.Data | Replaces.Data) != 0;
|
||||||
}
|
}
|
||||||
|
@ -593,8 +596,11 @@ namespace Ryujinx.HLE.HOS
|
||||||
{
|
{
|
||||||
Stubs = new BitVector32(),
|
Stubs = new BitVector32(),
|
||||||
Replaces = new BitVector32(),
|
Replaces = new BitVector32(),
|
||||||
|
Hash = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
string tempHash = string.Empty;
|
||||||
|
|
||||||
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||||
{
|
{
|
||||||
return modLoadResult;
|
return modLoadResult;
|
||||||
|
@ -630,8 +636,15 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
modLoadResult.Replaces[1 << i] = true;
|
modLoadResult.Replaces[1 << i] = true;
|
||||||
|
|
||||||
nsos[i] = new NsoExecutable(nsoFile.OpenRead().AsStorage(), nsoName);
|
using (FileStream stream = nsoFile.OpenRead())
|
||||||
Logger.Info?.Print(LogClass.ModLoader, $"NSO '{nsoName}' replaced");
|
{
|
||||||
|
nsos[i] = new NsoExecutable(stream.AsStorage(), nsoName);
|
||||||
|
Logger.Info?.Print(LogClass.ModLoader, $"NSO '{nsoName}' replaced");
|
||||||
|
using (MD5 md5 = MD5.Create())
|
||||||
|
{
|
||||||
|
tempHash += BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
|
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
|
||||||
|
@ -663,6 +676,14 @@ namespace Ryujinx.HLE.HOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(tempHash))
|
||||||
|
{
|
||||||
|
using (MD5 md5 = MD5.Create())
|
||||||
|
{
|
||||||
|
modLoadResult.Hash += BitConverter.ToString(md5.ComputeHash(tempHash.ToBytes())).Replace("-", "").ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return modLoadResult;
|
return modLoadResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,13 +82,6 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||||
// Apply Nsos patches.
|
// Apply Nsos patches.
|
||||||
device.Configuration.VirtualFileSystem.ModLoader.ApplyNsoPatches(programId, nsoExecutables);
|
device.Configuration.VirtualFileSystem.ModLoader.ApplyNsoPatches(programId, nsoExecutables);
|
||||||
|
|
||||||
// Don't use PTC if ExeFS files have been replaced.
|
|
||||||
bool enablePtc = device.System.EnablePtc && !modLoadResult.Modified;
|
|
||||||
if (!enablePtc)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Ptc, "Detected unsupported ExeFs modifications. PTC disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
string programName = string.Empty;
|
string programName = string.Empty;
|
||||||
|
|
||||||
if (!isHomebrew && programId > 0x010000000000FFFF)
|
if (!isHomebrew && programId > 0x010000000000FFFF)
|
||||||
|
@ -115,7 +108,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||||
device.System.KernelContext,
|
device.System.KernelContext,
|
||||||
metaLoader,
|
metaLoader,
|
||||||
nacpData,
|
nacpData,
|
||||||
enablePtc,
|
device.System.EnablePtc,
|
||||||
|
modLoadResult.Hash,
|
||||||
true,
|
true,
|
||||||
programName,
|
programName,
|
||||||
metaLoader.GetProgramId(),
|
metaLoader.GetProgramId(),
|
||||||
|
|
|
@ -212,6 +212,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
dummyExeFs.GetNpdm(),
|
dummyExeFs.GetNpdm(),
|
||||||
nacpData,
|
nacpData,
|
||||||
diskCacheEnabled: false,
|
diskCacheEnabled: false,
|
||||||
|
diskCacheSelector: string.Empty,
|
||||||
allowCodeMemoryForJit: true,
|
allowCodeMemoryForJit: true,
|
||||||
programName,
|
programName,
|
||||||
programId,
|
programId,
|
||||||
|
|
|
@ -186,6 +186,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
string.Empty,
|
string.Empty,
|
||||||
string.Empty,
|
string.Empty,
|
||||||
false,
|
false,
|
||||||
|
string.Empty,
|
||||||
codeAddress,
|
codeAddress,
|
||||||
codeSize);
|
codeSize);
|
||||||
|
|
||||||
|
@ -226,6 +227,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
MetaLoader metaLoader,
|
MetaLoader metaLoader,
|
||||||
BlitStruct<ApplicationControlProperty> applicationControlProperties,
|
BlitStruct<ApplicationControlProperty> applicationControlProperties,
|
||||||
bool diskCacheEnabled,
|
bool diskCacheEnabled,
|
||||||
|
string diskCacheSelector,
|
||||||
bool allowCodeMemoryForJit,
|
bool allowCodeMemoryForJit,
|
||||||
string name,
|
string name,
|
||||||
ulong programId,
|
ulong programId,
|
||||||
|
@ -379,6 +381,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||||
$"{programId:x16}",
|
$"{programId:x16}",
|
||||||
displayVersion,
|
displayVersion,
|
||||||
diskCacheEnabled,
|
diskCacheEnabled,
|
||||||
|
diskCacheSelector,
|
||||||
codeStart,
|
codeStart,
|
||||||
codeSize);
|
codeSize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue