Ensure all complete shim classes are updated for 13.1.0

- ProgramIndexMapInfo
- ProgramRegistry
- SystemSaveData
This commit is contained in:
Alex Barney 2022-01-18 21:38:06 -07:00
parent 74ed435dee
commit c389f471d4
3 changed files with 36 additions and 19 deletions

View file

@ -1,11 +1,15 @@
using System;
using System.Runtime.InteropServices;
using LibHac.Common;
using LibHac.FsSrv.Sf;
using LibHac.Sf;
namespace LibHac.Fs.Shim;
/// <summary>
/// Contains functions for registering multi-program application
/// information of the currently running application with FS.
/// </summary>
/// <remarks>Based on nnSdk 13.4.0</remarks>
public static class ProgramIndexMapInfoShim
{
/// <summary>
@ -23,10 +27,10 @@ public static class ProgramIndexMapInfoShim
using SharedRef<IFileSystemProxy> fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject();
var mapInfoBuffer = new InBuffer(MemoryMarshal.Cast<ProgramIndexMapInfo, byte>(mapInfo));
Result rc = fileSystemProxy.Get.RegisterProgramIndexMapInfo(mapInfoBuffer, mapInfo.Length);
Result rc = fileSystemProxy.Get.RegisterProgramIndexMapInfo(InBuffer.FromSpan(mapInfo), mapInfo.Length);
fs.Impl.AbortIfNeeded(rc);
return rc;
if (rc.IsFailure()) return rc.Miss();
return Result.Success;
}
}

View file

@ -1,5 +1,6 @@
using System;
using LibHac.Common;
using LibHac.Diag;
using LibHac.FsSrv;
using LibHac.FsSrv.Sf;
using LibHac.Ncm;
@ -7,6 +8,11 @@ using LibHac.Sf;
namespace LibHac.Fs.Shim;
/// <summary>
/// Contains functions for registering and unregistering currently running
/// processes and their permissions in the FS program registry.
/// </summary>
/// <remarks>Based on nnSdk 13.4.0</remarks>
public static class ProgramRegistry
{
/// <inheritdoc cref="ProgramRegistryImpl.RegisterProgram"/>
@ -33,11 +39,8 @@ public static class ProgramRegistry
{
using SharedRef<IProgramRegistry> programRegistry = fs.Impl.GetProgramRegistryServiceObject();
Result rc = programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value);
if (rc.IsFailure()) return rc.Miss();
rc = programRegistry.Get.UnregisterProgram(processId);
if (rc.IsFailure()) return rc.Miss();
Abort.DoAbortUnlessSuccess(programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value));
Abort.DoAbortUnlessSuccess(programRegistry.Get.UnregisterProgram(processId));
return Result.Success;
}

View file

@ -11,6 +11,10 @@ using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
namespace LibHac.Fs.Shim;
/// <summary>
/// Contains functions for mounting system save data file systems.
/// </summary>
/// <remarks>Based on nnSdk 13.4.0</remarks>
[SkipLocalsInit]
public static class SystemSaveData
{
@ -19,18 +23,18 @@ public static class SystemSaveData
return fs.MountSystemSaveData(mountName, saveDataId, Fs.SaveData.InvalidUserId);
}
public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId,
ulong saveDataId)
{
return fs.MountSystemSaveData(mountName, spaceId, saveDataId, Fs.SaveData.InvalidUserId);
}
public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, ulong saveDataId,
UserId userId)
{
return fs.MountSystemSaveData(mountName, SaveDataSpaceId.System, saveDataId, userId);
}
public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId,
ulong saveDataId)
{
return fs.MountSystemSaveData(mountName, spaceId, saveDataId, Fs.SaveData.InvalidUserId);
}
public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName,
SaveDataSpaceId spaceId, ulong saveDataId, UserId userId)
{
@ -58,6 +62,11 @@ public static class SystemSaveData
}
fs.Impl.AbortIfNeeded(rc);
if (rc.IsFailure()) return rc.Miss();
if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System))
fs.Impl.EnableFileSystemAccessorAccessLog(mountName);
return rc;
static Result Mount(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId,
@ -86,8 +95,9 @@ public static class SystemSaveData
if (spaceId == SaveDataSpaceId.System)
{
using var mountNameGenerator = new UniqueRef<ICommonMountNameGenerator>();
return fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(),
ref mountNameGenerator.Ref(), false, null, false);
return fs.Register(mountName, multiCommitTarget: fileSystemAdapterRaw, ref fileSystemAdapter.Ref(),
ref mountNameGenerator.Ref(), useDataCache: false, storageForPurgeFileDataCache: null,
usePathCache: false);
}
else
{