Update to LibHac v0.14.3 (#2925)

* Update to LibHac v0.14.3

* Fix loading NCAs that don't have a data partition
This commit is contained in:
Alex Barney 2021-12-23 09:55:50 -07:00 committed by GitHub
parent cb43cc7e32
commit aa932a6df1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 554 additions and 406 deletions

View file

@ -23,11 +23,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
try
{
LocalStorage storage = new LocalStorage(pfsPath, FileAccess.Read, FileMode.Open);
ReferenceCountedDisposable<LibHac.Fs.Fsa.IFileSystem> nsp = new(new PartitionFileSystem(storage));
using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(new PartitionFileSystem(storage));
ImportTitleKeysFromNsp(nsp.Target, context.Device.System.KeySet);
ImportTitleKeysFromNsp(nsp.Get, context.Device.System.KeySet);
openedFileSystem = new IFileSystem(FileSystemInterfaceAdapter.CreateShared(ref nsp));
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> adapter = FileSystemInterfaceAdapter.CreateShared(ref nsp.Ref(), true);
openedFileSystem = new IFileSystem(ref adapter.Ref());
}
catch (HorizonResultException ex)
{
@ -51,9 +53,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
}
LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
var sharedFs = new ReferenceCountedDisposable<LibHac.Fs.Fsa.IFileSystem>(fileSystem);
using var sharedFs = new SharedRef<LibHac.Fs.Fsa.IFileSystem>(fileSystem);
openedFileSystem = new IFileSystem(FileSystemInterfaceAdapter.CreateShared(ref sharedFs));
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> adapter = FileSystemInterfaceAdapter.CreateShared(ref sharedFs.Ref(), true);
openedFileSystem = new IFileSystem(ref adapter.Ref());
}
catch (HorizonResultException ex)
{
@ -89,13 +93,15 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
Result result = nsp.OpenFile(out LibHac.Fs.Fsa.IFile ncaFile, filename.ToU8Span(), OpenMode.Read);
using var ncaFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
Result result = nsp.OpenFile(ref ncaFile.Ref(), filename.ToU8Span(), OpenMode.Read);
if (result.IsFailure())
{
return (ResultCode)result.Value;
}
return OpenNcaFs(context, fullPath, ncaFile.AsStorage(), out openedFileSystem);
return OpenNcaFs(context, fullPath, ncaFile.Release().AsStorage(), out openedFileSystem);
}
catch (HorizonResultException ex)
{
@ -110,11 +116,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
{
Result result = nsp.OpenFile(out LibHac.Fs.Fsa.IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
using var ticketFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
Result result = nsp.OpenFile(ref ticketFile.Ref(), ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
if (result.IsSuccess())
{
Ticket ticket = new Ticket(ticketFile.AsStream());
Ticket ticket = new Ticket(ticketFile.Get.AsStream());
keySet.ExternalKeySet.Add(new RightsId(ticket.RightsId), new AccessKey(ticket.GetTitleKey(keySet)));
}

View file

@ -1,15 +1,16 @@
using LibHac;
using LibHac.Common;
using LibHac.Sf;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IDirectory : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDirectory> _baseDirectory;
private SharedRef<LibHac.FsSrv.Sf.IDirectory> _baseDirectory;
public IDirectory(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDirectory> directory)
public IDirectory(ref SharedRef<LibHac.FsSrv.Sf.IDirectory> directory)
{
_baseDirectory = directory;
_baseDirectory = SharedRef<LibHac.FsSrv.Sf.IDirectory>.CreateMove(ref directory);
}
[CommandHipc(0)]
@ -21,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
byte[] entryBuffer = new byte[bufferLen];
Result result = _baseDirectory.Target.Read(out long entriesRead, new OutBuffer(entryBuffer));
Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(entryBuffer));
context.Memory.Write(bufferPosition, entryBuffer);
context.ResponseData.Write(entriesRead);
@ -33,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
// GetEntryCount() -> u64
public ResultCode GetEntryCount(ServiceCtx context)
{
Result result = _baseDirectory.Target.GetEntryCount(out long entryCount);
Result result = _baseDirectory.Get.GetEntryCount(out long entryCount);
context.ResponseData.Write(entryCount);
@ -44,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
if (isDisposing)
{
_baseDirectory?.Dispose();
_baseDirectory.Destroy();
}
}
}

View file

@ -1,4 +1,5 @@
using LibHac;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Sf;
using Ryujinx.Common;
@ -7,11 +8,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IFile : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> _baseFile;
private SharedRef<LibHac.FsSrv.Sf.IFile> _baseFile;
public IFile(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> baseFile)
public IFile(ref SharedRef<LibHac.FsSrv.Sf.IFile> baseFile)
{
_baseFile = baseFile;
_baseFile = SharedRef<LibHac.FsSrv.Sf.IFile>.CreateMove(ref baseFile);
}
[CommandHipc(0)]
@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
byte[] data = new byte[context.Request.ReceiveBuff[0].Size];
Result result = _baseFile.Target.Read(out long bytesRead, offset, new OutBuffer(data), size, readOption);
Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(data), size, readOption);
context.Memory.Write(position, data);
@ -53,14 +54,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
context.Memory.Read(position, data);
return (ResultCode)_baseFile.Target.Write(offset, new InBuffer(data), size, writeOption).Value;
return (ResultCode)_baseFile.Get.Write(offset, new InBuffer(data), size, writeOption).Value;
}
[CommandHipc(2)]
// Flush()
public ResultCode Flush(ServiceCtx context)
{
return (ResultCode)_baseFile.Target.Flush().Value;
return (ResultCode)_baseFile.Get.Flush().Value;
}
[CommandHipc(3)]
@ -69,14 +70,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
long size = context.RequestData.ReadInt64();
return (ResultCode)_baseFile.Target.SetSize(size).Value;
return (ResultCode)_baseFile.Get.SetSize(size).Value;
}
[CommandHipc(4)]
// GetSize() -> u64 fileSize
public ResultCode GetSize(ServiceCtx context)
{
Result result = _baseFile.Target.GetSize(out long size);
Result result = _baseFile.Get.GetSize(out long size);
context.ResponseData.Write(size);
@ -87,7 +88,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
if (isDisposing)
{
_baseFile?.Dispose();
_baseFile.Destroy();
}
}
}

View file

@ -1,21 +1,22 @@
using LibHac;
using LibHac.Common;
using LibHac.Fs;
using LibHac.FsSrv.Sf;
using Path = LibHac.FsSrv.Sf.Path;
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IFileSystem : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> _fileSystem;
private SharedRef<LibHac.FsSrv.Sf.IFileSystem> _fileSystem;
public IFileSystem(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> provider)
public IFileSystem(ref SharedRef<LibHac.FsSrv.Sf.IFileSystem> provider)
{
_fileSystem = provider;
_fileSystem = SharedRef<LibHac.FsSrv.Sf.IFileSystem>.CreateMove(ref provider);
}
public ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystem> GetBaseFileSystem()
public SharedRef<LibHac.FsSrv.Sf.IFileSystem> GetBaseFileSystem()
{
return _fileSystem;
return SharedRef<LibHac.FsSrv.Sf.IFileSystem>.CreateCopy(in _fileSystem);
}
[CommandHipc(0)]
@ -29,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
long size = context.RequestData.ReadInt64();
return (ResultCode)_fileSystem.Target.CreateFile(in name, size, createOption).Value;
return (ResultCode)_fileSystem.Get.CreateFile(in name, size, createOption).Value;
}
[CommandHipc(1)]
@ -38,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteFile(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteFile(in name).Value;
}
[CommandHipc(2)]
@ -47,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.CreateDirectory(in name).Value;
return (ResultCode)_fileSystem.Get.CreateDirectory(in name).Value;
}
[CommandHipc(3)]
@ -56,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteDirectory(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteDirectory(in name).Value;
}
[CommandHipc(4)]
@ -65,7 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.DeleteDirectoryRecursively(in name).Value;
return (ResultCode)_fileSystem.Get.DeleteDirectoryRecursively(in name).Value;
}
[CommandHipc(5)]
@ -75,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
return (ResultCode)_fileSystem.Target.RenameFile(in currentName, in newName).Value;
return (ResultCode)_fileSystem.Get.RenameFile(in currentName, in newName).Value;
}
[CommandHipc(6)]
@ -85,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
ref readonly Path currentName = ref FileSystemProxyHelper.GetSfPath(context, index: 0);
ref readonly Path newName = ref FileSystemProxyHelper.GetSfPath(context, index: 1);
return (ResultCode)_fileSystem.Target.RenameDirectory(in currentName, in newName).Value;
return (ResultCode)_fileSystem.Get.RenameDirectory(in currentName, in newName).Value;
}
[CommandHipc(7)]
@ -94,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetEntryType(out uint entryType, in name);
Result result = _fileSystem.Get.GetEntryType(out uint entryType, in name);
context.ResponseData.Write((int)entryType);
@ -108,12 +109,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
Result result = _fileSystem.Target.OpenFile(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> file, in name, mode);
Result result = _fileSystem.Get.OpenFile(ref file.Ref(), in name, mode);
if (result.IsSuccess())
{
IFile fileInterface = new IFile(file);
IFile fileInterface = new IFile(ref file.Ref());
MakeObject(context, fileInterface);
}
@ -128,12 +130,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
uint mode = context.RequestData.ReadUInt32();
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
using var dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>();
Result result = _fileSystem.Target.OpenDirectory(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDirectory> dir, name, mode);
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref(), name, mode);
if (result.IsSuccess())
{
IDirectory dirInterface = new IDirectory(dir);
IDirectory dirInterface = new IDirectory(ref dir.Ref());
MakeObject(context, dirInterface);
}
@ -145,7 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
// Commit()
public ResultCode Commit(ServiceCtx context)
{
return (ResultCode)_fileSystem.Target.Commit().Value;
return (ResultCode)_fileSystem.Get.Commit().Value;
}
[CommandHipc(11)]
@ -154,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetFreeSpaceSize(out long size, in name);
Result result = _fileSystem.Get.GetFreeSpaceSize(out long size, in name);
context.ResponseData.Write(size);
@ -167,7 +170,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetTotalSpaceSize(out long size, in name);
Result result = _fileSystem.Get.GetTotalSpaceSize(out long size, in name);
context.ResponseData.Write(size);
@ -180,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
return (ResultCode)_fileSystem.Target.CleanDirectoryRecursively(in name).Value;
return (ResultCode)_fileSystem.Get.CleanDirectoryRecursively(in name).Value;
}
[CommandHipc(14)]
@ -189,7 +192,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
Result result = _fileSystem.Target.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, in name);
Result result = _fileSystem.Get.GetFileTimeStampRaw(out FileTimeStampRaw timestamp, in name);
context.ResponseData.Write(timestamp.Created);
context.ResponseData.Write(timestamp.Modified);
@ -209,7 +212,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
if (isDisposing)
{
_fileSystem?.Dispose();
_fileSystem.Destroy();
}
}
}

View file

@ -1,4 +1,5 @@
using LibHac;
using LibHac.Common;
using LibHac.Sf;
using Ryujinx.HLE.HOS.Ipc;
@ -6,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
class IStorage : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IStorage> _baseStorage;
private SharedRef<LibHac.FsSrv.Sf.IStorage> _baseStorage;
public IStorage(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IStorage> baseStorage)
public IStorage(ref SharedRef<LibHac.FsSrv.Sf.IStorage> baseStorage)
{
_baseStorage = baseStorage;
_baseStorage = SharedRef<LibHac.FsSrv.Sf.IStorage>.CreateMove(ref baseStorage);
}
[CommandHipc(0)]
@ -32,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
byte[] data = new byte[size];
Result result = _baseStorage.Target.Read((long)offset, new OutBuffer(data), (long)size);
Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(data), (long)size);
context.Memory.Write(buffDesc.Position, data);
@ -46,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
// GetSize() -> u64 size
public ResultCode GetSize(ServiceCtx context)
{
Result result = _baseStorage.Target.GetSize(out long size);
Result result = _baseStorage.Get.GetSize(out long size);
context.ResponseData.Write(size);
@ -57,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
{
if (isDisposing)
{
_baseStorage?.Dispose();
_baseStorage.Destroy();
}
}
}

View file

@ -1,22 +1,23 @@
using LibHac;
using LibHac.Common;
using LibHac.FsSrv;
namespace Ryujinx.HLE.HOS.Services.Fs
{
class IDeviceOperator : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDeviceOperator> _baseOperator;
private SharedRef<LibHac.FsSrv.Sf.IDeviceOperator> _baseOperator;
public IDeviceOperator(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDeviceOperator> baseOperator)
public IDeviceOperator(ref SharedRef<LibHac.FsSrv.Sf.IDeviceOperator> baseOperator)
{
_baseOperator = baseOperator;
_baseOperator = SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>.CreateMove(ref baseOperator);
}
[CommandHipc(0)]
// IsSdCardInserted() -> b8 is_inserted
public ResultCode IsSdCardInserted(ServiceCtx context)
{
Result result = _baseOperator.Target.IsSdCardInserted(out bool isInserted);
Result result = _baseOperator.Get.IsSdCardInserted(out bool isInserted);
context.ResponseData.Write(isInserted);
@ -27,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// IsGameCardInserted() -> b8 is_inserted
public ResultCode IsGameCardInserted(ServiceCtx context)
{
Result result = _baseOperator.Target.IsGameCardInserted(out bool isInserted);
Result result = _baseOperator.Get.IsGameCardInserted(out bool isInserted);
context.ResponseData.Write(isInserted);
@ -38,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// GetGameCardHandle() -> u32 gamecard_handle
public ResultCode GetGameCardHandle(ServiceCtx context)
{
Result result = _baseOperator.Target.GetGameCardHandle(out GameCardHandle handle);
Result result = _baseOperator.Get.GetGameCardHandle(out GameCardHandle handle);
context.ResponseData.Write(handle.Value);
@ -49,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
if (isDisposing)
{
_baseOperator?.Dispose();
_baseOperator.Destroy();
}
}
}

View file

@ -1,4 +1,5 @@
using LibHac;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Shim;
using LibHac.FsSrv;
@ -24,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[Service("fsp-srv")]
class IFileSystemProxy : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFileSystemProxy> _baseFileSystemProxy;
private SharedRef<LibHac.FsSrv.Sf.IFileSystemProxy> _baseFileSystemProxy;
public IFileSystemProxy(ServiceCtx context)
{
@ -67,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
}
FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
string extension = Path.GetExtension(fullPath);
string extension = System.IO.Path.GetExtension(fullPath);
if (extension == ".nca")
{
@ -102,11 +103,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenBisFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, in path, bisPartitionId);
Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref(), in path, bisPartitionId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -116,11 +118,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBisStorage(ServiceCtx context)
{
BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32();
using var storage = new SharedRef<IStorage>();
Result result = _baseFileSystemProxy.Target.OpenBisStorage(out ReferenceCountedDisposable<IStorage> storage, bisPartitionId);
Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref(), bisPartitionId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IStorage(storage));
MakeObject(context, new FileSystemProxy.IStorage(ref storage.Ref()));
return ResultCode.Success;
}
@ -129,17 +132,19 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// InvalidateBisCache() -> ()
public ResultCode InvalidateBisCache(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.InvalidateBisCache().Value;
return (ResultCode)_baseFileSystemProxy.Get.InvalidateBisCache().Value;
}
[CommandHipc(18)]
// OpenSdCardFileSystem() -> object<nn::fssrv::sf::IFileSystem>
public ResultCode OpenSdCardFileSystem(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenSdCardFileSystem(out var fileSystem);
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -148,7 +153,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// FormatSdCardFileSystem() -> ()
public ResultCode FormatSdCardFileSystem(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.FormatSdCardFileSystem().Value;
return (ResultCode)_baseFileSystemProxy.Get.FormatSdCardFileSystem().Value;
}
[CommandHipc(21)]
@ -157,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ulong saveDataId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.DeleteSaveDataFileSystem(saveDataId).Value;
return (ResultCode)_baseFileSystemProxy.Get.DeleteSaveDataFileSystem(saveDataId).Value;
}
[CommandHipc(22)]
@ -168,7 +173,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataCreationInfo creationInfo = context.RequestData.ReadStruct<SaveDataCreationInfo>();
SaveDataMetaInfo metaInfo = context.RequestData.ReadStruct<SaveDataMetaInfo>();
return (ResultCode)_baseFileSystemProxy.Target.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo).Value;
return (ResultCode)_baseFileSystemProxy.Get.CreateSaveDataFileSystem(in attribute, in creationInfo, in metaInfo).Value;
}
[CommandHipc(23)]
@ -178,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
SaveDataCreationInfo creationInfo = context.RequestData.ReadStruct<SaveDataCreationInfo>();
return (ResultCode)_baseFileSystemProxy.Target.CreateSaveDataFileSystemBySystemSaveDataId(in attribute, in creationInfo).Value;
return (ResultCode)_baseFileSystemProxy.Get.CreateSaveDataFileSystemBySystemSaveDataId(in attribute, in creationInfo).Value;
}
[CommandHipc(24)]
@ -188,7 +193,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] saveIdBuffer = new byte[context.Request.SendBuff[0].Size];
context.Memory.Read(context.Request.SendBuff[0].Position, saveIdBuffer);
return (ResultCode)_baseFileSystemProxy.Target.RegisterSaveDataFileSystemAtomicDeletion(new InBuffer(saveIdBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.RegisterSaveDataFileSystemAtomicDeletion(new InBuffer(saveIdBuffer)).Value;
}
[CommandHipc(25)]
@ -198,21 +203,21 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.DeleteSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId).Value;
return (ResultCode)_baseFileSystemProxy.Get.DeleteSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId).Value;
}
[CommandHipc(26)]
// FormatSdCardDryRun() -> ()
public ResultCode FormatSdCardDryRun(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.FormatSdCardDryRun().Value;
return (ResultCode)_baseFileSystemProxy.Get.FormatSdCardDryRun().Value;
}
[CommandHipc(27)]
// IsExFatSupported() -> (u8 isSupported)
public ResultCode IsExFatSupported(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.IsExFatSupported(out bool isSupported);
Result result = _baseFileSystemProxy.Get.IsExFatSupported(out bool isSupported);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(isSupported);
@ -227,7 +232,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
return (ResultCode)_baseFileSystemProxy.Target.DeleteSaveDataFileSystemBySaveDataAttribute(spaceId, in attribute).Value;
return (ResultCode)_baseFileSystemProxy.Get.DeleteSaveDataFileSystemBySaveDataAttribute(spaceId, in attribute).Value;
}
[CommandHipc(30)]
@ -236,11 +241,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
GameCardHandle handle = new GameCardHandle(context.RequestData.ReadInt32());
GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32();
using var storage = new SharedRef<IStorage>();
Result result = _baseFileSystemProxy.Target.OpenGameCardStorage(out ReferenceCountedDisposable<IStorage> storage, handle, partitionId);
Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref(), handle, partitionId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IStorage(storage));
MakeObject(context, new FileSystemProxy.IStorage(ref storage.Ref()));
return ResultCode.Success;
}
@ -251,11 +257,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
GameCardHandle handle = new GameCardHandle(context.RequestData.ReadInt32());
GameCardPartition partitionId = (GameCardPartition)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenGameCardFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, handle, partitionId);
Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref(), handle, partitionId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -269,7 +276,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
long dataSize = context.RequestData.ReadInt64();
long journalSize = context.RequestData.ReadInt64();
return (ResultCode)_baseFileSystemProxy.Target.ExtendSaveDataFileSystem(spaceId, saveDataId, dataSize, journalSize).Value;
return (ResultCode)_baseFileSystemProxy.Get.ExtendSaveDataFileSystem(spaceId, saveDataId, dataSize, journalSize).Value;
}
[CommandHipc(33)]
@ -278,7 +285,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ushort index = context.RequestData.ReadUInt16();
return (ResultCode)_baseFileSystemProxy.Target.DeleteCacheStorage(index).Value;
return (ResultCode)_baseFileSystemProxy.Get.DeleteCacheStorage(index).Value;
}
[CommandHipc(34)]
@ -287,7 +294,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ushort index = context.RequestData.ReadUInt16();
Result result = _baseFileSystemProxy.Target.GetCacheStorageSize(out long dataSize, out long journalSize, index);
Result result = _baseFileSystemProxy.Get.GetCacheStorageSize(out long dataSize, out long journalSize, index);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(dataSize);
@ -305,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataMetaInfo metaCreateInfo = context.RequestData.ReadStruct<SaveDataMetaInfo>();
HashSalt hashSalt = context.RequestData.ReadStruct<HashSalt>();
return (ResultCode)_baseFileSystemProxy.Target.CreateSaveDataFileSystemWithHashSalt(in attribute, in creationInfo, in metaCreateInfo, in hashSalt).Value;
return (ResultCode)_baseFileSystemProxy.Get.CreateSaveDataFileSystemWithHashSalt(in attribute, in creationInfo, in metaCreateInfo, in hashSalt).Value;
}
[CommandHipc(51)]
@ -314,11 +321,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, spaceId, in attribute);
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -329,11 +337,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataFileSystemBySystemSaveDataId(out ReferenceCountedDisposable<IFileSystem> fileSystem, spaceId, in attribute);
Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref(), spaceId, in attribute);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -344,11 +353,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenReadOnlySaveDataFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, spaceId, in attribute);
Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref(), spaceId, in attribute);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -363,7 +373,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] extraDataBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, extraDataBuffer);
Result result = _baseFileSystemProxy.Target.ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(new OutBuffer(extraDataBuffer), spaceId, saveDataId);
Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataBySaveDataSpaceId(new OutBuffer(extraDataBuffer), spaceId, saveDataId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.Memory.Write(context.Request.ReceiveBuff[0].Position, extraDataBuffer);
@ -380,7 +390,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] extraDataBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, extraDataBuffer);
Result result = _baseFileSystemProxy.Target.ReadSaveDataFileSystemExtraData(new OutBuffer(extraDataBuffer), saveDataId);
Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraData(new OutBuffer(extraDataBuffer), saveDataId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.Memory.Write(context.Request.ReceiveBuff[0].Position, extraDataBuffer);
@ -398,17 +408,19 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] extraDataBuffer = new byte[context.Request.SendBuff[0].Size];
context.Memory.Read(context.Request.SendBuff[0].Position, extraDataBuffer);
return (ResultCode)_baseFileSystemProxy.Target.WriteSaveDataFileSystemExtraData(saveDataId, spaceId, new InBuffer(extraDataBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.WriteSaveDataFileSystemExtraData(saveDataId, spaceId, new InBuffer(extraDataBuffer)).Value;
}
[CommandHipc(60)]
// OpenSaveDataInfoReader() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReader(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenSaveDataInfoReader(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader);
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new ISaveDataInfoReader(infoReader));
MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref()));
return ResultCode.Success;
}
@ -418,11 +430,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context)
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte();
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataInfoReaderBySaveDataSpaceId(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader, spaceId);
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref(), spaceId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new ISaveDataInfoReader(infoReader));
MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref()));
return ResultCode.Success;
}
@ -431,10 +444,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenSaveDataInfoReaderOnlyCacheStorage() -> object<nn::fssrv::sf::ISaveDataInfoReader>
public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenSaveDataInfoReaderOnlyCacheStorage(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader);
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new ISaveDataInfoReader(infoReader));
MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref()));
return ResultCode.Success;
}
@ -445,11 +460,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataInternalStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, spaceId, saveDataId);
Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref(), spaceId, saveDataId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -461,7 +477,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.UpdateSaveDataMacForDebug(spaceId, saveDataId).Value;
return (ResultCode)_baseFileSystemProxy.Get.UpdateSaveDataMacForDebug(spaceId, saveDataId).Value;
}
[CommandHipc(66)]
@ -476,7 +492,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] maskBuffer = new byte[context.Request.SendBuff[1].Size];
context.Memory.Read(context.Request.SendBuff[1].Position, maskBuffer);
return (ResultCode)_baseFileSystemProxy.Target.WriteSaveDataFileSystemExtraDataWithMask(saveDataId, spaceId, new InBuffer(extraDataBuffer), new InBuffer(maskBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.WriteSaveDataFileSystemExtraDataWithMask(saveDataId, spaceId, new InBuffer(extraDataBuffer), new InBuffer(maskBuffer)).Value;
}
[CommandHipc(67)]
@ -490,7 +506,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] infoBuffer = new byte[bufferLen];
Result result = _baseFileSystemProxy.Target.FindSaveDataWithFilter(out long count, new OutBuffer(infoBuffer), spaceId, in filter);
Result result = _baseFileSystemProxy.Get.FindSaveDataWithFilter(out long count, new OutBuffer(infoBuffer), spaceId, in filter);
if (result.IsFailure()) return (ResultCode)result.Value;
context.Memory.Write(bufferPosition, infoBuffer);
@ -504,11 +520,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
SaveDataFilter filter = context.RequestData.ReadStruct<SaveDataFilter>();
using var infoReader = new SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataInfoReaderWithFilter(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> infoReader, spaceId, in filter);
Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref(), spaceId, in filter);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new ISaveDataInfoReader(infoReader));
MakeObject(context, new ISaveDataInfoReader(ref infoReader.Ref()));
return ResultCode.Success;
}
@ -522,7 +539,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] outputBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer);
Result result = _baseFileSystemProxy.Target.ReadSaveDataFileSystemExtraDataBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute);
Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute);
if (result.IsFailure()) return (ResultCode)result.Value;
context.Memory.Write(context.Request.ReceiveBuff[0].Position, outputBuffer);
@ -542,7 +559,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] maskBuffer = new byte[context.Request.SendBuff[1].Size];
context.Memory.Read(context.Request.SendBuff[1].Position, maskBuffer);
return (ResultCode)_baseFileSystemProxy.Target.WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in attribute, spaceId, new InBuffer(extraDataBuffer), new InBuffer(maskBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.WriteSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(in attribute, spaceId, new InBuffer(extraDataBuffer), new InBuffer(maskBuffer)).Value;
}
[CommandHipc(71)]
@ -557,7 +574,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] outputBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer);
Result result = _baseFileSystemProxy.Target.ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute, new InBuffer(maskBuffer));
Result result = _baseFileSystemProxy.Get.ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(new OutBuffer(outputBuffer), spaceId, in attribute, new InBuffer(maskBuffer));
if (result.IsFailure()) return (ResultCode)result.Value;
context.Memory.Write(context.Request.ReceiveBuff[0].Position, outputBuffer);
@ -571,11 +588,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt32();
SaveDataMetaType metaType = (SaveDataMetaType)context.RequestData.ReadInt32();
SaveDataAttribute attribute = context.RequestData.ReadStruct<SaveDataAttribute>();
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
Result result = _baseFileSystemProxy.Target.OpenSaveDataMetaFile(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IFile> file, spaceId, in attribute, metaType);
Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref(), spaceId, in attribute, metaType);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new IFile(file));
MakeObject(context, new IFile(ref file.Ref()));
return ResultCode.Success;
}
@ -590,7 +608,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] outputBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, outputBuffer);
Result result = _baseFileSystemProxy.Target.ListAccessibleSaveDataOwnerId(out int readCount, new OutBuffer(outputBuffer), programId, startIndex, bufferCount);
Result result = _baseFileSystemProxy.Get.ListAccessibleSaveDataOwnerId(out int readCount, new OutBuffer(outputBuffer), programId, startIndex, bufferCount);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(readCount);
@ -602,11 +620,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenImageDirectoryFileSystem(ServiceCtx context)
{
ImageDirectoryId directoryId = (ImageDirectoryId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenImageDirectoryFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, directoryId);
Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref(), directoryId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -615,11 +634,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenBaseFileSystem(ServiceCtx context)
{
BaseFileSystemId fileSystemId = (BaseFileSystemId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenBaseFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, fileSystemId);
Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref(), fileSystemId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -628,11 +648,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenContentStorageFileSystem(ServiceCtx context)
{
ContentStorageId contentStorageId = (ContentStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenContentStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, contentStorageId);
Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref(), contentStorageId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -641,11 +662,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context)
{
CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenCloudBackupWorkStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, storageId);
Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref(), storageId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -654,11 +676,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenCustomStorageFileSystem(ServiceCtx context)
{
CustomStorageId customStorageId = (CustomStorageId)context.RequestData.ReadInt32();
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Target.OpenCustomStorageFileSystem(out ReferenceCountedDisposable<IFileSystem> fileSystem, customStorageId);
Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref(), customStorageId);
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -668,10 +691,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context)
{
var storage = context.Device.FileSystem.RomFs.AsStorage(true);
var sharedStorage = new ReferenceCountedDisposable<LibHac.Fs.IStorage>(storage);
ReferenceCountedDisposable<IStorage> sfStorage = StorageInterfaceAdapter.CreateShared(ref sharedStorage);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref()));
MakeObject(context, new FileSystemProxy.IStorage(sfStorage));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref()));
return ResultCode.Success;
}
@ -691,10 +714,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs
Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}");
var storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage);
var sharedStorage = new ReferenceCountedDisposable<LibHac.Fs.IStorage>(storage);
ReferenceCountedDisposable<IStorage> sfStorage = StorageInterfaceAdapter.CreateShared(ref sharedStorage);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref()));
MakeObject(context, new FileSystemProxy.IStorage(sfStorage));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref()));
return ResultCode.Success;
}
@ -726,10 +749,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs
LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
Nca nca = new Nca(context.Device.System.KeySet, ncaStorage);
LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
var sharedStorage = new ReferenceCountedDisposable<LibHac.Fs.IStorage>(romfsStorage);
ReferenceCountedDisposable<IStorage> sfStorage = StorageInterfaceAdapter.CreateShared(ref sharedStorage);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(romfsStorage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref()));
MakeObject(context, new FileSystemProxy.IStorage(sfStorage));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref()));
}
catch (HorizonResultException ex)
{
@ -757,10 +780,10 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context)
{
var storage = context.Device.FileSystem.RomFs.AsStorage(true);
var sharedStorage = new ReferenceCountedDisposable<LibHac.Fs.IStorage>(storage);
ReferenceCountedDisposable<IStorage> sfStorage = StorageInterfaceAdapter.CreateShared(ref sharedStorage);
using var sharedStorage = new SharedRef<LibHac.Fs.IStorage>(storage);
using var sfStorage = new SharedRef<IStorage>(new StorageInterfaceAdapter(ref sharedStorage.Ref()));
MakeObject(context, new FileSystemProxy.IStorage(sfStorage));
MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref()));
return ResultCode.Success;
}
@ -769,10 +792,12 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// OpenDataStorageByCurrentProcess() -> object<nn::fssrv::sf::IStorage> dataStorage
public ResultCode OpenDeviceOperator(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenDeviceOperator(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IDeviceOperator> deviceOperator);
using var deviceOperator = new SharedRef<LibHac.FsSrv.Sf.IDeviceOperator>();
Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new IDeviceOperator(deviceOperator));
MakeObject(context, new IDeviceOperator(ref deviceOperator.Ref()));
return ResultCode.Success;
}
@ -783,7 +808,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
long dataSize = context.RequestData.ReadInt64();
long journalSize = context.RequestData.ReadInt64();
Result result = _baseFileSystemProxy.Target.QuerySaveDataTotalSize(out long totalSize, dataSize, journalSize);
Result result = _baseFileSystemProxy.Get.QuerySaveDataTotalSize(out long totalSize, dataSize, journalSize);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(totalSize);
@ -794,7 +819,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandHipc(511)]
public ResultCode NotifySystemDataUpdateEvent(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.NotifySystemDataUpdateEvent().Value;
return (ResultCode)_baseFileSystemProxy.Get.NotifySystemDataUpdateEvent().Value;
}
[CommandHipc(523)]
@ -805,7 +830,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SdmmcPort port = context.RequestData.ReadStruct<SdmmcPort>();
SimulatingDeviceDetectionMode mode = context.RequestData.ReadStruct<SimulatingDeviceDetectionMode>();
return (ResultCode)_baseFileSystemProxy.Target.SimulateDeviceDetectionEvent(port, mode, signalEvent).Value;
return (ResultCode)_baseFileSystemProxy.Get.SimulateDeviceDetectionEvent(port, mode, signalEvent).Value;
}
[CommandHipc(602)]
@ -816,7 +841,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] readBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, readBuffer);
return (ResultCode)_baseFileSystemProxy.Target.VerifySaveDataFileSystem(saveDataId, new OutBuffer(readBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.VerifySaveDataFileSystem(saveDataId, new OutBuffer(readBuffer)).Value;
}
[CommandHipc(603)]
@ -824,7 +849,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ulong saveDataId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.CorruptSaveDataFileSystem(saveDataId).Value;
return (ResultCode)_baseFileSystemProxy.Get.CorruptSaveDataFileSystem(saveDataId).Value;
}
[CommandHipc(604)]
@ -832,13 +857,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
long size = context.RequestData.ReadInt64();
return (ResultCode)_baseFileSystemProxy.Target.CreatePaddingFile(size).Value;
return (ResultCode)_baseFileSystemProxy.Get.CreatePaddingFile(size).Value;
}
[CommandHipc(605)]
public ResultCode DeleteAllPaddingFiles(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.DeleteAllPaddingFiles().Value;
return (ResultCode)_baseFileSystemProxy.Get.DeleteAllPaddingFiles().Value;
}
[CommandHipc(606)]
@ -847,7 +872,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
LibHac.Ncm.StorageId storageId = (LibHac.Ncm.StorageId)context.RequestData.ReadInt64();
ProgramId programId = context.RequestData.ReadStruct<ProgramId>();
Result result = _baseFileSystemProxy.Target.GetRightsId(out RightsId rightsId, programId, storageId);
Result result = _baseFileSystemProxy.Get.GetRightsId(out RightsId rightsId, programId, storageId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.WriteStruct(rightsId);
@ -861,13 +886,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs
RightsId rightsId = context.RequestData.ReadStruct<RightsId>();
AccessKey accessKey = context.RequestData.ReadStruct<AccessKey>();
return (ResultCode)_baseFileSystemProxy.Target.RegisterExternalKey(in rightsId, in accessKey).Value;
return (ResultCode)_baseFileSystemProxy.Get.RegisterExternalKey(in rightsId, in accessKey).Value;
}
[CommandHipc(608)]
public ResultCode UnregisterAllExternalKey(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.UnregisterAllExternalKey().Value;
return (ResultCode)_baseFileSystemProxy.Get.UnregisterAllExternalKey().Value;
}
[CommandHipc(609)]
@ -875,7 +900,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
Result result = _baseFileSystemProxy.Target.GetRightsIdByPath(out RightsId rightsId, in path);
Result result = _baseFileSystemProxy.Get.GetRightsIdByPath(out RightsId rightsId, in path);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.WriteStruct(rightsId);
@ -888,7 +913,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
Result result = _baseFileSystemProxy.Target.GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in path);
Result result = _baseFileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in path);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(keyGeneration);
@ -905,7 +930,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
context.RequestData.BaseStream.Seek(4, SeekOrigin.Current);
long time = context.RequestData.ReadInt64();
return (ResultCode)_baseFileSystemProxy.Target.SetCurrentPosixTimeWithTimeDifference(time, timeDifference).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetCurrentPosixTimeWithTimeDifference(time, timeDifference).Value;
}
[CommandHipc(612)]
@ -913,7 +938,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
SaveDataSpaceId spaceId = context.RequestData.ReadStruct<SaveDataSpaceId>();
Result result = _baseFileSystemProxy.Target.GetFreeSpaceSizeForSaveData(out long freeSpaceSize, spaceId);
Result result = _baseFileSystemProxy.Get.GetFreeSpaceSizeForSaveData(out long freeSpaceSize, spaceId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(freeSpaceSize);
@ -930,7 +955,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] readBuffer = new byte[context.Request.ReceiveBuff[0].Size];
context.Memory.Read(context.Request.ReceiveBuff[0].Position, readBuffer);
return (ResultCode)_baseFileSystemProxy.Target.VerifySaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId, new OutBuffer(readBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.VerifySaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId, new OutBuffer(readBuffer)).Value;
}
[CommandHipc(614)]
@ -939,7 +964,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.CorruptSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId).Value;
return (ResultCode)_baseFileSystemProxy.Get.CorruptSaveDataFileSystemBySaveDataSpaceId(spaceId, saveDataId).Value;
}
[CommandHipc(615)]
@ -948,7 +973,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
Result result = _baseFileSystemProxy.Target.QuerySaveDataInternalStorageTotalSize(out long size, spaceId, saveDataId);
Result result = _baseFileSystemProxy.Get.QuerySaveDataInternalStorageTotalSize(out long size, spaceId, saveDataId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(size);
@ -962,7 +987,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64();
ulong saveDataId = context.RequestData.ReadUInt64();
Result result = _baseFileSystemProxy.Target.GetSaveDataCommitId(out long commitId, spaceId, saveDataId);
Result result = _baseFileSystemProxy.Get.GetSaveDataCommitId(out long commitId, spaceId, saveDataId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(commitId);
@ -975,7 +1000,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
RightsId rightsId = context.RequestData.ReadStruct<RightsId>();
return (ResultCode)_baseFileSystemProxy.Target.UnregisterExternalKey(in rightsId).Value;
return (ResultCode)_baseFileSystemProxy.Get.UnregisterExternalKey(in rightsId).Value;
}
[CommandHipc(620)]
@ -983,7 +1008,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
EncryptionSeed encryptionSeed = context.RequestData.ReadStruct<EncryptionSeed>();
return (ResultCode)_baseFileSystemProxy.Target.SetSdCardEncryptionSeed(in encryptionSeed).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetSdCardEncryptionSeed(in encryptionSeed).Value;
}
[CommandHipc(630)]
@ -992,14 +1017,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
bool isAccessible = context.RequestData.ReadBoolean();
return (ResultCode)_baseFileSystemProxy.Target.SetSdCardAccessibility(isAccessible).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetSdCardAccessibility(isAccessible).Value;
}
[CommandHipc(631)]
// IsSdCardAccessible() -> u8 isAccessible
public ResultCode IsSdCardAccessible(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.IsSdCardAccessible(out bool isAccessible);
Result result = _baseFileSystemProxy.Get.IsSdCardAccessible(out bool isAccessible);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(isAccessible);
@ -1012,7 +1037,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ulong processId = context.RequestData.ReadUInt64();
Result result = _baseFileSystemProxy.Target.IsAccessFailureDetected(out bool isDetected, processId);
Result result = _baseFileSystemProxy.Get.IsAccessFailureDetected(out bool isDetected, processId);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(isDetected);
@ -1025,7 +1050,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ulong processId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.ResolveAccessFailure(processId).Value;
return (ResultCode)_baseFileSystemProxy.Get.ResolveAccessFailure(processId).Value;
}
[CommandHipc(720)]
@ -1033,13 +1058,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ulong processId = context.RequestData.ReadUInt64();
return (ResultCode)_baseFileSystemProxy.Target.AbandonAccessFailure(processId).Value;
return (ResultCode)_baseFileSystemProxy.Get.AbandonAccessFailure(processId).Value;
}
[CommandHipc(800)]
public ResultCode GetAndClearErrorInfo(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.GetAndClearErrorInfo(out FileSystemProxyErrorInfo errorInfo);
Result result = _baseFileSystemProxy.Get.GetAndClearErrorInfo(out FileSystemProxyErrorInfo errorInfo);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.WriteStruct(errorInfo);
@ -1055,7 +1080,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] mapInfoBuffer = new byte[context.Request.SendBuff[0].Size];
context.Memory.Read(context.Request.SendBuff[0].Position, mapInfoBuffer);
return (ResultCode)_baseFileSystemProxy.Target.RegisterProgramIndexMapInfo(new InBuffer(mapInfoBuffer), programCount).Value;
return (ResultCode)_baseFileSystemProxy.Get.RegisterProgramIndexMapInfo(new InBuffer(mapInfoBuffer), programCount).Value;
}
[CommandHipc(1000)]
@ -1064,7 +1089,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
BisPartitionId partitionId = (BisPartitionId)context.RequestData.ReadInt32();
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
return (ResultCode)_baseFileSystemProxy.Target.SetBisRootForHost(partitionId, in path).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetBisRootForHost(partitionId, in path).Value;
}
[CommandHipc(1001)]
@ -1073,7 +1098,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
long dataSize = context.RequestData.ReadInt64();
long journalSize = context.RequestData.ReadInt64();
return (ResultCode)_baseFileSystemProxy.Target.SetSaveDataSize(dataSize, journalSize).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetSaveDataSize(dataSize, journalSize).Value;
}
[CommandHipc(1002)]
@ -1081,13 +1106,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context);
return (ResultCode)_baseFileSystemProxy.Target.SetSaveDataRootPath(in path).Value;
return (ResultCode)_baseFileSystemProxy.Get.SetSaveDataRootPath(in path).Value;
}
[CommandHipc(1003)]
public ResultCode DisableAutoSaveDataCreation(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.DisableAutoSaveDataCreation().Value;
return (ResultCode)_baseFileSystemProxy.Get.DisableAutoSaveDataCreation().Value;
}
[CommandHipc(1004)]
@ -1127,16 +1152,18 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandHipc(1007)]
public ResultCode RegisterUpdatePartition(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.RegisterUpdatePartition().Value;
return (ResultCode)_baseFileSystemProxy.Get.RegisterUpdatePartition().Value;
}
[CommandHipc(1008)]
public ResultCode OpenRegisteredUpdatePartition(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenRegisteredUpdatePartition(out ReferenceCountedDisposable<IFileSystem> fileSystem);
using var fileSystem = new SharedRef<IFileSystem>();
Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new FileSystemProxy.IFileSystem(fileSystem));
MakeObject(context, new FileSystemProxy.IFileSystem(ref fileSystem.Ref()));
return ResultCode.Success;
}
@ -1144,7 +1171,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandHipc(1009)]
public ResultCode GetAndClearMemoryReportInfo(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.GetAndClearMemoryReportInfo(out MemoryReportInfo reportInfo);
Result result = _baseFileSystemProxy.Get.GetAndClearMemoryReportInfo(out MemoryReportInfo reportInfo);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.WriteStruct(reportInfo);
@ -1155,7 +1182,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandHipc(1011)]
public ResultCode GetProgramIndexForAccessLog(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.GetProgramIndexForAccessLog(out int programIndex, out int programCount);
Result result = _baseFileSystemProxy.Get.GetProgramIndexForAccessLog(out int programIndex, out int programCount);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(programIndex);
@ -1169,7 +1196,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
FsStackUsageThreadType threadType = context.RequestData.ReadStruct<FsStackUsageThreadType>();
Result result = _baseFileSystemProxy.Target.GetFsStackUsage(out uint usage, threadType);
Result result = _baseFileSystemProxy.Get.GetFsStackUsage(out uint usage, threadType);
if (result.IsFailure()) return (ResultCode)result.Value;
context.ResponseData.Write(usage);
@ -1180,19 +1207,19 @@ namespace Ryujinx.HLE.HOS.Services.Fs
[CommandHipc(1013)]
public ResultCode UnsetSaveDataRootPath(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.UnsetSaveDataRootPath().Value;
return (ResultCode)_baseFileSystemProxy.Get.UnsetSaveDataRootPath().Value;
}
[CommandHipc(1014)]
public ResultCode OutputMultiProgramTagAccessLog(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.OutputMultiProgramTagAccessLog().Value;
return (ResultCode)_baseFileSystemProxy.Get.OutputMultiProgramTagAccessLog().Value;
}
[CommandHipc(1016)]
public ResultCode FlushAccessLogOnSdCard(ServiceCtx context)
{
return (ResultCode)_baseFileSystemProxy.Target.FlushAccessLogOnSdCard().Value;
return (ResultCode)_baseFileSystemProxy.Get.FlushAccessLogOnSdCard().Value;
}
[CommandHipc(1017)]
@ -1200,7 +1227,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
ApplicationInfo info = context.RequestData.ReadStruct<ApplicationInfo>();
return (ResultCode)_baseFileSystemProxy.Target.OutputApplicationInfoAccessLog(in info).Value;
return (ResultCode)_baseFileSystemProxy.Get.OutputApplicationInfoAccessLog(in info).Value;
}
[CommandHipc(1100)]
@ -1209,7 +1236,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
byte[] keyBuffer = new byte[context.Request.SendBuff[0].Size];
context.Memory.Read(context.Request.SendBuff[0].Position, keyBuffer);
return (ResultCode)_baseFileSystemProxy.Target.OverrideSaveDataTransferTokenSignVerificationKey(new InBuffer(keyBuffer)).Value;
return (ResultCode)_baseFileSystemProxy.Get.OverrideSaveDataTransferTokenSignVerificationKey(new InBuffer(keyBuffer)).Value;
}
[CommandHipc(1110)]
@ -1219,17 +1246,19 @@ namespace Ryujinx.HLE.HOS.Services.Fs
ulong saveDataId = context.RequestData.ReadUInt64();
long offset = context.RequestData.ReadInt64();
return (ResultCode)_baseFileSystemProxy.Target.CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, offset).Value;
return (ResultCode)_baseFileSystemProxy.Get.CorruptSaveDataFileSystemByOffset(spaceId, saveDataId, offset).Value;
}
[CommandHipc(1200)] // 6.0.0+
// OpenMultiCommitManager() -> object<nn::fssrv::sf::IMultiCommitManager>
public ResultCode OpenMultiCommitManager(ServiceCtx context)
{
Result result = _baseFileSystemProxy.Target.OpenMultiCommitManager(out ReferenceCountedDisposable<LibHac.FsSrv.Sf.IMultiCommitManager> commitManager);
using var commitManager = new SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>();
Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref());
if (result.IsFailure()) return (ResultCode)result.Value;
MakeObject(context, new IMultiCommitManager(commitManager));
MakeObject(context, new IMultiCommitManager(ref commitManager.Ref()));
return ResultCode.Success;
}
@ -1238,7 +1267,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
if (isDisposing)
{
_baseFileSystemProxy?.Dispose();
_baseFileSystemProxy.Destroy();
}
}
}

View file

@ -1,24 +1,25 @@
using LibHac;
using LibHac.Common;
using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy;
namespace Ryujinx.HLE.HOS.Services.Fs
{
class IMultiCommitManager : DisposableIpcService // 6.0.0+
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.IMultiCommitManager> _baseCommitManager;
private SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager> _baseCommitManager;
public IMultiCommitManager(ReferenceCountedDisposable<LibHac.FsSrv.Sf.IMultiCommitManager> baseCommitManager)
public IMultiCommitManager(ref SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager> baseCommitManager)
{
_baseCommitManager = baseCommitManager;
_baseCommitManager = SharedRef<LibHac.FsSrv.Sf.IMultiCommitManager>.CreateMove(ref baseCommitManager);
}
[CommandHipc(1)] // 6.0.0+
// Add(object<nn::fssrv::sf::IFileSystem>)
public ResultCode Add(ServiceCtx context)
{
IFileSystem fileSystem = GetObject<IFileSystem>(context, 0);
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> fileSystem = GetObject<IFileSystem>(context, 0).GetBaseFileSystem();
Result result = _baseCommitManager.Target.Add(fileSystem.GetBaseFileSystem());
Result result = _baseCommitManager.Get.Add(ref fileSystem.Ref());
return (ResultCode)result.Value;
}
@ -27,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
// Commit()
public ResultCode Commit(ServiceCtx context)
{
Result result = _baseCommitManager.Target.Commit();
Result result = _baseCommitManager.Get.Commit();
return (ResultCode)result.Value;
}
@ -36,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
if (isDisposing)
{
_baseCommitManager?.Dispose();
_baseCommitManager.Destroy();
}
}
}

View file

@ -1,15 +1,16 @@
using LibHac;
using LibHac.Common;
using LibHac.Sf;
namespace Ryujinx.HLE.HOS.Services.Fs
{
class ISaveDataInfoReader : DisposableIpcService
{
private ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> _baseReader;
private SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> _baseReader;
public ISaveDataInfoReader(ReferenceCountedDisposable<LibHac.FsSrv.Sf.ISaveDataInfoReader> baseReader)
public ISaveDataInfoReader(ref SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader> baseReader)
{
_baseReader = baseReader;
_baseReader = SharedRef<LibHac.FsSrv.Sf.ISaveDataInfoReader>.CreateMove(ref baseReader);
}
[CommandHipc(0)]
@ -17,11 +18,11 @@ namespace Ryujinx.HLE.HOS.Services.Fs
public ResultCode ReadSaveDataInfo(ServiceCtx context)
{
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
byte[] infoBuffer = new byte[bufferLen];
Result result = _baseReader.Target.Read(out long readCount, new OutBuffer(infoBuffer));
Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(infoBuffer));
context.Memory.Write(bufferPosition, infoBuffer);
context.ResponseData.Write(readCount);
@ -33,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
{
if (isDisposing)
{
_baseReader?.Dispose();
_baseReader.Destroy();
}
}
}