misc: chore: Fix object creation in HLE project

This commit is contained in:
Evan Husted 2025-01-26 15:15:26 -06:00
parent f1fd5c9366
commit beab133c8d
48 changed files with 194 additions and 194 deletions

View file

@ -217,8 +217,8 @@ namespace Ryujinx.HLE.FileSystem
if (AocData.TryGetValue(aocTitleId, out AocItem aoc)) if (AocData.TryGetValue(aocTitleId, out AocItem aoc))
{ {
FileStream file = new FileStream(aoc.ContainerPath, FileMode.Open, FileAccess.Read); FileStream file = new(aoc.ContainerPath, FileMode.Open, FileAccess.Read);
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> ncaFile = new();
switch (Path.GetExtension(aoc.ContainerPath)) switch (Path.GetExtension(aoc.ContainerPath))
{ {
@ -227,7 +227,7 @@ namespace Ryujinx.HLE.FileSystem
xci.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); xci.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
break; break;
case ".nsp": case ".nsp":
PartitionFileSystem pfs = new PartitionFileSystem(); PartitionFileSystem pfs = new();
pfs.Initialize(file.AsStorage()); pfs.Initialize(file.AsStorage());
pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
break; break;
@ -627,7 +627,7 @@ namespace Ryujinx.HLE.FileSystem
private static IFile OpenPossibleFragmentedFile(IFileSystem filesystem, string path, OpenMode mode) private static IFile OpenPossibleFragmentedFile(IFileSystem filesystem, string path, OpenMode mode)
{ {
using UniqueRef<IFile> file = new UniqueRef<IFile>(); using UniqueRef<IFile> file = new();
if (filesystem.FileExists($"{path}/00")) if (filesystem.FileExists($"{path}/00"))
{ {
@ -733,11 +733,11 @@ namespace Ryujinx.HLE.FileSystem
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
using UniqueRef<IFile> metaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> metaFile = new();
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
{ {
Cnmt meta = new Cnmt(metaFile.Get.AsStream()); Cnmt meta = new(metaFile.Get.AsStream());
if (meta.Type == ContentMetaType.SystemUpdate) if (meta.Type == ContentMetaType.SystemUpdate)
{ {
@ -762,7 +762,7 @@ namespace Ryujinx.HLE.FileSystem
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
using UniqueRef<IFile> systemVersionFile = new UniqueRef<IFile>(); using UniqueRef<IFile> systemVersionFile = new();
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
{ {
@ -798,11 +798,11 @@ namespace Ryujinx.HLE.FileSystem
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
using UniqueRef<IFile> metaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> metaFile = new();
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
{ {
Cnmt meta = new Cnmt(metaFile.Get.AsStream()); Cnmt meta = new(metaFile.Get.AsStream());
IStorage contentStorage = contentNcaStream.AsStorage(); IStorage contentStorage = contentNcaStream.AsStorage();
if (contentStorage.GetSize(out long size).IsSuccess()) if (contentStorage.GetSize(out long size).IsSuccess())
@ -867,11 +867,11 @@ namespace Ryujinx.HLE.FileSystem
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
using UniqueRef<IFile> metaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> metaFile = new();
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
{ {
Cnmt meta = new Cnmt(metaFile.Get.AsStream()); Cnmt meta = new(metaFile.Get.AsStream());
if (meta.Type == ContentMetaType.SystemUpdate) if (meta.Type == ContentMetaType.SystemUpdate)
{ {
@ -885,7 +885,7 @@ namespace Ryujinx.HLE.FileSystem
{ {
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
using UniqueRef<IFile> systemVersionFile = new UniqueRef<IFile>(); using UniqueRef<IFile> systemVersionFile = new();
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
{ {
@ -935,11 +935,11 @@ namespace Ryujinx.HLE.FileSystem
string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath;
using UniqueRef<IFile> metaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> metaFile = new();
if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess())
{ {
Cnmt meta = new Cnmt(metaFile.Get.AsStream()); Cnmt meta = new(metaFile.Get.AsStream());
if (contentStorage.GetSize(out long size).IsSuccess()) if (contentStorage.GetSize(out long size).IsSuccess())
{ {
@ -1002,7 +1002,7 @@ namespace Ryujinx.HLE.FileSystem
{ {
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid);
using UniqueRef<IFile> systemVersionFile = new UniqueRef<IFile>(); using UniqueRef<IFile> systemVersionFile = new();
if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess())
{ {

View file

@ -61,7 +61,7 @@ namespace Ryujinx.HLE.FileSystem
public void LoadRomFs(ulong pid, string fileName) public void LoadRomFs(ulong pid, string fileName)
{ {
FileStream romfsStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); FileStream romfsStream = new(fileName, FileMode.Open, FileAccess.Read);
_romFsByPid.AddOrUpdate(pid, romfsStream, (pid, oldStream) => _romFsByPid.AddOrUpdate(pid, romfsStream, (pid, oldStream) =>
{ {
@ -194,7 +194,7 @@ namespace Ryujinx.HLE.FileSystem
} }
fsServerClient = horizon.CreatePrivilegedHorizonClient(); fsServerClient = horizon.CreatePrivilegedHorizonClient();
FileSystemServer fsServer = new FileSystemServer(fsServerClient); FileSystemServer fsServer = new(fsServerClient);
RandomDataGenerator randomGenerator = Random.Shared.NextBytes; RandomDataGenerator randomGenerator = Random.Shared.NextBytes;
@ -208,7 +208,7 @@ namespace Ryujinx.HLE.FileSystem
SdCard.SetSdCardInserted(true); SdCard.SetSdCardInserted(true);
FileSystemServerConfig fsServerConfig = new FileSystemServerConfig FileSystemServerConfig fsServerConfig = new()
{ {
ExternalKeySet = KeySet.ExternalKeySet, ExternalKeySet = KeySet.ExternalKeySet,
FsCreators = fsServerObjects.FsCreators, FsCreators = fsServerObjects.FsCreators,
@ -270,7 +270,7 @@ namespace Ryujinx.HLE.FileSystem
{ {
foreach (DirectoryEntryEx ticketEntry in fs.EnumerateEntries("/", "*.tik")) foreach (DirectoryEntryEx ticketEntry in fs.EnumerateEntries("/", "*.tik"))
{ {
using UniqueRef<IFile> ticketFile = new UniqueRef<IFile>(); using UniqueRef<IFile> ticketFile = new();
Result result = fs.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read); Result result = fs.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
@ -334,7 +334,7 @@ namespace Ryujinx.HLE.FileSystem
{ {
Span<SaveDataInfo> info = stackalloc SaveDataInfo[8]; Span<SaveDataInfo> info = stackalloc SaveDataInfo[8];
using UniqueRef<SaveDataIterator> iterator = new UniqueRef<SaveDataIterator>(); using UniqueRef<SaveDataIterator> iterator = new();
Result rc = hos.Fs.OpenSaveDataIterator(ref iterator.Ref, spaceId); Result rc = hos.Fs.OpenSaveDataIterator(ref iterator.Ref, spaceId);
if (rc.IsFailure()) if (rc.IsFailure())

View file

@ -85,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet
{ {
_system.Device.UIHandler.DisplayCabinetDialog(out string newName); _system.Device.UIHandler.DisplayCabinetDialog(out string newName);
byte[] nameBytes = Encoding.UTF8.GetBytes(newName); byte[] nameBytes = Encoding.UTF8.GetBytes(newName);
Array41<byte> nickName = new Array41<byte>(); Array41<byte> nickName = new();
nameBytes.CopyTo(nickName.AsSpan()); nameBytes.CopyTo(nickName.AsSpan());
startParam.RegisterInfo.Nickname = nickName; startParam.RegisterInfo.Nickname = nickName;
NfpDevice devicePlayer1 = new() NfpDevice devicePlayer1 = new()

View file

@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error
if (romfs.FileExists(filePath)) if (romfs.FileExists(filePath))
{ {
using UniqueRef<IFile> binaryFile = new UniqueRef<IFile>(); using UniqueRef<IFile> binaryFile = new();
romfs.OpenFile(ref binaryFile.Ref, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); romfs.OpenFile(ref binaryFile.Ref, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
StreamReader reader = new(binaryFile.Get.AsStream(), Encoding.Unicode); StreamReader reader = new(binaryFile.Get.AsStream(), Encoding.Unicode);

View file

@ -205,7 +205,7 @@ namespace Ryujinx.HLE.HOS.Applets
else else
{ {
// Call the configured GUI handler to get user's input. // Call the configured GUI handler to get user's input.
SoftwareKeyboardUIArgs args = new SoftwareKeyboardUIArgs SoftwareKeyboardUIArgs args = new()
{ {
KeyboardMode = _keyboardForegroundConfig.Mode, KeyboardMode = _keyboardForegroundConfig.Mode,
HeaderText = StripUnicodeControlCodes(_keyboardForegroundConfig.HeaderText), HeaderText = StripUnicodeControlCodes(_keyboardForegroundConfig.HeaderText),

View file

@ -219,7 +219,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
return; return;
} }
using SKPaint paint = new SKPaint(_messageFont) using SKPaint paint = new(_messageFont)
{ {
Color = _textNormalColor, Color = _textNormalColor,
IsAntialias = true IsAntialias = true
@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
SKRect messageRectangle = MeasureString(MessageText, paint); SKRect messageRectangle = MeasureString(MessageText, paint);
float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left; float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left;
float messagePositionY = _messagePositionY - messageRectangle.Top; float messagePositionY = _messagePositionY - messageRectangle.Top;
SKPoint messagePosition = new SKPoint(messagePositionX, messagePositionY); SKPoint messagePosition = new(messagePositionX, messagePositionY);
SKRect messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height); SKRect messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height);
canvas.DrawRect(messageBoundRectangle, _panelBrush); canvas.DrawRect(messageBoundRectangle, _panelBrush);
@ -336,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state) private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state)
{ {
using SKPaint textPaint = new SKPaint(_labelsTextFont) using SKPaint textPaint = new(_labelsTextFont)
{ {
IsAntialias = true, IsAntialias = true,
Color = _textNormalColor Color = _textNormalColor
@ -360,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
float inputTextX = (_panelRectangle.Width - inputTextRectangle.Width) / 2 - inputTextRectangle.Left; float inputTextX = (_panelRectangle.Width - inputTextRectangle.Width) / 2 - inputTextRectangle.Left;
float inputTextY = boxY + 5; float inputTextY = boxY + 5;
SKPoint 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); 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. // Draw the cursor on top of the text and redraw the text with a different color if necessary.
@ -459,9 +459,9 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
using SKSurface textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888)); using SKSurface textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888));
SKCanvas textOverCanvas = textOverCursor.Canvas; SKCanvas textOverCanvas = textOverCursor.Canvas;
SKPoint textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top); SKPoint textRelativePosition = new(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top);
using SKPaint cursorPaint = new SKPaint(_inputTextFont) using SKPaint cursorPaint = new(_inputTextFont)
{ {
Color = cursorTextColor, Color = cursorTextColor,
IsAntialias = true 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); textOverCanvas.DrawText(state.InputText, textRelativePosition.X, textRelativePosition.Y + _inputTextFont.Metrics.XHeight + _inputTextFont.Metrics.Descent, cursorPaint);
SKPoint cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top); SKPoint cursorPosition = new((int)cursorRectangle.Left, (int)cursorRectangle.Top);
textOverCursor.Flush(); textOverCursor.Flush();
canvas.DrawSurface(textOverCursor, cursorPosition); canvas.DrawSurface(textOverCursor, cursorPosition);
} }
@ -492,7 +492,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
float iconWidth = icon.Width; float iconWidth = icon.Width;
float iconHeight = icon.Height; float iconHeight = icon.Height;
using SKPaint paint = new SKPaint(_labelsTextFont) using SKPaint paint = new(_labelsTextFont)
{ {
Color = _textNormalColor, Color = _textNormalColor,
IsAntialias = true IsAntialias = true
@ -514,8 +514,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
iconX += originX; iconX += originX;
iconY += originY; iconY += originY;
SKPoint iconPosition = new SKPoint((int)iconX, (int)iconY); SKPoint iconPosition = new((int)iconX, (int)iconY);
SKPoint labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); SKPoint labelPosition = new(labelPositionX + originX, labelPositionY + originY);
SKRect 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); fullWidth + 4 * _padPressedPenWidth, fullHeight + 4 * _padPressedPenWidth);
@ -545,7 +545,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private void DrawControllerToggle(SKCanvas canvas, SKPoint point) private void DrawControllerToggle(SKCanvas canvas, SKPoint point)
{ {
using SKPaint paint = new SKPaint(_labelsTextFont) using SKPaint paint = new(_labelsTextFont)
{ {
IsAntialias = true, IsAntialias = true,
Color = _textNormalColor Color = _textNormalColor
@ -574,8 +574,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
keyX += originX; keyX += originX;
keyY += originY; keyY += originY;
SKPoint labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); SKPoint labelPosition = new(labelPositionX + originX, labelPositionY + originY);
SKPoint overlayPosition = new SKPoint((int)keyX, (int)keyY); SKPoint overlayPosition = new((int)keyX, (int)keyY);
canvas.DrawBitmap(_keyModeIcon, overlayPosition); canvas.DrawBitmap(_keyModeIcon, overlayPosition);
canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, paint); canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, paint);

View file

@ -79,11 +79,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
public void Reset(Action<float> action, int totalMilliseconds, int sleepMilliseconds) public void Reset(Action<float> action, int totalMilliseconds, int sleepMilliseconds)
{ {
// Create a dedicated cancel token for each task. // Create a dedicated cancel token for each task.
TRef<bool> cancelled = new TRef<bool>(false); TRef<bool> cancelled = new(false);
Reset(new Thread(() => Reset(new Thread(() =>
{ {
SleepSubstepData substepData = new SleepSubstepData(sleepMilliseconds); SleepSubstepData substepData = new(sleepMilliseconds);
int totalCount = totalMilliseconds / sleepMilliseconds; int totalCount = totalMilliseconds / sleepMilliseconds;
int totalRemainder = totalMilliseconds - totalCount * sleepMilliseconds; int totalRemainder = totalMilliseconds - totalCount * sleepMilliseconds;
@ -126,11 +126,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
public void Reset(Action action, int sleepMilliseconds) public void Reset(Action action, int sleepMilliseconds)
{ {
// Create a dedicated cancel token for each task. // Create a dedicated cancel token for each task.
TRef<bool> cancelled = new TRef<bool>(false); TRef<bool> cancelled = new(false);
Reset(new Thread(() => Reset(new Thread(() =>
{ {
SleepSubstepData substepData = new SleepSubstepData(sleepMilliseconds); SleepSubstepData substepData = new(sleepMilliseconds);
while (!Volatile.Read(ref cancelled.Value)) while (!Volatile.Read(ref cancelled.Value))
{ {
@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
public void Reset(Action action) public void Reset(Action action)
{ {
// Create a dedicated cancel token for each task. // Create a dedicated cancel token for each task.
TRef<bool> cancelled = new TRef<bool>(false); TRef<bool> cancelled = new(false);
Reset(new Thread(() => Reset(new Thread(() =>
{ {

View file

@ -51,8 +51,8 @@ namespace Ryujinx.HLE.HOS
if (OperatingSystem.IsMacOS() && isArm64Host && for64Bit && context.Device.Configuration.UseHypervisor) if (OperatingSystem.IsMacOS() && isArm64Host && for64Bit && context.Device.Configuration.UseHypervisor)
{ {
HvEngine cpuEngine = new HvEngine(_tickSource); HvEngine cpuEngine = new(_tickSource);
HvMemoryManager memoryManager = new HvMemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); HvMemoryManager memoryManager = new(context.Memory, addressSpaceSize, invalidAccessHandler);
processContext = new ArmProcessContext<HvMemoryManager>(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit); processContext = new ArmProcessContext<HvMemoryManager>(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit);
} }
else else
@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS
switch (mode) switch (mode)
{ {
case MemoryManagerMode.SoftwarePageTable: case MemoryManagerMode.SoftwarePageTable:
MemoryManager memoryManager = new MemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); MemoryManager memoryManager = new(context.Memory, addressSpaceSize, invalidAccessHandler);
processContext = new ArmProcessContext<MemoryManager>(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit); processContext = new ArmProcessContext<MemoryManager>(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit);
break; break;
@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS
case MemoryManagerMode.HostMappedUnsafe: case MemoryManagerMode.HostMappedUnsafe:
if (addressSpace == null) if (addressSpace == null)
{ {
MemoryManagerHostTracked 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); processContext = new ArmProcessContext<MemoryManagerHostTracked>(pid, cpuEngine, _gpu, memoryManagerHostTracked, addressSpaceSize, for64Bit);
} }
else else
@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS
Logger.Warning?.Print(LogClass.Emulation, $"Allocated address space (0x{addressSpace.AddressSpaceSize:X}) is smaller than guest application requirements (0x{addressSpaceSize:X})"); Logger.Warning?.Print(LogClass.Emulation, $"Allocated address space (0x{addressSpace.AddressSpaceSize:X}) is smaller than guest application requirements (0x{addressSpaceSize:X})");
} }
MemoryManagerHostMapped memoryManagerHostMapped = new MemoryManagerHostMapped(addressSpace, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler); MemoryManagerHostMapped memoryManagerHostMapped = new(addressSpace, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler);
processContext = new ArmProcessContext<MemoryManagerHostMapped>(pid, cpuEngine, _gpu, memoryManagerHostMapped, addressSpace.AddressSpaceSize, for64Bit); processContext = new ArmProcessContext<MemoryManagerHostMapped>(pid, cpuEngine, _gpu, memoryManagerHostMapped, addressSpace.AddressSpaceSize, for64Bit);
} }
break; break;

View file

@ -154,11 +154,11 @@ namespace Ryujinx.HLE.HOS
timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize); timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize);
appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize); appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize);
SharedMemoryStorage hidStorage = new SharedMemoryStorage(KernelContext, hidPageList); SharedMemoryStorage hidStorage = new(KernelContext, hidPageList);
SharedMemoryStorage fontStorage = new SharedMemoryStorage(KernelContext, fontPageList); SharedMemoryStorage fontStorage = new(KernelContext, fontPageList);
SharedMemoryStorage iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList); SharedMemoryStorage iirsStorage = new(KernelContext, iirsPageList);
SharedMemoryStorage timeStorage = new SharedMemoryStorage(KernelContext, timePageList); SharedMemoryStorage timeStorage = new(KernelContext, timePageList);
SharedMemoryStorage appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList); SharedMemoryStorage appletCaptureBufferStorage = new(KernelContext, appletCaptureBufferPageList);
HidStorage = hidStorage; HidStorage = hidStorage;
@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS
public bool LoadKip(string kipPath) public bool LoadKip(string kipPath)
{ {
using SharedRef<IStorage> 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)); return ProcessLoaderHelper.LoadKip(KernelContext, new KipExecutable(in kipFile));
} }

View file

@ -56,7 +56,7 @@ namespace Ryujinx.HLE.HOS
Nca nca = new(_system.KeySet, ncaStorage); Nca nca = new(_system.KeySet, ncaStorage);
using IFileSystem ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel); using IFileSystem ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel);
using UniqueRef<IFileSystem> ncaFsRef = new UniqueRef<IFileSystem>(ncaFileSystem); using UniqueRef<IFileSystem> ncaFsRef = new(ncaFileSystem);
Result result = _fsClient.Register(mountName.ToU8Span(), ref ncaFsRef.Ref).ToHorizonResult(); Result result = _fsClient.Register(mountName.ToU8Span(), ref ncaFsRef.Ref).ToHorizonResult();
if (result.IsFailure) if (result.IsFailure)

View file

@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
_blocksCount = blockShifts.Length; _blocksCount = blockShifts.Length;
_blocks = new Block[_memoryBlockPageShifts.Length]; _blocks = new Block[_memoryBlockPageShifts.Length];
ArraySegment<ulong> 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++) for (int i = 0; i < blockShifts.Length; i++)
{ {

View file

@ -143,7 +143,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
bool shouldFillPages, bool shouldFillPages,
byte fillValue) byte fillValue)
{ {
using KScopedPageList scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); using KScopedPageList scopedPageList = new(Context.MemoryManager, pageList);
ulong currentVa = address; ulong currentVa = address;
@ -188,7 +188,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
} }
} }
using KScopedPageList scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); using KScopedPageList scopedPageList = new(Context.MemoryManager, pageList);
foreach (KPageNode pageNode in pageList) foreach (KPageNode pageNode in pageList)
{ {

View file

@ -617,7 +617,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
return result; return result;
} }
using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
return MapPages(address, pageList, permission, MemoryMapFlags.Private); return MapPages(address, pageList, permission, MemoryMapFlags.Private);
} }
@ -769,7 +769,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
Result result = region.AllocatePages(out KPageList pageList, pagesCount); Result result = region.AllocatePages(out KPageList pageList, pagesCount);
using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
void CleanUpForError() void CleanUpForError()
{ {
@ -1341,7 +1341,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
Result result = region.AllocatePages(out KPageList pageList, remainingPages); Result result = region.AllocatePages(out KPageList pageList, remainingPages);
using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); using OnScopeExit _ = new(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager));
void CleanUpForError() void CleanUpForError()
{ {
@ -1867,7 +1867,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
ulong dstLastPagePa = 0; ulong dstLastPagePa = 0;
ulong currentVa = va; ulong currentVa = va;
using OnScopeExit _ = new OnScopeExit(() => using OnScopeExit _ = new(() =>
{ {
if (dstFirstPagePa != 0) if (dstFirstPagePa != 0)
{ {

View file

@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
KProcess process = new(_context); KProcess process = new(_context);
using OnScopeExit _ = new OnScopeExit(process.DecrementReferenceCount); using OnScopeExit _ = new(process.DecrementReferenceCount);
KResourceLimit resourceLimit; KResourceLimit resourceLimit;
@ -1425,7 +1425,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
KCodeMemory codeMemory = new(_context); KCodeMemory codeMemory = new(_context);
using OnScopeExit _ = new OnScopeExit(codeMemory.DecrementReferenceCount); using OnScopeExit _ = new(codeMemory.DecrementReferenceCount);
KProcess currentProcess = KernelStatic.GetCurrentProcess(); KProcess currentProcess = KernelStatic.GetCurrentProcess();

View file

@ -1232,7 +1232,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{ {
if (_schedulerWaitEvent == null) if (_schedulerWaitEvent == null)
{ {
ManualResetEvent schedulerWaitEvent = new ManualResetEvent(false); ManualResetEvent schedulerWaitEvent = new(false);
if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null) if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null)
{ {

View file

@ -144,7 +144,7 @@ namespace Ryujinx.HLE.HOS
private static string EnsureBaseDirStructure(string modsBasePath) private static string EnsureBaseDirStructure(string modsBasePath)
{ {
DirectoryInfo modsDir = new DirectoryInfo(modsBasePath); DirectoryInfo modsDir = new(modsBasePath);
modsDir.CreateSubdirectory(AmsContentsDir); modsDir.CreateSubdirectory(AmsContentsDir);
modsDir.CreateSubdirectory(AmsNsoPatchDir); modsDir.CreateSubdirectory(AmsNsoPatchDir);
@ -201,7 +201,7 @@ namespace Ryujinx.HLE.HOS
public static string GetApplicationDir(string modsBasePath, string applicationId) public static string GetApplicationDir(string modsBasePath, string applicationId)
{ {
DirectoryInfo contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir)); DirectoryInfo contentsDir = new(Path.Combine(modsBasePath, AmsContentsDir));
DirectoryInfo applicationModsPath = FindApplicationDir(contentsDir, applicationId); DirectoryInfo applicationModsPath = FindApplicationDir(contentsDir, applicationId);
if (applicationModsPath == null) if (applicationModsPath == null)
@ -273,7 +273,7 @@ namespace Ryujinx.HLE.HOS
} }
} }
FileInfo fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer)); FileInfo fsFile = new(Path.Combine(applicationDir.FullName, RomfsContainer));
if (fsFile.Exists) if (fsFile.Exists)
{ {
Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path));
@ -432,7 +432,7 @@ namespace Ryujinx.HLE.HOS
foreach (string path in searchDirPaths) foreach (string path in searchDirPaths)
{ {
DirectoryInfo searchDir = new DirectoryInfo(path); DirectoryInfo searchDir = new(path);
if (!searchDir.Exists) if (!searchDir.Exists)
{ {
Logger.Warning?.Print(LogClass.ModLoader, $"Mod Search Dir '{searchDir.FullName}' doesn't exist"); Logger.Warning?.Print(LogClass.ModLoader, $"Mod Search Dir '{searchDir.FullName}' doesn't exist");
@ -470,8 +470,8 @@ namespace Ryujinx.HLE.HOS
return baseStorage; return baseStorage;
} }
HashSet<string> fileSet = new HashSet<string>(); HashSet<string> fileSet = new();
RomFsBuilder builder = new RomFsBuilder(); RomFsBuilder builder = new();
int count = 0; int count = 0;
Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Application {applicationId:X16}"); Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Application {applicationId:X16}");
@ -517,12 +517,12 @@ namespace Ryujinx.HLE.HOS
Logger.Info?.Print(LogClass.ModLoader, $"Replaced {fileSet.Count} file(s) over {count} mod(s). Processing base storage..."); Logger.Info?.Print(LogClass.ModLoader, $"Replaced {fileSet.Count} file(s) over {count} mod(s). Processing base storage...");
// And finally, the base romfs // And finally, the base romfs
RomFsFileSystem baseRom = new RomFsFileSystem(baseStorage); RomFsFileSystem baseRom = new(baseStorage);
foreach (DirectoryEntryEx entry in baseRom.EnumerateEntries() foreach (DirectoryEntryEx entry in baseRom.EnumerateEntries()
.Where(f => f.Type == DirectoryEntryType.File && !fileSet.Contains(f.FullPath)) .Where(f => f.Type == DirectoryEntryType.File && !fileSet.Contains(f.FullPath))
.OrderBy(f => f.FullPath, StringComparer.Ordinal)) .OrderBy(f => f.FullPath, StringComparer.Ordinal))
{ {
using UniqueRef<IFile> file = new UniqueRef<IFile>(); using UniqueRef<IFile> file = new();
baseRom.OpenFile(ref file.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); baseRom.OpenFile(ref file.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
builder.AddFile(entry.FullPath, file.Release()); builder.AddFile(entry.FullPath, file.Release());
@ -542,7 +542,7 @@ namespace Ryujinx.HLE.HOS
.Where(f => f.Type == DirectoryEntryType.File) .Where(f => f.Type == DirectoryEntryType.File)
.OrderBy(f => f.FullPath, StringComparer.Ordinal)) .OrderBy(f => f.FullPath, StringComparer.Ordinal))
{ {
LazyFile file = new LazyFile(entry.FullPath, rootPath, fs); LazyFile file = new(entry.FullPath, rootPath, fs);
if (fileSet.Add(entry.FullPath)) if (fileSet.Add(entry.FullPath))
{ {
@ -569,7 +569,7 @@ namespace Ryujinx.HLE.HOS
Logger.Info?.Print(LogClass.ModLoader, "Using replacement ExeFS partition"); Logger.Info?.Print(LogClass.ModLoader, "Using replacement ExeFS partition");
PartitionFileSystem pfs = new PartitionFileSystem(); PartitionFileSystem pfs = new();
pfs.Initialize(mods.ExefsContainers[0].Path.OpenRead().AsStorage()).ThrowIfFailure(); pfs.Initialize(mods.ExefsContainers[0].Path.OpenRead().AsStorage()).ThrowIfFailure();
exefs = pfs; exefs = pfs;
@ -753,7 +753,7 @@ namespace Ryujinx.HLE.HOS
patches[i] = new MemPatch(); patches[i] = new MemPatch();
} }
List<string> buildIds = new List<string>(programs.Length); List<string> buildIds = new(programs.Length);
foreach (IExecutable p in programs) foreach (IExecutable p in programs)
{ {
@ -793,17 +793,17 @@ namespace Ryujinx.HLE.HOS
Logger.Info?.Print(LogClass.ModLoader, $"Matching IPS patch '{patchFile.Name}' in '{mod.Name}' bid={buildId}"); Logger.Info?.Print(LogClass.ModLoader, $"Matching IPS patch '{patchFile.Name}' in '{mod.Name}' bid={buildId}");
using FileStream fs = patchFile.OpenRead(); using FileStream fs = patchFile.OpenRead();
using BinaryReader reader = new BinaryReader(fs); using BinaryReader reader = new(fs);
IpsPatcher patcher = new IpsPatcher(reader); IpsPatcher patcher = new(reader);
patcher.AddPatches(patches[index]); patcher.AddPatches(patches[index]);
} }
else if (StrEquals(".pchtxt", patchFile.Extension)) // IPSwitch else if (StrEquals(".pchtxt", patchFile.Extension)) // IPSwitch
{ {
using FileStream fs = patchFile.OpenRead(); using FileStream fs = patchFile.OpenRead();
using StreamReader reader = new StreamReader(fs); using StreamReader reader = new(fs);
IPSwitchPatcher patcher = new IPSwitchPatcher(reader); IPSwitchPatcher patcher = new(reader);
int index = GetIndex(patcher.BuildId); int index = GetIndex(patcher.BuildId);
if (index == -1) if (index == -1)

View file

@ -60,7 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
} }
} }
public void AddUser(string name, byte[] image, UserId userId = new UserId()) public void AddUser(string name, byte[] image, UserId userId = new())
{ {
if (userId.IsNull) if (userId.IsNull)
{ {
@ -194,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
SaveDataFilter 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); new LibHac.Fs.UserId((ulong)userId.High, (ulong)userId.Low), saveDataId: default, index: default);
using UniqueRef<SaveDataIterator> saveDataIterator = new UniqueRef<SaveDataIterator>(); using UniqueRef<SaveDataIterator> saveDataIterator = new();
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure(); _horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
try try
{ {
LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open); LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open);
PartitionFileSystem pfs = new PartitionFileSystem(); PartitionFileSystem pfs = new();
using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(pfs); using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(pfs);
pfs.Initialize(storage).ThrowIfFailure(); 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); LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
using SharedRef<LibHac.Fs.Fsa.IFileSystem> 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); 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('\\'); string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
using UniqueRef<LibHac.Fs.Fsa.IFile> 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); Result result = nsp.OpenFile(ref ncaFile.Ref, filename.ToU8Span(), OpenMode.Read);
if (result.IsFailure()) if (result.IsFailure())
@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{ {
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik")) foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
{ {
using UniqueRef<LibHac.Fs.Fsa.IFile> 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); Result result = nsp.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);

View file

@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32(); uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context); ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using SharedRef<LibHac.FsSrv.Sf.IFile> 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); 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(); uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context); ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>(); using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new();
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, name, mode); Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, name, mode);

View file

@ -110,7 +110,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32(); BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref, in path, bisPartitionId); Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref, in path, bisPartitionId);
if (result.IsFailure()) if (result.IsFailure())
@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBisStorage(ServiceCtx context) public ResultCode OpenBisStorage(ServiceCtx context)
{ {
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32(); BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
using SharedRef<IStorage> storage = new SharedRef<IStorage>(); using SharedRef<IStorage> storage = new();
Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref, bisPartitionId); Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref, bisPartitionId);
if (result.IsFailure()) if (result.IsFailure())
@ -152,7 +152,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem> // OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
public ResultCode OpenSdCardFileSystem(ServiceCtx context) public ResultCode OpenSdCardFileSystem(ServiceCtx context)
{ {
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref); Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref);
if (result.IsFailure()) if (result.IsFailure())
@ -260,7 +260,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
GameCardHandle handle = context.RequestData.ReadUInt32(); GameCardHandle handle = context.RequestData.ReadUInt32();
GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32(); GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32();
using SharedRef<IStorage> storage = new SharedRef<IStorage>(); using SharedRef<IStorage> storage = new();
Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref, handle, partitionId); Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref, handle, partitionId);
if (result.IsFailure()) if (result.IsFailure())
@ -279,7 +279,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
GameCardHandle handle = context.RequestData.ReadUInt32(); GameCardHandle handle = context.RequestData.ReadUInt32();
GameCardPartition partitionId = (GameCardPartition)context.RequestData.ReadInt32(); GameCardPartition partitionId = (GameCardPartition)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId); Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId);
if (result.IsFailure()) if (result.IsFailure())
@ -360,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>(); SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure()) if (result.IsFailure())
@ -379,7 +379,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>(); SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure()) if (result.IsFailure())
@ -398,7 +398,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>(); SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute);
if (result.IsFailure()) if (result.IsFailure())
@ -469,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSaveDataInfoReader() -> object<nn::fssrv::sf::ISaveDataInfoReader> // OpenSaveDataInfoReader() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReader(ServiceCtx context) public ResultCode OpenSaveDataInfoReader(ServiceCtx context)
{ {
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref);
if (result.IsFailure()) if (result.IsFailure())
@ -487,7 +487,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context) public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context)
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref, spaceId); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref, spaceId);
if (result.IsFailure()) if (result.IsFailure())
@ -504,7 +504,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSaveDataInfoReaderOnlyCacheStorage() -> object<nn::fssrv::sf::ISaveDataInfoReader> // OpenSaveDataInfoReaderOnlyCacheStorage() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context) public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context)
{ {
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref);
if (result.IsFailure()) if (result.IsFailure())
@ -523,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64(); ulong saveDataId = context.RequestData.ReadUInt64();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref, spaceId, saveDataId); Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref, spaceId, saveDataId);
if (result.IsFailure()) if (result.IsFailure())
@ -587,7 +587,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{ {
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>(); SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>();
using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>(); using SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref, spaceId, in filter); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref, spaceId, in filter);
if (result.IsFailure()) if (result.IsFailure())
@ -664,7 +664,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt32(); SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt32();
SaveDataMetaType metaType = (SaveDataMetaType)context.RequestData.ReadInt32(); SaveDataMetaType metaType = (SaveDataMetaType)context.RequestData.ReadInt32();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>(); SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using SharedRef<LibHac.FsSrv.Sf.IFile> file = new SharedRef<LibHac.FsSrv.Sf.IFile>(); using SharedRef<LibHac.FsSrv.Sf.IFile> file = new();
Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref, spaceId, in attribute, metaType); Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref, spaceId, in attribute, metaType);
if (result.IsFailure()) if (result.IsFailure())
@ -702,7 +702,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenImageDirectoryFileSystem(ServiceCtx context) public ResultCode OpenImageDirectoryFileSystem(ServiceCtx context)
{ {
ImageDirectoryId directoryId = (ImageDirectoryId)context.RequestData.ReadInt32(); ImageDirectoryId directoryId = (ImageDirectoryId)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId); Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId);
if (result.IsFailure()) if (result.IsFailure())
@ -719,7 +719,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBaseFileSystem(ServiceCtx context) public ResultCode OpenBaseFileSystem(ServiceCtx context)
{ {
BaseFileSystemId fileSystemId = (BaseFileSystemId)context.RequestData.ReadInt32(); BaseFileSystemId fileSystemId = (BaseFileSystemId)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref, fileSystemId); Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref, fileSystemId);
if (result.IsFailure()) if (result.IsFailure())
@ -736,7 +736,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenContentStorageFileSystem(ServiceCtx context) public ResultCode OpenContentStorageFileSystem(ServiceCtx context)
{ {
ContentStorageId contentStorageId = (ContentStorageId)context.RequestData.ReadInt32(); ContentStorageId contentStorageId = (ContentStorageId)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref, contentStorageId); Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref, contentStorageId);
if (result.IsFailure()) if (result.IsFailure())
@ -753,7 +753,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context) public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context)
{ {
CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32(); CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref, storageId); Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref, storageId);
if (result.IsFailure()) if (result.IsFailure())
@ -770,7 +770,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCustomStorageFileSystem(ServiceCtx context) public ResultCode OpenCustomStorageFileSystem(ServiceCtx context)
{ {
CustomStorageId customStorageId = (CustomStorageId)context.RequestData.ReadInt32(); CustomStorageId customStorageId = (CustomStorageId)context.RequestData.ReadInt32();
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, customStorageId); Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, customStorageId);
if (result.IsFailure()) if (result.IsFailure())
@ -788,8 +788,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context) public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
{ {
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); 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<LibHac.Fs.IStorage> sharedStorage = new(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); using SharedRef<IStorage> sfStorage = new(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -813,8 +813,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}"); Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}");
LibHac.Fs.IStorage storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage); 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<LibHac.Fs.IStorage> sharedStorage = new(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); using SharedRef<IStorage> sfStorage = new(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -848,8 +848,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open); LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
Nca nca = new(context.Device.System.KeySet, ncaStorage); Nca nca = new(context.Device.System.KeySet, ncaStorage);
LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
using SharedRef<LibHac.Fs.IStorage> sharedStorage = new SharedRef<LibHac.Fs.IStorage>(romfsStorage); using SharedRef<LibHac.Fs.IStorage> sharedStorage = new(romfsStorage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); using SharedRef<IStorage> sfStorage = new(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
} }
@ -879,8 +879,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context) public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
{ {
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); 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<LibHac.Fs.IStorage> sharedStorage = new(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); using SharedRef<IStorage> sfStorage = new(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -899,8 +899,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs
} }
LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); 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<LibHac.Fs.IStorage> sharedStorage = new(storage);
using SharedRef<IStorage> sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref)); using SharedRef<IStorage> sfStorage = new(new StorageInterfaceAdapter(ref sharedStorage.Ref));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref));
@ -911,7 +911,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage // OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
public ResultCode OpenDeviceOperator(ServiceCtx context) public ResultCode OpenDeviceOperator(ServiceCtx context)
{ {
using SharedRef<LibHac.FsSrv.Sf.IDeviceOperator> deviceOperator = new SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>(); using SharedRef<LibHac.FsSrv.Sf.IDeviceOperator> deviceOperator = new();
Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref); Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref);
if (result.IsFailure()) if (result.IsFailure())
@ -1310,7 +1310,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandCmif(1008)] [CommandCmif(1008)]
public ResultCode OpenRegisteredUpdatePartition(ServiceCtx context) public ResultCode OpenRegisteredUpdatePartition(ServiceCtx context)
{ {
using SharedRef<IFileSystem> fileSystem = new SharedRef<IFileSystem>(); using SharedRef<IFileSystem> fileSystem = new();
Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref); Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref);
if (result.IsFailure()) if (result.IsFailure())
@ -1420,7 +1420,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenMultiCommitManager() -> object<nn::fssrv::sf::IMultiCommitManager> // OpenMultiCommitManager() -> object<nn::fssrv::sf::IMultiCommitManager>
public ResultCode OpenMultiCommitManager(ServiceCtx context) public ResultCode OpenMultiCommitManager(ServiceCtx context)
{ {
using SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager> commitManager = new SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>(); using SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager> commitManager = new();
Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref); Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref);
if (result.IsFailure()) if (result.IsFailure())

View file

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

View file

@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
lock (_scanLock) lock (_scanLock)
{ {
Dictionary<ulong, NetworkInfo> results = new Dictionary<ulong, NetworkInfo>(); Dictionary<ulong, NetworkInfo> results = new();
foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast) foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast)
{ {

View file

@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
{ {
public bool NeedsRealId => true; public bool NeedsRealId => true;
private static InitializeMessage InitializeMemory = new InitializeMessage(); private static InitializeMessage InitializeMemory = new();
private const int InactiveTimeout = 6000; private const int InactiveTimeout = 6000;
private const int FailureTimeout = 4000; private const int FailureTimeout = 4000;
@ -31,16 +31,16 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
private bool _useP2pProxy; private bool _useP2pProxy;
private NetworkError _lastError; private NetworkError _lastError;
private readonly ManualResetEvent _connected = new ManualResetEvent(false); private readonly ManualResetEvent _connected = new(false);
private readonly ManualResetEvent _error = new ManualResetEvent(false); private readonly ManualResetEvent _error = new(false);
private readonly ManualResetEvent _scan = new ManualResetEvent(false); private readonly ManualResetEvent _scan = new(false);
private readonly ManualResetEvent _reject = new ManualResetEvent(false); private readonly ManualResetEvent _reject = new(false);
private readonly AutoResetEvent _apConnected = new AutoResetEvent(false); private readonly AutoResetEvent _apConnected = new(false);
private readonly RyuLdnProtocol _protocol; private readonly RyuLdnProtocol _protocol;
private readonly NetworkTimeout _timeout; private readonly NetworkTimeout _timeout;
private readonly List<NetworkInfo> _availableGames = new List<NetworkInfo>(); private readonly List<NetworkInfo> _availableGames = new();
private DisconnectReason _disconnectReason; private DisconnectReason _disconnectReason;
private P2pProxyServer _hostedProxy; private P2pProxyServer _hostedProxy;
@ -490,7 +490,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData)); SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData));
// Send a network change event with dummy data immediately. Necessary to avoid crashes in some games // Send a network change event with dummy data immediately. Necessary to avoid crashes in some games
NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
{ {
Common = new CommonNetworkInfo() Common = new CommonNetworkInfo()
{ {
@ -610,7 +610,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
SendAsync(_protocol.Encode(PacketId.Connect, request)); SendAsync(_protocol.Encode(PacketId.Connect, request));
NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
{ {
Common = request.NetworkInfo.Common, Common = request.NetworkInfo.Common,
Ldn = request.NetworkInfo.Ldn Ldn = request.NetworkInfo.Ldn

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{ {
private const ushort EphemeralBase = 49152; private const ushort EphemeralBase = 49152;
private readonly List<ushort> _ephemeralPorts = new List<ushort>(); private readonly List<ushort> _ephemeralPorts = new();
private readonly Lock _lock = new(); private readonly Lock _lock = new();

View file

@ -13,8 +13,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public EndPoint LocalEndpoint { get; } public EndPoint LocalEndpoint { get; }
public IPAddress LocalAddress { get; } public IPAddress LocalAddress { get; }
private readonly List<LdnProxySocket> _sockets = new List<LdnProxySocket>(); private readonly List<LdnProxySocket> _sockets = new();
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new Dictionary<ProtocolType, EphemeralPortPool>(); private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new();
private readonly IProxyClient _parent; private readonly IProxyClient _parent;
private RyuLdnProtocol _protocol; private RyuLdnProtocol _protocol;
@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public void HandleData(LdnHeader header, ProxyDataHeader proxyHeader, byte[] data) public void HandleData(LdnHeader header, ProxyDataHeader proxyHeader, byte[] data)
{ {
ProxyDataPacket packet = new ProxyDataPacket() { Header = proxyHeader, Data = data }; ProxyDataPacket packet = new() { Header = proxyHeader, Data = data };
ForRoutedSockets(proxyHeader.Info, (socket) => ForRoutedSockets(proxyHeader.Info, (socket) =>
{ {
@ -179,7 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{ {
// We must ask the other side to initialize a connection, so they can accept a socket for us. // We must ask the other side to initialize a connection, so they can accept a socket for us.
ProxyConnectRequest request = new ProxyConnectRequest ProxyConnectRequest request = new()
{ {
Info = MakeInfo(localEp, remoteEp, type) Info = MakeInfo(localEp, remoteEp, type)
}; };
@ -191,7 +191,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{ {
// We must tell the other side that we have accepted their request for connection. // We must tell the other side that we have accepted their request for connection.
ProxyConnectResponse request = new ProxyConnectResponse ProxyConnectResponse request = new()
{ {
Info = MakeInfo(localEp, remoteEp, type) Info = MakeInfo(localEp, remoteEp, type)
}; };
@ -203,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
{ {
// We must tell the other side that our connection is dropped. // We must tell the other side that our connection is dropped.
ProxyDisconnectMessage request = new ProxyDisconnectMessage ProxyDisconnectMessage request = new()
{ {
Info = MakeInfo(localEp, remoteEp, type), Info = MakeInfo(localEp, remoteEp, type),
DisconnectReason = 0 // TODO DisconnectReason = 0 // TODO
@ -217,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// We send exactly as much as the user wants us to, currently instantly. // We send exactly as much as the user wants us to, currently instantly.
// TODO: handle over "virtual mtu" (we have a max packet size to worry about anyways). fragment if tcp? throw if udp? // TODO: handle over "virtual mtu" (we have a max packet size to worry about anyways). fragment if tcp? throw if udp?
ProxyDataHeader request = new ProxyDataHeader ProxyDataHeader request = new()
{ {
Info = MakeInfo(localEp, remoteEp, type), Info = MakeInfo(localEp, remoteEp, type),
DataLength = (uint)buffer.Length DataLength = (uint)buffer.Length

View file

@ -18,21 +18,21 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private readonly LdnProxy _proxy; private readonly LdnProxy _proxy;
private bool _isListening; private bool _isListening;
private readonly List<LdnProxySocket> _listenSockets = new List<LdnProxySocket>(); private readonly List<LdnProxySocket> _listenSockets = new();
private readonly Queue<ProxyConnectRequest> _connectRequests = new Queue<ProxyConnectRequest>(); private readonly Queue<ProxyConnectRequest> _connectRequests = new();
private readonly AutoResetEvent _acceptEvent = new AutoResetEvent(false); private readonly AutoResetEvent _acceptEvent = new(false);
private readonly int _acceptTimeout = -1; private readonly int _acceptTimeout = -1;
private readonly Queue<int> _errors = new Queue<int>(); private readonly Queue<int> _errors = new();
private readonly AutoResetEvent _connectEvent = new AutoResetEvent(false); private readonly AutoResetEvent _connectEvent = new(false);
private ProxyConnectResponse _connectResponse; private ProxyConnectResponse _connectResponse;
private int _receiveTimeout = -1; private int _receiveTimeout = -1;
private readonly AutoResetEvent _receiveEvent = new AutoResetEvent(false); private readonly AutoResetEvent _receiveEvent = new(false);
private readonly Queue<ProxyDataPacket> _receiveQueue = new Queue<ProxyDataPacket>(); private readonly Queue<ProxyDataPacket> _receiveQueue = new();
// private int _sendTimeout = -1; // Sends are techically instant right now, so not _really_ used. // private int _sendTimeout = -1; // Sends are techically instant right now, so not _really_ used.
@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
// private bool _writeShutdown; // private bool _writeShutdown;
private bool _closed; private bool _closed;
private readonly Dictionary<SocketOptionName, int> _socketOptions = new Dictionary<SocketOptionName, int>() private readonly Dictionary<SocketOptionName, int> _socketOptions = new()
{ {
{ SocketOptionName.Broadcast, 0 }, //TODO: honor this value { SocketOptionName.Broadcast, 0 }, //TODO: honor this value
{ SocketOptionName.DontLinger, 0 }, { SocketOptionName.DontLinger, 0 },
@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
} }
} }
IPEndPoint localEp = new IPEndPoint(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType)); IPEndPoint localEp = new(_proxy.LocalAddress, _proxy.GetEphemeralPort(ProtocolType));
LocalEndPoint = localEp; LocalEndPoint = localEp;
return localEp; return localEp;

View file

@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private readonly RyuLdnProtocol _protocol; private readonly RyuLdnProtocol _protocol;
private readonly ManualResetEvent _connected = new ManualResetEvent(false); private readonly ManualResetEvent _connected = new(false);
private readonly ManualResetEvent _ready = new ManualResetEvent(false); private readonly ManualResetEvent _ready = new(false);
private readonly AutoResetEvent _error = new AutoResetEvent(false); private readonly AutoResetEvent _error = new(false);
public P2pProxyClient(string address, int port) : base(address, port) public P2pProxyClient(string address, int port) : base(address, port)
{ {

View file

@ -29,22 +29,22 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
private const ushort AuthWaitSeconds = 1; private const ushort AuthWaitSeconds = 1;
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); private readonly ReaderWriterLockSlim _lock = new(LockRecursionPolicy.SupportsRecursion);
public ushort PrivatePort { get; } public ushort PrivatePort { get; }
private ushort _publicPort; private ushort _publicPort;
private bool _disposed; private bool _disposed;
private readonly CancellationTokenSource _disposedCancellation = new CancellationTokenSource(); private readonly CancellationTokenSource _disposedCancellation = new();
private NatDevice _natDevice; private NatDevice _natDevice;
private Mapping _portMapping; private Mapping _portMapping;
private readonly List<P2pProxySession> _players = new List<P2pProxySession>(); private readonly List<P2pProxySession> _players = new();
private readonly List<ExternalProxyToken> _waitingTokens = new List<ExternalProxyToken>(); private readonly List<ExternalProxyToken> _waitingTokens = new();
private readonly AutoResetEvent _tokenEvent = new AutoResetEvent(false); private readonly AutoResetEvent _tokenEvent = new(false);
private uint _broadcastAddress; private uint _broadcastAddress;
@ -112,8 +112,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
public async Task<ushort> NatPunch() public async Task<ushort> NatPunch()
{ {
NatDiscoverer discoverer = new NatDiscoverer(); NatDiscoverer discoverer = new();
CancellationTokenSource cts = new CancellationTokenSource(1000); CancellationTokenSource cts = new(1000);
NatDevice device; NatDevice device;
@ -300,7 +300,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
session.SetIpv4(waitToken.VirtualIp); session.SetIpv4(waitToken.VirtualIp);
ProxyConfig pconfig = new ProxyConfig ProxyConfig pconfig = new()
{ {
ProxyIp = session.VirtualIpAddress, ProxyIp = session.VirtualIpAddress,
ProxySubnetMask = 0xFFFF0000 // TODO: Use from server. ProxySubnetMask = 0xFFFF0000 // TODO: Use from server.

View file

@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
string nickName = amiiboDump.AmiiboNickname; string nickName = amiiboDump.AmiiboNickname;
LogFinalData(titleId, appId, head, tail, finalID, nickName, initDateTime, writeDateTime, settingsValue, writeCounterValue, applicationAreas); LogFinalData(titleId, appId, head, tail, finalID, nickName, initDateTime, writeDateTime, settingsValue, writeCounterValue, applicationAreas);
VirtualAmiiboFile virtualAmiiboFile = new VirtualAmiiboFile VirtualAmiiboFile virtualAmiiboFile = new()
{ {
FileVersion = 1, FileVersion = 1,
TagUuid = uid, TagUuid = uid,
@ -182,7 +182,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
readBytes = newFileBytes; readBytes = newFileBytes;
} }
AmiiboDecryptor amiiboDecryptor = new AmiiboDecryptor(keyRetailBinPath); AmiiboDecryptor amiiboDecryptor = new(keyRetailBinPath);
AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes); AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes);
byte[] oldData = amiiboDump.GetData(); byte[] oldData = amiiboDump.GetData();
@ -250,7 +250,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
readBytes = newFileBytes; readBytes = newFileBytes;
} }
AmiiboDecryptor amiiboDecryptor = new AmiiboDecryptor(keyRetailBinPath); AmiiboDecryptor amiiboDecryptor = new(keyRetailBinPath);
AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes); AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes);
amiiboDump.AmiiboNickname = newNickName; amiiboDump.AmiiboNickname = newNickName;
byte[] oldData = amiiboDump.GetData(); byte[] oldData = amiiboDump.GetData();

View file

@ -91,7 +91,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(seedBytes, 0, dataForAes, 2, seedBytes.Length); Array.Copy(seedBytes, 0, dataForAes, 2, seedBytes.Length);
byte[] derivedBytes; byte[] derivedBytes;
using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) using (HMACSHA256 hmac = new(key.HmacKey))
{ {
derivedBytes = hmac.ComputeHash(dataForAes); derivedBytes = hmac.ComputeHash(dataForAes);
} }
@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
dataForHmacKey[1] = 0x01; // Counter (1) dataForHmacKey[1] = 0x01; // Counter (1)
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length); Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) using (HMACSHA256 hmac = new(key.HmacKey))
{ {
derivedBytes = hmac.ComputeHash(dataForHmacKey); derivedBytes = hmac.ComputeHash(dataForHmacKey);
} }
@ -121,7 +121,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length); Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
byte[] derivedBytes; byte[] derivedBytes;
using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) using (HMACSHA256 hmac = new(key.HmacKey))
{ {
derivedBytes = hmac.ComputeHash(dataForHmacKey); derivedBytes = hmac.ComputeHash(dataForHmacKey);
} }
@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(data, 0x054, tagHmacData, 8, 44); Array.Copy(data, 0x054, tagHmacData, 8, 44);
byte[] tagHmac; byte[] tagHmac;
using (HMACSHA256 hmac = new HMACSHA256(hmacTagKey)) using (HMACSHA256 hmac = new(hmacTagKey))
{ {
tagHmac = hmac.ComputeHash(tagHmacData); tagHmac = hmac.ComputeHash(tagHmacData);
} }
@ -258,7 +258,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(data, 0x054, dataHmacData, offset, len5); Array.Copy(data, 0x054, dataHmacData, offset, len5);
byte[] dataHmac; byte[] dataHmac;
using (HMACSHA256 hmac = new HMACSHA256(hmacDataKey)) using (HMACSHA256 hmac = new(hmacDataKey))
{ {
dataHmac = hmac.ComputeHash(dataHmacData); dataHmac = hmac.ComputeHash(dataHmacData);
} }
@ -278,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(data, 0x054, tagHmacData, 8, 44); Array.Copy(data, 0x054, tagHmacData, 8, 44);
byte[] calculatedTagHmac; byte[] calculatedTagHmac;
using (HMACSHA256 hmac = new HMACSHA256(hmacTagKey)) using (HMACSHA256 hmac = new(hmacTagKey))
{ {
calculatedTagHmac = hmac.ComputeHash(tagHmacData); calculatedTagHmac = hmac.ComputeHash(tagHmacData);
} }
@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
Array.Copy(data, 0x054, dataHmacData, offset, len5); Array.Copy(data, 0x054, dataHmacData, offset, len5);
byte[] calculatedDataHmac; byte[] calculatedDataHmac;
using (HMACSHA256 hmac = new HMACSHA256(hmacDataKey)) using (HMACSHA256 hmac = new(hmacDataKey))
{ {
calculatedDataHmac = hmac.ComputeHash(dataHmacData); calculatedDataHmac = hmac.ComputeHash(dataHmacData);
} }

View file

@ -18,8 +18,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
MemoryAllocator = new NvMemoryAllocator(); MemoryAllocator = new NvMemoryAllocator();
Host1x = new Host1xDevice(gpu.Synchronization); Host1x = new Host1xDevice(gpu.Synchronization);
Smmu = gpu.CreateDeviceMemoryManager(pid); Smmu = gpu.CreateDeviceMemoryManager(pid);
NvdecDevice nvdec = new NvdecDevice(Smmu); NvdecDevice nvdec = new(Smmu);
VicDevice vic = new VicDevice(Smmu); VicDevice vic = new(Smmu);
Host1x.RegisterDevice(ClassId.Nvdec, nvdec); Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
Host1x.RegisterDevice(ClassId.Vic, vic); Host1x.RegisterDevice(ClassId.Vic, vic);
} }

View file

@ -33,8 +33,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
} }
private static readonly VmRegion[] _vmRegions = { private static readonly VmRegion[] _vmRegions = {
new VmRegion((ulong)BigPageSize << 16, SmallRegionLimit), new((ulong)BigPageSize << 16, SmallRegionLimit),
new VmRegion(SmallRegionLimit, DefaultUserSize), new(SmallRegionLimit, DefaultUserSize),
}; };
private readonly AddressSpaceContext _asContext; private readonly AddressSpaceContext _asContext;

View file

@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
Nca nca = new(_device.System.KeySet, ncaFileStream); Nca nca = new(_device.System.KeySet, ncaFileStream);
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
using UniqueRef<IFile> fontFile = new UniqueRef<IFile>(); using UniqueRef<IFile> fontFile = new();
romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure(); romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure();

View file

@ -326,7 +326,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel); IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel);
using UniqueRef<IFile> firmwareFile = new UniqueRef<IFile>(); using UniqueRef<IFile> firmwareFile = new();
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read); Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read);
if (result.IsFailure()) if (result.IsFailure())

View file

@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
using UniqueRef<IFile> trustedCertsFileRef = new UniqueRef<IFile>(); using UniqueRef<IFile> trustedCertsFileRef = new();
Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read); Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read);

View file

@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream); Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream);
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
using UniqueRef<IFile> binaryListFile = new UniqueRef<IFile>(); using UniqueRef<IFile> binaryListFile = new();
romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
continue; continue;
} }
using UniqueRef<IFile> tzif = new UniqueRef<IFile>(); using UniqueRef<IFile> tzif = new();
if (romfs.OpenFile(ref tzif.Ref, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure()) if (romfs.OpenFile(ref tzif.Ref, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure())
{ {
@ -269,7 +269,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
Nca nca = new(_virtualFileSystem.KeySet, ncaFile); Nca nca = new(_virtualFileSystem.KeySet, ncaFile);
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
using UniqueRef<IFile> timeZoneBinaryFile = new UniqueRef<IFile>(); using UniqueRef<IFile> timeZoneBinaryFile = new();
Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read); Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read);

View file

@ -62,7 +62,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
Logger.Info?.Print(LogClass.Loader, $"Loading {name}..."); Logger.Info?.Print(LogClass.Loader, $"Loading {name}...");
using UniqueRef<IFile> nsoFile = new UniqueRef<IFile>(); using UniqueRef<IFile> nsoFile = new();
exeFs.OpenFile(ref nsoFile.Ref, $"/{name}".ToU8Span(), OpenMode.Read).ThrowIfFailure(); exeFs.OpenFile(ref nsoFile.Ref, $"/{name}".ToU8Span(), OpenMode.Read).ThrowIfFailure();

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.Loaders.Processes
public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "") public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "")
{ {
MetaLoader metaLoader = exeFs.GetNpdm(); MetaLoader metaLoader = exeFs.GetNpdm();
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1); BlitStruct<ApplicationControlProperty> nacpData = new(1);
ulong programId = metaLoader.GetProgramId(); ulong programId = metaLoader.GetProgramId();
device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]); device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]);

View file

@ -45,7 +45,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
path = ProcessConst.MainNpdmPath; path = ProcessConst.MainNpdmPath;
} }
using UniqueRef<IFile> npdmFile = new UniqueRef<IFile>(); using UniqueRef<IFile> npdmFile = new();
fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure(); fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();

View file

@ -49,7 +49,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
ModLoader.GetSdModsBasePath()); ModLoader.GetSdModsBasePath());
// Load Nacp file. // Load Nacp file.
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1); BlitStruct<ApplicationControlProperty> nacpData = new(1);
if (controlNca != null) if (controlNca != null)
{ {
@ -214,9 +214,9 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
public static BlitStruct<ApplicationControlProperty> GetNacp(this Nca controlNca, Switch device) public static BlitStruct<ApplicationControlProperty> GetNacp(this Nca controlNca, Switch device)
{ {
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1); BlitStruct<ApplicationControlProperty> nacpData = new(1);
using UniqueRef<IFile> controlFile = new UniqueRef<IFile>(); using UniqueRef<IFile> controlFile = new();
Result result = controlNca.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel) Result result = controlNca.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel)
.OpenFile(ref controlFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read); .OpenFile(ref controlFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read);
@ -236,7 +236,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
public static Cnmt GetCnmt(this Nca cnmtNca, IntegrityCheckLevel checkLevel, ContentMetaType metaType) public static Cnmt GetCnmt(this Nca cnmtNca, IntegrityCheckLevel checkLevel, ContentMetaType metaType)
{ {
string path = $"/{metaType}_{cnmtNca.Header.TitleId:x16}.cnmt"; string path = $"/{metaType}_{cnmtNca.Header.TitleId:x16}.cnmt";
using UniqueRef<IFile> cnmtFile = new UniqueRef<IFile>(); using UniqueRef<IFile> cnmtFile = new();
try try
{ {

View file

@ -28,7 +28,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
{ {
fileSystem.ImportTickets(partitionFileSystem); fileSystem.ImportTickets(partitionFileSystem);
Dictionary<ulong, ContentMetaData> programs = new Dictionary<ulong, ContentMetaData>(); Dictionary<ulong, ContentMetaData> programs = new();
foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.cnmt.nca")) 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) public static Nca GetNca(this IFileSystem fileSystem, KeySet keySet, string path)
{ {
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>(); using UniqueRef<IFile> ncaFile = new();
fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure(); fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure();

View file

@ -161,7 +161,7 @@ namespace Ryujinx.HLE.Loaders.Processes
public bool LoadNxo(string path) public bool LoadNxo(string path)
{ {
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1); BlitStruct<ApplicationControlProperty> nacpData = new(1);
IFileSystem dummyExeFs = null; IFileSystem dummyExeFs = null;
Stream romfsStream = null; Stream romfsStream = null;

View file

@ -180,7 +180,7 @@ namespace Ryujinx.HLE.Loaders.Processes
KProcess process = new(context); KProcess process = new(context);
ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory( ArmProcessContextFactory processContextFactory = new(
context.Device.System.TickSource, context.Device.System.TickSource,
context.Device.Gpu, context.Device.Gpu,
string.Empty, string.Empty,
@ -373,7 +373,7 @@ namespace Ryujinx.HLE.Loaders.Processes
displayVersion = device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? string.Empty; displayVersion = device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? string.Empty;
} }
ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory( ArmProcessContextFactory processContextFactory = new(
context.Device.System.TickSource, context.Device.System.TickSource,
context.Device.Gpu, context.Device.Gpu,
$"{programId:x16}", $"{programId:x16}",

View file

@ -18,7 +18,7 @@ namespace Ryujinx.HLE
const int OffsetOfApplicationPublisherStrings = 0x200; const int OffsetOfApplicationPublisherStrings = 0x200;
BlitStruct<ApplicationControlProperty> nacpData = new BlitStruct<ApplicationControlProperty>(1); BlitStruct<ApplicationControlProperty> nacpData = new(1);
// name and publisher buffer // name and publisher buffer
// repeat once for each locale (the ApplicationControlProperty has 16 locales) // repeat once for each locale (the ApplicationControlProperty has 16 locales)

View file

@ -22,7 +22,7 @@ namespace Ryujinx.HLE.Utilities
} }
else else
{ {
PartitionFileSystem pfsTemp = new PartitionFileSystem(); PartitionFileSystem pfsTemp = new();
Result initResult = pfsTemp.Initialize(file.AsStorage()); Result initResult = pfsTemp.Initialize(file.AsStorage());
if (throwOnFailure) if (throwOnFailure)