misc: chore: Use explicit types in HLE project

This commit is contained in:
Evan Husted 2025-01-25 14:13:18 -06:00
parent 58c1ab7989
commit 5eba42fa06
80 changed files with 410 additions and 397 deletions

View file

@ -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 UniqueRef<SaveDataIterator>();
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();

View file

@ -29,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);
@ -69,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()
{

View file

@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
byte[] deviceAccountId = new byte[0x10];
RandomNumberGenerator.Fill(deviceId);
var descriptor = new SecurityTokenDescriptor
SecurityTokenDescriptor descriptor = new SecurityTokenDescriptor
{
Subject = new GenericIdentity(Convert.ToHexString(rawUserId).ToLower()),
SigningCredentials = credentials,

View file

@ -214,7 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
_vrModeEnabled = vrModeEnabled;
using var lblApi = new LblApi();
using LblApi lblApi = new LblApi();
if (vrModeEnabled)
{

View file

@ -118,10 +118,10 @@ namespace Ryujinx.HLE.HOS.Services.Caps
}
// NOTE: The saved JPEG file doesn't have the limitation in the extra EXIF data.
using var bitmap = new SKBitmap(new SKImageInfo(1280, 720, SKColorType.Rgba8888));
using SKBitmap bitmap = new SKBitmap(new SKImageInfo(1280, 720, SKColorType.Rgba8888));
Marshal.Copy(screenshotData, 0, bitmap.GetPixels(), screenshotData.Length);
using var data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
using var file = File.OpenWrite(filePath);
using SKData data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
using FileStream file = File.OpenWrite(filePath);
data.SaveTo(file);
return ResultCode.Success;

View file

@ -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 PartitionFileSystem();
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 SharedRef<LibHac.Fs.Fsa.IFileSystem>(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 UniqueRef<LibHac.Fs.Fsa.IFile>();
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 UniqueRef<LibHac.Fs.Fsa.IFile>();
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)
{

View file

@ -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);

View file

@ -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);

View file

@ -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 SharedRef<LibHac.FsSrv.Sf.IFile>();
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 SharedRef<LibHac.FsSrv.Sf.IDirectory>();
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, name, mode);

View file

@ -3,6 +3,7 @@ using LibHac.Common;
using LibHac.Sf;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Memory;
using System.Threading;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
@ -38,7 +39,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);
if (context.Device.DirtyHacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix) && IsXc2)

View file

@ -3,6 +3,7 @@ using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Shim;
using LibHac.FsSrv.Impl;
using LibHac.FsSrv.Sf;
using LibHac.FsSystem;
using LibHac.Ncm;
using LibHac.Sf;
@ -12,10 +13,12 @@ using LibHac.Tools.FsSystem.NcaUtils;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy;
using Ryujinx.Memory;
using System;
using System.IO;
using static Ryujinx.HLE.Utilities.StringUtils;
using GameCardHandle = System.UInt32;
using IFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.IFile;
using IFileSystem = LibHac.FsSrv.Sf.IFileSystem;
using IStorage = LibHac.FsSrv.Sf.IStorage;
@ -29,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public IFileSystemProxy(ServiceCtx context) : base(context.Device.System.FsServer)
{
var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
HorizonClient applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
_baseFileSystemProxy = applicationClient.Fs.Impl.GetFileSystemProxyServiceObject();
}
@ -106,8 +109,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
using var fileSystem = new SharedRef<IFileSystem>();
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref, in path, bisPartitionId);
if (result.IsFailure())
@ -125,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBisStorage(ServiceCtx context)
{
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
using var storage = new SharedRef<IStorage>();
using SharedRef<IStorage> storage = new SharedRef<IStorage>();
Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref, bisPartitionId);
if (result.IsFailure())
@ -149,7 +152,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
public ResultCode OpenSdCardFileSystem(ServiceCtx context)
{
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref);
if (result.IsFailure())
@ -257,7 +260,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
GameCardHandle handle = context.RequestData.ReadUInt32();
GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32();
using var storage = new SharedRef<IStorage>();
using SharedRef<IStorage> storage = new SharedRef<IStorage>();
Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref, handle, partitionId);
if (result.IsFailure())
@ -276,7 +279,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
GameCardHandle handle = context.RequestData.ReadUInt32();
GameCardPartition partitionId = (GameCardPartition)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId);
if (result.IsFailure())
@ -357,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure())
@ -376,7 +379,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure())
@ -395,7 +398,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure())
@ -466,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSaveDataInfoReader() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReader(ServiceCtx context)
{
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref);
if (result.IsFailure())
@ -484,7 +487,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context)
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte();
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref, spaceId);
if (result.IsFailure())
@ -501,7 +504,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSaveDataInfoReaderOnlyCacheStorage() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context)
{
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref);
if (result.IsFailure())
@ -520,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref, spaceId, saveDataId);
if (result.IsFailure())
@ -567,7 +570,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 = _baseFileSystemProxy.Get.FindSaveDataWithFilter(out long count, new OutBuffer(region.Memory.Span), spaceId, in filter);
if (result.IsFailure())
{
@ -584,7 +587,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>();
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref, spaceId, in filter);
if (result.IsFailure())
@ -661,7 +664,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt32();
SaveDataMetaType metaType = (SaveDataMetaType)context.RequestData.ReadInt32();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
using SharedRef<LibHac.FsSrv.Sf.IFile> file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref, spaceId, in attribute, metaType);
if (result.IsFailure())
@ -699,7 +702,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenImageDirectoryFileSystem(ServiceCtx context)
{
ImageDirectoryId directoryId = (ImageDirectoryId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId);
if (result.IsFailure())
@ -716,7 +719,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBaseFileSystem(ServiceCtx context)
{
BaseFileSystemId fileSystemId = (BaseFileSystemId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref, fileSystemId);
if (result.IsFailure())
@ -733,7 +736,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenContentStorageFileSystem(ServiceCtx context)
{
ContentStorageId contentStorageId = (ContentStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref, contentStorageId);
if (result.IsFailure())
@ -750,7 +753,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context)
{
CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref, storageId);
if (result.IsFailure())
@ -767,7 +770,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCustomStorageFileSystem(ServiceCtx context)
{
CustomStorageId customStorageId = (CustomStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, customStorageId);
if (result.IsFailure())
@ -784,9 +787,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
{
var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -809,9 +812,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}");
var storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
LibHac.Fs.IStorage storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage);
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -845,8 +848,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
Nca nca = new(context.Device.System.KeySet, ncaStorage);
LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(romfsStorage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(romfsStorage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
}
@ -875,9 +878,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenPatchDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage>
public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
{
var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -895,9 +898,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs
throw new NotImplementedException($"Accessing storage from other programs is not supported (program index = {programIndex}).");
}
var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true);
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -908,7 +911,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
public ResultCode OpenDeviceOperator(ServiceCtx context)
{
using var deviceOperator = new SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>();
using SharedRef<LibHac.FsSrv.Sf.IDeviceOperator> deviceOperator = new SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>();
Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref);
if (result.IsFailure())
@ -1023,7 +1026,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandCmif(609)]
public ResultCode GetRightsIdByPath(ServiceCtx context)
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
Result result = _baseFileSystemProxy.Get.GetRightsIdByPath(out RightsId rightsId, in path);
if (result.IsFailure())
@ -1039,7 +1042,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandCmif(610)]
public ResultCode GetRightsIdAndKeyGenerationByPath(ServiceCtx context)
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
Result result = _baseFileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in path);
if (result.IsFailure())
@ -1236,7 +1239,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode SetBisRootForHost(ServiceCtx context)
{
BisPartitionId partitionId = (BisPartitionId)context.RequestData.ReadInt32();
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
return (ResultCode)_baseFileSystemProxy.Get.SetBisRootForHost(partitionId, in path).Value;
}
@ -1253,7 +1256,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandCmif(1002)]
public ResultCode SetSaveDataRootPath(ServiceCtx context)
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
return (ResultCode)_baseFileSystemProxy.Get.SetSaveDataRootPath(in path).Value;
}
@ -1307,7 +1310,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandCmif(1008)]
public ResultCode OpenRegisteredUpdatePartition(ServiceCtx context)
{
using var fileSystem = new SharedRef<IFileSystem>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref);
if (result.IsFailure())
@ -1417,7 +1420,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenMultiCommitManager() -> object<nn::fssrv::sf::IMultiCommitManager>
public ResultCode OpenMultiCommitManager(ServiceCtx context)
{
using var commitManager = new SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>();
using SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager> commitManager = new SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>();
Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref);
if (result.IsFailure())

View file

@ -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);

View file

@ -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);

View file

@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented.
ApplicationControlProperty controlProperty = context.Device.Processes.ActiveApplication.ApplicationControlProperties;
foreach (var localCommunicationId in controlProperty.LocalCommunicationId.ItemsRo)
foreach (ulong localCommunicationId in controlProperty.LocalCommunicationId.ItemsRo)
{
if (localCommunicationId == localCommunicationIdChecked)
{

View file

@ -244,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
byte[] ip = address.GetAddressBytes();
var macAddress = new Array6<byte>();
Array6<byte> macAddress = new Array6<byte>();
new byte[] { 0x02, 0x00, ip[0], ip[1], ip[2], ip[3] }.CopyTo(macAddress.AsSpan());
return macAddress;

View file

@ -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 Dictionary<ulong, NetworkInfo>();
foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast)
{

View file

@ -490,7 +490,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 NetworkChangeEventArgs(new NetworkInfo()
{
Common = new CommonNetworkInfo()
{
@ -610,7 +610,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
SendAsync(_protocol.Encode(PacketId.Connect, request));
var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
{
Common = request.NetworkInfo.Common,
Ldn = request.NetworkInfo.Ldn

View file

@ -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);

View file

@ -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)];

View file

@ -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;
}

View file

@ -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 HMACSHA256(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 HMACSHA256(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 HMACSHA256(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 HMACSHA256(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 HMACSHA256(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 HMACSHA256(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 HMACSHA256(hmacDataKey))
{
calculatedDataHmac = hmac.ComputeHash(dataHmacData);
}

View file

@ -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 NvdecDevice(Smmu);
VicDevice vic = new VicDevice(Smmu);
Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
Host1x.RegisterDevice(ClassId.Vic, vic);
}

View file

@ -104,7 +104,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.
@ -336,9 +336,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
for (uint i = 0; i < writeEntries; i++)
{
ref var region = ref arguments.Regions[(int)i];
ref VaRegion region = ref arguments.Regions[(int)i];
var vmRegion = _vmRegions[i];
VmRegion vmRegion = _vmRegions[i];
uint pageSize = _pageSizes[i];
region.PageSize = pageSize;

View file

@ -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);
}

View file

@ -55,7 +55,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)
{

View file

@ -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 UniqueRef<IFile>();
romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure();

View file

@ -1,3 +1,4 @@
using Microsoft.IO;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
@ -235,7 +236,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();
@ -307,7 +308,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();
}
@ -453,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services
response.RawData = _responseDataStream.ToArray();
using var responseStream = response.GetStreamTipc();
using RecyclableMemoryStream responseStream = response.GetStreamTipc();
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
}
else
@ -463,7 +464,7 @@ namespace Ryujinx.HLE.HOS.Services
if (!isTipcCommunication)
{
using var responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
using RecyclableMemoryStream responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
}

View file

@ -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 UniqueRef<IFile>();
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read);
if (result.IsFailure())

View file

@ -315,9 +315,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);

View file

@ -303,7 +303,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,
@ -322,7 +322,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,

View file

@ -12,9 +12,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)
{

View file

@ -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

View file

@ -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 UniqueRef<IFile>();
Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read);

View file

@ -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);
}

View file

@ -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 UniqueRef<IFile>();
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 = new();
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 UniqueRef<IFile>();
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 UniqueRef<IFile>();
Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read);