diff --git a/Ryujinx.HLE/FileSystem/Content/ContentManager.cs b/Ryujinx.HLE/FileSystem/Content/ContentManager.cs index a8e9e96176..4c4f3c8676 100644 --- a/Ryujinx.HLE/FileSystem/Content/ContentManager.cs +++ b/Ryujinx.HLE/FileSystem/Content/ContentManager.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using LibHac.Ncm; @@ -827,7 +828,7 @@ namespace Ryujinx.HLE.FileSystem.Content LibHac.Crypto.Sha256.GenerateSha256Hash(content, hash); - if (LibHac.Util.ArraysEqual(hash.ToArray(), meta.ContentEntries[0].Hash)) + if (LibHac.Utilities.ArraysEqual(hash.ToArray(), meta.ContentEntries[0].Hash)) { updateNcas.Remove(metaEntry.TitleId); } @@ -962,7 +963,7 @@ namespace Ryujinx.HLE.FileSystem.Content LibHac.Crypto.Sha256.GenerateSha256Hash(content, hash); - if (LibHac.Util.ArraysEqual(hash.ToArray(), meta.ContentEntries[0].Hash)) + if (LibHac.Utilities.ArraysEqual(hash.ToArray(), meta.ContentEntries[0].Hash)) { updateNcas.Remove(metaEntry.TitleId); } diff --git a/Ryujinx.HLE/FileSystem/SaveHelper.cs b/Ryujinx.HLE/FileSystem/SaveHelper.cs index b9abcb8555..51a2551529 100644 --- a/Ryujinx.HLE/FileSystem/SaveHelper.cs +++ b/Ryujinx.HLE/FileSystem/SaveHelper.cs @@ -1,4 +1,4 @@ -using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using Ryujinx.HLE.HOS; using System.IO; diff --git a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index a95c9c0f5e..5b44f2d7ed 100644 --- a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -1,7 +1,8 @@ using LibHac; using LibHac.Common; using LibHac.Fs; -using LibHac.FsService; +using LibHac.Fs.Fsa; +using LibHac.FsSrv; using LibHac.FsSystem; using LibHac.Spl; using Ryujinx.Common.Configuration; diff --git a/Ryujinx.HLE/HOS/ApplicationLoader.cs b/Ryujinx.HLE/HOS/ApplicationLoader.cs index b52678de5e..16c9664db5 100644 --- a/Ryujinx.HLE/HOS/ApplicationLoader.cs +++ b/Ryujinx.HLE/HOS/ApplicationLoader.cs @@ -3,9 +3,9 @@ using LibHac; using LibHac.Account; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; -using LibHac.Ncm; using LibHac.Ns; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; @@ -20,6 +20,7 @@ using System.Linq; using System.Reflection; using static LibHac.Fs.ApplicationSaveDataManagement; +using ApplicationId = LibHac.Ncm.ApplicationId; namespace Ryujinx.HLE.HOS { @@ -73,7 +74,7 @@ namespace Ryujinx.HLE.HOS if (TitleId != 0) { - EnsureSaveData(new TitleId(TitleId)); + EnsureSaveData(new ApplicationId(TitleId)); } LoadExeFs(codeFs, metaData); @@ -333,7 +334,7 @@ namespace Ryujinx.HLE.HOS if (TitleId != 0) { - EnsureSaveData(new TitleId(TitleId)); + EnsureSaveData(new ApplicationId(TitleId)); } LoadExeFs(codeFs, metaData); @@ -549,7 +550,7 @@ namespace Ryujinx.HLE.HOS } } - private Result EnsureSaveData(TitleId titleId) + private Result EnsureSaveData(ApplicationId applicationId) { Logger.Info?.Print(LogClass.Application, "Ensuring required savedata exists."); @@ -557,7 +558,7 @@ namespace Ryujinx.HLE.HOS ref ApplicationControlProperty control = ref ControlData.Value; - if (Util.IsEmpty(ControlData.ByteSpan)) + if (LibHac.Utilities.IsEmpty(ControlData.ByteSpan)) { // If the current application doesn't have a loaded control property, create a dummy one // and set the savedata sizes so a user savedata will be created. @@ -573,7 +574,7 @@ namespace Ryujinx.HLE.HOS FileSystemClient fs = _fileSystem.FsClient; - Result rc = fs.EnsureApplicationCacheStorage(out _, titleId, ref control); + Result rc = fs.EnsureApplicationCacheStorage(out _, applicationId, ref control); if (rc.IsFailure()) { @@ -582,7 +583,7 @@ namespace Ryujinx.HLE.HOS return rc; } - rc = EnsureApplicationSaveData(fs, out _, titleId, ref control, ref user); + rc = EnsureApplicationSaveData(fs, out _, applicationId, ref control, ref user); if (rc.IsFailure()) { diff --git a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs index 3412940443..ac96b86570 100644 --- a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs +++ b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs @@ -1,8 +1,8 @@ using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; -using Ryujinx.Common.Logging; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem.Content; diff --git a/Ryujinx.HLE/HOS/ModLoader.cs b/Ryujinx.HLE/HOS/ModLoader.cs index 786484aeaa..3d701525a8 100644 --- a/Ryujinx.HLE/HOS/ModLoader.cs +++ b/Ryujinx.HLE/HOS/ModLoader.cs @@ -1,5 +1,6 @@ using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.RomFs; using Ryujinx.Common.Configuration; diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs index 5b26b981bc..54de42cc61 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs @@ -2,7 +2,6 @@ using LibHac; using LibHac.Account; using LibHac.Common; using LibHac.Fs; -using LibHac.Ncm; using LibHac.Ns; using Ryujinx.Common; using Ryujinx.Common.Logging; @@ -18,6 +17,7 @@ using System.Numerics; using static LibHac.Fs.ApplicationSaveDataManagement; using AccountUid = Ryujinx.HLE.HOS.Services.Account.Acc.UserId; +using ApplicationId = LibHac.Ncm.ApplicationId; namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy { @@ -29,9 +29,9 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati public IApplicationFunctions(Horizon system) { - _gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext); + _gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext); _friendInvitationStorageChannelEvent = new KEvent(system.KernelContext); - _notificationStorageChannelEvent = new KEvent(system.KernelContext); + _notificationStorageChannelEvent = new KEvent(system.KernelContext); } [Command(1)] @@ -48,28 +48,28 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati // EnsureSaveData(nn::account::Uid) -> u64 public ResultCode EnsureSaveData(ServiceCtx context) { - Uid userId = context.RequestData.ReadStruct().ToLibHacUid(); - TitleId titleId = new TitleId(context.Process.TitleId); + Uid userId = context.RequestData.ReadStruct().ToLibHacUid(); + ApplicationId applicationId = new ApplicationId(context.Process.TitleId); BlitStruct controlHolder = context.Device.Application.ControlData; ref ApplicationControlProperty control = ref controlHolder.Value; - if (Util.IsEmpty(controlHolder.ByteSpan)) + if (LibHac.Utilities.IsEmpty(controlHolder.ByteSpan)) { // If the current application doesn't have a loaded control property, create a dummy one // and set the savedata sizes so a user savedata will be created. control = ref new BlitStruct(1).Value; // The set sizes don't actually matter as long as they're non-zero because we use directory savedata. - control.UserAccountSaveDataSize = 0x4000; + control.UserAccountSaveDataSize = 0x4000; control.UserAccountSaveDataJournalSize = 0x4000; Logger.Warning?.Print(LogClass.ServiceAm, "No control file was found for this game. Using a dummy one instead. This may cause inaccuracies in some games."); } - Result result = EnsureApplicationSaveData(context.Device.FileSystem.FsClient, out long requiredSize, titleId, + Result result = EnsureApplicationSaveData(context.Device.FileSystem.FsClient, out long requiredSize, applicationId, ref control, ref userId); context.ResponseData.Write(requiredSize); @@ -87,7 +87,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati // TODO: When above calls are implemented, switch to using ns:am long desiredLanguageCode = context.Device.System.State.DesiredLanguageCode; - + int supportedLanguages = (int)context.Device.Application.ControlData.Value.SupportedLanguages; int firstSupported = BitOperations.TrailingZeroCount(supportedLanguages); @@ -210,10 +210,10 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati // InitializeApplicationCopyrightFrameBuffer(s32 width, s32 height, handle transfer_memory, u64 transfer_memory_size) public ResultCode InitializeApplicationCopyrightFrameBuffer(ServiceCtx context) { - int width = context.RequestData.ReadInt32(); - int height = context.RequestData.ReadInt32(); - ulong transferMemorySize = context.RequestData.ReadUInt64(); - int transferMemoryHandle = context.Request.HandleDesc.ToCopy[0]; + int width = context.RequestData.ReadInt32(); + int height = context.RequestData.ReadInt32(); + ulong transferMemorySize = context.RequestData.ReadUInt64(); + int transferMemoryHandle = context.Request.HandleDesc.ToCopy[0]; ulong transferMemoryAddress = context.Process.HandleTable.GetObject(transferMemoryHandle).Address; ResultCode resultCode = ResultCode.InvalidParameters; @@ -258,12 +258,12 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati // SetApplicationCopyrightImage(buffer frame_buffer, s32 x, s32 y, s32 width, s32 height, s32 window_origin_mode) public ResultCode SetApplicationCopyrightImage(ServiceCtx context) { - long frameBufferPos = context.Request.SendBuff[0].Position; - long frameBufferSize = context.Request.SendBuff[0].Size; - int x = context.RequestData.ReadInt32(); - int y = context.RequestData.ReadInt32(); - int width = context.RequestData.ReadInt32(); - int height = context.RequestData.ReadInt32(); + long frameBufferPos = context.Request.SendBuff[0].Position; + long frameBufferSize = context.Request.SendBuff[0].Size; + int x = context.RequestData.ReadInt32(); + int y = context.RequestData.ReadInt32(); + int width = context.RequestData.ReadInt32(); + int height = context.RequestData.ReadInt32(); uint windowOriginMode = context.RequestData.ReadUInt32(); ResultCode resultCode = ResultCode.InvalidParameters; @@ -272,7 +272,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati { ResultCode result = SetApplicationCopyrightImageImpl(x, y, width, height, frameBufferPos, frameBufferSize, windowOriginMode); - if (resultCode != ResultCode.Success) + if (result != ResultCode.Success) { resultCode = result; } diff --git a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs index 525dff60a4..c4d251f975 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs @@ -44,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy return ResultCode.PartitionNotFound; } - LibHac.Fs.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); + LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); openedFileSystem = new IFileSystem(fileSystem); } @@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\'); - Result result = nsp.OpenFile(out LibHac.Fs.IFile ncaFile, filename.ToU8Span(), OpenMode.Read); + Result result = nsp.OpenFile(out LibHac.Fs.Fsa.IFile ncaFile, filename.ToU8Span(), OpenMode.Read); if (result.IsFailure()) { return (ResultCode)result.Value; @@ -99,11 +99,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy return ResultCode.PathDoesNotExist; } - public static void ImportTitleKeysFromNsp(LibHac.Fs.IFileSystem nsp, Keyset keySet) + public static void ImportTitleKeysFromNsp(LibHac.Fs.Fsa.IFileSystem nsp, Keyset keySet) { foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik")) { - Result result = nsp.OpenFile(out LibHac.Fs.IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read); + Result result = nsp.OpenFile(out LibHac.Fs.Fsa.IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read); if (result.IsSuccess()) { diff --git a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs index 3d07b50973..ccad1ce3e5 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs @@ -7,9 +7,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { class IDirectory : IpcService { - private LibHac.Fs.IDirectory _baseDirectory; + private LibHac.Fs.Fsa.IDirectory _baseDirectory; - public IDirectory(LibHac.Fs.IDirectory directory) + public IDirectory(LibHac.Fs.Fsa.IDirectory directory) { _baseDirectory = directory; } diff --git a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs index 02fc967f53..cdec98c56b 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs @@ -6,9 +6,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { class IFile : IpcService, IDisposable { - private LibHac.Fs.IFile _baseFile; + private LibHac.Fs.Fsa.IFile _baseFile; - public IFile(LibHac.Fs.IFile baseFile) + public IFile(LibHac.Fs.Fsa.IFile baseFile) { _baseFile = baseFile; } @@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { long position = context.Request.ReceiveBuff[0].Position; - ReadOption readOption = (ReadOption)context.RequestData.ReadInt32(); + ReadOption readOption = new ReadOption(context.RequestData.ReadInt32()); context.RequestData.BaseStream.Position += 4; long offset = context.RequestData.ReadInt64(); @@ -42,7 +42,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { long position = context.Request.SendBuff[0].Position; - WriteOption writeOption = (WriteOption)context.RequestData.ReadInt32(); + WriteOption writeOption = new WriteOption(context.RequestData.ReadInt32()); context.RequestData.BaseStream.Position += 4; long offset = context.RequestData.ReadInt64(); diff --git a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs index b907e17a9f..25d63bb901 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs @@ -1,21 +1,21 @@ using LibHac; using LibHac.Common; using LibHac.Fs; - +using LibHac.Fs.Fsa; using static Ryujinx.HLE.Utilities.StringUtils; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { class IFileSystem : IpcService { - private LibHac.Fs.IFileSystem _fileSystem; + private LibHac.Fs.Fsa.IFileSystem _fileSystem; - public IFileSystem(LibHac.Fs.IFileSystem provider) + public IFileSystem(LibHac.Fs.Fsa.IFileSystem provider) { _fileSystem = provider; } - public LibHac.Fs.IFileSystem GetBaseFileSystem() + public LibHac.Fs.Fsa.IFileSystem GetBaseFileSystem() { return _fileSystem; } @@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy U8Span name = ReadUtf8Span(context); - Result result = _fileSystem.OpenFile(out LibHac.Fs.IFile file, name, mode); + Result result = _fileSystem.OpenFile(out LibHac.Fs.Fsa.IFile file, name, mode); if (result.IsSuccess()) { @@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy U8Span name = ReadUtf8Span(context); - Result result = _fileSystem.OpenDirectory(out LibHac.Fs.IDirectory dir, name, mode); + Result result = _fileSystem.OpenDirectory(out LibHac.Fs.Fsa.IDirectory dir, name, mode); if (result.IsSuccess()) { diff --git a/Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs b/Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs index c9f2f74c47..7551d6274b 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/IDeviceOperator.cs @@ -1,13 +1,13 @@ using LibHac; -using LibHac.FsService; +using LibHac.FsSrv; namespace Ryujinx.HLE.HOS.Services.Fs { class IDeviceOperator : IpcService { - private LibHac.FsService.IDeviceOperator _baseOperator; + private LibHac.FsSrv.IDeviceOperator _baseOperator; - public IDeviceOperator(LibHac.FsService.IDeviceOperator baseOperator) + public IDeviceOperator(LibHac.FsSrv.IDeviceOperator baseOperator) { _baseOperator = baseOperator; } diff --git a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs index 42e778d626..44f406a070 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs @@ -1,6 +1,6 @@ using LibHac; using LibHac.Fs; -using LibHac.FsService; +using LibHac.FsSrv; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using LibHac.Ncm; @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [Service("fsp-srv")] class IFileSystemProxy : IpcService { - private LibHac.FsService.IFileSystemProxy _baseFileSystemProxy; + private LibHac.FsSrv.IFileSystemProxy _baseFileSystemProxy; public IFileSystemProxy(ServiceCtx context) { @@ -97,7 +97,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs Result rc = FileSystemProxyHelper.ReadFsPath(out FsPath path, context); if (rc.IsFailure()) return (ResultCode)rc.Value; - rc = _baseFileSystemProxy.OpenBisFileSystem(out LibHac.Fs.IFileSystem fileSystem, ref path, bisPartitionId); + rc = _baseFileSystemProxy.OpenBisFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, ref path, bisPartitionId); if (rc.IsFailure()) return (ResultCode)rc.Value; MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem)); @@ -109,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenSdCardFileSystem() -> object public ResultCode OpenSdCardFileSystem(ServiceCtx context) { - Result rc = _baseFileSystemProxy.OpenSdCardFileSystem(out LibHac.Fs.IFileSystem fileSystem); + Result rc = _baseFileSystemProxy.OpenSdCardFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem); if (rc.IsFailure()) return (ResultCode)rc.Value; MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem)); @@ -136,17 +136,17 @@ namespace Ryujinx.HLE.HOS.Services.Fs // TODO: There's currently no program registry for FS to reference. // Workaround that by setting the application ID and owner ID if they're not already set - if (attribute.TitleId == TitleId.Zero) + if (attribute.ProgramId == ProgramId.InvalidId) { - attribute.TitleId = new TitleId(context.Process.TitleId); + attribute.ProgramId = new ProgramId(context.Process.TitleId); } - if (creationInfo.OwnerId == TitleId.Zero) + if (creationInfo.OwnerId == 0) { - creationInfo.OwnerId = new TitleId(context.Process.TitleId); + creationInfo.OwnerId = 0; } - Logger.Info?.Print(LogClass.ServiceFs, $"Creating save with title ID {attribute.TitleId.Value:x16}"); + Logger.Info?.Print(LogClass.ServiceFs, $"Creating save with title ID {attribute.ProgramId.Value:x16}"); Result result = _baseFileSystemProxy.CreateSaveDataFileSystem(ref attribute, ref creationInfo, ref metaCreateInfo); @@ -213,14 +213,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs // TODO: There's currently no program registry for FS to reference. // Workaround that by setting the application ID and owner ID if they're not already set - if (attribute.TitleId == TitleId.Zero) + if (attribute.ProgramId == ProgramId.InvalidId) { - attribute.TitleId = new TitleId(context.Process.TitleId); + attribute.ProgramId = new ProgramId(context.Process.TitleId); } - if (creationInfo.OwnerId == TitleId.Zero) + if (creationInfo.OwnerId == 0) { - creationInfo.OwnerId = new TitleId(context.Process.TitleId); + creationInfo.OwnerId = 0; } Result result = _baseFileSystemProxy.CreateSaveDataFileSystemWithHashSalt(ref attribute, ref creationInfo, ref metaCreateInfo, ref hashSalt); @@ -237,12 +237,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs // TODO: There's currently no program registry for FS to reference. // Workaround that by setting the application ID if it's not already set - if (attribute.TitleId == TitleId.Zero) + if (attribute.ProgramId == ProgramId.InvalidId) { - attribute.TitleId = new TitleId(context.Process.TitleId); + attribute.ProgramId = new ProgramId(context.Process.TitleId); } - Result result = _baseFileSystemProxy.OpenSaveDataFileSystem(out LibHac.Fs.IFileSystem fileSystem, spaceId, ref attribute); + Result result = _baseFileSystemProxy.OpenSaveDataFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute); if (result.IsSuccess()) { @@ -259,7 +259,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); - Result result = _baseFileSystemProxy.OpenSaveDataFileSystemBySystemSaveDataId(out LibHac.Fs.IFileSystem fileSystem, spaceId, ref attribute); + Result result = _baseFileSystemProxy.OpenSaveDataFileSystemBySystemSaveDataId(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute); if (result.IsSuccess()) { @@ -278,12 +278,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs // TODO: There's currently no program registry for FS to reference. // Workaround that by setting the application ID if it's not already set - if (attribute.TitleId == TitleId.Zero) + if (attribute.ProgramId == ProgramId.InvalidId) { - attribute.TitleId = new TitleId(context.Process.TitleId); + attribute.ProgramId = new ProgramId(context.Process.TitleId); } - Result result = _baseFileSystemProxy.OpenReadOnlySaveDataFileSystem(out LibHac.Fs.IFileSystem fileSystem, spaceId, ref attribute); + Result result = _baseFileSystemProxy.OpenReadOnlySaveDataFileSystem(out LibHac.Fs.Fsa.IFileSystem fileSystem, spaceId, ref attribute); if (result.IsSuccess()) { @@ -296,7 +296,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [Command(60)] public ResultCode OpenSaveDataInfoReader(ServiceCtx context) { - Result result = _baseFileSystemProxy.OpenSaveDataInfoReader(out LibHac.FsService.ISaveDataInfoReader infoReader); + Result result = _baseFileSystemProxy.OpenSaveDataInfoReader(out ReferenceCountedDisposable infoReader); if (result.IsSuccess()) { @@ -311,7 +311,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte(); - Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderBySaveDataSpaceId(out LibHac.FsService.ISaveDataInfoReader infoReader, spaceId); + Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderBySaveDataSpaceId(out ReferenceCountedDisposable infoReader, spaceId); if (result.IsSuccess()) { @@ -326,12 +326,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataFilter filter = new SaveDataFilter(); filter.SetSaveDataType(SaveDataType.Cache); - filter.SetProgramId(new TitleId(context.Process.TitleId)); + filter.SetProgramId(new ProgramId(context.Process.TitleId)); // FS would query the User and SdCache space IDs to find where the existing cache is (if any). // We always have the SD card inserted, so we can always use SdCache for now. Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderBySaveDataSpaceId( - out LibHac.FsService.ISaveDataInfoReader infoReader, SaveDataSpaceId.SdCache); + out ReferenceCountedDisposable infoReader, SaveDataSpaceId.SdCache); if (result.IsSuccess()) { @@ -366,7 +366,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataFilter filter = context.RequestData.ReadStruct(); - Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderWithFilter(out LibHac.FsService.ISaveDataInfoReader infoReader, spaceId, ref filter); + Result result = _baseFileSystemProxy.OpenSaveDataInfoReaderWithFilter( + out ReferenceCountedDisposable infoReader, spaceId, ref filter); if (result.IsSuccess()) { @@ -478,7 +479,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenDataStorageByCurrentProcess() -> object dataStorage public ResultCode OpenDeviceOperator(ServiceCtx context) { - Result result = _baseFileSystemProxy.OpenDeviceOperator(out LibHac.FsService.IDeviceOperator deviceOperator); + Result result = _baseFileSystemProxy.OpenDeviceOperator(out LibHac.FsSrv.IDeviceOperator deviceOperator); if (result.IsSuccess()) { @@ -558,7 +559,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenMultiCommitManager() -> object public ResultCode OpenMultiCommitManager(ServiceCtx context) { - Result result = _baseFileSystemProxy.OpenMultiCommitManager(out LibHac.FsService.IMultiCommitManager commitManager); + Result result = _baseFileSystemProxy.OpenMultiCommitManager(out LibHac.FsSrv.IMultiCommitManager commitManager); if (result.IsSuccess()) { diff --git a/Ryujinx.HLE/HOS/Services/Fs/IMultiCommitManager.cs b/Ryujinx.HLE/HOS/Services/Fs/IMultiCommitManager.cs index c26f54b690..0c8ba98268 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/IMultiCommitManager.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/IMultiCommitManager.cs @@ -5,9 +5,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs { class IMultiCommitManager : IpcService // 6.0.0+ { - private LibHac.FsService.IMultiCommitManager _baseCommitManager; + private LibHac.FsSrv.IMultiCommitManager _baseCommitManager; - public IMultiCommitManager(LibHac.FsService.IMultiCommitManager baseCommitManager) + public IMultiCommitManager(LibHac.FsSrv.IMultiCommitManager baseCommitManager) { _baseCommitManager = baseCommitManager; } diff --git a/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs b/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs index a76a74125f..943dab98ff 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs @@ -1,12 +1,13 @@ -using LibHac; +using System; +using LibHac; namespace Ryujinx.HLE.HOS.Services.Fs { - class ISaveDataInfoReader : IpcService + class ISaveDataInfoReader : IpcService, IDisposable { - private LibHac.FsService.ISaveDataInfoReader _baseReader; + private ReferenceCountedDisposable _baseReader; - public ISaveDataInfoReader(LibHac.FsService.ISaveDataInfoReader baseReader) + public ISaveDataInfoReader(ReferenceCountedDisposable baseReader) { _baseReader = baseReader; } @@ -20,12 +21,17 @@ namespace Ryujinx.HLE.HOS.Services.Fs byte[] infoBuffer = new byte[bufferLen]; - Result result = _baseReader.ReadSaveDataInfo(out long readCount, infoBuffer); + Result result = _baseReader.Target.Read(out long readCount, infoBuffer); context.Memory.Write((ulong)bufferPosition, infoBuffer); context.ResponseData.Write(readCount); return (ResultCode)result.Value; } + + public void Dispose() + { + _baseReader.Dispose(); + } } } diff --git a/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs b/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs index fcb254ffdf..0fe6220c6b 100644 --- a/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs +++ b/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs @@ -2,7 +2,6 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Shim; -using LibHac.Ncm; using Ryujinx.HLE.HOS.Services.Mii.Types; using System.Runtime.CompilerServices; @@ -137,7 +136,8 @@ namespace Ryujinx.HLE.HOS.Services.Mii { // TODO: We're currently always specifying the owner ID because FS doesn't have a way of // knowing which process called it - result = _filesystemClient.CreateSystemSaveData(targetSaveDataId, new TitleId(targetTitleId), 0x10000, 0x10000, SaveDataFlags.KeepAfterResettingSystemSaveDataWithoutUserSaveData); + result = _filesystemClient.CreateSystemSaveData(targetSaveDataId, targetTitleId, 0x10000, + 0x10000, SaveDataFlags.KeepAfterResettingSystemSaveDataWithoutUserSaveData); if (result.IsFailure()) return result; result = _filesystemClient.MountSystemSaveData(mountName, SaveDataSpaceId.System, targetSaveDataId); diff --git a/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs b/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs index 2ccebede9b..7db4ab34b1 100644 --- a/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs +++ b/Ryujinx.HLE/HOS/Services/Mii/Types/StoreData.cs @@ -73,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types private ReadOnlySpan AsSpan() { - return MemoryMarshal.AsBytes(SpanHelpers.CreateReadOnlySpan(ref this, 1)); + return MemoryMarshal.AsBytes(SpanHelpers.CreateReadOnlySpan(in this, 1)); } private ReadOnlySpan AsSpanWithoutCrc() diff --git a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs index da7ffa86aa..c41e6618a8 100644 --- a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using Ryujinx.Common.Logging; diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs index 26a354da38..b66ffc3f1b 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using Ryujinx.Common.Logging; diff --git a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs index a44b7c486e..292e360b53 100644 --- a/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs +++ b/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs @@ -1,5 +1,5 @@ using LibHac.Fs; -using LibHac.Loader; +using LibHac.Kernel; using System; namespace Ryujinx.HLE.Loaders.Executables @@ -31,6 +31,7 @@ namespace Ryujinx.HLE.Loaders.Executables public byte IdealCoreId { get; } public int Version { get; } public string Name { get; } + public KipExecutable(IStorage inStorage) { KipReader reader = new KipReader(); @@ -70,11 +71,11 @@ namespace Ryujinx.HLE.Loaders.Executables DataSize = DecompressSection(reader, KipReader.SegmentType.Data, DataOffset, Program); } - private static int DecompressSection(KipReader reader, KipReader.SegmentType segmentType, int offset, byte[] Program) + private static int DecompressSection(KipReader reader, KipReader.SegmentType segmentType, int offset, byte[] program) { reader.GetSegmentSize(segmentType, out int uncompressedSize).ThrowIfFailure(); - var span = Program.AsSpan().Slice(offset, uncompressedSize); + var span = program.AsSpan().Slice(offset, uncompressedSize); reader.ReadSegment(segmentType, span).ThrowIfFailure(); diff --git a/Ryujinx.HLE/Ryujinx.HLE.csproj b/Ryujinx.HLE/Ryujinx.HLE.csproj index 9fea6e4352..92d776a41f 100644 --- a/Ryujinx.HLE/Ryujinx.HLE.csproj +++ b/Ryujinx.HLE/Ryujinx.HLE.csproj @@ -46,7 +46,7 @@ - + diff --git a/Ryujinx/Ui/ApplicationLibrary.cs b/Ryujinx/Ui/ApplicationLibrary.cs index 742dcc073d..09062c860a 100644 --- a/Ryujinx/Ui/ApplicationLibrary.cs +++ b/Ryujinx/Ui/ApplicationLibrary.cs @@ -1,12 +1,10 @@ using LibHac; using LibHac.Common; using LibHac.Fs; -using LibHac.Fs.Shim; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; -using LibHac.Ncm; using LibHac.Ns; -using LibHac.Spl; using Ryujinx.Common.Logging; using Ryujinx.Common.Configuration; using Ryujinx.Configuration.System; @@ -14,13 +12,11 @@ using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.Loaders.Npdm; using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Reflection; using System.Text; using System.Text.Json; -using RightsId = LibHac.Fs.RightsId; using JsonHelper = Ryujinx.Common.Utilities.JsonHelper; namespace Ryujinx.Ui @@ -212,9 +208,6 @@ namespace Ryujinx.Ui ReadControlData(controlFs, controlHolder.ByteSpan); - // Creates NACP class from the NACP file - controlFs.OpenFile(out IFile controlNacpFile, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure(); - // Get the title name, title ID, developer name and version number from the NACP version = IsUpdateApplied(titleId, out string updateVersion) ? updateVersion : controlHolder.Value.DisplayVersion.ToString(); diff --git a/Ryujinx/Ui/DlcWindow.cs b/Ryujinx/Ui/DlcWindow.cs index 09ff9afcb1..b9b770c0cf 100644 --- a/Ryujinx/Ui/DlcWindow.cs +++ b/Ryujinx/Ui/DlcWindow.cs @@ -1,9 +1,10 @@ using Gtk; using LibHac; using LibHac.Common; -using LibHac.FsSystem.NcaUtils; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; +using LibHac.FsSystem.NcaUtils; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.HLE.FileSystem; diff --git a/Ryujinx/Ui/GameTableContextMenu.cs b/Ryujinx/Ui/GameTableContextMenu.cs index 93306b5763..a654b385d3 100644 --- a/Ryujinx/Ui/GameTableContextMenu.cs +++ b/Ryujinx/Ui/GameTableContextMenu.cs @@ -3,6 +3,7 @@ using LibHac; using LibHac.Account; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.Fs.Shim; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; @@ -45,19 +46,19 @@ namespace Ryujinx.Ui MenuItem openSaveUserDir = new MenuItem("Open User Save Directory") { - Sensitive = !Util.IsEmpty(controlData.ByteSpan) && controlData.Value.UserAccountSaveDataSize > 0, + Sensitive = !Utilities.IsEmpty(controlData.ByteSpan) && controlData.Value.UserAccountSaveDataSize > 0, TooltipText = "Open the directory which contains Application's User Saves." }; MenuItem openSaveDeviceDir = new MenuItem("Open Device Save Directory") { - Sensitive = !Util.IsEmpty(controlData.ByteSpan) && controlData.Value.DeviceSaveDataSize > 0, + Sensitive = !Utilities.IsEmpty(controlData.ByteSpan) && controlData.Value.DeviceSaveDataSize > 0, TooltipText = "Open the directory which contains Application's Device Saves." }; MenuItem openSaveBcatDir = new MenuItem("Open BCAT Save Directory") { - Sensitive = !Util.IsEmpty(controlData.ByteSpan) && controlData.Value.BcatDeliveryCacheStorageSize > 0, + Sensitive = !Utilities.IsEmpty(controlData.ByteSpan) && controlData.Value.BcatDeliveryCacheStorageSize > 0, TooltipText = "Open the directory which contains Application's BCAT Saves." }; @@ -175,7 +176,7 @@ namespace Ryujinx.Ui ref ApplicationControlProperty control = ref controlHolder.Value; - if (LibHac.Util.IsEmpty(controlHolder.ByteSpan)) + if (LibHac.Utilities.IsEmpty(controlHolder.ByteSpan)) { // If the current application doesn't have a loaded control property, create a dummy one // and set the savedata sizes so a user savedata will be created. @@ -191,7 +192,7 @@ namespace Ryujinx.Ui Uid user = new Uid(1, 0); - result = EnsureApplicationSaveData(_virtualFileSystem.FsClient, out _, new TitleId(titleId), ref control, ref user); + result = EnsureApplicationSaveData(_virtualFileSystem.FsClient, out _, new LibHac.Ncm.ApplicationId(titleId), ref control, ref user); if (result.IsFailure()) { @@ -539,7 +540,7 @@ namespace Ryujinx.Ui private void OpenSaveDir(string titleName, ulong titleId, SaveDataFilter filter) { - filter.SetProgramId(new TitleId(titleId)); + filter.SetProgramId(new ProgramId(titleId)); if (!TryFindSaveData(titleName, titleId, _controlData, filter, out ulong saveDataId)) { diff --git a/Ryujinx/Ui/SaveImporter.cs b/Ryujinx/Ui/SaveImporter.cs index 4e02d200d8..946b6cd39d 100644 --- a/Ryujinx/Ui/SaveImporter.cs +++ b/Ryujinx/Ui/SaveImporter.cs @@ -11,6 +11,8 @@ using System.IO; using System.Linq; using System.Runtime.CompilerServices; +using ApplicationId = LibHac.Ncm.ApplicationId; + namespace Ryujinx.Ui { internal class SaveImporter @@ -57,7 +59,7 @@ namespace Ryujinx.Ui { SaveDataAttribute key = save.Attribute; - Result result = fs.CreateSaveData(key.TitleId, key.UserId, key.TitleId, 0, 0, 0); + Result result = fs.CreateSaveData(new ApplicationId(key.ProgramId.Value), key.UserId, key.ProgramId.Value, 0, 0, 0); if (result.IsFailure()) return result; bool isOldMounted = false; @@ -70,7 +72,7 @@ namespace Ryujinx.Ui isOldMounted = true; - result = fs.MountSaveData("NewSave".ToU8Span(), key.TitleId, key.UserId); + result = fs.MountSaveData("NewSave".ToU8Span(), new ApplicationId(key.ProgramId.Value), key.UserId); if (result.IsFailure()) return result; isNewMounted = true; @@ -132,7 +134,7 @@ namespace Ryujinx.Ui { Type = SaveDataType.Account, UserId = userId, - TitleId = new TitleId(titleId) + ProgramId = new ProgramId(titleId) }; SaveToImport save = new SaveToImport(dataPath, attribute); diff --git a/Ryujinx/Ui/TitleUpdateWindow.cs b/Ryujinx/Ui/TitleUpdateWindow.cs index 35fdf8728e..d332b5477b 100644 --- a/Ryujinx/Ui/TitleUpdateWindow.cs +++ b/Ryujinx/Ui/TitleUpdateWindow.cs @@ -2,6 +2,7 @@ using Gtk; using LibHac; using LibHac.Common; using LibHac.Fs; +using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.FsSystem.NcaUtils; using LibHac.Ns;