mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add Ncm.ProgramLocation
This commit is contained in:
parent
1744e0a562
commit
52c0903f61
3 changed files with 42 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using LibHac.Common;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Fs.Shim;
|
||||
|
@ -50,12 +51,10 @@ namespace LibHac
|
|||
return new HorizonClient(this, new ProcessId(processId));
|
||||
}
|
||||
|
||||
public HorizonClient CreateHorizonClient(ProgramId programId, AccessControlBits.Bits fsPermissions)
|
||||
public HorizonClient CreateHorizonClient(ProgramLocation location, AccessControlBits.Bits fsPermissions)
|
||||
{
|
||||
HorizonClient client = CreateHorizonClient();
|
||||
|
||||
var dataHeader = new AccessControlDataHeader();
|
||||
var descriptor = new AccessControlDescriptor();
|
||||
var dataHeader = new AccessControlDataHeader();
|
||||
|
||||
descriptor.Version = 1;
|
||||
dataHeader.Version = 1;
|
||||
|
@ -63,11 +62,25 @@ namespace LibHac
|
|||
descriptor.AccessFlags = (ulong)fsPermissions;
|
||||
dataHeader.AccessFlags = (ulong)fsPermissions;
|
||||
|
||||
LoaderClient.Fs.RegisterProgram(client.ProcessId.Value, programId, StorageId.BuiltInUser,
|
||||
SpanHelpers.AsReadOnlyByteSpan(in dataHeader), SpanHelpers.AsReadOnlyByteSpan(in descriptor))
|
||||
.ThrowIfFailure();
|
||||
return CreateHorizonClientImpl(location, SpanHelpers.AsReadOnlyByteSpan(in dataHeader),
|
||||
SpanHelpers.AsReadOnlyByteSpan(in descriptor));
|
||||
}
|
||||
|
||||
public HorizonClient CreateHorizonClient(ProgramLocation location, ReadOnlySpan<byte> fsAccessControlData,
|
||||
ReadOnlySpan<byte> fsAccessControlDescriptor)
|
||||
{
|
||||
return CreateHorizonClientImpl(location, fsAccessControlData, fsAccessControlDescriptor);
|
||||
}
|
||||
|
||||
private HorizonClient CreateHorizonClientImpl(ProgramLocation location, ReadOnlySpan<byte> accessControlData,
|
||||
ReadOnlySpan<byte> accessControlDescriptor)
|
||||
{
|
||||
HorizonClient client = CreateHorizonClient();
|
||||
|
||||
LoaderClient.Fs.RegisterProgram(client.ProcessId.Value, location.ProgramId, location.StorageId,
|
||||
accessControlData, accessControlDescriptor).ThrowIfFailure();
|
||||
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
src/LibHac/Ncm/ProgramLocation.cs
Normal file
14
src/LibHac/Ncm/ProgramLocation.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
namespace LibHac.Ncm
|
||||
{
|
||||
public readonly struct ProgramLocation
|
||||
{
|
||||
public readonly ProgramId ProgramId;
|
||||
public readonly StorageId StorageId;
|
||||
|
||||
public ProgramLocation(ProgramId programId, StorageId storageId)
|
||||
{
|
||||
ProgramId = programId;
|
||||
StorageId = storageId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,11 +20,14 @@ namespace LibHac.Tests.FsSrv
|
|||
|
||||
var programs = new HorizonClient[count];
|
||||
|
||||
programs[0] = hos.CreateHorizonClient(new ProgramId(1), AccessControlBits.Bits.RegisterProgramIndexMapInfo);
|
||||
programs[0] = hos.CreateHorizonClient(new ProgramLocation(new ProgramId(1), StorageId.BuiltInSystem),
|
||||
AccessControlBits.Bits.RegisterProgramIndexMapInfo);
|
||||
|
||||
for (int i = 1; i < programs.Length; i++)
|
||||
{
|
||||
programs[i] = hos.CreateHorizonClient(new ProgramId((ulong)(i + 1)), AccessControlBits.Bits.None);
|
||||
programs[i] =
|
||||
hos.CreateHorizonClient(new ProgramLocation(new ProgramId((ulong)(i + 1)), StorageId.BuiltInSystem),
|
||||
AccessControlBits.Bits.None);
|
||||
}
|
||||
|
||||
var map = new ProgramIndexMapInfo[count];
|
||||
|
@ -191,4 +194,4 @@ namespace LibHac.Tests.FsSrv
|
|||
Assert.False(manager.Get(new ProgramId(2)).HasValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue