mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-07 17:10:02 +02:00
misc: chore: Use explicit types & fix object creation
This commit is contained in:
@@ -3,6 +3,7 @@ using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -52,12 +53,12 @@ namespace Ryujinx.HLE.Exceptions
|
||||
if (callingType != null && callingMethod != null)
|
||||
{
|
||||
// If the type is past 0xF, we are using TIPC
|
||||
var ipcCommands = Request.Type > IpcMessageType.TipcCloseSession ? Service.TipcCommands : Service.CmifCommands;
|
||||
IReadOnlyDictionary<int, MethodInfo> ipcCommands = Request.Type > IpcMessageType.TipcCloseSession ? Service.TipcCommands : Service.CmifCommands;
|
||||
|
||||
// Find the handler for the method called
|
||||
var ipcHandler = ipcCommands.FirstOrDefault(x => x.Value == callingMethod);
|
||||
var ipcCommandId = ipcHandler.Key;
|
||||
var ipcMethod = ipcHandler.Value;
|
||||
KeyValuePair<int, MethodInfo> ipcHandler = ipcCommands.FirstOrDefault(x => x.Value == callingMethod);
|
||||
int ipcCommandId = ipcHandler.Key;
|
||||
MethodInfo ipcMethod = ipcHandler.Value;
|
||||
|
||||
if (ipcMethod != null)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ namespace Ryujinx.HLE.Exceptions
|
||||
{
|
||||
sb.AppendLine("\tPtrBuff:");
|
||||
|
||||
foreach (var buff in Request.PtrBuff)
|
||||
foreach (IpcPtrBuffDesc buff in Request.PtrBuff)
|
||||
{
|
||||
sb.AppendLine($"\t[{buff.Index}] Position: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
|
||||
}
|
||||
@@ -92,7 +93,7 @@ namespace Ryujinx.HLE.Exceptions
|
||||
{
|
||||
sb.AppendLine("\tSendBuff:");
|
||||
|
||||
foreach (var buff in Request.SendBuff)
|
||||
foreach (IpcBuffDesc buff in Request.SendBuff)
|
||||
{
|
||||
sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
|
||||
}
|
||||
@@ -102,7 +103,7 @@ namespace Ryujinx.HLE.Exceptions
|
||||
{
|
||||
sb.AppendLine("\tReceiveBuff:");
|
||||
|
||||
foreach (var buff in Request.ReceiveBuff)
|
||||
foreach (IpcBuffDesc buff in Request.ReceiveBuff)
|
||||
{
|
||||
sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
|
||||
}
|
||||
@@ -112,7 +113,7 @@ namespace Ryujinx.HLE.Exceptions
|
||||
{
|
||||
sb.AppendLine("\tExchangeBuff:");
|
||||
|
||||
foreach (var buff in Request.ExchangeBuff)
|
||||
foreach (IpcBuffDesc buff in Request.ExchangeBuff)
|
||||
{
|
||||
sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}");
|
||||
}
|
||||
@@ -122,7 +123,7 @@ namespace Ryujinx.HLE.Exceptions
|
||||
{
|
||||
sb.AppendLine("\tRecvListBuff:");
|
||||
|
||||
foreach (var buff in Request.RecvListBuff)
|
||||
foreach (IpcRecvListBuffDesc buff in Request.RecvListBuff)
|
||||
{
|
||||
sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}");
|
||||
}
|
||||
@@ -146,8 +147,8 @@ namespace Ryujinx.HLE.Exceptions
|
||||
// Find the IIpcService method that threw this exception
|
||||
while ((frame = trace.GetFrame(i++)) != null)
|
||||
{
|
||||
var method = frame.GetMethod();
|
||||
var declType = method?.DeclaringType;
|
||||
MethodBase method = frame.GetMethod();
|
||||
Type declType = method?.DeclaringType;
|
||||
|
||||
if (typeof(IpcService).IsAssignableFrom(declType))
|
||||
{
|
||||
|
||||
@@ -107,15 +107,15 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
foreach (StorageId storageId in Enum.GetValues<StorageId>())
|
||||
{
|
||||
if (!ContentPath.TryGetContentPath(storageId, out var contentPathString))
|
||||
if (!ContentPath.TryGetContentPath(storageId, out string contentPathString))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!ContentPath.TryGetRealPath(contentPathString, out var contentDirectory))
|
||||
if (!ContentPath.TryGetRealPath(contentPathString, out string contentDirectory))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var registeredDirectory = Path.Combine(contentDirectory, "registered");
|
||||
string registeredDirectory = Path.Combine(contentDirectory, "registered");
|
||||
|
||||
Directory.CreateDirectory(registeredDirectory);
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
if (_locationEntries.TryGetValue(storageId, out var locationEntriesItem) && locationEntriesItem?.Count == 0)
|
||||
if (_locationEntries.TryGetValue(storageId, out LinkedList<LocationEntry> locationEntriesItem) && locationEntriesItem?.Count == 0)
|
||||
{
|
||||
_locationEntries.Remove(storageId);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
if (!mergedToContainer)
|
||||
{
|
||||
using var pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(containerPath, _virtualFileSystem);
|
||||
using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(containerPath, _virtualFileSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,17 +217,17 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
if (AocData.TryGetValue(aocTitleId, out AocItem aoc))
|
||||
{
|
||||
var file = new FileStream(aoc.ContainerPath, FileMode.Open, FileAccess.Read);
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
FileStream file = new(aoc.ContainerPath, FileMode.Open, FileAccess.Read);
|
||||
using UniqueRef<IFile> ncaFile = new();
|
||||
|
||||
switch (Path.GetExtension(aoc.ContainerPath))
|
||||
{
|
||||
case ".xci":
|
||||
var xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure);
|
||||
XciPartition xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure);
|
||||
xci.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
break;
|
||||
case ".nsp":
|
||||
var pfs = new PartitionFileSystem();
|
||||
PartitionFileSystem pfs = new();
|
||||
pfs.Initialize(file.AsStorage());
|
||||
pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
break;
|
||||
@@ -278,7 +278,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
if (_contentDictionary.ContainsValue(ncaId))
|
||||
{
|
||||
var content = _contentDictionary.FirstOrDefault(x => x.Value == ncaId);
|
||||
KeyValuePair<(ulong titleId, NcaContentType type), string> content = _contentDictionary.FirstOrDefault(x => x.Value == ncaId);
|
||||
ulong titleId = content.Key.titleId;
|
||||
|
||||
NcaContentType contentType = content.Key.type;
|
||||
@@ -295,7 +295,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_contentDictionary.TryGetValue((titleId, contentType), out var contentDictionaryItem))
|
||||
if (_contentDictionary.TryGetValue((titleId, contentType), out string contentDictionaryItem))
|
||||
{
|
||||
return UInt128Utils.FromHex(contentDictionaryItem);
|
||||
}
|
||||
@@ -430,8 +430,8 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
public void InstallFirmware(string firmwareSource)
|
||||
{
|
||||
ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out var contentPathString);
|
||||
ContentPath.TryGetRealPath(contentPathString, out var contentDirectory);
|
||||
ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out string contentPathString);
|
||||
ContentPath.TryGetRealPath(contentPathString, out string contentDirectory);
|
||||
string registeredDirectory = Path.Combine(contentDirectory, "registered");
|
||||
string temporaryDirectory = Path.Combine(contentDirectory, "temp");
|
||||
|
||||
@@ -478,8 +478,8 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
public void InstallFirmware(Stream stream, bool isXci)
|
||||
{
|
||||
ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out var contentPathString);
|
||||
ContentPath.TryGetRealPath(contentPathString, out var contentDirectory);
|
||||
ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out string contentPathString);
|
||||
ContentPath.TryGetRealPath(contentPathString, out string contentDirectory);
|
||||
string registeredDirectory = Path.Combine(contentDirectory, "registered");
|
||||
string temporaryDirectory = Path.Combine(contentDirectory, "temp");
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
if (Directory.Exists(keysSource))
|
||||
{
|
||||
foreach (var filePath in Directory.EnumerateFiles(keysSource, "*.keys"))
|
||||
foreach (string filePath in Directory.EnumerateFiles(keysSource, "*.keys"))
|
||||
{
|
||||
VerifyKeysFile(filePath);
|
||||
File.Copy(filePath, Path.Combine(installDirectory, Path.GetFileName(filePath)), true);
|
||||
@@ -544,7 +544,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
Directory.Delete(temporaryDirectory, true);
|
||||
}
|
||||
Directory.CreateDirectory(temporaryDirectory);
|
||||
foreach (var entry in archive.Entries)
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (Path.GetExtension(entry.FullName).Equals(".keys", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -584,7 +584,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
private void InstallFromPartition(IFileSystem filesystem, string temporaryDirectory)
|
||||
{
|
||||
foreach (var entry in filesystem.EnumerateEntries("/", "*.nca"))
|
||||
foreach (DirectoryEntryEx entry in filesystem.EnumerateEntries("/", "*.nca"))
|
||||
{
|
||||
Nca nca = new(_virtualFileSystem.KeySet, OpenPossibleFragmentedFile(filesystem, entry.FullPath, OpenMode.Read).AsStorage());
|
||||
|
||||
@@ -608,7 +608,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
private static void InstallFromZip(ZipArchive archive, string temporaryDirectory)
|
||||
{
|
||||
foreach (var entry in archive.Entries)
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (entry.FullName.EndsWith(".nca") || entry.FullName.EndsWith(".nca/00"))
|
||||
{
|
||||
@@ -648,7 +648,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
private static IFile OpenPossibleFragmentedFile(IFileSystem filesystem, string path, OpenMode mode)
|
||||
{
|
||||
using var file = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> file = new();
|
||||
|
||||
if (filesystem.FileExists($"{path}/00"))
|
||||
{
|
||||
@@ -759,7 +759,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
Dictionary<ulong, List<(NcaContentType type, string path)>> updateNcas = new();
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
if (entry.FullName.EndsWith(".nca") || entry.FullName.EndsWith(".nca/00"))
|
||||
{
|
||||
@@ -768,7 +768,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
Nca nca = new(_virtualFileSystem.KeySet, storage);
|
||||
|
||||
if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem))
|
||||
if (updateNcas.TryGetValue(nca.Header.TitleId, out List<(NcaContentType type, string path)> updateNcasItem))
|
||||
{
|
||||
updateNcasItem.Add((nca.Header.ContentType, entry.FullName));
|
||||
}
|
||||
@@ -779,13 +779,13 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
if (updateNcas.TryGetValue(SystemUpdateTitleId, out var ncaEntry))
|
||||
if (updateNcas.TryGetValue(SystemUpdateTitleId, out List<(NcaContentType type, string path)> ncaEntry))
|
||||
{
|
||||
string metaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path;
|
||||
|
||||
CnmtContentMetaEntry[] metaEntries = null;
|
||||
|
||||
var fileEntry = archive.GetEntry(metaPath);
|
||||
ZipArchiveEntry fileEntry = archive.GetEntry(metaPath);
|
||||
|
||||
using (Stream ncaStream = GetZipStream(fileEntry))
|
||||
{
|
||||
@@ -795,11 +795,11 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
|
||||
|
||||
using var metaFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> metaFile = new();
|
||||
|
||||
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
var meta = new Cnmt(metaFile.Get.AsStream());
|
||||
Cnmt meta = new(metaFile.Get.AsStream());
|
||||
|
||||
if (meta.Type == ContentMetaType.SystemUpdate)
|
||||
{
|
||||
@@ -815,16 +815,16 @@ namespace Ryujinx.HLE.FileSystem
|
||||
throw new FileNotFoundException("System update title was not found in the firmware package.");
|
||||
}
|
||||
|
||||
if (updateNcas.TryGetValue(SystemVersionTitleId, out var updateNcasItem))
|
||||
if (updateNcas.TryGetValue(SystemVersionTitleId, out List<(NcaContentType type, string path)> updateNcasItem))
|
||||
{
|
||||
string versionEntry = updateNcasItem.FirstOrDefault(x => x.type != NcaContentType.Meta).path;
|
||||
|
||||
using Stream ncaStream = GetZipStream(archive.GetEntry(versionEntry));
|
||||
Nca nca = new(_virtualFileSystem.KeySet, ncaStream.AsStorage());
|
||||
|
||||
var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
|
||||
using var systemVersionFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> systemVersionFile = new();
|
||||
|
||||
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
@@ -860,11 +860,11 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
|
||||
|
||||
using var metaFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> metaFile = new();
|
||||
|
||||
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
var meta = new Cnmt(metaFile.Get.AsStream());
|
||||
Cnmt meta = new(metaFile.Get.AsStream());
|
||||
|
||||
IStorage contentStorage = contentNcaStream.AsStorage();
|
||||
if (contentStorage.GetSize(out long size).IsSuccess())
|
||||
@@ -892,9 +892,9 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
StringBuilder extraNcas = new();
|
||||
|
||||
foreach (var entry in updateNcas)
|
||||
foreach (KeyValuePair<ulong, List<(NcaContentType type, string path)>> entry in updateNcas)
|
||||
{
|
||||
foreach (var (type, path) in entry.Value)
|
||||
foreach ((NcaContentType type, string path) in entry.Value)
|
||||
{
|
||||
extraNcas.AppendLine(path);
|
||||
}
|
||||
@@ -919,7 +919,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
Dictionary<ulong, List<(NcaContentType type, string path)>> updateNcas = new();
|
||||
|
||||
foreach (var entry in filesystem.EnumerateEntries("/", "*.nca"))
|
||||
foreach (DirectoryEntryEx entry in filesystem.EnumerateEntries("/", "*.nca"))
|
||||
{
|
||||
IStorage ncaStorage = OpenPossibleFragmentedFile(filesystem, entry.FullPath, OpenMode.Read).AsStorage();
|
||||
|
||||
@@ -931,11 +931,11 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
|
||||
|
||||
using var metaFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> metaFile = new();
|
||||
|
||||
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
var meta = new Cnmt(metaFile.Get.AsStream());
|
||||
Cnmt meta = new(metaFile.Get.AsStream());
|
||||
|
||||
if (meta.Type == ContentMetaType.SystemUpdate)
|
||||
{
|
||||
@@ -947,9 +947,9 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
else if (nca.Header.TitleId == SystemVersionTitleId && nca.Header.ContentType == NcaContentType.Data)
|
||||
{
|
||||
var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
|
||||
using var systemVersionFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> systemVersionFile = new();
|
||||
|
||||
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
@@ -957,7 +957,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem))
|
||||
if (updateNcas.TryGetValue(nca.Header.TitleId, out List<(NcaContentType type, string path)> updateNcasItem))
|
||||
{
|
||||
updateNcasItem.Add((nca.Header.ContentType, entry.FullPath));
|
||||
}
|
||||
@@ -976,7 +976,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
foreach (CnmtContentMetaEntry metaEntry in metaEntries)
|
||||
{
|
||||
if (updateNcas.TryGetValue(metaEntry.TitleId, out var ncaEntry))
|
||||
if (updateNcas.TryGetValue(metaEntry.TitleId, out List<(NcaContentType type, string path)> ncaEntry))
|
||||
{
|
||||
string metaNcaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path;
|
||||
string contentPath = ncaEntry.FirstOrDefault(x => x.type != NcaContentType.Meta).path;
|
||||
@@ -999,11 +999,11 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
|
||||
|
||||
using var metaFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> metaFile = new();
|
||||
|
||||
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
var meta = new Cnmt(metaFile.Get.AsStream());
|
||||
Cnmt meta = new(metaFile.Get.AsStream());
|
||||
|
||||
if (contentStorage.GetSize(out long size).IsSuccess())
|
||||
{
|
||||
@@ -1030,9 +1030,9 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
StringBuilder extraNcas = new();
|
||||
|
||||
foreach (var entry in updateNcas)
|
||||
foreach (KeyValuePair<ulong, List<(NcaContentType type, string path)>> entry in updateNcas)
|
||||
{
|
||||
foreach (var (type, path) in entry.Value)
|
||||
foreach ((NcaContentType type, string path) in entry.Value)
|
||||
{
|
||||
extraNcas.AppendLine(path);
|
||||
}
|
||||
@@ -1050,22 +1050,22 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
var locationEnties = _locationEntries[StorageId.BuiltInSystem];
|
||||
LinkedList<LocationEntry> locationEnties = _locationEntries[StorageId.BuiltInSystem];
|
||||
|
||||
foreach (var entry in locationEnties)
|
||||
foreach (LocationEntry entry in locationEnties)
|
||||
{
|
||||
if (entry.ContentType == NcaContentType.Data)
|
||||
{
|
||||
var path = VirtualFileSystem.SwitchPathToSystemPath(entry.ContentPath);
|
||||
string path = VirtualFileSystem.SwitchPathToSystemPath(entry.ContentPath);
|
||||
|
||||
using FileStream fileStream = File.OpenRead(path);
|
||||
Nca nca = new(_virtualFileSystem.KeySet, fileStream.AsStorage());
|
||||
|
||||
if (nca.Header.TitleId == SystemVersionTitleId && nca.Header.ContentType == NcaContentType.Data)
|
||||
{
|
||||
var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
|
||||
|
||||
using var systemVersionFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> systemVersionFile = new();
|
||||
|
||||
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
|
||||
{
|
||||
@@ -1132,7 +1132,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
public bool AreKeysAlredyPresent(string pathToCheck)
|
||||
{
|
||||
string[] fileNames = ["prod.keys", "title.keys", "console.keys", "dev.keys"];
|
||||
foreach (var file in fileNames)
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
if (File.Exists(Path.Combine(pathToCheck, file)))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
// TODO: Replace this with a check for IdOffset as soon as LibHac supports it:
|
||||
// && entry.IdOffset == programIndex
|
||||
|
||||
foreach (var entry in _cnmt.ContentEntries)
|
||||
foreach (CnmtContentEntry entry in _cnmt.ContentEntries)
|
||||
{
|
||||
if (entry.Type != type)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
public void LoadRomFs(ulong pid, string fileName)
|
||||
{
|
||||
var romfsStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||
FileStream romfsStream = new(fileName, FileMode.Open, FileAccess.Read);
|
||||
|
||||
_romFsByPid.AddOrUpdate(pid, romfsStream, (_, oldStream) =>
|
||||
{
|
||||
@@ -140,8 +140,8 @@ namespace Ryujinx.HLE.FileSystem
|
||||
return $"{rawPath}:/";
|
||||
}
|
||||
|
||||
var basePath = rawPath.AsSpan(0, firstSeparatorOffset);
|
||||
var fileName = rawPath.AsSpan(firstSeparatorOffset + 1);
|
||||
ReadOnlySpan<char> basePath = rawPath.AsSpan(0, firstSeparatorOffset);
|
||||
ReadOnlySpan<char> fileName = rawPath.AsSpan(firstSeparatorOffset + 1);
|
||||
|
||||
return $"{basePath}:/{fileName}";
|
||||
}
|
||||
@@ -194,7 +194,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
|
||||
fsServerClient = horizon.CreatePrivilegedHorizonClient();
|
||||
var fsServer = new FileSystemServer(fsServerClient);
|
||||
FileSystemServer fsServer = new(fsServerClient);
|
||||
|
||||
RandomDataGenerator randomGenerator = Random.Shared.NextBytes;
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
SdCard.SetSdCardInserted(true);
|
||||
|
||||
var fsServerConfig = new FileSystemServerConfig
|
||||
FileSystemServerConfig fsServerConfig = new()
|
||||
{
|
||||
ExternalKeySet = KeySet.ExternalKeySet,
|
||||
FsCreators = fsServerObjects.FsCreators,
|
||||
@@ -270,7 +270,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
foreach (DirectoryEntryEx ticketEntry in fs.EnumerateEntries("/", "*.tik"))
|
||||
{
|
||||
using var ticketFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> ticketFile = new();
|
||||
|
||||
Result result = fs.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
continue;
|
||||
|
||||
Ticket ticket = new(new MemoryStream(ticketData));
|
||||
var titleKey = ticket.GetTitleKey(KeySet);
|
||||
byte[] titleKey = ticket.GetTitleKey(KeySet);
|
||||
|
||||
if (titleKey != null)
|
||||
{
|
||||
@@ -334,7 +334,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
Span<SaveDataInfo> info = stackalloc SaveDataInfo[8];
|
||||
|
||||
using var iterator = new UniqueRef<SaveDataIterator>();
|
||||
using UniqueRef<SaveDataIterator> iterator = new();
|
||||
|
||||
Result rc = hos.Fs.OpenSaveDataIterator(ref iterator.Ref, spaceId);
|
||||
if (rc.IsFailure())
|
||||
@@ -398,7 +398,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
}
|
||||
|
||||
const string MountName = "SaveDir";
|
||||
var mountNameU8 = MountName.ToU8Span();
|
||||
U8Span mountNameU8 = MountName.ToU8Span();
|
||||
|
||||
BisPartitionId partitionId = info.SpaceId switch
|
||||
{
|
||||
@@ -415,7 +415,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
try
|
||||
{
|
||||
var path = $"{MountName}:/save/{info.SaveDataId:x16}".ToU8Span();
|
||||
U8Span path = $"{MountName}:/save/{info.SaveDataId:x16}".ToU8Span();
|
||||
|
||||
rc = hos.Fs.GetEntryType(out _, path);
|
||||
|
||||
@@ -437,7 +437,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
list = null;
|
||||
|
||||
var mountName = "system".ToU8Span();
|
||||
U8Span mountName = "system".ToU8Span();
|
||||
DirectoryHandle handle = default;
|
||||
List<ulong> localList = [];
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
// Only save data IDs added to SystemExtraDataFixInfo will be fixed.
|
||||
private static Result FixUnindexedSystemSaves(HorizonClient hos, List<ulong> existingSaveIds)
|
||||
{
|
||||
foreach (var fixInfo in _systemExtraDataFixInfo)
|
||||
foreach (ExtraDataFixInfo fixInfo in _systemExtraDataFixInfo)
|
||||
{
|
||||
if (!existingSaveIds.Contains(fixInfo.StaticSaveDataId))
|
||||
{
|
||||
@@ -665,7 +665,7 @@ namespace Ryujinx.HLE.FileSystem
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
foreach (var stream in _romFsByPid.Values)
|
||||
foreach (Stream stream in _romFsByPid.Values)
|
||||
{
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
|
||||
|
||||
if (romfs.FileExists(filePath))
|
||||
{
|
||||
using var binaryFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> binaryFile = new();
|
||||
|
||||
romfs.OpenFile(ref binaryFile.Ref, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
StreamReader reader = new(binaryFile.Get.AsStream(), Encoding.Unicode);
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
|
||||
_interactiveSession.DataAvailable += OnInteractiveData;
|
||||
|
||||
var launchParams = _normalSession.Pop();
|
||||
var keyboardConfig = _normalSession.Pop();
|
||||
byte[] launchParams = _normalSession.Pop();
|
||||
byte[] keyboardConfig = _normalSession.Pop();
|
||||
|
||||
_isBackground = keyboardConfig.Length == Unsafe.SizeOf<SoftwareKeyboardInitialize>();
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
else
|
||||
{
|
||||
// Call the configured GUI handler to get user's input.
|
||||
var args = new SoftwareKeyboardUIArgs
|
||||
SoftwareKeyboardUIArgs args = new()
|
||||
{
|
||||
KeyboardMode = _keyboardForegroundConfig.Mode,
|
||||
HeaderText = StripUnicodeControlCodes(_keyboardForegroundConfig.HeaderText),
|
||||
@@ -263,7 +263,7 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
private void OnInteractiveData(object sender, EventArgs e)
|
||||
{
|
||||
// Obtain the validation status response.
|
||||
var data = _interactiveSession.Pop();
|
||||
byte[] data = _interactiveSession.Pop();
|
||||
|
||||
if (_isBackground)
|
||||
{
|
||||
@@ -318,7 +318,7 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
using MemoryStream stream = new(data);
|
||||
using BinaryReader reader = new(stream);
|
||||
|
||||
var request = (InlineKeyboardRequest)reader.ReadUInt32();
|
||||
InlineKeyboardRequest request = (InlineKeyboardRequest)reader.ReadUInt32();
|
||||
|
||||
long remaining;
|
||||
|
||||
@@ -398,14 +398,14 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
remaining = stream.Length - stream.Position;
|
||||
if (remaining == Marshal.SizeOf<SoftwareKeyboardCalc>())
|
||||
{
|
||||
var keyboardCalcData = reader.ReadBytes((int)remaining);
|
||||
var keyboardCalc = ReadStruct<SoftwareKeyboardCalc>(keyboardCalcData);
|
||||
byte[] keyboardCalcData = reader.ReadBytes((int)remaining);
|
||||
SoftwareKeyboardCalc keyboardCalc = ReadStruct<SoftwareKeyboardCalc>(keyboardCalcData);
|
||||
|
||||
newCalc = keyboardCalc.ToExtended();
|
||||
}
|
||||
else if (remaining == Marshal.SizeOf<SoftwareKeyboardCalcEx>() || remaining == SoftwareKeyboardCalcEx.AlternativeSize)
|
||||
{
|
||||
var keyboardCalcData = reader.ReadBytes((int)remaining);
|
||||
byte[] keyboardCalcData = reader.ReadBytes((int)remaining);
|
||||
|
||||
newCalc = ReadStruct<SoftwareKeyboardCalcEx>(keyboardCalcData);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
_state.OverwriteMode = overwriteMode.GetValueOrDefault(_state.OverwriteMode);
|
||||
_state.TypingEnabled = typingEnabled.GetValueOrDefault(_state.TypingEnabled);
|
||||
|
||||
var begin = _state.CursorBegin;
|
||||
var end = _state.CursorEnd;
|
||||
int begin = _state.CursorBegin;
|
||||
int end = _state.CursorEnd;
|
||||
_state.CursorBegin = Math.Min(begin, end);
|
||||
_state.CursorEnd = Math.Max(begin, end);
|
||||
|
||||
|
||||
@@ -74,10 +74,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
_padCancelIcon = LoadResource(typeof(SoftwareKeyboardRendererBase).Assembly, padCancelIconPath, 0, 0);
|
||||
_keyModeIcon = LoadResource(typeof(SoftwareKeyboardRendererBase).Assembly, keyModeIconPath, 0, 0);
|
||||
|
||||
var panelColor = ToColor(uiTheme.DefaultBackgroundColor, 255);
|
||||
var panelTransparentColor = ToColor(uiTheme.DefaultBackgroundColor, 150);
|
||||
var borderColor = ToColor(uiTheme.DefaultBorderColor);
|
||||
var selectionBackgroundColor = ToColor(uiTheme.SelectionBackgroundColor);
|
||||
SKColor panelColor = ToColor(uiTheme.DefaultBackgroundColor, 255);
|
||||
SKColor panelTransparentColor = ToColor(uiTheme.DefaultBackgroundColor, 150);
|
||||
SKColor borderColor = ToColor(uiTheme.DefaultBorderColor);
|
||||
SKColor selectionBackgroundColor = ToColor(uiTheme.SelectionBackgroundColor);
|
||||
|
||||
_textNormalColor = ToColor(uiTheme.DefaultForegroundColor);
|
||||
_textSelectedColor = ToColor(uiTheme.SelectionForegroundColor);
|
||||
@@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
{
|
||||
try
|
||||
{
|
||||
using var typeface = SKTypeface.FromFamilyName(fontFamily, SKFontStyle.Normal);
|
||||
using SKTypeface typeface = SKTypeface.FromFamilyName(fontFamily, SKFontStyle.Normal);
|
||||
_messageFont = new SKFont(typeface, 26);
|
||||
_inputTextFont = new SKFont(typeface, _inputTextFontSize);
|
||||
_labelsTextFont = new SKFont(typeface, 24);
|
||||
@@ -151,10 +151,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
|
||||
private static SKColor ToColor(ThemeColor color, byte? overrideAlpha = null, bool flipRgb = false)
|
||||
{
|
||||
var a = (byte)(color.A * 255);
|
||||
var r = (byte)(color.R * 255);
|
||||
var g = (byte)(color.G * 255);
|
||||
var b = (byte)(color.B * 255);
|
||||
byte a = (byte)(color.A * 255);
|
||||
byte r = (byte)(color.R * 255);
|
||||
byte g = (byte)(color.G * 255);
|
||||
byte b = (byte)(color.B * 255);
|
||||
|
||||
if (flipRgb)
|
||||
{
|
||||
@@ -177,7 +177,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
{
|
||||
Debug.Assert(resourceStream != null);
|
||||
|
||||
var bitmap = SKBitmap.Decode(resourceStream);
|
||||
SKBitmap bitmap = SKBitmap.Decode(resourceStream);
|
||||
|
||||
if (newHeight != 0 && newWidth != 0)
|
||||
{
|
||||
@@ -198,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
{
|
||||
return;
|
||||
}
|
||||
var canvas = _surface.Canvas;
|
||||
SKCanvas canvas = _surface.Canvas;
|
||||
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
canvas.DrawRect(_panelRectangle, _panelBrush);
|
||||
@@ -219,18 +219,18 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
return;
|
||||
}
|
||||
|
||||
using var paint = new SKPaint(_messageFont)
|
||||
using SKPaint paint = new SKPaint(_messageFont)
|
||||
{
|
||||
Color = _textNormalColor,
|
||||
IsAntialias = true
|
||||
};
|
||||
|
||||
var canvas = _surface.Canvas;
|
||||
var messageRectangle = MeasureString(MessageText, paint);
|
||||
SKCanvas canvas = _surface.Canvas;
|
||||
SKRect messageRectangle = MeasureString(MessageText, paint);
|
||||
float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left;
|
||||
float messagePositionY = _messagePositionY - messageRectangle.Top;
|
||||
var messagePosition = new SKPoint(messagePositionX, messagePositionY);
|
||||
var messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height);
|
||||
SKPoint messagePosition = new(messagePositionX, messagePositionY);
|
||||
SKRect messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height);
|
||||
|
||||
canvas.DrawRect(messageBoundRectangle, _panelBrush);
|
||||
|
||||
@@ -336,12 +336,12 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
|
||||
private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state)
|
||||
{
|
||||
using var textPaint = new SKPaint(_labelsTextFont)
|
||||
using SKPaint textPaint = new SKPaint(_labelsTextFont)
|
||||
{
|
||||
IsAntialias = true,
|
||||
Color = _textNormalColor
|
||||
};
|
||||
var inputTextRectangle = MeasureString(state.InputText, textPaint);
|
||||
SKRect inputTextRectangle = MeasureString(state.InputText, textPaint);
|
||||
|
||||
float boxWidth = (int)(Math.Max(300, inputTextRectangle.Width + inputTextRectangle.Left + 8));
|
||||
float boxHeight = 32;
|
||||
@@ -360,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
float inputTextX = (_panelRectangle.Width - inputTextRectangle.Width) / 2 - inputTextRectangle.Left;
|
||||
float inputTextY = boxY + 5;
|
||||
|
||||
var inputTextPosition = new SKPoint(inputTextX, inputTextY);
|
||||
SKPoint inputTextPosition = new(inputTextX, inputTextY);
|
||||
canvas.DrawText(state.InputText, inputTextPosition.X, inputTextPosition.Y + (_labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent), textPaint);
|
||||
|
||||
// Draw the cursor on top of the text and redraw the text with a different color if necessary.
|
||||
@@ -387,8 +387,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
ReadOnlySpan<char> textUntilBegin = state.InputText.AsSpan(0, state.CursorBegin);
|
||||
ReadOnlySpan<char> textUntilEnd = state.InputText.AsSpan(0, state.CursorEnd);
|
||||
|
||||
var selectionBeginRectangle = MeasureString(textUntilBegin, textPaint);
|
||||
var selectionEndRectangle = MeasureString(textUntilEnd, textPaint);
|
||||
SKRect selectionBeginRectangle = MeasureString(textUntilBegin, textPaint);
|
||||
SKRect selectionEndRectangle = MeasureString(textUntilEnd, textPaint);
|
||||
|
||||
cursorVisible = true;
|
||||
cursorPositionXLeft = inputTextX + selectionBeginRectangle.Width + selectionBeginRectangle.Left;
|
||||
@@ -406,7 +406,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
|
||||
int cursorBegin = Math.Min(state.InputText.Length, state.CursorBegin);
|
||||
ReadOnlySpan<char> textUntilCursor = state.InputText.AsSpan(0, cursorBegin);
|
||||
var cursorTextRectangle = MeasureString(textUntilCursor, textPaint);
|
||||
SKRect cursorTextRectangle = MeasureString(textUntilCursor, textPaint);
|
||||
|
||||
cursorVisible = true;
|
||||
cursorPositionXLeft = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left;
|
||||
@@ -452,16 +452,16 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
}
|
||||
else
|
||||
{
|
||||
var cursorRectangle = SKRect.Create(cursorPositionXLeft, cursorPositionYTop, cursorWidth, cursorHeight);
|
||||
SKRect cursorRectangle = SKRect.Create(cursorPositionXLeft, cursorPositionYTop, cursorWidth, cursorHeight);
|
||||
|
||||
canvas.DrawRect(cursorRectangle, cursorPen);
|
||||
canvas.DrawRect(cursorRectangle, cursorBrush);
|
||||
|
||||
using var textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888));
|
||||
var textOverCanvas = textOverCursor.Canvas;
|
||||
var textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top);
|
||||
using SKSurface textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888));
|
||||
SKCanvas textOverCanvas = textOverCursor.Canvas;
|
||||
SKPoint textRelativePosition = new(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top);
|
||||
|
||||
using var cursorPaint = new SKPaint(_inputTextFont)
|
||||
using SKPaint cursorPaint = new SKPaint(_inputTextFont)
|
||||
{
|
||||
Color = cursorTextColor,
|
||||
IsAntialias = true
|
||||
@@ -469,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
|
||||
textOverCanvas.DrawText(state.InputText, textRelativePosition.X, textRelativePosition.Y + _inputTextFont.Metrics.XHeight + _inputTextFont.Metrics.Descent, cursorPaint);
|
||||
|
||||
var cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top);
|
||||
SKPoint cursorPosition = new((int)cursorRectangle.Left, (int)cursorRectangle.Top);
|
||||
textOverCursor.Flush();
|
||||
canvas.DrawSurface(textOverCursor, cursorPosition);
|
||||
}
|
||||
@@ -492,13 +492,13 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
float iconWidth = icon.Width;
|
||||
float iconHeight = icon.Height;
|
||||
|
||||
using var paint = new SKPaint(_labelsTextFont)
|
||||
using SKPaint paint = new SKPaint(_labelsTextFont)
|
||||
{
|
||||
Color = _textNormalColor,
|
||||
IsAntialias = true
|
||||
};
|
||||
|
||||
var labelRectangle = MeasureString(label, paint);
|
||||
SKRect labelRectangle = MeasureString(label, paint);
|
||||
|
||||
float labelPositionX = iconWidth + 8 - labelRectangle.Left;
|
||||
float labelPositionY = 3;
|
||||
@@ -514,13 +514,13 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
iconX += originX;
|
||||
iconY += originY;
|
||||
|
||||
var iconPosition = new SKPoint((int)iconX, (int)iconY);
|
||||
var labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY);
|
||||
SKPoint iconPosition = new((int)iconX, (int)iconY);
|
||||
SKPoint labelPosition = new(labelPositionX + originX, labelPositionY + originY);
|
||||
|
||||
var selectedRectangle = SKRect.Create(originX - 2 * _padPressedPenWidth, originY - 2 * _padPressedPenWidth,
|
||||
SKRect selectedRectangle = SKRect.Create(originX - 2 * _padPressedPenWidth, originY - 2 * _padPressedPenWidth,
|
||||
fullWidth + 4 * _padPressedPenWidth, fullHeight + 4 * _padPressedPenWidth);
|
||||
|
||||
var boundRectangle = SKRect.Create(originX, originY, fullWidth, fullHeight);
|
||||
SKRect boundRectangle = SKRect.Create(originX, originY, fullWidth, fullHeight);
|
||||
boundRectangle.Inflate(4 * _padPressedPenWidth, 4 * _padPressedPenWidth);
|
||||
|
||||
canvas.DrawRect(boundRectangle, _panelBrush);
|
||||
@@ -545,12 +545,12 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
|
||||
private void DrawControllerToggle(SKCanvas canvas, SKPoint point)
|
||||
{
|
||||
using var paint = new SKPaint(_labelsTextFont)
|
||||
using SKPaint paint = new SKPaint(_labelsTextFont)
|
||||
{
|
||||
IsAntialias = true,
|
||||
Color = _textNormalColor
|
||||
};
|
||||
var labelRectangle = MeasureString(ControllerToggleText, paint);
|
||||
SKRect labelRectangle = MeasureString(ControllerToggleText, paint);
|
||||
|
||||
// Use relative positions so we can center the entire drawing later.
|
||||
|
||||
@@ -574,8 +574,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
keyX += originX;
|
||||
keyY += originY;
|
||||
|
||||
var labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY);
|
||||
var overlayPosition = new SKPoint((int)keyX, (int)keyY);
|
||||
SKPoint labelPosition = new(labelPositionX + originX, labelPositionY + originY);
|
||||
SKPoint overlayPosition = new((int)keyX, (int)keyY);
|
||||
|
||||
canvas.DrawBitmap(_keyModeIcon, overlayPosition);
|
||||
canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, paint);
|
||||
@@ -593,7 +593,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
// Convert the pixel format used in the image to the one used in the Switch surface.
|
||||
_surface.Flush();
|
||||
|
||||
var buffer = new byte[_imageInfo.BytesSize];
|
||||
byte[] buffer = new byte[_imageInfo.BytesSize];
|
||||
fixed (byte* bufferPtr = buffer)
|
||||
{
|
||||
if (!_surface.ReadPixels(_imageInfo, (nint)bufferPtr, _imageInfo.RowBytes, 0, 0))
|
||||
|
||||
@@ -79,11 +79,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
public void Reset(Action<float> action, int totalMilliseconds, int sleepMilliseconds)
|
||||
{
|
||||
// Create a dedicated cancel token for each task.
|
||||
var cancelled = new TRef<bool>(false);
|
||||
TRef<bool> cancelled = new(false);
|
||||
|
||||
Reset(new Thread(() =>
|
||||
{
|
||||
var substepData = new SleepSubstepData(sleepMilliseconds);
|
||||
SleepSubstepData substepData = new(sleepMilliseconds);
|
||||
|
||||
int totalCount = totalMilliseconds / sleepMilliseconds;
|
||||
int totalRemainder = totalMilliseconds - totalCount * sleepMilliseconds;
|
||||
@@ -126,11 +126,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
public void Reset(Action action, int sleepMilliseconds)
|
||||
{
|
||||
// Create a dedicated cancel token for each task.
|
||||
var cancelled = new TRef<bool>(false);
|
||||
TRef<bool> cancelled = new(false);
|
||||
|
||||
Reset(new Thread(() =>
|
||||
{
|
||||
var substepData = new SleepSubstepData(sleepMilliseconds);
|
||||
SleepSubstepData substepData = new(sleepMilliseconds);
|
||||
|
||||
while (!Volatile.Read(ref cancelled.Value))
|
||||
{
|
||||
@@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
|
||||
public void Reset(Action action)
|
||||
{
|
||||
// Create a dedicated cancel token for each task.
|
||||
var cancelled = new TRef<bool>(false);
|
||||
TRef<bool> cancelled = new(false);
|
||||
|
||||
Reset(new Thread(() =>
|
||||
{
|
||||
|
||||
@@ -67,21 +67,21 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
var cpuEngine = new HvEngine(_tickSource);
|
||||
var memoryManager = new HvMemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
HvEngine cpuEngine = new(_tickSource);
|
||||
HvMemoryManager memoryManager = new(context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<HvMemoryManager>(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AddressSpace.TryCreateWithoutMirror(addressSpaceSize, out var addressSpace))
|
||||
if (!AddressSpace.TryCreateWithoutMirror(addressSpaceSize, out MemoryBlock addressSpace))
|
||||
{
|
||||
throw new Exception("Address space creation failed");
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Cpu, $"NCE Base AS Address: 0x{addressSpace.Pointer.ToInt64():X} Size: 0x{addressSpace.Size:X}");
|
||||
|
||||
var cpuEngine = new NceEngine(_tickSource);
|
||||
var memoryManager = new MemoryManagerNative(addressSpace, context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
NceEngine cpuEngine = new(_tickSource);
|
||||
MemoryManagerNative memoryManager = new(addressSpace, context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<MemoryManagerNative>(pid, cpuEngine, _gpu, memoryManager, addressSpace.Size, for64Bit, memoryManager.ReservedSize);
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
case MemoryManagerMode.SoftwarePageTable:
|
||||
{
|
||||
var mm = new MemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
MemoryManager mm = new(context.Memory, addressSpaceSize, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<MemoryManager>(pid, cpuEngine, _gpu, mm, addressSpaceSize, for64Bit);
|
||||
}
|
||||
break;
|
||||
@@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS
|
||||
case MemoryManagerMode.HostMappedUnsafe:
|
||||
if (addressSpace == null && asNoMirror == null)
|
||||
{
|
||||
var memoryManagerHostTracked = new MemoryManagerHostTracked(context.Memory, addressSpaceSize, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler);
|
||||
MemoryManagerHostTracked memoryManagerHostTracked = new(context.Memory, addressSpaceSize, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<MemoryManagerHostTracked>(pid, cpuEngine, _gpu, memoryManagerHostTracked, addressSpaceSize, for64Bit);
|
||||
}
|
||||
else
|
||||
@@ -138,12 +138,12 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
if (addressSpace != null)
|
||||
{
|
||||
var mm = new MemoryManagerHostMapped(addressSpace, unsafeMode, invalidAccessHandler);
|
||||
MemoryManagerHostMapped mm = new(addressSpace, unsafeMode, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<MemoryManagerHostMapped>(pid, cpuEngine, _gpu, mm, addressSpace.AddressSpaceSize, for64Bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
var mm = new MemoryManagerHostNoMirror(asNoMirror, context.Memory, unsafeMode, invalidAccessHandler);
|
||||
MemoryManagerHostNoMirror mm = new(asNoMirror, context.Memory, unsafeMode, invalidAccessHandler);
|
||||
processContext = new ArmProcessContext<MemoryManagerHostNoMirror>(pid, cpuEngine, _gpu, mm, asNoMirror.Size, for64Bit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler
|
||||
|
||||
private bool ConsumeIf(string toConsume)
|
||||
{
|
||||
var mangledPart = Mangled.AsSpan(_position);
|
||||
ReadOnlySpan<char> mangledPart = Mangled.AsSpan(_position);
|
||||
|
||||
if (mangledPart.StartsWith(toConsume.AsSpan()))
|
||||
{
|
||||
|
||||
@@ -154,11 +154,11 @@ namespace Ryujinx.HLE.HOS
|
||||
timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize);
|
||||
appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize);
|
||||
|
||||
var hidStorage = new SharedMemoryStorage(KernelContext, hidPageList);
|
||||
var fontStorage = new SharedMemoryStorage(KernelContext, fontPageList);
|
||||
var iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList);
|
||||
var timeStorage = new SharedMemoryStorage(KernelContext, timePageList);
|
||||
var appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList);
|
||||
SharedMemoryStorage hidStorage = new(KernelContext, hidPageList);
|
||||
SharedMemoryStorage fontStorage = new(KernelContext, fontPageList);
|
||||
SharedMemoryStorage iirsStorage = new(KernelContext, iirsPageList);
|
||||
SharedMemoryStorage timeStorage = new(KernelContext, timePageList);
|
||||
SharedMemoryStorage appletCaptureBufferStorage = new(KernelContext, appletCaptureBufferPageList);
|
||||
|
||||
HidStorage = hidStorage;
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace Ryujinx.HLE.HOS
|
||||
HorizonFsClient fsClient = new(this);
|
||||
|
||||
ServiceTable = new ServiceTable();
|
||||
var services = ServiceTable.GetServices(new HorizonOptions
|
||||
IEnumerable<ServiceEntry> services = ServiceTable.GetServices(new HorizonOptions
|
||||
(Device.Configuration.IgnoreMissingServices,
|
||||
LibHacHorizonManager.BcatClient,
|
||||
fsClient,
|
||||
@@ -273,7 +273,7 @@ namespace Ryujinx.HLE.HOS
|
||||
Device.AudioDeviceDriver,
|
||||
TickSource));
|
||||
|
||||
foreach (var service in services)
|
||||
foreach (ServiceEntry service in services)
|
||||
{
|
||||
const ProcessCreationFlags Flags =
|
||||
ProcessCreationFlags.EnableAslr |
|
||||
@@ -305,7 +305,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public bool LoadKip(string kipPath)
|
||||
{
|
||||
using var kipFile = new SharedRef<IStorage>(new LocalStorage(kipPath, FileAccess.Read));
|
||||
using SharedRef<IStorage> kipFile = new(new LocalStorage(kipPath, FileAccess.Read));
|
||||
|
||||
return ProcessLoaderHelper.LoadKip(KernelContext, new KipExecutable(in kipFile));
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
Nca nca = new(_system.KeySet, ncaStorage);
|
||||
|
||||
using var ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel);
|
||||
using var ncaFsRef = new UniqueRef<IFileSystem>(ncaFileSystem);
|
||||
using IFileSystem ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel);
|
||||
using UniqueRef<IFileSystem> ncaFsRef = new(ncaFileSystem);
|
||||
|
||||
Result result = _fsClient.Register(mountName.ToU8Span(), ref ncaFsRef.Ref).ToHorizonResult();
|
||||
if (result.IsFailure)
|
||||
@@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public Result OpenFile(out FileHandle handle, string path, OpenMode openMode)
|
||||
{
|
||||
var result = _fsClient.OpenFile(out var libhacHandle, path.ToU8Span(), (LibHac.Fs.OpenMode)openMode);
|
||||
LibHac.Result result = _fsClient.OpenFile(out LibHac.Fs.FileHandle libhacHandle, path.ToU8Span(), (LibHac.Fs.OpenMode)openMode);
|
||||
handle = new(libhacHandle);
|
||||
|
||||
return result.ToHorizonResult();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
for (int i = 0; i < MemoryRegions.Length; i++)
|
||||
{
|
||||
var region = MemoryRegions[i];
|
||||
KMemoryRegionManager region = MemoryRegions[i];
|
||||
|
||||
if (address >= region.Address && address < region.EndAddr)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
while (pagesCount != 0)
|
||||
{
|
||||
var region = GetMemoryRegion(address);
|
||||
KMemoryRegionManager region = GetMemoryRegion(address);
|
||||
|
||||
ulong countToProcess = Math.Min(pagesCount, region.GetPageOffsetFromEnd(address));
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
if (result == Result.Success)
|
||||
{
|
||||
foreach (var node in pageList)
|
||||
foreach (KPageNode node in pageList)
|
||||
{
|
||||
IncrementPagesReferenceCount(node.Address, node.PagesCount);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
public bool ClearRange(ulong offset, int count)
|
||||
{
|
||||
int depth = HighestDepthIndex;
|
||||
var bits = _bitStorages[depth];
|
||||
ArraySegment<ulong> bits = _bitStorages[depth];
|
||||
|
||||
int bitInd = (int)(offset / UInt64BitSize);
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
_blocksCount = blockShifts.Length;
|
||||
_blocks = new Block[_memoryBlockPageShifts.Length];
|
||||
|
||||
var currBitmapStorage = new ArraySegment<ulong>(new ulong[CalculateManagementOverheadSize(size, blockShifts)]);
|
||||
ArraySegment<ulong> currBitmapStorage = new(new ulong[CalculateManagementOverheadSize(size, blockShifts)]);
|
||||
|
||||
for (int i = 0; i < blockShifts.Length; i++)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public void IncrementPagesReferenceCount(KMemoryManager manager)
|
||||
{
|
||||
foreach (var node in this)
|
||||
foreach (KPageNode node in this)
|
||||
{
|
||||
manager.IncrementPagesReferenceCount(node.Address, node.PagesCount);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
public void DecrementPagesReferenceCount(KMemoryManager manager)
|
||||
{
|
||||
foreach (var node in this)
|
||||
foreach (KPageNode node in this)
|
||||
{
|
||||
manager.DecrementPagesReferenceCount(node.Address, node.PagesCount);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
/// <inheritdoc/>
|
||||
protected override void GetPhysicalRegions(ulong va, ulong size, KPageList pageList)
|
||||
{
|
||||
var ranges = _cpuMemory.GetPhysicalRegions(va, size);
|
||||
foreach (var range in ranges)
|
||||
IEnumerable<MemoryRange> ranges = _cpuMemory.GetPhysicalRegions(va, size);
|
||||
foreach (MemoryRange range in ranges)
|
||||
{
|
||||
pageList.AddRange(range.Address + DramMemoryMap.DramBase, range.Size / PageSize);
|
||||
}
|
||||
@@ -143,11 +143,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
bool shouldFillPages,
|
||||
byte fillValue)
|
||||
{
|
||||
using var scopedPageList = new KScopedPageList(Context.MemoryManager, pageList);
|
||||
using KScopedPageList scopedPageList = new(Context.MemoryManager, pageList);
|
||||
|
||||
ulong currentVa = address;
|
||||
|
||||
foreach (var pageNode in pageList)
|
||||
foreach (KPageNode pageNode in pageList)
|
||||
{
|
||||
ulong addr = pageNode.Address - DramMemoryMap.DramBase;
|
||||
ulong size = pageNode.PagesCount * PageSize;
|
||||
@@ -188,16 +188,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
}
|
||||
}
|
||||
|
||||
using var scopedPageList = new KScopedPageList(Context.MemoryManager, pageList);
|
||||
using KScopedPageList scopedPageList = new(Context.MemoryManager, pageList);
|
||||
|
||||
foreach (var pageNode in pageList)
|
||||
foreach (KPageNode pageNode in pageList)
|
||||
{
|
||||
Context.CommitMemory(pageNode.Address - DramMemoryMap.DramBase, pageNode.PagesCount * PageSize);
|
||||
}
|
||||
|
||||
ulong offset = 0;
|
||||
|
||||
foreach (var region in regions)
|
||||
foreach (HostMemoryRange region in regions)
|
||||
{
|
||||
_cpuMemory.MapForeign(va + offset, region.Address, region.Size);
|
||||
|
||||
@@ -214,9 +214,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
KPageList pagesToClose = new();
|
||||
|
||||
var regions = _cpuMemory.GetPhysicalRegions(address, pagesCount * PageSize);
|
||||
IEnumerable<MemoryRange> regions = _cpuMemory.GetPhysicalRegions(address, pagesCount * PageSize);
|
||||
|
||||
foreach (var region in regions)
|
||||
foreach (MemoryRange region in regions)
|
||||
{
|
||||
ulong pa = region.Address + DramMemoryMap.DramBase;
|
||||
if (DramMemoryMap.IsHeapPhysicalAddress(pa))
|
||||
|
||||
@@ -631,7 +631,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
return result;
|
||||
}
|
||||
|
||||
using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
|
||||
return MapPages(address, pageList, permission, MemoryMapFlags.Private);
|
||||
}
|
||||
@@ -783,7 +783,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
Result result = region.AllocatePages(out KPageList pageList, pagesCount);
|
||||
|
||||
using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
|
||||
void CleanUpForError()
|
||||
{
|
||||
@@ -1355,7 +1355,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
Result result = region.AllocatePages(out KPageList pageList, remainingPages);
|
||||
|
||||
using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
|
||||
|
||||
void CleanUpForError()
|
||||
{
|
||||
@@ -1887,7 +1887,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ulong dstLastPagePa = 0;
|
||||
ulong currentVa = va;
|
||||
|
||||
using var _ = new OnScopeExit(() =>
|
||||
using OnScopeExit _ = new(() =>
|
||||
{
|
||||
if (dstFirstPagePa != 0)
|
||||
{
|
||||
@@ -1948,7 +1948,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
Context.Memory.Fill(GetDramAddressFromPa(dstFirstPagePa), unusedSizeBefore, (byte)_ipcFillValue);
|
||||
|
||||
ulong copySize = addressRounded <= endAddr ? addressRounded - address : size;
|
||||
var data = srcPageTable.GetReadOnlySequence(addressTruncated + unusedSizeBefore, (int)copySize);
|
||||
ReadOnlySequence<byte> data = srcPageTable.GetReadOnlySequence(addressTruncated + unusedSizeBefore, (int)copySize);
|
||||
|
||||
((IWritableBlock)Context.Memory).Write(GetDramAddressFromPa(dstFirstPagePa + unusedSizeBefore), data);
|
||||
|
||||
@@ -2014,7 +2014,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
if (send)
|
||||
{
|
||||
ulong copySize = endAddr - endAddrTruncated;
|
||||
var data = srcPageTable.GetReadOnlySequence(endAddrTruncated, (int)copySize);
|
||||
ReadOnlySequence<byte> data = srcPageTable.GetReadOnlySequence(endAddrTruncated, (int)copySize);
|
||||
|
||||
((IWritableBlock)Context.Memory).Write(GetDramAddressFromPa(dstLastPagePa), data);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Diagnostics.Demangler;
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
@@ -50,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
EnsureLoaded();
|
||||
|
||||
var context = thread.Context;
|
||||
IExecutionContext context = thread.Context;
|
||||
|
||||
StringBuilder trace = new();
|
||||
|
||||
@@ -112,13 +113,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
EnsureLoaded();
|
||||
|
||||
var context = thread.Context;
|
||||
IExecutionContext context = thread.Context;
|
||||
|
||||
StringBuilder sb = new();
|
||||
|
||||
string GetReg(int x)
|
||||
{
|
||||
var v = x == 32 ? context.Pc : context.GetX(x);
|
||||
ulong v = x == 32 ? context.Pc : context.GetX(x);
|
||||
if (!AnalyzePointer(out PointerInfo info, v, thread))
|
||||
{
|
||||
return $"0x{v:x16}";
|
||||
@@ -253,7 +254,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
moduleName = string.Empty;
|
||||
|
||||
var rodataStart = image.BaseAddress + image.Size;
|
||||
ulong rodataStart = image.BaseAddress + image.Size;
|
||||
|
||||
KMemoryInfo roInfo = _owner.MemoryManager.QueryMemory(rodataStart);
|
||||
if (roInfo.Permission != KMemoryPermission.Read)
|
||||
@@ -261,7 +262,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return false;
|
||||
}
|
||||
|
||||
var rwdataStart = roInfo.Address + roInfo.Size;
|
||||
ulong rwdataStart = roInfo.Address + roInfo.Size;
|
||||
|
||||
KMemoryInfo.Pool.Release(roInfo);
|
||||
|
||||
@@ -293,7 +294,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
pathLength = Math.Min(pathLength, rodataBuf.Length - 8);
|
||||
var pathBuf = rodataBuf.Slice(8, pathLength);
|
||||
Span<byte> pathBuf = rodataBuf.Slice(8, pathLength);
|
||||
int lastSlash = pathBuf.LastIndexOfAny(new byte[] { (byte)'\\', (byte)'/' });
|
||||
|
||||
moduleName = Encoding.ASCII.GetString(pathBuf.Slice(lastSlash + 1).TrimEnd((byte)0));
|
||||
@@ -311,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
info = default;
|
||||
|
||||
ulong sp = thread.Context.GetX(31);
|
||||
var memoryInfo = _owner.MemoryManager.QueryMemory(address);
|
||||
KMemoryInfo memoryInfo = _owner.MemoryManager.QueryMemory(address);
|
||||
MemoryState memoryState = memoryInfo.State;
|
||||
|
||||
if (!memoryState.HasFlag(MemoryState.Stack)) // Is this pointer within the stack?
|
||||
@@ -461,12 +462,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
lock (_images)
|
||||
{
|
||||
var image = new Image(textOffset, textSize, symbols.OrderBy(x => x.Value).ToArray());
|
||||
Image image = new(textOffset, textSize, symbols.OrderBy(x => x.Value).ToArray());
|
||||
|
||||
string moduleName;
|
||||
if (!GetModuleName(out moduleName, image))
|
||||
{
|
||||
var newIndex = _images.Count;
|
||||
int newIndex = _images.Count;
|
||||
moduleName = $"(unknown{newIndex})";
|
||||
}
|
||||
image.Name = moduleName;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
KProcess process = new(_context);
|
||||
|
||||
using var _ = new OnScopeExit(process.DecrementReferenceCount);
|
||||
using OnScopeExit _ = new(process.DecrementReferenceCount);
|
||||
|
||||
KResourceLimit resourceLimit;
|
||||
|
||||
@@ -1418,7 +1418,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
KCodeMemory codeMemory = new(_context);
|
||||
|
||||
using var _ = new OnScopeExit(codeMemory.DecrementReferenceCount);
|
||||
using OnScopeExit _ = new(codeMemory.DecrementReferenceCount);
|
||||
|
||||
KProcess currentProcess = KernelStatic.GetCurrentProcess();
|
||||
|
||||
@@ -2836,7 +2836,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
|
||||
var syncObjs = new Span<KSynchronizationObject>(currentThread.WaitSyncObjects)[..handles.Length];
|
||||
Span<KSynchronizationObject> syncObjs = new Span<KSynchronizationObject>(currentThread.WaitSyncObjects)[..handles.Length];
|
||||
|
||||
if (handles.Length != 0)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
public KThread ScheduledThreadsElementAtOrDefault(int core, int index)
|
||||
{
|
||||
int currentIndex = 0;
|
||||
foreach (var scheduledThread in ScheduledThreads(core))
|
||||
foreach (KThread scheduledThread in ScheduledThreads(core))
|
||||
{
|
||||
if (currentIndex == index)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
|
||||
public KThread ScheduledThreadsWithDynamicPriorityFirstOrDefault(int core, int dynamicPriority)
|
||||
{
|
||||
foreach (var scheduledThread in ScheduledThreads(core))
|
||||
foreach (KThread scheduledThread in ScheduledThreads(core))
|
||||
{
|
||||
if (scheduledThread.DynamicPriority == dynamicPriority)
|
||||
{
|
||||
|
||||
@@ -1245,7 +1245,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
{
|
||||
if (_schedulerWaitEvent == null)
|
||||
{
|
||||
var schedulerWaitEvent = new ManualResetEventSlim(false);
|
||||
ManualResetEventSlim schedulerWaitEvent = new(false);
|
||||
|
||||
if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public void InitializeFsServer(VirtualFileSystem virtualFileSystem)
|
||||
{
|
||||
virtualFileSystem.InitializeFsServer(Server, out var fsClient);
|
||||
virtualFileSystem.InitializeFsServer(Server, out HorizonClient fsClient);
|
||||
|
||||
FsClient = fsClient;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Loader;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.RomFs;
|
||||
using LibHac.Util;
|
||||
@@ -150,7 +151,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
private static string EnsureBaseDirStructure(string modsBasePath)
|
||||
{
|
||||
var modsDir = new DirectoryInfo(modsBasePath);
|
||||
DirectoryInfo modsDir = new(modsBasePath);
|
||||
|
||||
modsDir.CreateSubdirectory(AmsContentsDir);
|
||||
modsDir.CreateSubdirectory(AmsNsoPatchDir);
|
||||
@@ -168,23 +169,23 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
System.Text.StringBuilder types = new();
|
||||
|
||||
foreach (var modDir in dir.EnumerateDirectories())
|
||||
foreach (DirectoryInfo modDir in dir.EnumerateDirectories())
|
||||
{
|
||||
types.Clear();
|
||||
Mod<DirectoryInfo> mod = new("", null, true);
|
||||
|
||||
if (StrEquals(RomfsDir, modDir.Name) && modDir.Parent != null)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
Mod modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
bool enabled = modData?.Enabled ?? true;
|
||||
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('R');
|
||||
}
|
||||
else if (StrEquals(ExefsDir, modDir.Name) && modDir.Parent != null)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
var enabled = modData?.Enabled ?? true;
|
||||
Mod modData = modMetadata.Mods.FirstOrDefault(x => modDir.Parent.FullName.Equals(x.Path));
|
||||
bool enabled = modData?.Enabled ?? true;
|
||||
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('E');
|
||||
@@ -207,8 +208,8 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public static string GetApplicationDir(string modsBasePath, string applicationId)
|
||||
{
|
||||
var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir));
|
||||
var applicationModsPath = FindApplicationDir(contentsDir, applicationId);
|
||||
DirectoryInfo contentsDir = new(Path.Combine(modsBasePath, AmsContentsDir));
|
||||
DirectoryInfo applicationModsPath = FindApplicationDir(contentsDir, applicationId);
|
||||
|
||||
if (applicationModsPath == null)
|
||||
{
|
||||
@@ -250,7 +251,7 @@ namespace Ryujinx.HLE.HOS
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var modDir in patchDir.EnumerateDirectories())
|
||||
foreach (DirectoryInfo modDir in patchDir.EnumerateDirectories())
|
||||
{
|
||||
patches.Add(new Mod<DirectoryInfo>(modDir.Name, modDir, true));
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Found {type} patch '{modDir.Name}'");
|
||||
@@ -279,11 +280,11 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
var fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer));
|
||||
FileInfo fsFile = new(Path.Combine(applicationDir.FullName, RomfsContainer));
|
||||
if (fsFile.Exists)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path));
|
||||
var enabled = modData == null || modData.Enabled;
|
||||
Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path));
|
||||
bool enabled = modData == null || modData.Enabled;
|
||||
|
||||
mods.RomfsContainers.Add(new Mod<FileInfo>($"<{applicationDir.Name} RomFs>", fsFile, enabled));
|
||||
}
|
||||
@@ -291,8 +292,8 @@ namespace Ryujinx.HLE.HOS
|
||||
fsFile = new FileInfo(Path.Combine(applicationDir.FullName, ExefsContainer));
|
||||
if (fsFile.Exists)
|
||||
{
|
||||
var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path));
|
||||
var enabled = modData == null || modData.Enabled;
|
||||
Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path));
|
||||
bool enabled = modData == null || modData.Enabled;
|
||||
|
||||
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{applicationDir.Name} ExeFs>", fsFile, enabled));
|
||||
}
|
||||
@@ -309,7 +310,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((applicationId & 0x1000) != 0 ? "DLC" : "Application")} {applicationId:X16} in \"{contentsDir.FullName}\"");
|
||||
|
||||
var applicationDir = FindApplicationDir(contentsDir, $"{applicationId:x16}");
|
||||
DirectoryInfo applicationDir = FindApplicationDir(contentsDir, $"{applicationId:x16}");
|
||||
|
||||
if (applicationDir != null)
|
||||
{
|
||||
@@ -449,9 +450,9 @@ namespace Ryujinx.HLE.HOS
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var path in searchDirPaths)
|
||||
foreach (string path in searchDirPaths)
|
||||
{
|
||||
var searchDir = new DirectoryInfo(path);
|
||||
DirectoryInfo searchDir = new(path);
|
||||
if (!searchDir.Exists)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ModLoader, $"Mod Search Dir '{searchDir.FullName}' doesn't exist");
|
||||
@@ -460,7 +461,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
if (!TryQuery(searchDir, patches, modCaches))
|
||||
{
|
||||
foreach (var subdir in searchDir.EnumerateDirectories())
|
||||
foreach (DirectoryInfo subdir in searchDir.EnumerateDirectories())
|
||||
{
|
||||
TryQuery(subdir, patches, modCaches);
|
||||
}
|
||||
@@ -489,14 +490,14 @@ namespace Ryujinx.HLE.HOS
|
||||
return baseStorage;
|
||||
}
|
||||
|
||||
var fileSet = new HashSet<string>();
|
||||
var builder = new RomFsBuilder();
|
||||
HashSet<string> fileSet = new();
|
||||
RomFsBuilder builder = new();
|
||||
int count = 0;
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Application {applicationId:X16}");
|
||||
|
||||
// Prioritize loose files first
|
||||
foreach (var mod in mods.RomfsDirs)
|
||||
foreach (Mod<DirectoryInfo> mod in mods.RomfsDirs)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
@@ -511,7 +512,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
|
||||
// Then files inside images
|
||||
foreach (var mod in mods.RomfsContainers)
|
||||
foreach (Mod<FileInfo> mod in mods.RomfsContainers)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
@@ -536,12 +537,12 @@ namespace Ryujinx.HLE.HOS
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Replaced {fileSet.Count} file(s) over {count} mod(s). Processing base storage...");
|
||||
|
||||
// And finally, the base romfs
|
||||
var baseRom = new RomFsFileSystem(baseStorage);
|
||||
foreach (var entry in baseRom.EnumerateEntries()
|
||||
RomFsFileSystem baseRom = new(baseStorage);
|
||||
foreach (DirectoryEntryEx entry in baseRom.EnumerateEntries()
|
||||
.Where(f => f.Type == DirectoryEntryType.File && !fileSet.Contains(f.FullPath))
|
||||
.OrderBy(f => f.FullPath, StringComparer.Ordinal))
|
||||
{
|
||||
using var file = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> file = new();
|
||||
|
||||
baseRom.OpenFile(ref file.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
builder.AddFile(entry.FullPath, file.Release());
|
||||
@@ -556,12 +557,12 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet<string> fileSet, RomFsBuilder builder)
|
||||
{
|
||||
foreach (var entry in fs.EnumerateEntries()
|
||||
foreach (DirectoryEntryEx entry in fs.EnumerateEntries()
|
||||
.AsParallel()
|
||||
.Where(f => f.Type == DirectoryEntryType.File)
|
||||
.OrderBy(f => f.FullPath, StringComparer.Ordinal))
|
||||
{
|
||||
var file = new LazyFile(entry.FullPath, rootPath, fs);
|
||||
LazyFile file = new(entry.FullPath, rootPath, fs);
|
||||
|
||||
if (fileSet.Add(entry.FullPath))
|
||||
{
|
||||
@@ -588,7 +589,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, "Using replacement ExeFS partition");
|
||||
|
||||
var pfs = new PartitionFileSystem();
|
||||
PartitionFileSystem pfs = new();
|
||||
pfs.Initialize(mods.ExefsContainers[0].Path.OpenRead().AsStorage()).ThrowIfFailure();
|
||||
exefs = pfs;
|
||||
|
||||
@@ -626,9 +627,9 @@ namespace Ryujinx.HLE.HOS
|
||||
throw new ArgumentOutOfRangeException(nameof(nsos), nsos.Length, "NSO Count is incorrect");
|
||||
}
|
||||
|
||||
var exeMods = mods.ExefsDirs;
|
||||
List<Mod<DirectoryInfo>> exeMods = mods.ExefsDirs;
|
||||
|
||||
foreach (var mod in exeMods)
|
||||
foreach (Mod<DirectoryInfo> mod in exeMods)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
@@ -637,7 +638,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
for (int i = 0; i < ProcessConst.ExeFsPrefixes.Length; ++i)
|
||||
{
|
||||
var nsoName = ProcessConst.ExeFsPrefixes[i];
|
||||
string nsoName = ProcessConst.ExeFsPrefixes[i];
|
||||
|
||||
FileInfo nsoFile = new(Path.Combine(mod.Path.FullName, nsoName));
|
||||
if (nsoFile.Exists)
|
||||
@@ -705,7 +706,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal void ApplyNroPatches(NroExecutable nro)
|
||||
{
|
||||
var nroPatches = _patches.NroPatches;
|
||||
List<Mod<DirectoryInfo>> nroPatches = _patches.NroPatches;
|
||||
|
||||
if (nroPatches.Count == 0)
|
||||
{
|
||||
@@ -747,11 +748,11 @@ namespace Ryujinx.HLE.HOS
|
||||
return;
|
||||
}
|
||||
|
||||
var cheats = mods.Cheats;
|
||||
var processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v })
|
||||
List<Cheat> cheats = mods.Cheats;
|
||||
Dictionary<string, ulong> 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);
|
||||
|
||||
foreach (var cheat in cheats)
|
||||
foreach (Cheat cheat in cheats)
|
||||
{
|
||||
string cheatId = Path.GetFileNameWithoutExtension(cheat.Path.Name).ToUpper();
|
||||
|
||||
@@ -772,7 +773,7 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
internal static void EnableCheats(ulong applicationId, TamperMachine tamperMachine)
|
||||
{
|
||||
var contentDirectory = FindApplicationDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{applicationId:x16}");
|
||||
DirectoryInfo contentDirectory = FindApplicationDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{applicationId:x16}");
|
||||
string enabledCheatsPath = Path.Combine(contentDirectory.FullName, CheatDir, "enabled.txt");
|
||||
|
||||
if (File.Exists(enabledCheatsPath))
|
||||
@@ -792,11 +793,11 @@ namespace Ryujinx.HLE.HOS
|
||||
patches[i] = new MemPatch();
|
||||
}
|
||||
|
||||
var buildIds = new List<string>(programs.Length);
|
||||
List<string> buildIds = new(programs.Length);
|
||||
|
||||
foreach (IExecutable p in programs)
|
||||
{
|
||||
var buildId = p switch
|
||||
string buildId = p switch
|
||||
{
|
||||
NsoExecutable nso => Convert.ToHexString(nso.BuildId).TrimEnd('0'),
|
||||
NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'),
|
||||
@@ -808,15 +809,15 @@ namespace Ryujinx.HLE.HOS
|
||||
int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small
|
||||
|
||||
// Collect patches
|
||||
foreach (var mod in mods)
|
||||
foreach (Mod<DirectoryInfo> mod in mods)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var patchDir = mod.Path;
|
||||
foreach (var patchFile in patchDir.EnumerateFiles())
|
||||
DirectoryInfo patchDir = mod.Path;
|
||||
foreach (FileInfo patchFile in patchDir.EnumerateFiles())
|
||||
{
|
||||
if (StrEquals(".ips", patchFile.Extension)) // IPS|IPS32
|
||||
{
|
||||
@@ -831,18 +832,18 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Matching IPS patch '{patchFile.Name}' in '{mod.Name}' bid={buildId}");
|
||||
|
||||
using var fs = patchFile.OpenRead();
|
||||
using var reader = new BinaryReader(fs);
|
||||
using FileStream fs = patchFile.OpenRead();
|
||||
using BinaryReader reader = new(fs);
|
||||
|
||||
var patcher = new IpsPatcher(reader);
|
||||
IpsPatcher patcher = new(reader);
|
||||
patcher.AddPatches(patches[index]);
|
||||
}
|
||||
else if (StrEquals(".pchtxt", patchFile.Extension)) // IPSwitch
|
||||
{
|
||||
using var fs = patchFile.OpenRead();
|
||||
using var reader = new StreamReader(fs);
|
||||
using FileStream fs = patchFile.OpenRead();
|
||||
using StreamReader reader = new(fs);
|
||||
|
||||
var patcher = new IPSwitchPatcher(reader);
|
||||
IPSwitchPatcher patcher = new(reader);
|
||||
|
||||
int index = GetIndex(patcher.BuildId);
|
||||
if (index == -1)
|
||||
|
||||
@@ -191,10 +191,10 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
|
||||
private void DeleteSaveData(UserId userId)
|
||||
{
|
||||
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default,
|
||||
SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default,
|
||||
new LibHac.Fs.UserId((ulong)userId.High, (ulong)userId.Low), saveDataId: default, index: default);
|
||||
|
||||
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
||||
using UniqueRef<SaveDataIterator> saveDataIterator = new();
|
||||
|
||||
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc.Types;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
ProfilesJson profilesJson = JsonHelper.DeserializeFromFile(_profilesJsonPath, _serializerContext.ProfilesJson);
|
||||
|
||||
foreach (var profile in profilesJson.Profiles)
|
||||
foreach (UserProfileJson profile in profilesJson.Profiles)
|
||||
{
|
||||
UserProfile addedProfile = new(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
|
||||
|
||||
@@ -68,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
LastOpened = LastOpened.ToString(),
|
||||
};
|
||||
|
||||
foreach (var profile in profiles)
|
||||
foreach (KeyValuePair<string, UserProfile> profile in profiles)
|
||||
{
|
||||
profilesJson.Profiles.Add(new UserProfileJson()
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
byte[] deviceAccountId = new byte[0x10];
|
||||
RandomNumberGenerator.Fill(deviceAccountId);
|
||||
|
||||
var descriptor = new SecurityTokenDescriptor
|
||||
SecurityTokenDescriptor descriptor = new()
|
||||
{
|
||||
Subject = new ClaimsIdentity([new Claim(JwtRegisteredClaimNames.Sub, Convert.ToHexString(rawUserId).ToLower())]),
|
||||
SigningCredentials = credentials,
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||
|
||||
_vrModeEnabled = vrModeEnabled;
|
||||
|
||||
using var lblApi = new LblApi();
|
||||
using LblApi lblApi = new();
|
||||
|
||||
if (vrModeEnabled)
|
||||
{
|
||||
|
||||
+3
-2
@@ -13,6 +13,7 @@ using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage;
|
||||
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
@@ -117,7 +118,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
||||
public ResultCode EnsureSaveData(ServiceCtx context)
|
||||
{
|
||||
Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// Mask out the low nibble of the program ID to get the application ID
|
||||
ApplicationId applicationId = new(process.Identity.ApplicationId);
|
||||
@@ -238,7 +239,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
||||
ushort index = (ushort)context.RequestData.ReadUInt64();
|
||||
long saveSize = context.RequestData.ReadInt64();
|
||||
long journalSize = context.RequestData.ReadInt64();
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// Mask out the low nibble of the program ID to get the application ID
|
||||
ApplicationId applicationId = new(process.Identity.ApplicationId);
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash);
|
||||
}
|
||||
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
||||
using SKBitmap bitmap = new(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
||||
|
||||
IntPtr pixels = bitmap.GetPixels();
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
Marshal.Copy(screenshotData, 0, pixels, ScreenshotDataSize);
|
||||
|
||||
using var data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
|
||||
using var file = File.OpenWrite(filePath);
|
||||
using FileStream file = File.OpenWrite(filePath);
|
||||
data.SaveTo(file);
|
||||
|
||||
return ResultCode.Success;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
try
|
||||
{
|
||||
LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open);
|
||||
var pfs = new PartitionFileSystem();
|
||||
PartitionFileSystem pfs = new();
|
||||
using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(pfs);
|
||||
pfs.Initialize(storage).ThrowIfFailure();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
}
|
||||
|
||||
LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||
using var sharedFs = new SharedRef<LibHac.Fs.Fsa.IFileSystem>(fileSystem);
|
||||
using SharedRef<LibHac.Fs.Fsa.IFileSystem> sharedFs = new(fileSystem);
|
||||
|
||||
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> adapter = FileSystemInterfaceAdapter.CreateShared(ref sharedFs.Ref, true);
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
||||
|
||||
using var ncaFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
|
||||
using UniqueRef<LibHac.Fs.Fsa.IFile> ncaFile = new();
|
||||
|
||||
Result result = nsp.OpenFile(ref ncaFile.Ref, filename.ToU8Span(), OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
@@ -122,14 +122,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
|
||||
{
|
||||
using var ticketFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
|
||||
using UniqueRef<LibHac.Fs.Fsa.IFile> ticketFile = new();
|
||||
|
||||
Result result = nsp.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
Ticket ticket = new(ticketFile.Get.AsStream());
|
||||
var titleKey = ticket.GetTitleKey(keySet);
|
||||
byte[] titleKey = ticket.GetTitleKey(keySet);
|
||||
|
||||
if (titleKey != null)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
@@ -3,6 +3,7 @@ using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
long offset = context.RequestData.ReadInt64();
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption);
|
||||
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
|
||||
using SharedRef<LibHac.FsSrv.Sf.IFile> file = new();
|
||||
|
||||
Result result = _fileSystem.Get.OpenFile(ref file.Ref, in name, mode);
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
using var dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>();
|
||||
using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new();
|
||||
|
||||
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, in name, mode);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
size = bufferLen;
|
||||
}
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(readCount);
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>();
|
||||
PackedMomentProcessorConfig packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>();
|
||||
PackedClusteringProcessorConfig packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>();
|
||||
PackedImageTransferProcessorConfig packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>();
|
||||
PackedTeraPluginProcessorConfig packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
||||
|
||||
byte[] ip = address.GetAddressBytes();
|
||||
|
||||
var macAddress = new Array6<byte>();
|
||||
Array6<byte> macAddress = new();
|
||||
new byte[] { 0x02, 0x00, ip[0], ip[1], ip[2], ip[3] }.CopyTo(macAddress.AsSpan());
|
||||
|
||||
return macAddress;
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
|
||||
|
||||
lock (_scanLock)
|
||||
{
|
||||
var newResults = _scanResultsLast;
|
||||
Dictionary<ulong, NetworkInfo> newResults = _scanResultsLast;
|
||||
newResults.Clear();
|
||||
|
||||
_scanResultsLast = _scanResults;
|
||||
@@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
|
||||
|
||||
lock (_scanLock)
|
||||
{
|
||||
var results = new Dictionary<ulong, NetworkInfo>();
|
||||
Dictionary<ulong, NetworkInfo> results = new();
|
||||
|
||||
foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast)
|
||||
{
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData));
|
||||
|
||||
// Send a network change event with dummy data immediately. Necessary to avoid crashes in some games
|
||||
var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = new CommonNetworkInfo()
|
||||
{
|
||||
@@ -613,7 +613,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
|
||||
SendAsync(_protocol.Encode(PacketId.Connect, request));
|
||||
|
||||
var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = request.NetworkInfo.Common,
|
||||
Ldn = request.NetworkInfo.Ldn
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
{
|
||||
_proxy.ReturnEphemeralPort(ProtocolType, (ushort)((IPEndPoint)LocalEndPoint).Port);
|
||||
}
|
||||
var asIPEndpoint = (IPEndPoint)localEP;
|
||||
IPEndPoint asIPEndpoint = (IPEndPoint)localEP;
|
||||
if (asIPEndpoint.Port == 0)
|
||||
{
|
||||
asIPEndpoint.Port = (ushort)_proxy.GetEphemeralPort(ProtocolType);
|
||||
|
||||
@@ -440,18 +440,18 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types
|
||||
|
||||
int indexFor4 = 3 * (int)age + 9 * (int)gender + (int)race;
|
||||
|
||||
var facelineTypeInfo = RandomMiiFacelineArray[indexFor4];
|
||||
var facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race];
|
||||
var facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4];
|
||||
var facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4];
|
||||
var hairTypeInfo = RandomMiiHairTypeArray[indexFor4];
|
||||
var hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age];
|
||||
var eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4];
|
||||
var eyeColorInfo = RandomMiiEyeColorArray[(int)race];
|
||||
var eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4];
|
||||
var noseTypeInfo = RandomMiiNoseTypeArray[indexFor4];
|
||||
var mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4];
|
||||
var glassTypeInfo = RandomMiiGlassTypeArray[(int)age];
|
||||
RandomMiiData4 facelineTypeInfo = RandomMiiFacelineArray[indexFor4];
|
||||
RandomMiiData3 facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race];
|
||||
RandomMiiData4 facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4];
|
||||
RandomMiiData4 facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4];
|
||||
RandomMiiData4 hairTypeInfo = RandomMiiHairTypeArray[indexFor4];
|
||||
RandomMiiData3 hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age];
|
||||
RandomMiiData4 eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4];
|
||||
RandomMiiData2 eyeColorInfo = RandomMiiEyeColorArray[(int)race];
|
||||
RandomMiiData4 eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4];
|
||||
RandomMiiData4 noseTypeInfo = RandomMiiNoseTypeArray[indexFor4];
|
||||
RandomMiiData4 mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4];
|
||||
RandomMiiData2 glassTypeInfo = RandomMiiGlassTypeArray[(int)age];
|
||||
|
||||
// Faceline
|
||||
coreData.FacelineType = (FacelineType)facelineTypeInfo.Values[utilImpl.GetRandom(facelineTypeInfo.ValuesCount)];
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
|
||||
public AmiiboDecryptor(string keyRetailBinPath)
|
||||
{
|
||||
var combinedKeys = File.ReadAllBytes(keyRetailBinPath);
|
||||
var keys = AmiiboMasterKey.FromCombinedBin(combinedKeys);
|
||||
byte[] combinedKeys = File.ReadAllBytes(keyRetailBinPath);
|
||||
(AmiiboMasterKey DataKey, AmiiboMasterKey TagKey) keys = AmiiboMasterKey.FromCombinedBin(combinedKeys);
|
||||
DataKey = keys.DataKey;
|
||||
TagKey = keys.TagKey;
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
if (deriveAes)
|
||||
{
|
||||
// Derive AES Key and IV
|
||||
var dataForAes = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForAes = new byte[2 + seedBytes.Length];
|
||||
dataForAes[0] = 0x00;
|
||||
dataForAes[1] = 0x00; // Counter (0)
|
||||
Array.Copy(seedBytes, 0, dataForAes, 2, seedBytes.Length);
|
||||
|
||||
byte[] derivedBytes;
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForAes);
|
||||
}
|
||||
@@ -100,12 +100,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
derivedAesIv = derivedBytes.Skip(16).Take(16).ToArray();
|
||||
|
||||
// Derive HMAC Key
|
||||
var dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
dataForHmacKey[0] = 0x00;
|
||||
dataForHmacKey[1] = 0x01; // Counter (1)
|
||||
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
|
||||
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForHmacKey);
|
||||
}
|
||||
@@ -115,13 +115,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
else
|
||||
{
|
||||
// Derive HMAC Key only
|
||||
var dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
dataForHmacKey[0] = 0x00;
|
||||
dataForHmacKey[1] = 0x01; // Counter (1)
|
||||
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
|
||||
|
||||
byte[] derivedBytes;
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForHmacKey);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, tagHmacData, 8, 44);
|
||||
|
||||
byte[] tagHmac;
|
||||
using (var hmac = new HMACSHA256(hmacTagKey))
|
||||
using (HMACSHA256 hmac = new(hmacTagKey))
|
||||
{
|
||||
tagHmac = hmac.ComputeHash(tagHmacData);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, dataHmacData, offset, len5);
|
||||
|
||||
byte[] dataHmac;
|
||||
using (var hmac = new HMACSHA256(hmacDataKey))
|
||||
using (HMACSHA256 hmac = new(hmacDataKey))
|
||||
{
|
||||
dataHmac = hmac.ComputeHash(dataHmacData);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, tagHmacData, 8, 44);
|
||||
|
||||
byte[] calculatedTagHmac;
|
||||
using (var hmac = new HMACSHA256(hmacTagKey))
|
||||
using (HMACSHA256 hmac = new(hmacTagKey))
|
||||
{
|
||||
calculatedTagHmac = hmac.ComputeHash(tagHmacData);
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, dataHmacData, offset, len5);
|
||||
|
||||
byte[] calculatedDataHmac;
|
||||
using (var hmac = new HMACSHA256(hmacDataKey))
|
||||
using (HMACSHA256 hmac = new(hmacDataKey))
|
||||
{
|
||||
calculatedDataHmac = hmac.ComputeHash(dataHmacData);
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
context.Device.System.NfpDevices[i].State = NfpDeviceState.SearchingForTag;
|
||||
|
||||
// ▼ If a tag has already been injected via Bridge, use it immediately.
|
||||
if (KenjinxAmiiboShim.TryConsume(out var tagBytes))
|
||||
if (KenjinxAmiiboShim.TryConsume(out byte[] tagBytes))
|
||||
{
|
||||
var dev = context.Device.System.NfpDevices[i];
|
||||
NfpDevice dev = context.Device.System.NfpDevices[i];
|
||||
|
||||
if (TryGetFigureIdFrom1Dc(tagBytes, out var fid, out var raw))
|
||||
if (TryGetFigureIdFrom1Dc(tagBytes, out string fid, out string raw))
|
||||
{
|
||||
dev.AmiiboId = fid;
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceNfp, $"Kenjinx: raw@1DC={raw} → FigureID={fid}");
|
||||
@@ -182,11 +182,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
// ▼ Poll during the search for newly injected tags.
|
||||
for (int d = 0; d < context.Device.System.NfpDevices.Count; d++)
|
||||
{
|
||||
var dev = context.Device.System.NfpDevices[d];
|
||||
NfpDevice dev = context.Device.System.NfpDevices[d];
|
||||
|
||||
if (dev.State == NfpDeviceState.SearchingForTag && KenjinxAmiiboShim.TryConsume(out var tagBytesLoop))
|
||||
if (dev.State == NfpDeviceState.SearchingForTag && KenjinxAmiiboShim.TryConsume(out byte[] tagBytesLoop))
|
||||
{
|
||||
if (TryGetFigureIdFrom1Dc(tagBytesLoop, out var fid, out var raw))
|
||||
if (TryGetFigureIdFrom1Dc(tagBytesLoop, out string fid, out string raw))
|
||||
{
|
||||
dev.AmiiboId = fid;
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceNfp, $"Kenjinx: raw@1DC={raw} → FigureID={fid}");
|
||||
@@ -267,7 +267,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
return false;
|
||||
}
|
||||
|
||||
var s = data.AsSpan(off, len);
|
||||
Span<byte> s = data.AsSpan(off, len);
|
||||
|
||||
// Debug string "AA-BB-..." in uppercase letters
|
||||
debugRaw = $"{s[0]:X2}-{s[1]:X2}-{s[2]:X2}-{s[3]:X2}-{s[4]:X2}-{s[5]:X2}-{s[6]:X2}-{s[7]:X2}";
|
||||
@@ -286,8 +286,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
{
|
||||
if (data == null || data.Length == 0) return "0000000000000000";
|
||||
|
||||
using var sha = SHA1.Create();
|
||||
var hash = sha.ComputeHash(data); // 20 Bytes
|
||||
using SHA1 sha = SHA1.Create();
|
||||
byte[] hash = sha.ComputeHash(data); // 20 Bytes
|
||||
char[] buf = new char[16];
|
||||
for (int i = 0, k = 0; i < 8; i++)
|
||||
{
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
MemoryAllocator = new NvMemoryAllocator();
|
||||
Host1x = new Host1xDevice(gpu.Synchronization);
|
||||
Smmu = gpu.CreateDeviceMemoryManager(pid);
|
||||
var nvdec = new NvdecDevice(Smmu);
|
||||
var vic = new VicDevice(Smmu);
|
||||
NvdecDevice nvdec = new(Smmu);
|
||||
VicDevice vic = new(Smmu);
|
||||
Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
|
||||
Host1x.RegisterDevice(ClassId.Vic, vic);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
|
||||
private NvInternalResult BindChannel(ref BindChannelArguments arguments)
|
||||
{
|
||||
var channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData<NvHostChannelDeviceFile>(arguments.Fd);
|
||||
NvHostChannelDeviceFile channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData<NvHostChannelDeviceFile>(arguments.Fd);
|
||||
if (channelDeviceFile == null)
|
||||
{
|
||||
// TODO: Return invalid Fd error.
|
||||
@@ -339,9 +339,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
|
||||
for (uint i = 0; i < writeEntries; i++)
|
||||
{
|
||||
ref var region = ref regionsSpan[(int)i];
|
||||
ref VaRegion region = ref regionsSpan[(int)i];
|
||||
|
||||
var vmRegion = _vmRegions[i];
|
||||
VmRegion vmRegion = _vmRegions[i];
|
||||
uint pageSize = _pageSizes[i];
|
||||
|
||||
region.PageSize = pageSize;
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
||||
|
||||
public void Close()
|
||||
{
|
||||
foreach (var map in _maps.Values)
|
||||
foreach (Range map in _maps.Values)
|
||||
{
|
||||
Gmm.Unmap(map.Start, map.End - map.Start);
|
||||
}
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
||||
{
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBuffer.Mem);
|
||||
|
||||
var data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
||||
ReadOnlySpan<byte> data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
||||
|
||||
_host1xContext.Host1x.Submit(MemoryMarshal.Cast<byte, int>(data), _contextId);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Services.Arp;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using System;
|
||||
using static LibHac.Ns.ApplicationControlProperty;
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
||||
if (titleId != 0)
|
||||
{
|
||||
_titleId = titleId;
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
|
||||
_ratingAge = new int[process.ApplicationControlProperties.RatingAge.Length];
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService
|
||||
MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
|
||||
|
||||
// Return ResultCode.ServiceUnavailable if data is locked by another process.
|
||||
var filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable();
|
||||
IEnumerable<KeyValuePair<UserId, ApplicationPlayStatistics>> filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable();
|
||||
|
||||
if (queryCapability == PlayLogQueryCapability.None)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
|
||||
Nca nca = new(_device.System.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
|
||||
using var fontFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> fontFile = new();
|
||||
|
||||
romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.IO;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Memory;
|
||||
@@ -82,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, () =>
|
||||
{
|
||||
var currentThread = KernelStatic.GetCurrentThread();
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
currentThread.HostThread.Name = $"{{{Name}}}";
|
||||
|
||||
Main();
|
||||
@@ -241,7 +242,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
}
|
||||
}
|
||||
|
||||
var rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1);
|
||||
Result rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1);
|
||||
|
||||
_selfThread.HandlePostSyscall();
|
||||
|
||||
@@ -313,7 +314,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
{
|
||||
_context.Syscall.CloseHandle(serverSessionHandle);
|
||||
|
||||
if (RemoveSessionObj(serverSessionHandle, out var session))
|
||||
if (RemoveSessionObj(serverSessionHandle, out IpcService session))
|
||||
{
|
||||
(session as IDisposable)?.Dispose();
|
||||
}
|
||||
@@ -466,7 +467,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
response.RawData = _responseDataStream.ToArray();
|
||||
|
||||
var responseStream = response.GetStreamTipc();
|
||||
RecyclableMemoryStream responseStream = response.GetStreamTipc();
|
||||
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
|
||||
MemoryStreamManager.Shared.ReleaseStream(responseStream);
|
||||
}
|
||||
@@ -477,7 +478,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
if (!isTipcCommunication)
|
||||
{
|
||||
var responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
|
||||
RecyclableMemoryStream responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
|
||||
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
|
||||
MemoryStreamManager.Shared.ReleaseStream(responseStream);
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
|
||||
IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel);
|
||||
|
||||
using var firmwareFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> firmwareFile = new();
|
||||
|
||||
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
|
||||
@@ -331,9 +331,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
}
|
||||
}
|
||||
|
||||
using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
|
||||
using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize);
|
||||
using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize);
|
||||
using WritableRegion readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
|
||||
using WritableRegion writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize);
|
||||
using WritableRegion errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize);
|
||||
|
||||
_context.BuildMask(readFds, readFdsOut.Memory.Span);
|
||||
_context.BuildMask(writeFds, writeFdsOut.Memory.Span);
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
public static bool TryConvertSocketOption(BsdSocketOption option, SocketOptionLevel level, out SocketOptionName name)
|
||||
{
|
||||
var table = level switch
|
||||
Dictionary<BsdSocketOption, SocketOptionName> table = level switch
|
||||
{
|
||||
SocketOptionLevel.Socket => _soSocketOptionMap,
|
||||
SocketOptionLevel.IP => _ipSocketOptionMap,
|
||||
@@ -323,7 +323,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
public static LinuxError ValidateSocketOption(BsdSocketOption option, SocketOptionLevel level, bool write)
|
||||
{
|
||||
var table = level switch
|
||||
Dictionary<BsdSocketOption, OptionDir> table = level switch
|
||||
{
|
||||
SocketOptionLevel.Socket => _validSoSocketOptionMap,
|
||||
SocketOptionLevel.IP => _validIpSocketOptionMap,
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
||||
|
||||
public static void Select(List<ISocketImpl> readEvents, List<ISocketImpl> writeEvents, List<ISocketImpl> errorEvents, int timeout)
|
||||
{
|
||||
var readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
var writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
var errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
|
||||
if (readDefault.Count != 0 || writeDefault.Count != 0 || errorDefault.Count != 0)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
|
||||
|
||||
public IPHostEntry ResolveAddress(string host)
|
||||
{
|
||||
foreach (var hostEntry in _mitmHostEntries)
|
||||
foreach (KeyValuePair<string, IPAddress> hostEntry in _mitmHostEntries)
|
||||
{
|
||||
// Check for AMS hosts file extension: "*"
|
||||
// NOTE: MatchesSimpleExpression also allows "?" as a wildcard
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
|
||||
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var trustedCertsFileRef = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> trustedCertsFileRef = new();
|
||||
|
||||
Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
using (WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
{
|
||||
Encoding.ASCII.GetBytes(_hostName, region.Memory.Span);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var binaryListFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> binaryListFile = new();
|
||||
|
||||
romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
|
||||
public IEnumerable<(int Offset, string Location, string Abbr)> ParseTzOffsets()
|
||||
{
|
||||
var tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath();
|
||||
string tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath();
|
||||
|
||||
if (string.IsNullOrEmpty(tzBinaryContentPath))
|
||||
{
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
}
|
||||
|
||||
List<(int Offset, string Location, string Abbr)> outList = [];
|
||||
var now = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
long now = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open))
|
||||
using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel))
|
||||
{
|
||||
@@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
continue;
|
||||
}
|
||||
|
||||
using var tzif = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> tzif = new();
|
||||
|
||||
if (romfs.OpenFile(ref tzif.Ref, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure())
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
continue;
|
||||
}
|
||||
|
||||
var abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..];
|
||||
Span<byte> abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..];
|
||||
int abbrEnd = abbrStart.IndexOf((byte)0);
|
||||
|
||||
outList.Add((ttInfo.GmtOffset, locName, Encoding.UTF8.GetString(abbrStart[..abbrEnd])));
|
||||
@@ -269,7 +269,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
Nca nca = new(_virtualFileSystem.KeySet, ncaFile);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var timeZoneBinaryFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> timeZoneBinaryFile = new();
|
||||
|
||||
Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters
|
||||
}
|
||||
|
||||
// Use the conditional begin instruction stored in the stack.
|
||||
var upperInstruction = context.CurrentBlock.BaseInstruction;
|
||||
byte[] upperInstruction = context.CurrentBlock.BaseInstruction;
|
||||
CodeType codeType = InstructionHelper.GetCodeType(upperInstruction);
|
||||
|
||||
// Pop the current block of operations from the stack so control instructions
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Tamper
|
||||
// Instructions are multi-word, with 32bit words. Split the raw instruction
|
||||
// and parse each word into individual nybbles of bits.
|
||||
|
||||
var words = rawInstruction.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] words = rawInstruction.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
byte[] instruction = new byte[WordSize * words.Length];
|
||||
|
||||
|
||||
@@ -73,14 +73,14 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
public void EnableCheats(string[] enabledCheats)
|
||||
{
|
||||
foreach (var program in _programDictionary.Values)
|
||||
foreach (ITamperProgram program in _programDictionary.Values)
|
||||
{
|
||||
program.IsEnabled = false;
|
||||
}
|
||||
|
||||
foreach (var cheat in enabledCheats)
|
||||
foreach (string cheat in enabledCheats)
|
||||
{
|
||||
if (_programDictionary.TryGetValue(cheat, out var program))
|
||||
if (_programDictionary.TryGetValue(cheat, out ITamperProgram program))
|
||||
{
|
||||
program.IsEnabled = true;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
// --- TRY 0: Our conflict-free shim class first (recommended) ---
|
||||
// Type name including assembly: Ryujinx.HLE
|
||||
var shimType = Type.GetType(
|
||||
Type? shimType = Type.GetType(
|
||||
"Ryujinx.HLE.HOS.Services.Nfc.Nfp.KenjinxAmiiboShim, Ryujinx.HLE",
|
||||
throwOnError: false
|
||||
);
|
||||
if (shimType != null)
|
||||
{
|
||||
var m = shimType.GetMethod(
|
||||
MethodInfo? m = shimType.GetMethod(
|
||||
"InjectAmiibo",
|
||||
BindingFlags.Public | BindingFlags.Static,
|
||||
binder: null,
|
||||
@@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
var ok = (bool)(m.Invoke(null, new object[] { data }) ?? false);
|
||||
bool ok = (bool)(m.Invoke(null, new object[] { data }) ?? false);
|
||||
if (ok)
|
||||
{
|
||||
message = "Injected via KenjinxAmiiboShim.InjectAmiibo";
|
||||
@@ -45,13 +45,13 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
// --- TRY 0.5: If available – static API directly on NfpManager ---
|
||||
// (Only if you later add a static InjectAmiibo(...) method to NfpManager.)
|
||||
var nfpManagerType = Type.GetType(
|
||||
Type? nfpManagerType = Type.GetType(
|
||||
"Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager, Ryujinx.HLE",
|
||||
throwOnError: false
|
||||
);
|
||||
if (nfpManagerType != null)
|
||||
{
|
||||
var m = nfpManagerType.GetMethod(
|
||||
MethodInfo? m = nfpManagerType.GetMethod(
|
||||
"InjectAmiibo",
|
||||
BindingFlags.Public | BindingFlags.Static,
|
||||
binder: null,
|
||||
@@ -61,15 +61,15 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
var ok = m.Invoke(null, new object[] { data });
|
||||
object? ok = m.Invoke(null, new object[] { data });
|
||||
message = "Injected via NfpManager.InjectAmiibo(static)";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// --- TRY 1: Direct access to an existing manager in the system object (your existing code) ---
|
||||
var sys = device.System;
|
||||
var nfpMgr =
|
||||
HOS.Horizon? sys = device.System;
|
||||
object? nfpMgr =
|
||||
GetField(sys, "NfpManager") ??
|
||||
GetField(sys, "_nfpManager") ??
|
||||
GetField(sys, "NfcManager") ??
|
||||
@@ -78,7 +78,7 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
if (nfpMgr != null)
|
||||
{
|
||||
// Possible method identifiers depending on the tree:
|
||||
var mi =
|
||||
MethodInfo? mi =
|
||||
GetMethod(nfpMgr, "InjectAmiibo", new[] { typeof(byte[]) }) ??
|
||||
GetMethod(nfpMgr, "LoadAmiiboFromBytes", new[] { typeof(byte[]) }) ??
|
||||
GetMethod(nfpMgr, "LoadVirtualAmiibo", new[] { typeof(byte[]) }) ??
|
||||
@@ -101,7 +101,7 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
if (device?.System is null) return;
|
||||
|
||||
// --- Clear via Shim (if present) ---
|
||||
var shimType = Type.GetType(
|
||||
Type? shimType = Type.GetType(
|
||||
"Ryujinx.HLE.HOS.Services.Nfc.Nfp.KenjinxAmiiboShim, Ryujinx.HLE",
|
||||
throwOnError: false
|
||||
);
|
||||
@@ -110,7 +110,7 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
?.Invoke(null, null);
|
||||
|
||||
// --- Optional: Static clear API on NfpManager (if available) ---
|
||||
var nfpManagerType = Type.GetType(
|
||||
Type? nfpManagerType = Type.GetType(
|
||||
"Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager, Ryujinx.HLE",
|
||||
throwOnError: false
|
||||
);
|
||||
@@ -119,8 +119,8 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
?.Invoke(null, null);
|
||||
|
||||
// --- Your existing instance fallback ---
|
||||
var sys = device.System;
|
||||
var nfpMgr =
|
||||
HOS.Horizon? sys = device.System;
|
||||
object? nfpMgr =
|
||||
GetField(sys, "NfpManager") ??
|
||||
GetField(sys, "_nfpManager") ??
|
||||
GetField(sys, "NfcManager") ??
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
if (nfpMgr != null)
|
||||
{
|
||||
var mi =
|
||||
MethodInfo? mi =
|
||||
GetMethod(nfpMgr, "ClearAmiibo", Type.EmptyTypes) ??
|
||||
GetMethod(nfpMgr, "ResetVirtualAmiibo", Type.EmptyTypes);
|
||||
|
||||
@@ -138,14 +138,14 @@ namespace Ryujinx.HLE.Kenjinx
|
||||
|
||||
private static object? GetField(object target, string name)
|
||||
{
|
||||
var t = target.GetType();
|
||||
var f = t.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
|
||||
Type t = target.GetType();
|
||||
FieldInfo? f = t.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
|
||||
return f?.GetValue(target);
|
||||
}
|
||||
|
||||
private static MethodInfo? GetMethod(object target, string name, Type[]? sig)
|
||||
{
|
||||
var t = target.GetType();
|
||||
Type t = target.GetType();
|
||||
return t.GetMethod(
|
||||
name,
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy,
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Ryujinx.HLE.Loaders.Executables
|
||||
{
|
||||
reader.GetSegmentSize(segmentType, out int uncompressedSize).ThrowIfFailure();
|
||||
|
||||
var span = program.AsSpan((int)offset, uncompressedSize);
|
||||
Span<byte> span = program.AsSpan((int)offset, uncompressedSize);
|
||||
|
||||
reader.ReadSegment(segmentType, span).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Ryujinx.HLE.Loaders.Executables
|
||||
{
|
||||
reader.GetSegmentSize(segmentType, out uint uncompressedSize).ThrowIfFailure();
|
||||
|
||||
var span = Program.AsSpan((int)offset, (int)uncompressedSize);
|
||||
Span<byte> span = Program.AsSpan((int)offset, (int)uncompressedSize);
|
||||
|
||||
reader.ReadSegment(segmentType, span).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
ReadOnlySpan<byte> ips32TailMagic = "EEOF"u8;
|
||||
|
||||
MemPatch patches = new();
|
||||
var header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan();
|
||||
Span<byte> header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan();
|
||||
|
||||
if (header.Length != ipsHeaderMagic.Length)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
}
|
||||
else // Copy mode
|
||||
{
|
||||
var patch = reader.ReadBytes(patchSize);
|
||||
byte[] patch = reader.ReadBytes(patchSize);
|
||||
|
||||
if (patch.Length != patchSize)
|
||||
{
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
}
|
||||
else if (line.StartsWith("@flag"))
|
||||
{
|
||||
var tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (tokens.Length < 2)
|
||||
{
|
||||
@@ -234,7 +234,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
continue;
|
||||
}
|
||||
|
||||
var tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (tokens.Length < 2 ||
|
||||
!int.TryParse(tokens[0], System.Globalization.NumberStyles.HexNumber, null, out int offset))
|
||||
@@ -253,12 +253,12 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
|
||||
if (tokens[1][0] == '"')
|
||||
{
|
||||
var patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0");
|
||||
byte[] patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0");
|
||||
patches.Add((uint)offset, patch);
|
||||
}
|
||||
else
|
||||
{
|
||||
var patch = Hex2ByteArrayBE(tokens[1]);
|
||||
byte[] patch = Hex2ByteArrayBE(tokens[1]);
|
||||
patches.Add((uint)offset, patch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (patchOffset, patch) in patches._patches)
|
||||
foreach ((uint patchOffset, byte[] patch) in patches._patches)
|
||||
{
|
||||
_patches[patchOffset] = patch;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace Ryujinx.HLE.Loaders.Mods
|
||||
public int Patch(Span<byte> memory, int protectedOffset = 0)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (var (offset, patch) in _patches.OrderBy(item => item.Key))
|
||||
foreach ((uint offset, byte[] patch) in _patches.OrderBy(item => item.Key))
|
||||
{
|
||||
int patchOffset = (int)offset;
|
||||
int patchSize = patch.Length;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
Logger.Info?.Print(LogClass.Loader, $"Loading {name}...");
|
||||
|
||||
using var nsoFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> nsoFile = new();
|
||||
|
||||
exeFs.OpenFile(ref nsoFile.Ref, $"/{name}".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "")
|
||||
{
|
||||
MetaLoader metaLoader = exeFs.GetNpdm();
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]);
|
||||
|
||||
@@ -12,21 +12,21 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
{
|
||||
public static ulong GetProgramId(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return npdm.Aci.ProgramId.Value;
|
||||
}
|
||||
|
||||
public static string GetProgramName(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return StringUtils.Utf8ZToString(npdm.Meta.ProgramName);
|
||||
}
|
||||
|
||||
public static bool IsProgram64Bit(this MetaLoader metaLoader)
|
||||
{
|
||||
metaLoader.GetNpdm(out var npdm).ThrowIfFailure();
|
||||
metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure();
|
||||
|
||||
return (npdm.Meta.Flags & 1) != 0;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
path = ProcessConst.MainNpdmPath;
|
||||
}
|
||||
|
||||
using var npdmFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> npdmFile = new();
|
||||
|
||||
fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
ModLoader.GetSdModsBasePath());
|
||||
|
||||
// Load Nacp file.
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
|
||||
if (controlNca != null)
|
||||
{
|
||||
@@ -210,9 +210,9 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
public static BlitStruct<ApplicationControlProperty> GetNacp(this Nca controlNca, Switch device)
|
||||
{
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
|
||||
using var controlFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> controlFile = new();
|
||||
|
||||
Result result = controlNca.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel)
|
||||
.OpenFile(ref controlFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read);
|
||||
@@ -232,7 +232,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
public static Cnmt GetCnmt(this Nca cnmtNca, IntegrityCheckLevel checkLevel, ContentMetaType metaType)
|
||||
{
|
||||
string path = $"/{metaType}_{cnmtNca.Header.TitleId:x16}.cnmt";
|
||||
using var cnmtFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> cnmtFile = new();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
{
|
||||
fileSystem.ImportTickets(partitionFileSystem);
|
||||
|
||||
var programs = new Dictionary<ulong, ContentMetaData>();
|
||||
Dictionary<ulong, ContentMetaData> programs = new();
|
||||
|
||||
foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.cnmt.nca"))
|
||||
{
|
||||
@@ -152,7 +152,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
public static Nca GetNca(this IFileSystem fileSystem, KeySet keySet, string path)
|
||||
{
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> ncaFile = new();
|
||||
|
||||
fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
||||
public bool LoadNxo(string path)
|
||||
{
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
IFileSystem dummyExeFs = null;
|
||||
Stream romfsStream = null;
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
|
||||
public bool LoadNxo(Stream stream, bool isNro, string name)
|
||||
{
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
BlitStruct<ApplicationControlProperty> nacpData = new(1);
|
||||
IFileSystem dummyExeFs = null;
|
||||
Stream romfsStream = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.UI.Input
|
||||
{
|
||||
@@ -29,7 +30,7 @@ namespace Ryujinx.HLE.UI.Input
|
||||
{
|
||||
NpadButton buttons = 0;
|
||||
|
||||
foreach (var state in _lastStates)
|
||||
foreach (NpadCommonState state in _lastStates)
|
||||
{
|
||||
buttons |= state.Buttons;
|
||||
}
|
||||
@@ -73,10 +74,10 @@ namespace Ryujinx.HLE.UI.Input
|
||||
{
|
||||
const int MaxEntries = 1024;
|
||||
|
||||
ref var npadState = ref _device.Hid.SharedMemory.Npads[npadIndex];
|
||||
ref var lastEntry = ref _lastStates[npadIndex];
|
||||
ref NpadState npadState = ref _device.Hid.SharedMemory.Npads[npadIndex];
|
||||
ref NpadCommonState lastEntry = ref _lastStates[npadIndex];
|
||||
|
||||
var fullKeyEntries = GetCommonStateLifo(ref npadState.InternalState).ReadEntries(MaxEntries);
|
||||
ReadOnlySpan<AtomicStorage<NpadCommonState>> fullKeyEntries = GetCommonStateLifo(ref npadState.InternalState).ReadEntries(MaxEntries);
|
||||
|
||||
int firstEntryNum;
|
||||
|
||||
@@ -94,7 +95,7 @@ namespace Ryujinx.HLE.UI.Input
|
||||
|
||||
for (; firstEntryNum >= 0; firstEntryNum--)
|
||||
{
|
||||
var entry = fullKeyEntries[firstEntryNum];
|
||||
AtomicStorage<NpadCommonState> entry = fullKeyEntries[firstEntryNum];
|
||||
|
||||
// The interval of valid entries should be contiguous.
|
||||
if (entry.SamplingNumber < lastEntry.SamplingNumber)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Ryujinx.HLE.Utilities
|
||||
}
|
||||
else
|
||||
{
|
||||
var pfsTemp = new PartitionFileSystem();
|
||||
PartitionFileSystem pfsTemp = new();
|
||||
Result initResult = pfsTemp.Initialize(stream.AsStorage());
|
||||
|
||||
if (throwOnFailure)
|
||||
|
||||
Reference in New Issue
Block a user