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