Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
4250732353 | |||
4d1579acbf | |||
6279f5e430 | |||
b7d2bff6aa | |||
7c327fecb3 |
@ -1576,8 +1576,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
if (SelectedApplication != null)
|
||||
{
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, SelectedApplication.TitleId);
|
||||
string modsBasePath = VirtualFileSystem.ModLoader.GetModsBasePath();
|
||||
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(modsBasePath, SelectedApplication.TitleId);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
}
|
||||
@ -1587,8 +1587,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
if (SelectedApplication != null)
|
||||
{
|
||||
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, SelectedApplication.TitleId);
|
||||
string sdModsBasePath = VirtualFileSystem.ModLoader.GetSdModsBasePath();
|
||||
string titleModsPath = VirtualFileSystem.ModLoader.GetTitleDir(sdModsBasePath, SelectedApplication.TitleId);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId);
|
||||
string modsBasePath = virtualFileSystem.ModLoader.GetModsBasePath();
|
||||
string titleModsPath = virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, titleId);
|
||||
ulong titleIdValue = ulong.Parse(titleId, System.Globalization.NumberStyles.HexNumber);
|
||||
|
||||
_enabledCheatsPath = Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
||||
|
@ -300,11 +300,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
||||
IsCopyRegionComplete(srcCopyTexture, srcCopyTextureFormat, srcX1, srcY1, srcX2, srcY2) &&
|
||||
IsCopyRegionComplete(dstCopyTexture, dstCopyTextureFormat, dstX1, dstY1, dstX2, dstY2);
|
||||
|
||||
// We can only allow aliasing of color formats as depth if the source and destination textures
|
||||
// are the same, as we can't blit between different depth formats.
|
||||
bool srcDepthAlias = srcCopyTexture.Format == dstCopyTexture.Format;
|
||||
|
||||
var srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||
memoryManager,
|
||||
srcCopyTexture,
|
||||
offset,
|
||||
srcCopyTextureFormat,
|
||||
srcDepthAlias,
|
||||
!canDirectCopy,
|
||||
false,
|
||||
srcHint);
|
||||
@ -325,6 +330,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
||||
// When the source texture that was found has a depth format,
|
||||
// we must enforce the target texture also has a depth format,
|
||||
// as copies between depth and color formats are not allowed.
|
||||
// For depth blit, the destination texture format should always match exactly.
|
||||
|
||||
if (srcTexture.Format.IsDepthOrStencil())
|
||||
{
|
||||
@ -340,7 +346,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
||||
dstCopyTexture,
|
||||
0,
|
||||
dstCopyTextureFormat,
|
||||
true,
|
||||
depthAlias: false,
|
||||
shouldCreate: true,
|
||||
srcTexture.ScaleMode == TextureScaleMode.Scaled,
|
||||
dstHint);
|
||||
|
||||
|
@ -1118,7 +1118,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
bool forSampler = (flags & TextureSearchFlags.ForSampler) != 0;
|
||||
|
||||
TextureMatchQuality matchQuality = TextureCompatibility.FormatMatches(Info, info, forSampler, (flags & TextureSearchFlags.ForCopy) != 0);
|
||||
TextureMatchQuality matchQuality = TextureCompatibility.FormatMatches(Info, info, forSampler, (flags & TextureSearchFlags.DepthAlias) != 0);
|
||||
|
||||
if (matchQuality == TextureMatchQuality.NoMatch)
|
||||
{
|
||||
|
@ -249,6 +249,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <param name="copyTexture">Copy texture to find or create</param>
|
||||
/// <param name="offset">Offset to be added to the physical texture address</param>
|
||||
/// <param name="formatInfo">Format information of the copy texture</param>
|
||||
/// <param name="depthAlias">Indicates if aliasing between color and depth format should be allowed</param>
|
||||
/// <param name="shouldCreate">Indicates if a new texture should be created if none is found on the cache</param>
|
||||
/// <param name="preferScaling">Indicates if the texture should be scaled from the start</param>
|
||||
/// <param name="sizeHint">A hint indicating the minimum used size for the texture</param>
|
||||
/// <returns>The texture</returns>
|
||||
@ -257,6 +259,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
TwodTexture copyTexture,
|
||||
ulong offset,
|
||||
FormatInfo formatInfo,
|
||||
bool depthAlias,
|
||||
bool shouldCreate,
|
||||
bool preferScaling,
|
||||
Size sizeHint)
|
||||
@ -293,6 +296,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
TextureSearchFlags flags = TextureSearchFlags.ForCopy;
|
||||
|
||||
if (depthAlias)
|
||||
{
|
||||
flags |= TextureSearchFlags.DepthAlias;
|
||||
}
|
||||
|
||||
if (preferScaling)
|
||||
{
|
||||
flags |= TextureSearchFlags.WithUpscale;
|
||||
|
@ -220,18 +220,18 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// <param name="lhs">Texture information to compare</param>
|
||||
/// <param name="rhs">Texture information to compare with</param>
|
||||
/// <param name="forSampler">Indicates that the texture will be used for shader sampling</param>
|
||||
/// <param name="forCopy">Indicates that the texture will be used as copy source or target</param>
|
||||
/// <param name="depthAlias">Indicates if aliasing between color and depth format should be allowed</param>
|
||||
/// <returns>A value indicating how well the formats match</returns>
|
||||
public static TextureMatchQuality FormatMatches(TextureInfo lhs, TextureInfo rhs, bool forSampler, bool forCopy)
|
||||
public static TextureMatchQuality FormatMatches(TextureInfo lhs, TextureInfo rhs, bool forSampler, bool depthAlias)
|
||||
{
|
||||
// D32F and R32F texture have the same representation internally,
|
||||
// however the R32F format is used to sample from depth textures.
|
||||
if (lhs.FormatInfo.Format == Format.D32Float && rhs.FormatInfo.Format == Format.R32Float && (forSampler || forCopy))
|
||||
if (lhs.FormatInfo.Format == Format.D32Float && rhs.FormatInfo.Format == Format.R32Float && (forSampler || depthAlias))
|
||||
{
|
||||
return TextureMatchQuality.FormatAlias;
|
||||
}
|
||||
|
||||
if (forCopy)
|
||||
if (depthAlias)
|
||||
{
|
||||
// The 2D engine does not support depth-stencil formats, so it will instead
|
||||
// use equivalent color formats. We must also consider them as compatible.
|
||||
|
@ -11,7 +11,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
None = 0,
|
||||
ForSampler = 1 << 1,
|
||||
ForCopy = 1 << 2,
|
||||
WithUpscale = 1 << 3,
|
||||
NoCreate = 1 << 4
|
||||
DepthAlias = 1 << 3,
|
||||
WithUpscale = 1 << 4,
|
||||
NoCreate = 1 << 5
|
||||
}
|
||||
}
|
@ -1015,8 +1015,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private void SetRenderTargetsInternal(ITexture[] colors, ITexture depthStencil, bool filterWriteMasked)
|
||||
{
|
||||
FramebufferParams?.UpdateModifications();
|
||||
CreateFramebuffer(colors, depthStencil, filterWriteMasked);
|
||||
FramebufferParams?.UpdateModifications();
|
||||
CreateRenderPass();
|
||||
SignalStateChange();
|
||||
SignalAttachmentChange();
|
||||
|
@ -327,7 +327,7 @@ namespace Ryujinx.HLE.HOS
|
||||
private void StartNewServices()
|
||||
{
|
||||
ServiceTable = new ServiceTable();
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices));
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient));
|
||||
|
||||
foreach (var service in services)
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
|
||||
// Title independent mods
|
||||
private class PatchCache
|
||||
public class PatchCache
|
||||
{
|
||||
public List<Mod<DirectoryInfo>> NsoPatches { get; }
|
||||
public List<Mod<DirectoryInfo>> NroPatches { get; }
|
||||
@ -107,14 +107,14 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<ulong, ModCache> _appMods; // key is TitleId
|
||||
private PatchCache _patches;
|
||||
public Dictionary<ulong, ModCache> AppMods; // key is TitleId
|
||||
public PatchCache Patches;
|
||||
|
||||
private static readonly EnumerationOptions DirEnumOptions;
|
||||
private static readonly EnumerationOptions _dirEnumOptions;
|
||||
|
||||
static ModLoader()
|
||||
{
|
||||
DirEnumOptions = new EnumerationOptions
|
||||
_dirEnumOptions = new EnumerationOptions
|
||||
{
|
||||
MatchCasing = MatchCasing.CaseInsensitive,
|
||||
MatchType = MatchType.Simple,
|
||||
@ -125,73 +125,37 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public ModLoader()
|
||||
{
|
||||
_appMods = new Dictionary<ulong, ModCache>();
|
||||
_patches = new PatchCache();
|
||||
AppMods = new Dictionary<ulong, ModCache>();
|
||||
Patches = new PatchCache();
|
||||
}
|
||||
|
||||
private void Clear()
|
||||
public void Clear()
|
||||
{
|
||||
_appMods.Clear();
|
||||
_patches = new PatchCache();
|
||||
AppMods.Clear();
|
||||
Patches = new PatchCache();
|
||||
}
|
||||
|
||||
private static bool StrEquals(string s1, string s2) => string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static string GetModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetModsPath());
|
||||
public static string GetSdModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetSdModsPath());
|
||||
public string GetModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetModsPath());
|
||||
public string GetSdModsBasePath() => EnsureBaseDirStructure(AppDataManager.GetSdModsPath());
|
||||
|
||||
private static string EnsureBaseDirStructure(string modsBasePath)
|
||||
private string EnsureBaseDirStructure(string modsBasePath)
|
||||
{
|
||||
var modsDir = new DirectoryInfo(modsBasePath);
|
||||
|
||||
modsDir.CreateSubdirectory(AmsContentsDir);
|
||||
modsDir.CreateSubdirectory(AmsNsoPatchDir);
|
||||
modsDir.CreateSubdirectory(AmsNroPatchDir);
|
||||
// TODO: uncomment when KIPs are supported
|
||||
// modsDir.CreateSubdirectory(AmsKipPatchDir);
|
||||
// modsDir.CreateSubdirectory(AmsKipPatchDir); // uncomment when KIPs are supported
|
||||
|
||||
return modsDir.FullName;
|
||||
}
|
||||
|
||||
private static DirectoryInfo FindTitleDir(DirectoryInfo contentsDir, string titleId)
|
||||
=> contentsDir.EnumerateDirectories($"{titleId}*", DirEnumOptions).FirstOrDefault();
|
||||
=> contentsDir.EnumerateDirectories($"{titleId}*", _dirEnumOptions).FirstOrDefault();
|
||||
|
||||
private static void AddModsFromDirectory(ModCache mods, DirectoryInfo dir, string titleId)
|
||||
{
|
||||
System.Text.StringBuilder types = new();
|
||||
|
||||
foreach (var modDir in dir.EnumerateDirectories())
|
||||
{
|
||||
types.Clear();
|
||||
Mod<DirectoryInfo> mod = new("", null);
|
||||
|
||||
if (StrEquals(RomfsDir, modDir.Name))
|
||||
{
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleId} RomFs>", modDir));
|
||||
types.Append('R');
|
||||
}
|
||||
else if (StrEquals(ExefsDir, modDir.Name))
|
||||
{
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleId} ExeFs>", modDir));
|
||||
types.Append('E');
|
||||
}
|
||||
else if (StrEquals(CheatDir, modDir.Name))
|
||||
{
|
||||
types.Append('C', QueryCheatsDir(mods, modDir));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModsFromDirectory(mods, modDir, titleId);
|
||||
}
|
||||
|
||||
if (types.Length > 0)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Found mod '{mod.Name}' [{types}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTitleDir(string modsBasePath, string titleId)
|
||||
public string GetTitleDir(string modsBasePath, string titleId)
|
||||
{
|
||||
var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir));
|
||||
var titleModsPath = FindTitleDir(contentsDir, titleId);
|
||||
@ -206,32 +170,17 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
|
||||
// Static Query Methods
|
||||
private static void QueryPatchDirs(PatchCache cache, DirectoryInfo patchDir)
|
||||
public static void QueryPatchDirs(PatchCache cache, DirectoryInfo patchDir)
|
||||
{
|
||||
if (cache.Initialized || !patchDir.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (cache.Initialized || !patchDir.Exists) return;
|
||||
|
||||
List<Mod<DirectoryInfo>> patches;
|
||||
string type;
|
||||
var patches = cache.KipPatches;
|
||||
string type = null;
|
||||
|
||||
if (StrEquals(AmsNsoPatchDir, patchDir.Name))
|
||||
{
|
||||
patches = cache.NsoPatches; type = "NSO";
|
||||
}
|
||||
else if (StrEquals(AmsNroPatchDir, patchDir.Name))
|
||||
{
|
||||
patches = cache.NroPatches; type = "NRO";
|
||||
}
|
||||
else if (StrEquals(AmsKipPatchDir, patchDir.Name))
|
||||
{
|
||||
patches = cache.KipPatches; type = "KIP";
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (StrEquals(AmsNsoPatchDir, patchDir.Name)) { patches = cache.NsoPatches; type = "NSO"; }
|
||||
else if (StrEquals(AmsNroPatchDir, patchDir.Name)) { patches = cache.NroPatches; type = "NRO"; }
|
||||
else if (StrEquals(AmsKipPatchDir, patchDir.Name)) { patches = cache.KipPatches; type = "KIP"; }
|
||||
else return;
|
||||
|
||||
foreach (var modDir in patchDir.EnumerateDirectories())
|
||||
{
|
||||
@ -240,12 +189,9 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
private static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
|
||||
public static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
|
||||
{
|
||||
if (!titleDir.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!titleDir.Exists) return;
|
||||
|
||||
var fsFile = new FileInfo(Path.Combine(titleDir.FullName, RomfsContainer));
|
||||
if (fsFile.Exists)
|
||||
@ -259,15 +205,64 @@ namespace Ryujinx.HLE.HOS
|
||||
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{titleDir.Name} ExeFs>", fsFile));
|
||||
}
|
||||
|
||||
AddModsFromDirectory(mods, titleDir, titleDir.Name);
|
||||
System.Text.StringBuilder types = new System.Text.StringBuilder(5);
|
||||
|
||||
foreach (var modDir in titleDir.EnumerateDirectories())
|
||||
{
|
||||
types.Clear();
|
||||
Mod<DirectoryInfo> mod = new Mod<DirectoryInfo>("", null);
|
||||
|
||||
if (StrEquals(RomfsDir, modDir.Name))
|
||||
{
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleDir.Name} RomFs>", modDir));
|
||||
types.Append('R');
|
||||
}
|
||||
else if (StrEquals(ExefsDir, modDir.Name))
|
||||
{
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>($"<{titleDir.Name} ExeFs>", modDir));
|
||||
types.Append('E');
|
||||
}
|
||||
else if (StrEquals(CheatDir, modDir.Name))
|
||||
{
|
||||
for (int i = 0; i < QueryCheatsDir(mods, modDir); i++)
|
||||
{
|
||||
types.Append('C');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var romfs = new DirectoryInfo(Path.Combine(modDir.FullName, RomfsDir));
|
||||
var exefs = new DirectoryInfo(Path.Combine(modDir.FullName, ExefsDir));
|
||||
var cheat = new DirectoryInfo(Path.Combine(modDir.FullName, CheatDir));
|
||||
|
||||
if (romfs.Exists)
|
||||
{
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(modDir.Name, romfs));
|
||||
types.Append('R');
|
||||
}
|
||||
|
||||
if (exefs.Exists)
|
||||
{
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(modDir.Name, exefs));
|
||||
types.Append('E');
|
||||
}
|
||||
|
||||
if (cheat.Exists)
|
||||
{
|
||||
for (int i = 0; i < QueryCheatsDir(mods, cheat); i++)
|
||||
{
|
||||
types.Append('C');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (types.Length > 0) Logger.Info?.Print(LogClass.ModLoader, $"Found mod '{mod.Name}' [{types}]");
|
||||
}
|
||||
}
|
||||
|
||||
public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong titleId)
|
||||
{
|
||||
if (!contentsDir.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!contentsDir.Exists) return;
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((titleId & 0x1000) != 0 ? "DLC" : "Title")} {titleId:X16}");
|
||||
|
||||
@ -307,16 +302,9 @@ namespace Ryujinx.HLE.HOS
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldCheatsCount = mods.Cheats.Count;
|
||||
|
||||
// A cheat file can contain several cheats for the same executable, so the file must be parsed in
|
||||
// order to properly enumerate them.
|
||||
mods.Cheats.AddRange(GetCheatsInFile(file));
|
||||
|
||||
if (mods.Cheats.Count - oldCheatsCount > 0)
|
||||
{
|
||||
numMods++;
|
||||
}
|
||||
}
|
||||
|
||||
return numMods;
|
||||
@ -325,54 +313,57 @@ namespace Ryujinx.HLE.HOS
|
||||
private static IEnumerable<Cheat> GetCheatsInFile(FileInfo cheatFile)
|
||||
{
|
||||
string cheatName = DefaultCheatName;
|
||||
List<string> instructions = new();
|
||||
List<Cheat> cheats = new();
|
||||
List<string> instructions = new List<string>();
|
||||
List<Cheat> cheats = new List<Cheat>();
|
||||
|
||||
using StreamReader cheatData = cheatFile.OpenText();
|
||||
while (cheatData.ReadLine() is { } line)
|
||||
using (StreamReader cheatData = cheatFile.OpenText())
|
||||
{
|
||||
line = line.Trim();
|
||||
|
||||
if (line.StartsWith('['))
|
||||
string line;
|
||||
while ((line = cheatData.ReadLine()) != null)
|
||||
{
|
||||
// This line starts a new cheat section.
|
||||
if (!line.EndsWith(']') || line.Length < 3)
|
||||
line = line.Trim();
|
||||
|
||||
if (line.StartsWith('['))
|
||||
{
|
||||
// Skip the entire file if there's any error while parsing the cheat file.
|
||||
// This line starts a new cheat section.
|
||||
if (!line.EndsWith(']') || line.Length < 3)
|
||||
{
|
||||
// Skip the entire file if there's any error while parsing the cheat file.
|
||||
|
||||
Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed");
|
||||
Logger.Warning?.Print(LogClass.ModLoader, $"Ignoring cheat '{cheatFile.FullName}' because it is malformed");
|
||||
|
||||
return Array.Empty<Cheat>();
|
||||
return new List<Cheat>();
|
||||
}
|
||||
|
||||
// Add the previous section to the list.
|
||||
if (instructions.Count != 0)
|
||||
{
|
||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||
}
|
||||
|
||||
// Start a new cheat section.
|
||||
cheatName = line.Substring(1, line.Length - 2);
|
||||
instructions = new List<string>();
|
||||
}
|
||||
|
||||
// Add the previous section to the list.
|
||||
if (instructions.Count > 0)
|
||||
else if (line.Length > 0)
|
||||
{
|
||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||
// The line contains an instruction.
|
||||
instructions.Add(line);
|
||||
}
|
||||
|
||||
// Start a new cheat section.
|
||||
cheatName = line.Substring(1, line.Length - 2);
|
||||
instructions.Clear();
|
||||
}
|
||||
else if (line.Length > 0)
|
||||
|
||||
// Add the last section being processed.
|
||||
if (instructions.Count != 0)
|
||||
{
|
||||
// The line contains an instruction.
|
||||
instructions.Add(line);
|
||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last section being processed.
|
||||
if (instructions.Count > 0)
|
||||
{
|
||||
cheats.Add(new Cheat($"<{cheatName} Cheat>", cheatFile, instructions));
|
||||
}
|
||||
|
||||
return cheats;
|
||||
}
|
||||
|
||||
// Assumes searchDirPaths don't overlap
|
||||
private static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params string[] searchDirPaths)
|
||||
public static void CollectMods(Dictionary<ulong, ModCache> modCaches, PatchCache patches, params string[] searchDirPaths)
|
||||
{
|
||||
static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) ||
|
||||
StrEquals(AmsNroPatchDir, name) ||
|
||||
@ -384,7 +375,7 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
if (IsContentsDir(searchDir.Name))
|
||||
{
|
||||
foreach ((ulong titleId, ModCache cache) in modCaches)
|
||||
foreach (var (titleId, cache) in modCaches)
|
||||
{
|
||||
QueryContentsDir(cache, searchDir, titleId);
|
||||
}
|
||||
@ -428,15 +419,15 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
foreach (ulong titleId in titles)
|
||||
{
|
||||
_appMods[titleId] = new ModCache();
|
||||
AppMods[titleId] = new ModCache();
|
||||
}
|
||||
|
||||
CollectMods(_appMods, _patches, searchDirPaths);
|
||||
CollectMods(AppMods, Patches, searchDirPaths);
|
||||
}
|
||||
|
||||
internal IStorage ApplyRomFsMods(ulong titleId, IStorage baseStorage)
|
||||
{
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
||||
{
|
||||
return baseStorage;
|
||||
}
|
||||
@ -496,7 +487,7 @@ namespace Ryujinx.HLE.HOS
|
||||
return newStorage;
|
||||
}
|
||||
|
||||
private static void AddFiles(IFileSystem fs, string modName, ISet<string> fileSet, RomFsBuilder builder)
|
||||
private static void AddFiles(IFileSystem fs, string modName, HashSet<string> fileSet, RomFsBuilder builder)
|
||||
{
|
||||
foreach (var entry in fs.EnumerateEntries()
|
||||
.Where(f => f.Type == DirectoryEntryType.File)
|
||||
@ -518,7 +509,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal bool ReplaceExefsPartition(ulong titleId, ref IFileSystem exefs)
|
||||
{
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -546,13 +537,13 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal ModLoadResult ApplyExefsMods(ulong titleId, NsoExecutable[] nsos)
|
||||
{
|
||||
ModLoadResult modLoadResult = new()
|
||||
ModLoadResult modLoadResult = new ModLoadResult
|
||||
{
|
||||
Stubs = new BitVector32(),
|
||||
Replaces = new BitVector32()
|
||||
};
|
||||
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||
{
|
||||
return modLoadResult;
|
||||
}
|
||||
@ -570,7 +561,7 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
var nsoName = ProcessConst.ExeFsPrefixes[i];
|
||||
|
||||
FileInfo nsoFile = new(Path.Combine(mod.Path.FullName, nsoName));
|
||||
FileInfo nsoFile = new FileInfo(Path.Combine(mod.Path.FullName, nsoName));
|
||||
if (nsoFile.Exists)
|
||||
{
|
||||
if (modLoadResult.Replaces[1 << i])
|
||||
@ -589,7 +580,7 @@ namespace Ryujinx.HLE.HOS
|
||||
modLoadResult.Stubs[1 << i] |= File.Exists(Path.Combine(mod.Path.FullName, nsoName + StubExtension));
|
||||
}
|
||||
|
||||
FileInfo npdmFile = new(Path.Combine(mod.Path.FullName, "main.npdm"));
|
||||
FileInfo npdmFile = new FileInfo(Path.Combine(mod.Path.FullName, "main.npdm"));
|
||||
if (npdmFile.Exists)
|
||||
{
|
||||
if (modLoadResult.Npdm != null)
|
||||
@ -620,7 +611,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal void ApplyNroPatches(NroExecutable nro)
|
||||
{
|
||||
var nroPatches = _patches.NroPatches;
|
||||
var nroPatches = Patches.NroPatches;
|
||||
|
||||
if (nroPatches.Count == 0) return;
|
||||
|
||||
@ -631,9 +622,9 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal bool ApplyNsoPatches(ulong titleId, params IExecutable[] programs)
|
||||
{
|
||||
IEnumerable<Mod<DirectoryInfo>> nsoMods = _patches.NsoPatches;
|
||||
IEnumerable<Mod<DirectoryInfo>> nsoMods = Patches.NsoPatches;
|
||||
|
||||
if (_appMods.TryGetValue(titleId, out ModCache mods))
|
||||
if (AppMods.TryGetValue(titleId, out ModCache mods))
|
||||
{
|
||||
nsoMods = nsoMods.Concat(mods.ExefsDirs);
|
||||
}
|
||||
@ -645,7 +636,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal void LoadCheats(ulong titleId, ProcessTamperInfo tamperInfo, TamperMachine tamperMachine)
|
||||
{
|
||||
if (tamperInfo?.BuildIds == null || tamperInfo.CodeAddresses == null)
|
||||
if (tamperInfo == null || tamperInfo.BuildIds == null || tamperInfo.CodeAddresses == null)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.ModLoader, "Unable to install cheat because the associated process is invalid");
|
||||
|
||||
@ -654,14 +645,14 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for title {titleId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}");
|
||||
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.Cheats.Count == 0)
|
||||
if (!AppMods.TryGetValue(titleId, out ModCache mods) || mods.Cheats.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cheats = mods.Cheats;
|
||||
var processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v })
|
||||
.ToDictionary(x => x.k[..Math.Min(Cheat.CheatIdSize, x.k.Length)], x => x.v);
|
||||
.ToDictionary(x => x.k.Substring(0, Math.Min(Cheat.CheatIdSize, x.k.Length)), x => x.v);
|
||||
|
||||
foreach (var cheat in cheats)
|
||||
{
|
||||
@ -767,4 +758,4 @@ namespace Ryujinx.HLE.HOS
|
||||
return count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +0,0 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.HOS.Services.Arp;
|
||||
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat
|
||||
{
|
||||
[Service("bcat:a", "bcat:a")]
|
||||
[Service("bcat:m", "bcat:m")]
|
||||
[Service("bcat:u", "bcat:u")]
|
||||
[Service("bcat:s", "bcat:s")]
|
||||
class IServiceCreator : DisposableIpcService
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _base;
|
||||
|
||||
public IServiceCreator(ServiceCtx context, string serviceName)
|
||||
{
|
||||
var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
|
||||
applicationClient.Sm.GetService(ref _base, serviceName).ThrowIfFailure();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
_base.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// CreateBcatService(pid) -> object<nn::bcat::detail::ipc::IBcatService>
|
||||
public ResultCode CreateBcatService(ServiceCtx context)
|
||||
{
|
||||
// TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
|
||||
// Add an instance of nn::bcat::detail::service::core::PassphraseManager.
|
||||
// Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
|
||||
// Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin".
|
||||
// If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400.
|
||||
|
||||
MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context)));
|
||||
|
||||
// NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
|
||||
// return ResultCode.NullObject;
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// CreateDeliveryCacheStorageService(pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
||||
public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
|
||||
{
|
||||
ulong pid = context.RequestData.ReadUInt64();
|
||||
|
||||
using var serv = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||
|
||||
Result rc = _base.Get.CreateDeliveryCacheStorageService(ref serv.Ref, pid);
|
||||
|
||||
if (rc.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new IDeliveryCacheStorageService(context, ref serv.Ref));
|
||||
}
|
||||
|
||||
return (ResultCode)rc.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(2)]
|
||||
// CreateDeliveryCacheStorageServiceWithApplicationId(nn::ApplicationId) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
||||
public ResultCode CreateDeliveryCacheStorageServiceWithApplicationId(ServiceCtx context)
|
||||
{
|
||||
ApplicationId applicationId = context.RequestData.ReadStruct<ApplicationId>();
|
||||
|
||||
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||
|
||||
Result rc = _base.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref service.Ref, applicationId);
|
||||
|
||||
if (rc.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new IDeliveryCacheStorageService(context, ref service.Ref));
|
||||
}
|
||||
|
||||
return (ResultCode)rc.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat
|
||||
{
|
||||
enum ResultCode
|
||||
{
|
||||
ModuleId = 122,
|
||||
ErrorCodeShift = 9,
|
||||
|
||||
Success = 0,
|
||||
|
||||
InvalidArgument = (1 << ErrorCodeShift) | ModuleId,
|
||||
NotFound = (2 << ErrorCodeShift) | ModuleId,
|
||||
TargetLocked = (3 << ErrorCodeShift) | ModuleId,
|
||||
TargetAlreadyMounted = (4 << ErrorCodeShift) | ModuleId,
|
||||
TargetNotMounted = (5 << ErrorCodeShift) | ModuleId,
|
||||
AlreadyOpen = (6 << ErrorCodeShift) | ModuleId,
|
||||
NotOpen = (7 << ErrorCodeShift) | ModuleId,
|
||||
InternetRequestDenied = (8 << ErrorCodeShift) | ModuleId,
|
||||
ServiceOpenLimitReached = (9 << ErrorCodeShift) | ModuleId,
|
||||
SaveDataNotFound = (10 << ErrorCodeShift) | ModuleId,
|
||||
NetworkServiceAccountNotAvailable = (31 << ErrorCodeShift) | ModuleId,
|
||||
PassphrasePathNotFound = (80 << ErrorCodeShift) | ModuleId,
|
||||
DataVerificationFailed = (81 << ErrorCodeShift) | ModuleId,
|
||||
PermissionDenied = (90 << ErrorCodeShift) | ModuleId,
|
||||
AllocationFailed = (91 << ErrorCodeShift) | ModuleId,
|
||||
InvalidOperation = (98 << ErrorCodeShift) | ModuleId,
|
||||
InvalidDeliveryCacheStorageFile = (204 << ErrorCodeShift) | ModuleId,
|
||||
StorageOpenLimitReached = (205 << ErrorCodeShift) | ModuleId
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using Ryujinx.HLE.HOS.Services.Arp;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||
{
|
||||
class IBcatService : IpcService
|
||||
{
|
||||
public IBcatService(ApplicationLaunchProperty applicationLaunchProperty) { }
|
||||
|
||||
[CommandCmif(10100)]
|
||||
// RequestSyncDeliveryCache() -> object<nn::bcat::detail::ipc::IDeliveryCacheProgressService>
|
||||
public ResultCode RequestSyncDeliveryCache(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IDeliveryCacheProgressService(context));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
using LibHac;
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||
{
|
||||
class IDeliveryCacheDirectoryService : DisposableIpcService
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> _base;
|
||||
|
||||
public IDeliveryCacheDirectoryService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> baseService)
|
||||
{
|
||||
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>.CreateMove(ref baseService);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
_base.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// Open(nn::bcat::DirectoryName)
|
||||
public ResultCode Open(ServiceCtx context)
|
||||
{
|
||||
DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
|
||||
|
||||
Result result = _base.Get.Open(ref directoryName);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// Read() -> (u32, buffer<nn::bcat::DeliveryCacheDirectoryEntry, 6>)
|
||||
public ResultCode Read(ServiceCtx context)
|
||||
{
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
{
|
||||
Result result = _base.Get.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(2)]
|
||||
// GetCount() -> u32
|
||||
public ResultCode GetCount(ServiceCtx context)
|
||||
{
|
||||
Result result = _base.Get.GetCount(out int count);
|
||||
|
||||
context.ResponseData.Write(count);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
using LibHac;
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Common;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||
{
|
||||
class IDeliveryCacheFileService : DisposableIpcService
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> _base;
|
||||
|
||||
public IDeliveryCacheFileService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> baseService)
|
||||
{
|
||||
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>.CreateMove(ref baseService);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
_base.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// Open(nn::bcat::DirectoryName, nn::bcat::FileName)
|
||||
public ResultCode Open(ServiceCtx context)
|
||||
{
|
||||
DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
|
||||
FileName fileName = context.RequestData.ReadStruct<FileName>();
|
||||
|
||||
Result result = _base.Get.Open(ref directoryName, ref fileName);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// Read(u64) -> (u64, buffer<bytes, 6>)
|
||||
public ResultCode Read(ServiceCtx context)
|
||||
{
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
long offset = context.RequestData.ReadInt64();
|
||||
|
||||
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
{
|
||||
Result result = _base.Get.Read(out long bytesRead, offset, region.Memory.Span);
|
||||
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(2)]
|
||||
// GetSize() -> u64
|
||||
public ResultCode GetSize(ServiceCtx context)
|
||||
{
|
||||
Result result = _base.Get.GetSize(out long size);
|
||||
|
||||
context.ResponseData.Write(size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(3)]
|
||||
// GetDigest() -> nn::bcat::Digest
|
||||
public ResultCode GetDigest(ServiceCtx context)
|
||||
{
|
||||
Result result = _base.Get.GetDigest(out Digest digest);
|
||||
|
||||
context.ResponseData.WriteStruct(digest);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||
{
|
||||
class IDeliveryCacheProgressService : IpcService
|
||||
{
|
||||
private KEvent _event;
|
||||
private int _eventHandle;
|
||||
|
||||
public IDeliveryCacheProgressService(ServiceCtx context)
|
||||
{
|
||||
_event = new KEvent(context.Device.System.KernelContext);
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// GetEvent() -> handle<copy>
|
||||
public ResultCode GetEvent(ServiceCtx context)
|
||||
{
|
||||
if (_eventHandle == 0)
|
||||
{
|
||||
if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out _eventHandle) != Result.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
}
|
||||
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_eventHandle);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// GetImpl() -> buffer<nn::bcat::detail::DeliveryCacheProgressImpl, 0x1a>
|
||||
public ResultCode GetImpl(ServiceCtx context)
|
||||
{
|
||||
DeliveryCacheProgressImpl deliveryCacheProgress = new DeliveryCacheProgressImpl
|
||||
{
|
||||
State = DeliveryCacheProgressImpl.Status.Done,
|
||||
Result = 0
|
||||
};
|
||||
|
||||
ulong dcpSize = WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
|
||||
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(dcpSize);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private ulong WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
|
||||
{
|
||||
return MemoryHelper.Write(context.Memory, ipcDesc.Position, deliveryCacheProgress);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
using LibHac;
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
||||
{
|
||||
class IDeliveryCacheStorageService : DisposableIpcService
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> _base;
|
||||
|
||||
public IDeliveryCacheStorageService(ServiceCtx context, ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> baseService)
|
||||
{
|
||||
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>.CreateMove(ref baseService);
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// CreateFileService() -> object<nn::bcat::detail::ipc::IDeliveryCacheFileService>
|
||||
public ResultCode CreateFileService(ServiceCtx context)
|
||||
{
|
||||
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
|
||||
|
||||
Result result = _base.Get.CreateFileService(ref service.Ref);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new IDeliveryCacheFileService(ref service.Ref));
|
||||
}
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// CreateDirectoryService() -> object<nn::bcat::detail::ipc::IDeliveryCacheDirectoryService>
|
||||
public ResultCode CreateDirectoryService(ServiceCtx context)
|
||||
{
|
||||
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
|
||||
|
||||
Result result = _base.Get.CreateDirectoryService(ref service.Ref);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
MakeObject(context, new IDeliveryCacheDirectoryService(ref service.Ref));
|
||||
}
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
|
||||
[CommandCmif(10)]
|
||||
// EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>)
|
||||
public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context)
|
||||
{
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
{
|
||||
Result result = _base.Get.EnumerateDeliveryCacheDirectory(out int count, MemoryMarshal.Cast<byte, DirectoryName>(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(count);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
_base.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Loader;
|
||||
using LibHac.Ns;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||
using ApplicationId = LibHac.Ncm.ApplicationId;
|
||||
|
||||
@ -18,8 +17,8 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||
new[] { programId },
|
||||
ModLoader.GetModsBasePath(),
|
||||
ModLoader.GetSdModsBasePath());
|
||||
device.Configuration.VirtualFileSystem.ModLoader.GetModsBasePath(),
|
||||
device.Configuration.VirtualFileSystem.ModLoader.GetSdModsBasePath());
|
||||
|
||||
if (programId != 0)
|
||||
{
|
||||
@ -37,4 +36,4 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
return processResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ApplicationId = LibHac.Ncm.ApplicationId;
|
||||
@ -36,8 +35,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
// Collecting mods related to AocTitleIds and ProgramId.
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||
device.Configuration.ContentManager.GetAocTitleIds().Prepend(metaLoader.GetProgramId()),
|
||||
ModLoader.GetModsBasePath(),
|
||||
ModLoader.GetSdModsBasePath());
|
||||
device.Configuration.VirtualFileSystem.ModLoader.GetModsBasePath(),
|
||||
device.Configuration.VirtualFileSystem.ModLoader.GetSdModsBasePath());
|
||||
|
||||
// Load Nacp file.
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
|
48
src/Ryujinx.Horizon/Bcat/BcatIpcServer.cs
Normal file
48
src/Ryujinx.Horizon/Bcat/BcatIpcServer.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using Ryujinx.Horizon.Bcat.Ipc;
|
||||
using Ryujinx.Horizon.Bcat.Types;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using Ryujinx.Horizon.Sdk.Sm;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat
|
||||
{
|
||||
internal class BcatIpcServer
|
||||
{
|
||||
private const int BcatMaxSessionsCount = 8;
|
||||
private const int BcatTotalMaxSessionsCount = BcatMaxSessionsCount * 4;
|
||||
|
||||
private const int PointerBufferSize = 0x400;
|
||||
private const int MaxDomains = 64;
|
||||
private const int MaxDomainObjects = 64;
|
||||
private const int MaxPortsCount = 4;
|
||||
|
||||
private SmApi _sm;
|
||||
private BcatServerManager _serverManager;
|
||||
|
||||
private static readonly ManagerOptions _bcatManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||
|
||||
internal void Initialize()
|
||||
{
|
||||
HeapAllocator allocator = new();
|
||||
|
||||
_sm = new SmApi();
|
||||
_sm.Initialize().AbortOnFailure();
|
||||
|
||||
_serverManager = new BcatServerManager(allocator, _sm, MaxPortsCount, _bcatManagerOptions, BcatTotalMaxSessionsCount);
|
||||
|
||||
_serverManager.RegisterServer((int)BcatPortIndex.Admin, ServiceName.Encode("bcat:a"), BcatMaxSessionsCount);
|
||||
_serverManager.RegisterServer((int)BcatPortIndex.Manager, ServiceName.Encode("bcat:m"), BcatMaxSessionsCount);
|
||||
_serverManager.RegisterServer((int)BcatPortIndex.User, ServiceName.Encode("bcat:u"), BcatMaxSessionsCount);
|
||||
_serverManager.RegisterServer((int)BcatPortIndex.System, ServiceName.Encode("bcat:s"), BcatMaxSessionsCount);
|
||||
}
|
||||
|
||||
public void ServiceRequests()
|
||||
{
|
||||
_serverManager.ServiceRequests();
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
_serverManager.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
24
src/Ryujinx.Horizon/Bcat/BcatMain.cs
Normal file
24
src/Ryujinx.Horizon/Bcat/BcatMain.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Ryujinx.Horizon.LogManager;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat
|
||||
{
|
||||
internal class BcatMain : IService
|
||||
{
|
||||
public static void Main(ServiceTable serviceTable)
|
||||
{
|
||||
BcatIpcServer ipcServer = new();
|
||||
|
||||
ipcServer.Initialize();
|
||||
|
||||
serviceTable.SignalServiceReady();
|
||||
|
||||
ipcServer.ServiceRequests();
|
||||
ipcServer.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
29
src/Ryujinx.Horizon/Bcat/BcatResult.cs
Normal file
29
src/Ryujinx.Horizon/Bcat/BcatResult.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Ryujinx.Horizon.Common;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat
|
||||
{
|
||||
class BcatResult
|
||||
{
|
||||
private const int ModuleId = 122;
|
||||
|
||||
public static Result Success => new(ModuleId, 0);
|
||||
public static Result InvalidArgument => new(ModuleId, 1);
|
||||
public static Result NotFound => new(ModuleId, 2);
|
||||
public static Result TargetLocked => new(ModuleId, 3);
|
||||
public static Result TargetAlreadyMounted => new(ModuleId, 4);
|
||||
public static Result TargetNotMounted => new(ModuleId, 5);
|
||||
public static Result AlreadyOpen => new(ModuleId, 6);
|
||||
public static Result NotOpen => new(ModuleId, 7);
|
||||
public static Result InternetRequestDenied => new(ModuleId, 8);
|
||||
public static Result ServiceOpenLimitReached => new(ModuleId, 9);
|
||||
public static Result SaveDataNotFound => new(ModuleId, 10);
|
||||
public static Result NetworkServiceAccountNotAvailable => new(ModuleId, 31);
|
||||
public static Result PassphrasePathNotFound => new(ModuleId, 80);
|
||||
public static Result DataVerificationFailed => new(ModuleId, 81);
|
||||
public static Result PermissionDenied => new(ModuleId, 90);
|
||||
public static Result AllocationFailed => new(ModuleId, 91);
|
||||
public static Result InvalidOperation => new(ModuleId, 98);
|
||||
public static Result InvalidDeliveryCacheStorageFile => new(ModuleId, 204);
|
||||
public static Result StorageOpenLimitReached => new(ModuleId, 205);
|
||||
}
|
||||
}
|
28
src/Ryujinx.Horizon/Bcat/BcatServerManager.cs
Normal file
28
src/Ryujinx.Horizon/Bcat/BcatServerManager.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Ryujinx.Horizon.Bcat.Ipc;
|
||||
using Ryujinx.Horizon.Bcat.Types;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using Ryujinx.Horizon.Sdk.Sm;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat
|
||||
{
|
||||
class BcatServerManager : ServerManager
|
||||
{
|
||||
public BcatServerManager(HeapAllocator allocator, SmApi sm, int maxPorts, ManagerOptions options, int maxSessions) : base(allocator, sm, maxPorts, options, maxSessions)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Result OnNeedsToAccept(int portIndex, Server server)
|
||||
{
|
||||
return (BcatPortIndex)portIndex switch
|
||||
{
|
||||
BcatPortIndex.Admin => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.Admin)),
|
||||
BcatPortIndex.Manager => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.Manager)),
|
||||
BcatPortIndex.User => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.User)),
|
||||
BcatPortIndex.System => AcceptImpl(server, new BcatService(BcatServicePermissionLevel.System)),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(portIndex)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
82
src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs
Normal file
82
src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using ApplicationId = Ryujinx.Horizon.Sdk.Ncm.ApplicationId;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class ServiceCreator : IServiceCreator, IDisposable
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _libHacService;
|
||||
|
||||
private int _disposalState;
|
||||
|
||||
public ServiceCreator(string serviceName)
|
||||
{
|
||||
HorizonStatic.Options.BcatClient.Sm.GetService(ref _libHacService, serviceName).ThrowIfFailure();
|
||||
}
|
||||
|
||||
[CmifCommand(0)]
|
||||
public Result CreateBcatService(out IBcatService bcatService, [ClientProcessId] ulong pid)
|
||||
{
|
||||
// TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
|
||||
// Add an instance of nn::bcat::detail::service::core::PassphraseManager.
|
||||
// Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
|
||||
// Add an instance of nn::bcat::detail::service::core::TaskManager who loads "bcat-sys:/" system save data and opens "dc/task.bin".
|
||||
// If the file don't exist, create a new one (with a size of 0x800 bytes) and write 2 empty structs with a size of 0x400 bytes.
|
||||
|
||||
bcatService = new BcatService(Bcat.Types.BcatServicePermissionLevel.User);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(1)]
|
||||
public Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, [ClientProcessId] ulong pid)
|
||||
{
|
||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||
|
||||
var resultCode = _libHacService.Get.CreateDeliveryCacheStorageService(ref libHacService.Ref, pid);
|
||||
|
||||
if (resultCode.IsSuccess())
|
||||
{
|
||||
service = new DeliveryCacheStorageService(ref libHacService.Ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
service = null;
|
||||
}
|
||||
|
||||
return resultCode.ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(2)]
|
||||
public Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, ApplicationId applicationId)
|
||||
{
|
||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
||||
|
||||
var resultCode = _libHacService.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref libHacService.Ref, new LibHac.ApplicationId(applicationId.Id));
|
||||
|
||||
if (resultCode.IsSuccess())
|
||||
{
|
||||
service = new DeliveryCacheStorageService(ref libHacService.Ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
service = null;
|
||||
}
|
||||
|
||||
return resultCode.ToHorizonResult();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
||||
{
|
||||
_libHacService.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/BcatService.cs
Normal file
25
src/Ryujinx.Horizon/Bcat/Ipc/ServiceCreator/BcatService.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Ryujinx.Horizon.Bcat.Types;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class BcatService : IBcatService
|
||||
{
|
||||
private readonly BcatServicePermissionLevel _permissionLevel;
|
||||
|
||||
public BcatService(BcatServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
[CmifCommand(10100)]
|
||||
public Result RequestSyncDeliveryCache(out IDeliveryCacheProgressService deliveryCacheProgressService)
|
||||
{
|
||||
deliveryCacheProgressService = new DeliveryCacheProgressService();
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService, IDisposable
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> _libHacService;
|
||||
private int _disposalState;
|
||||
|
||||
public DeliveryCacheDirectoryService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> libHacService)
|
||||
{
|
||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>.CreateMove(ref libHacService);
|
||||
}
|
||||
|
||||
[CmifCommand(0)]
|
||||
public Result Open(DirectoryName directoryName)
|
||||
{
|
||||
return _libHacService.Get.Open(ref directoryName).ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(1)]
|
||||
public Result Read(out int entriesRead, [Buffer(Sdk.Sf.Hipc.HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DeliveryCacheDirectoryEntry> entriesBuffer)
|
||||
{
|
||||
return _libHacService.Get.Read(out entriesRead, entriesBuffer).ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(2)]
|
||||
public Result GetCount(out int count)
|
||||
{
|
||||
return _libHacService.Get.GetCount(out count).ToHorizonResult();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
||||
{
|
||||
_libHacService.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class DeliveryCacheFileService : IDeliveryCacheFileService, IDisposable
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> _libHacService;
|
||||
private int _disposalState;
|
||||
|
||||
public DeliveryCacheFileService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService> libHacService)
|
||||
{
|
||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>.CreateMove(ref libHacService);
|
||||
}
|
||||
|
||||
[CmifCommand(0)]
|
||||
public Result Open(DirectoryName directoryName, FileName fileName)
|
||||
{
|
||||
return _libHacService.Get.Open(ref directoryName, ref fileName).ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(1)]
|
||||
public Result Read(long offset, out long bytesRead, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> data)
|
||||
{
|
||||
return _libHacService.Get.Read(out bytesRead, offset, data).ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(2)]
|
||||
public Result GetSize(out long size)
|
||||
{
|
||||
return _libHacService.Get.GetSize(out size).ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(3)]
|
||||
public Result GetDigest(out Digest digest)
|
||||
{
|
||||
return _libHacService.Get.GetDigest(out digest).ToHorizonResult();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
||||
{
|
||||
_libHacService.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Horizon.Bcat.Ipc.Types;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.OsTypes;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class DeliveryCacheProgressService : IDeliveryCacheProgressService, IDisposable
|
||||
{
|
||||
private int _handle;
|
||||
private SystemEventType _systemEvent;
|
||||
private int _disposalState;
|
||||
|
||||
[CmifCommand(0)]
|
||||
public Result GetEvent([CopyHandle] out int handle)
|
||||
{
|
||||
if (_handle == 0)
|
||||
{
|
||||
Os.CreateSystemEvent(out _systemEvent, EventClearMode.ManualClear, true).AbortOnFailure();
|
||||
|
||||
_handle = Os.GetReadableHandleOfSystemEvent(ref _systemEvent);
|
||||
}
|
||||
|
||||
handle = _handle;
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
[CmifCommand(1)]
|
||||
public Result GetImpl([Buffer(HipcBufferFlags.Out | HipcBufferFlags.Pointer, 0x200)] out DeliveryCacheProgressImpl deliveryCacheProgressImpl)
|
||||
{
|
||||
deliveryCacheProgressImpl = new DeliveryCacheProgressImpl
|
||||
{
|
||||
State = DeliveryCacheProgressImpl.Status.Done,
|
||||
Result = 0
|
||||
};
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceBcat);
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_handle != 0 && Interlocked.Exchange(ref _disposalState, 1) == 0)
|
||||
{
|
||||
Os.DestroySystemEvent(ref _systemEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
using LibHac.Bcat;
|
||||
using LibHac.Common;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Bcat;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using Ryujinx.Horizon.Sdk.Sf.Hipc;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc
|
||||
{
|
||||
partial class DeliveryCacheStorageService : IDeliveryCacheStorageService, IDisposable
|
||||
{
|
||||
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> _libHacService;
|
||||
private int _disposalState;
|
||||
|
||||
public DeliveryCacheStorageService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> libHacService)
|
||||
{
|
||||
_libHacService = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>.CreateMove(ref libHacService);
|
||||
}
|
||||
|
||||
[CmifCommand(0)]
|
||||
public Result CreateFileService(out IDeliveryCacheFileService service)
|
||||
{
|
||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
|
||||
|
||||
var resultCode = _libHacService.Get.CreateFileService(ref libHacService.Ref);
|
||||
|
||||
if (resultCode.IsSuccess())
|
||||
{
|
||||
service = new DeliveryCacheFileService(ref libHacService.Ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
service = null;
|
||||
}
|
||||
|
||||
return resultCode.ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(1)]
|
||||
public Result CreateDirectoryService(out IDeliveryCacheDirectoryService service)
|
||||
{
|
||||
using var libHacService = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
|
||||
|
||||
var resultCode = _libHacService.Get.CreateDirectoryService(ref libHacService.Ref);
|
||||
|
||||
if (resultCode.IsSuccess())
|
||||
{
|
||||
service = new DeliveryCacheDirectoryService(ref libHacService.Ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
service = null;
|
||||
}
|
||||
|
||||
return resultCode.ToHorizonResult();
|
||||
}
|
||||
|
||||
[CmifCommand(10)]
|
||||
public Result EnumerateDeliveryCacheDirectory(out int count, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<DirectoryName> directoryNames)
|
||||
{
|
||||
return _libHacService.Get.EnumerateDeliveryCacheDirectory(out count, directoryNames).ToHorizonResult();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _disposalState, 1) == 0)
|
||||
{
|
||||
_libHacService.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types
|
||||
namespace Ryujinx.Horizon.Bcat.Ipc.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
public struct DeliveryCacheProgressImpl
|
10
src/Ryujinx.Horizon/Bcat/Types/BcatPortIndex.cs
Normal file
10
src/Ryujinx.Horizon/Bcat/Types/BcatPortIndex.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Ryujinx.Horizon.Bcat.Types
|
||||
{
|
||||
enum BcatPortIndex
|
||||
{
|
||||
Admin,
|
||||
Manager,
|
||||
User,
|
||||
System
|
||||
}
|
||||
}
|
10
src/Ryujinx.Horizon/Bcat/Types/BcatServicePermissionLevel.cs
Normal file
10
src/Ryujinx.Horizon/Bcat/Types/BcatServicePermissionLevel.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Ryujinx.Horizon.Bcat.Types
|
||||
{
|
||||
enum BcatServicePermissionLevel
|
||||
{
|
||||
Admin = -1,
|
||||
User = 1,
|
||||
System = 2,
|
||||
Manager = 6
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using LibHac;
|
||||
|
||||
namespace Ryujinx.Horizon
|
||||
{
|
||||
public struct HorizonOptions
|
||||
@ -5,10 +7,13 @@ namespace Ryujinx.Horizon
|
||||
public bool IgnoreMissingServices { get; }
|
||||
public bool ThrowOnInvalidCommandIds { get; }
|
||||
|
||||
public HorizonOptions(bool ignoreMissingServices)
|
||||
public HorizonClient BcatClient { get; }
|
||||
|
||||
public HorizonOptions(bool ignoreMissingServices, HorizonClient bcatClient)
|
||||
{
|
||||
IgnoreMissingServices = ignoreMissingServices;
|
||||
ThrowOnInvalidCommandIds = true;
|
||||
BcatClient = bcatClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
src/Ryujinx.Horizon/LibHacResultExtensions.cs
Normal file
12
src/Ryujinx.Horizon/LibHacResultExtensions.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Horizon.Common;
|
||||
|
||||
namespace Ryujinx.Horizon
|
||||
{
|
||||
internal static class LibHacResultExtensions
|
||||
{
|
||||
public static Result ToHorizonResult(this LibHac.Result result)
|
||||
{
|
||||
return new Result((int)result.Module, (int)result.Description);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,12 +9,12 @@ namespace Ryujinx.Horizon.Prepo
|
||||
private const int PrepoMaxSessionsCount = 12;
|
||||
private const int PrepoTotalMaxSessionsCount = PrepoMaxSessionsCount * 6;
|
||||
|
||||
private const int PointerBufferSize = 0x3800;
|
||||
private const int PointerBufferSize = 0x80;
|
||||
private const int MaxDomains = 64;
|
||||
private const int MaxDomainObjects = 16;
|
||||
private const int MaxPortsCount = 6;
|
||||
|
||||
private static readonly ManagerOptions _logManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||
private static readonly ManagerOptions _prepoManagerOptions = new(PointerBufferSize, MaxDomains, MaxDomainObjects, false);
|
||||
|
||||
private SmApi _sm;
|
||||
private PrepoServerManager _serverManager;
|
||||
@ -26,7 +26,7 @@ namespace Ryujinx.Horizon.Prepo
|
||||
_sm = new SmApi();
|
||||
_sm.Initialize().AbortOnFailure();
|
||||
|
||||
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _logManagerOptions, PrepoTotalMaxSessionsCount);
|
||||
_serverManager = new PrepoServerManager(allocator, _sm, MaxPortsCount, _prepoManagerOptions, PrepoTotalMaxSessionsCount);
|
||||
|
||||
_serverManager.RegisterServer((int)PrepoPortIndex.Admin, ServiceName.Encode("prepo:a"), PrepoMaxSessionsCount); // 1.0.0-5.1.0
|
||||
_serverManager.RegisterServer((int)PrepoPortIndex.Admin2, ServiceName.Encode("prepo:a2"), PrepoMaxSessionsCount); // 6.0.0+
|
||||
|
10
src/Ryujinx.Horizon/Sdk/Bcat/IBcatService.cs
Normal file
10
src/Ryujinx.Horizon/Sdk/Bcat/IBcatService.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IBcatService : IServiceObject
|
||||
{
|
||||
Result RequestSyncDeliveryCache(out IDeliveryCacheProgressService deliveryCacheProgressService);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using LibHac.Bcat;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IDeliveryCacheDirectoryService : IServiceObject
|
||||
{
|
||||
Result GetCount(out int count);
|
||||
Result Open(DirectoryName directoryName);
|
||||
Result Read(out int entriesRead, Span<DeliveryCacheDirectoryEntry> entriesBuffer);
|
||||
}
|
||||
}
|
15
src/Ryujinx.Horizon/Sdk/Bcat/IDeliveryCacheFileService.cs
Normal file
15
src/Ryujinx.Horizon/Sdk/Bcat/IDeliveryCacheFileService.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using LibHac.Bcat;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IDeliveryCacheFileService : IServiceObject
|
||||
{
|
||||
Result GetDigest(out Digest digest);
|
||||
Result GetSize(out long size);
|
||||
Result Open(DirectoryName directoryName, FileName fileName);
|
||||
Result Read(long offset, out long bytesRead, Span<byte> data);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Horizon.Bcat.Ipc.Types;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IDeliveryCacheProgressService : IServiceObject
|
||||
{
|
||||
Result GetEvent(out int handle);
|
||||
Result GetImpl(out DeliveryCacheProgressImpl deliveryCacheProgressImpl);
|
||||
}
|
||||
}
|
14
src/Ryujinx.Horizon/Sdk/Bcat/IDeliveryCacheStorageService.cs
Normal file
14
src/Ryujinx.Horizon/Sdk/Bcat/IDeliveryCacheStorageService.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using LibHac.Bcat;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IDeliveryCacheStorageService : IServiceObject
|
||||
{
|
||||
Result CreateDirectoryService(out IDeliveryCacheDirectoryService service);
|
||||
Result CreateFileService(out IDeliveryCacheFileService service);
|
||||
Result EnumerateDeliveryCacheDirectory(out int count, Span<DirectoryName> directoryNames);
|
||||
}
|
||||
}
|
12
src/Ryujinx.Horizon/Sdk/Bcat/IServiceCreator.cs
Normal file
12
src/Ryujinx.Horizon/Sdk/Bcat/IServiceCreator.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Sf;
|
||||
|
||||
namespace Ryujinx.Horizon.Sdk.Bcat
|
||||
{
|
||||
internal interface IServiceCreator : IServiceObject
|
||||
{
|
||||
Result CreateBcatService(out IBcatService service, ulong pid);
|
||||
Result CreateDeliveryCacheStorageService(out IDeliveryCacheStorageService service, ulong pid);
|
||||
Result CreateDeliveryCacheStorageServiceWithApplicationId(out IDeliveryCacheStorageService service, Ncm.ApplicationId applicationId);
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using Ryujinx.Horizon.Bcat;
|
||||
using Ryujinx.Horizon.LogManager;
|
||||
using Ryujinx.Horizon.Prepo;
|
||||
using System.Collections.Generic;
|
||||
@ -23,6 +24,7 @@ namespace Ryujinx.Horizon
|
||||
|
||||
RegisterService<LmMain>();
|
||||
RegisterService<PrepoMain>();
|
||||
RegisterService<BcatMain>();
|
||||
|
||||
_totalServices = entries.Count;
|
||||
|
||||
|
@ -460,16 +460,16 @@ namespace Ryujinx.Ui.Widgets
|
||||
|
||||
private void OpenTitleModDir_Clicked(object sender, EventArgs args)
|
||||
{
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, _titleIdText);
|
||||
string modsBasePath = _virtualFileSystem.ModLoader.GetModsBasePath();
|
||||
string titleModsPath = _virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, _titleIdText);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
}
|
||||
|
||||
private void OpenTitleSdModDir_Clicked(object sender, EventArgs args)
|
||||
{
|
||||
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, _titleIdText);
|
||||
string sdModsBasePath = _virtualFileSystem.ModLoader.GetSdModsBasePath();
|
||||
string titleModsPath = _virtualFileSystem.ModLoader.GetTitleDir(sdModsBasePath, _titleIdText);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ namespace Ryujinx.Ui.Windows
|
||||
builder.Autoconnect(this);
|
||||
_baseTitleInfoLabel.Text = $"Cheats Available for {titleName} [{titleId:X16}]";
|
||||
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
||||
string modsBasePath = virtualFileSystem.ModLoader.GetModsBasePath();
|
||||
string titleModsPath = virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, titleId.ToString("X16"));
|
||||
|
||||
_enabledCheatsPath = System.IO.Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
||||
|
||||
|
@ -720,6 +720,7 @@ namespace Ryujinx.Ui.Windows
|
||||
if (Directory.Exists(_addGameDirBox.Buffer.Text))
|
||||
{
|
||||
_gameDirsBoxStore.AppendValues(_addGameDirBox.Buffer.Text);
|
||||
_directoryChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -835,4 +836,4 @@ namespace Ryujinx.Ui.Windows
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user