mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Use file-scoped namespaces
This commit is contained in:
parent
6fe89a2966
commit
34dda02c38
@ -1 +1 @@
|
||||
5.0.402
|
||||
6.0.100
|
@ -22,10 +22,10 @@ using static Nuke.Common.IO.FileSystemTasks;
|
||||
using static Nuke.Common.IO.PathConstruction;
|
||||
using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
||||
|
||||
namespace LibHacBuild
|
||||
namespace LibHacBuild;
|
||||
|
||||
partial class Build : NukeBuild
|
||||
{
|
||||
partial class Build : NukeBuild
|
||||
{
|
||||
public static int Main() => Execute<Build>(x => x.Standard);
|
||||
|
||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||
@ -704,5 +704,4 @@ namespace LibHacBuild
|
||||
Logger.Error("\nError running stage 2 codegen. Skipping...\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using Nuke.Common;
|
||||
|
||||
namespace LibHacBuild.CodeGen
|
||||
namespace LibHacBuild.CodeGen;
|
||||
|
||||
public static class Common
|
||||
{
|
||||
public static class Common
|
||||
{
|
||||
public static string GetHeader()
|
||||
{
|
||||
string nl = Environment.NewLine;
|
||||
@ -105,5 +105,4 @@ namespace LibHacBuild.CodeGen
|
||||
|
||||
return Path.Combine(currentDir, "src");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace LibHacBuild.CodeGen
|
||||
namespace LibHacBuild.CodeGen;
|
||||
|
||||
public class IndentingStringBuilder
|
||||
{
|
||||
public class IndentingStringBuilder
|
||||
{
|
||||
public int LevelSize { get; set; } = 4;
|
||||
public int Level { get; private set; }
|
||||
|
||||
@ -85,5 +85,4 @@ namespace LibHacBuild.CodeGen
|
||||
}
|
||||
|
||||
public override string ToString() => _sb.ToString();
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using static LibHacBuild.CodeGen.Common;
|
||||
|
||||
namespace LibHacBuild.CodeGen.Stage1
|
||||
namespace LibHacBuild.CodeGen.Stage1;
|
||||
|
||||
public static class ResultCodeGen
|
||||
{
|
||||
public static class ResultCodeGen
|
||||
{
|
||||
// RyuJIT will always be inlined a function if its CIL size is <= 0x10 bytes
|
||||
private const int InlineThreshold = 0x10;
|
||||
|
||||
@ -499,10 +499,10 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ResultArchiveBuilder
|
||||
{
|
||||
public class ResultArchiveBuilder
|
||||
{
|
||||
private List<ResultInfo> Results = new List<ResultInfo>();
|
||||
|
||||
public void Add(ResultInfo result)
|
||||
@ -580,20 +580,20 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
public bool IsAbstract;
|
||||
}
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
}
|
||||
}
|
||||
|
||||
public class ModuleInfo
|
||||
{
|
||||
public class ModuleInfo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Namespace { get; set; }
|
||||
|
||||
public ResultInfo[] Results { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{" + nameof(ClassName) + ",nq}")]
|
||||
public class NamespaceInfo
|
||||
{
|
||||
[DebuggerDisplay("{" + nameof(ClassName) + ",nq}")]
|
||||
public class NamespaceInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ClassName { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
@ -602,11 +602,11 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
|
||||
public bool NeedsAggressiveInlining { get; set; }
|
||||
public ResultInfo[] Results { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{" + nameof(Name) + ",nq}")]
|
||||
public class ResultInfo
|
||||
{
|
||||
[DebuggerDisplay("{" + nameof(Name) + ",nq}")]
|
||||
public class ResultInfo
|
||||
{
|
||||
public int ModuleId { get; set; }
|
||||
public int DescriptionStart { get; set; }
|
||||
public int DescriptionEnd { get; set; }
|
||||
@ -621,24 +621,24 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
public string ErrorCode => $"{2000 + ModuleId:d4}-{DescriptionStart:d4}";
|
||||
public int InnerValue => ModuleId & 0x1ff | ((DescriptionStart & 0x7ffff) << 9);
|
||||
public bool IsAbstract => Flags.HasFlag(ResultInfoFlags.Abstract);
|
||||
}
|
||||
}
|
||||
|
||||
public class ResultSet
|
||||
{
|
||||
public class ResultSet
|
||||
{
|
||||
public List<ModuleInfo> Modules { get; set; }
|
||||
public List<NamespaceInfo> Namespaces { get; set; }
|
||||
public List<ResultInfo> Results { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ResultInfoFlags
|
||||
{
|
||||
[Flags]
|
||||
public enum ResultInfoFlags
|
||||
{
|
||||
None = 0,
|
||||
Abstract = 1 << 0
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModuleMap : ClassMap<ModuleInfo>
|
||||
{
|
||||
public sealed class ModuleMap : ClassMap<ModuleInfo>
|
||||
{
|
||||
public ModuleMap()
|
||||
{
|
||||
Map(m => m.Id);
|
||||
@ -652,10 +652,10 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
return field;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NamespaceMap : ClassMap<NamespaceInfo>
|
||||
{
|
||||
public sealed class NamespaceMap : ClassMap<NamespaceInfo>
|
||||
{
|
||||
public NamespaceMap()
|
||||
{
|
||||
Map(m => m.Name).Name("Namespace");
|
||||
@ -669,10 +669,10 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
return field;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ResultMap : ClassMap<ResultInfo>
|
||||
{
|
||||
public sealed class ResultMap : ClassMap<ResultInfo>
|
||||
{
|
||||
public ResultMap()
|
||||
{
|
||||
Map(m => m.ModuleId).Name("Module");
|
||||
@ -711,5 +711,4 @@ namespace LibHacBuild.CodeGen.Stage1
|
||||
return flags;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ using LibHac.Common.Keys;
|
||||
using LibHac.Crypto;
|
||||
using static LibHacBuild.CodeGen.Common;
|
||||
|
||||
namespace LibHacBuild.CodeGen.Stage2
|
||||
namespace LibHacBuild.CodeGen.Stage2;
|
||||
|
||||
public static class KeysCodeGen
|
||||
{
|
||||
public static class KeysCodeGen
|
||||
{
|
||||
private static string InputMainKeyFileName = "IncludedKeys.txt";
|
||||
private static string GeneratedFilePath = "LibHac/Common/Keys/DefaultKeySet.Generated.cs";
|
||||
|
||||
@ -389,5 +389,4 @@ namespace LibHacBuild.CodeGen.Stage2
|
||||
0xE7, 0x86, 0x3B, 0x4F, 0x8E, 0x13, 0x09, 0x47, 0x32, 0x0E, 0x04, 0xB8, 0x4D, 0x5B, 0xB0, 0x46,
|
||||
0x71, 0xB0, 0x5C, 0xF4, 0xAD, 0x63, 0x4F, 0xC5, 0xE2, 0xAC, 0x1E, 0xC4, 0x33, 0x96, 0x09, 0x7B
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
using System.IO;
|
||||
using Octokit;
|
||||
|
||||
namespace LibHacBuild.CodeGen.Stage2
|
||||
namespace LibHacBuild.CodeGen.Stage2;
|
||||
|
||||
// Some codegen depends on classes in LibHac.
|
||||
// The part that does is split out into a separate project so the main build project
|
||||
// doesn't depend on LibHac.
|
||||
public static class RunStage2
|
||||
{
|
||||
// Some codegen depends on classes in LibHac.
|
||||
// The part that does is split out into a separate project so the main build project
|
||||
// doesn't depend on LibHac.
|
||||
public static class RunStage2
|
||||
{
|
||||
private const string SolutionFileName = "LibHac.sln";
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
@ -22,5 +22,4 @@ namespace LibHacBuild.CodeGen.Stage2
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<RootNamespace>LibHacBuild.CodeGen</RootNamespace>
|
||||
<IsPackable>False</IsPackable>
|
||||
|
@ -11,10 +11,10 @@ using Nuke.Common.IO;
|
||||
using Nuke.Common.Tools.NuGet;
|
||||
using static Nuke.Common.IO.FileSystemTasks;
|
||||
|
||||
namespace LibHacBuild
|
||||
namespace LibHacBuild;
|
||||
|
||||
public partial class Build
|
||||
{
|
||||
public partial class Build
|
||||
{
|
||||
public void RepackNugetPackage(string path)
|
||||
{
|
||||
AbsolutePath tempDir = TempDirectory / Path.GetFileName(path);
|
||||
@ -132,5 +132,4 @@ namespace LibHacBuild
|
||||
{
|
||||
return BitConverter.ToString(arr).ToLower().Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<RootNamespace>LibHacBuild</RootNamespace>
|
||||
<IsPackable>False</IsPackable>
|
||||
|
@ -3,12 +3,12 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Account
|
||||
namespace LibHac.Account;
|
||||
|
||||
[DebuggerDisplay("0x{ToString(),nq}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Uid : IEquatable<Uid>, IComparable<Uid>, IComparable
|
||||
{
|
||||
[DebuggerDisplay("0x{ToString(),nq}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Uid : IEquatable<Uid>, IComparable<Uid>, IComparable
|
||||
{
|
||||
public static Uid Zero => default;
|
||||
|
||||
public readonly Id128 Id;
|
||||
@ -55,5 +55,4 @@ namespace LibHac.Account
|
||||
public static bool operator >(Uid left, Uid right) => left.CompareTo(right) > 0;
|
||||
public static bool operator <=(Uid left, Uid right) => left.CompareTo(right) <= 0;
|
||||
public static bool operator >=(Uid left, Uid right) => left.CompareTo(right) >= 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac
|
||||
namespace LibHac;
|
||||
|
||||
public readonly struct ApplicationId : IEquatable<ApplicationId>
|
||||
{
|
||||
public readonly struct ApplicationId : IEquatable<ApplicationId>
|
||||
{
|
||||
public static ApplicationId InvalidId => default;
|
||||
|
||||
public readonly ulong Value;
|
||||
@ -19,5 +19,4 @@ namespace LibHac
|
||||
public override bool Equals(object obj) => obj is ApplicationId id && Equals(id);
|
||||
public bool Equals(ApplicationId other) => Value == other.Value;
|
||||
public override int GetHashCode() => HashCode.Combine(Value);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Arp
|
||||
namespace LibHac.Arp;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x10)]
|
||||
public struct ApplicationLaunchProperty
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x10)]
|
||||
public struct ApplicationLaunchProperty
|
||||
{
|
||||
[FieldOffset(0x0)] public ApplicationId ApplicationId;
|
||||
[FieldOffset(0x8)] public uint Version;
|
||||
[FieldOffset(0xC)] public Ncm.StorageId BaseStorageId;
|
||||
[FieldOffset(0xD)] public Ncm.StorageId UpdateStorageId;
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ using LibHac.Arp.Impl;
|
||||
using LibHac.Common;
|
||||
using LibHac.Ns;
|
||||
|
||||
namespace LibHac.Arp
|
||||
namespace LibHac.Arp;
|
||||
|
||||
public class ArpClient : IDisposable
|
||||
{
|
||||
public class ArpClient : IDisposable
|
||||
{
|
||||
private HorizonClient _hosClient;
|
||||
private SharedRef<IReader> _reader;
|
||||
|
||||
@ -71,5 +71,4 @@ namespace LibHac.Arp
|
||||
_reader.SetByMove(ref reader.Ref());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using LibHac.Ns;
|
||||
|
||||
namespace LibHac.Arp.Impl
|
||||
namespace LibHac.Arp.Impl;
|
||||
|
||||
public interface IReader : IDisposable
|
||||
{
|
||||
public interface IReader : IDisposable
|
||||
{
|
||||
Result GetApplicationLaunchProperty(out ApplicationLaunchProperty launchProperty, ulong processId);
|
||||
Result GetApplicationLaunchPropertyWithApplicationId(out ApplicationLaunchProperty launchProperty, ApplicationId applicationId);
|
||||
Result GetApplicationControlProperty(out ApplicationControlProperty controlProperty, ulong processId);
|
||||
Result GetApplicationControlPropertyWithApplicationId(out ApplicationControlProperty controlProperty, ApplicationId applicationId);
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using LibHac.Bcat.Impl.Service.Core;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
public class BcatServer
|
||||
{
|
||||
public class BcatServer
|
||||
{
|
||||
private const int ServiceTypeCount = 4;
|
||||
|
||||
internal HorizonClient Hos { get; }
|
||||
@ -86,5 +86,4 @@ namespace LibHac.Bcat
|
||||
return StorageManager;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
public enum BcatServiceType
|
||||
{
|
||||
public enum BcatServiceType
|
||||
{
|
||||
BcatU,
|
||||
BcatS,
|
||||
BcatM,
|
||||
BcatA
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x38)]
|
||||
public struct DeliveryCacheDirectoryEntry
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x38)]
|
||||
public struct DeliveryCacheDirectoryEntry
|
||||
{
|
||||
[FieldOffset(0x00)] public FileName Name;
|
||||
[FieldOffset(0x20)] public long Size;
|
||||
[FieldOffset(0x28)] public Digest Digest;
|
||||
@ -15,5 +15,4 @@ namespace LibHac.Bcat
|
||||
Size = size;
|
||||
Digest = digest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 16)]
|
||||
public struct Digest
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 16)]
|
||||
public struct Digest
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy0;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy1;
|
||||
|
||||
@ -25,5 +25,4 @@ namespace LibHac.Bcat
|
||||
{
|
||||
return Bytes.ToHexString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = MaxSize)]
|
||||
public struct DirectoryName
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = MaxSize)]
|
||||
public struct DirectoryName
|
||||
{
|
||||
private const int MaxSize = 0x20;
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy0;
|
||||
@ -49,5 +49,4 @@ namespace LibHac.Bcat
|
||||
{
|
||||
return StringUtils.Utf8ZToString(Bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = MaxSize)]
|
||||
public struct FileName
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = MaxSize)]
|
||||
public struct FileName
|
||||
{
|
||||
private const int MaxSize = 0x20;
|
||||
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy0;
|
||||
@ -52,5 +52,4 @@ namespace LibHac.Bcat
|
||||
{
|
||||
return StringUtils.Utf8ZToString(Bytes);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,10 +2,10 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Sm;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
namespace LibHac.Bcat.Impl.Ipc;
|
||||
|
||||
internal class BcatServiceObject : IServiceObject
|
||||
{
|
||||
internal class BcatServiceObject : IServiceObject
|
||||
{
|
||||
private SharedRef<IServiceCreator> _serviceCreator;
|
||||
|
||||
public BcatServiceObject(ref SharedRef<IServiceCreator> serviceCreator)
|
||||
@ -23,5 +23,4 @@ namespace LibHac.Bcat.Impl.Ipc
|
||||
serviceObject.SetByCopy(in _serviceCreator);
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
namespace LibHac.Bcat.Impl.Ipc;
|
||||
|
||||
public interface IDeliveryCacheDirectoryService : IDisposable
|
||||
{
|
||||
public interface IDeliveryCacheDirectoryService : IDisposable
|
||||
{
|
||||
Result Open(ref DirectoryName name);
|
||||
Result Read(out int entriesRead, Span<DeliveryCacheDirectoryEntry> entryBuffer);
|
||||
Result GetCount(out int count);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
namespace LibHac.Bcat.Impl.Ipc;
|
||||
|
||||
public interface IDeliveryCacheFileService : IDisposable
|
||||
{
|
||||
public interface IDeliveryCacheFileService : IDisposable
|
||||
{
|
||||
Result Open(ref DirectoryName directoryName, ref FileName fileName);
|
||||
Result Read(out long bytesRead, long offset, Span<byte> destination);
|
||||
Result GetSize(out long size);
|
||||
Result GetDigest(out Digest digest);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
namespace LibHac.Bcat.Impl.Ipc;
|
||||
|
||||
public interface IDeliveryCacheStorageService : IDisposable
|
||||
{
|
||||
public interface IDeliveryCacheStorageService : IDisposable
|
||||
{
|
||||
Result CreateFileService(ref SharedRef<IDeliveryCacheFileService> outFileService);
|
||||
Result CreateDirectoryService(ref SharedRef<IDeliveryCacheDirectoryService> outDirectoryService);
|
||||
Result EnumerateDeliveryCacheDirectory(out int namesRead, Span<DirectoryName> nameBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Ipc
|
||||
namespace LibHac.Bcat.Impl.Ipc;
|
||||
|
||||
public interface IServiceCreator : IDisposable
|
||||
{
|
||||
public interface IServiceCreator : IDisposable
|
||||
{
|
||||
Result CreateDeliveryCacheStorageService(ref SharedRef<IDeliveryCacheStorageService> outService,
|
||||
ulong processId);
|
||||
|
||||
Result CreateDeliveryCacheStorageServiceWithApplicationId(
|
||||
ref SharedRef<IDeliveryCacheStorageService> outService, ApplicationId applicationId);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service
|
||||
namespace LibHac.Bcat.Impl.Service;
|
||||
|
||||
[Flags]
|
||||
internal enum AccessControl
|
||||
{
|
||||
[Flags]
|
||||
internal enum AccessControl
|
||||
{
|
||||
None = 0,
|
||||
MountOwnDeliveryCacheStorage = 1 << 1,
|
||||
MountOthersDeliveryCacheStorage = 1 << 2,
|
||||
DeliveryTaskManagement = 1 << 3,
|
||||
Debug = 1 << 4,
|
||||
All = ~0
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service.Core
|
||||
namespace LibHac.Bcat.Impl.Service.Core;
|
||||
|
||||
internal class DeliveryCacheDirectoryMetaAccessor
|
||||
{
|
||||
internal class DeliveryCacheDirectoryMetaAccessor
|
||||
{
|
||||
private const int MaxEntryCount = 100;
|
||||
private const int MetaFileHeaderValue = 1;
|
||||
|
||||
@ -97,5 +97,4 @@ namespace LibHac.Bcat.Impl.Service.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service.Core
|
||||
namespace LibHac.Bcat.Impl.Service.Core;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x40)]
|
||||
internal struct DeliveryCacheDirectoryMetaEntry
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x40)]
|
||||
internal struct DeliveryCacheDirectoryMetaEntry
|
||||
{
|
||||
[FieldOffset(0x00)] public DirectoryName Name;
|
||||
[FieldOffset(0x20)] public Digest Digest;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service.Core
|
||||
namespace LibHac.Bcat.Impl.Service.Core;
|
||||
|
||||
internal class DeliveryCacheFileMetaAccessor
|
||||
{
|
||||
internal class DeliveryCacheFileMetaAccessor
|
||||
{
|
||||
private const int MaxEntryCount = 100;
|
||||
private const int MetaFileHeaderValue = 1;
|
||||
|
||||
@ -118,5 +118,4 @@ namespace LibHac.Bcat.Impl.Service.Core
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service.Core
|
||||
namespace LibHac.Bcat.Impl.Service.Core;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x80)]
|
||||
internal struct DeliveryCacheFileMetaEntry
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x80)]
|
||||
internal struct DeliveryCacheFileMetaEntry
|
||||
{
|
||||
[FieldOffset(0x00)] public FileName Name;
|
||||
[FieldOffset(0x20)] public long Id;
|
||||
[FieldOffset(0x28)] public long Size;
|
||||
[FieldOffset(0x30)] public Digest Digest;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Shim;
|
||||
using static LibHac.Fs.StringTraits;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service.Core
|
||||
namespace LibHac.Bcat.Impl.Service.Core;
|
||||
|
||||
internal class DeliveryCacheStorageManager
|
||||
{
|
||||
internal class DeliveryCacheStorageManager
|
||||
{
|
||||
private const int MaxEntryCount = 4;
|
||||
|
||||
private BcatServer Server { get; }
|
||||
@ -395,5 +395,4 @@ namespace LibHac.Bcat.Impl.Service.Core
|
||||
|
||||
private static ReadOnlySpan<byte> FilesDirectoryName => // files
|
||||
new[] { (byte)'f', (byte)'i', (byte)'l', (byte)'e', (byte)'s' };
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ using LibHac.Bcat.Impl.Ipc;
|
||||
using LibHac.Bcat.Impl.Service.Core;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service
|
||||
namespace LibHac.Bcat.Impl.Service;
|
||||
|
||||
internal class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService
|
||||
{
|
||||
internal class DeliveryCacheDirectoryService : IDeliveryCacheDirectoryService
|
||||
{
|
||||
private BcatServer Server { get; }
|
||||
private object Locker { get; } = new object();
|
||||
private DeliveryCacheStorageService Parent { get; }
|
||||
@ -103,5 +103,4 @@ namespace LibHac.Bcat.Impl.Service
|
||||
{
|
||||
Parent.NotifyCloseDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service
|
||||
namespace LibHac.Bcat.Impl.Service;
|
||||
|
||||
internal class DeliveryCacheFileService : IDeliveryCacheFileService
|
||||
{
|
||||
internal class DeliveryCacheFileService : IDeliveryCacheFileService
|
||||
{
|
||||
private BcatServer Server { get; }
|
||||
private object Locker { get; } = new object();
|
||||
private DeliveryCacheStorageService Parent { get; }
|
||||
@ -119,5 +119,4 @@ namespace LibHac.Bcat.Impl.Service
|
||||
|
||||
Parent.NotifyCloseFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using LibHac.Bcat.Impl.Service.Core;
|
||||
using LibHac.Common;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service
|
||||
namespace LibHac.Bcat.Impl.Service;
|
||||
|
||||
internal class DeliveryCacheStorageService : IDeliveryCacheStorageService
|
||||
{
|
||||
internal class DeliveryCacheStorageService : IDeliveryCacheStorageService
|
||||
{
|
||||
private const int MaxOpenCount = 8;
|
||||
private BcatServer Server { get; }
|
||||
|
||||
@ -108,5 +108,4 @@ namespace LibHac.Bcat.Impl.Service
|
||||
{
|
||||
Server.GetStorageManager().Release(ApplicationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
using LibHac.Bcat.Impl.Ipc;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Bcat.Impl.Service
|
||||
namespace LibHac.Bcat.Impl.Service;
|
||||
|
||||
// Todo: Update BCAT service object management
|
||||
internal class ServiceCreator : IServiceCreator
|
||||
{
|
||||
// Todo: Update BCAT service object management
|
||||
internal class ServiceCreator : IServiceCreator
|
||||
{
|
||||
private BcatServer Server { get; }
|
||||
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Local
|
||||
@ -55,5 +55,4 @@ namespace LibHac.Bcat.Impl.Service
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
// code generation portion of the build.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace LibHac.Bcat
|
||||
namespace LibHac.Bcat;
|
||||
|
||||
public static class ResultBcat
|
||||
{
|
||||
public static class ResultBcat
|
||||
{
|
||||
public const int ModuleBcat = 122;
|
||||
|
||||
/// <summary>Error code: 2122-0001; Inner value: 0x27a</summary>
|
||||
@ -51,5 +51,4 @@ namespace LibHac.Bcat
|
||||
public static Result.Base InvalidDeliveryCacheStorageFile => new Result.Base(ModuleBcat, 204);
|
||||
/// <summary>Error code: 2122-0205; Inner value: 0x19a7a</summary>
|
||||
public static Result.Base StorageOpenLimitReached => new Result.Base(ModuleBcat, 205);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace LibHac
|
||||
namespace LibHac;
|
||||
|
||||
public class BitReader
|
||||
{
|
||||
public class BitReader
|
||||
{
|
||||
public byte[] Buffer { get; private set; }
|
||||
public int LengthBits { get; private set; }
|
||||
public int Position { get; set; }
|
||||
@ -129,5 +129,4 @@ namespace LibHac
|
||||
Positive = 1,
|
||||
Negative = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
namespace LibHac
|
||||
namespace LibHac;
|
||||
|
||||
public static class BitTools
|
||||
{
|
||||
public static class BitTools
|
||||
{
|
||||
public static int SignExtend32(int value, int bits)
|
||||
{
|
||||
int shift = 8 * sizeof(int) - bits;
|
||||
return (value << shift) >> shift;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ using LibHac.Common;
|
||||
using LibHac.Crypto;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Boot
|
||||
namespace LibHac.Boot;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0xB0)]
|
||||
public struct EncryptedKeyBlob
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0xB0)]
|
||||
public struct EncryptedKeyBlob
|
||||
{
|
||||
#if DEBUG
|
||||
[FieldOffset(0x00)] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Buffer32 _dummy1;
|
||||
[FieldOffset(0x20)] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Buffer32 _dummy2;
|
||||
@ -50,12 +50,12 @@ namespace LibHac.Boot
|
||||
}
|
||||
|
||||
public override readonly string ToString() => ReadOnlyBytes.ToHexString();
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x90)]
|
||||
public struct KeyBlob
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x90)]
|
||||
public struct KeyBlob
|
||||
{
|
||||
#if DEBUG
|
||||
[FieldOffset(0x00)] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Buffer32 _dummy1;
|
||||
[FieldOffset(0x20)] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Buffer32 _dummy2;
|
||||
@ -90,5 +90,4 @@ namespace LibHac.Boot
|
||||
}
|
||||
|
||||
public override readonly string ToString() => ReadOnlyBytes.ToHexString();
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,11 @@ using LibHac.Common.Keys;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Boot
|
||||
namespace LibHac.Boot;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x170)]
|
||||
public struct Package1MarikoOemHeader
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x170)]
|
||||
public struct Package1MarikoOemHeader
|
||||
{
|
||||
[FieldOffset(0x000)] private byte _aesMac;
|
||||
[FieldOffset(0x010)] private byte _rsaSig;
|
||||
[FieldOffset(0x110)] private byte _salt;
|
||||
@ -29,11 +29,11 @@ namespace LibHac.Boot
|
||||
public ReadOnlySpan<byte> Salt => SpanHelpers.CreateSpan(ref _salt, 0x20);
|
||||
public ReadOnlySpan<byte> Hash => SpanHelpers.CreateSpan(ref _hash, 0x20);
|
||||
public ReadOnlySpan<byte> Reserved => SpanHelpers.CreateSpan(ref _reserved, 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1MetaData
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1MetaData
|
||||
{
|
||||
[FieldOffset(0x00)] public uint LoaderHash;
|
||||
[FieldOffset(0x04)] public uint SecureMonitorHash;
|
||||
[FieldOffset(0x08)] public uint BootloaderHash;
|
||||
@ -43,20 +43,20 @@ namespace LibHac.Boot
|
||||
|
||||
public U8Span BuildDate => new U8Span(SpanHelpers.CreateSpan(ref _buildDate, 0xE));
|
||||
public ReadOnlySpan<byte> Iv => SpanHelpers.CreateSpan(ref _buildDate, 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1Stage1Footer
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1Stage1Footer
|
||||
{
|
||||
[FieldOffset(0x00)] public int Pk11Size;
|
||||
[FieldOffset(0x10)] private byte _iv;
|
||||
|
||||
public ReadOnlySpan<byte> Iv => SpanHelpers.CreateSpan(ref _iv, 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1Pk11Header
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x20)]
|
||||
public struct Package1Pk11Header
|
||||
{
|
||||
public const uint ExpectedMagic = 0x31314B50; // PK11
|
||||
|
||||
[FieldOffset(0x00)] public uint Magic;
|
||||
@ -66,17 +66,17 @@ namespace LibHac.Boot
|
||||
[FieldOffset(0x14)] public int BootloaderOffset;
|
||||
[FieldOffset(0x18)] public int SecureMonitorSize;
|
||||
[FieldOffset(0x1C)] public int SecureMonitorOffset;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Package1Section
|
||||
{
|
||||
public enum Package1Section
|
||||
{
|
||||
Bootloader,
|
||||
SecureMonitor,
|
||||
WarmBoot
|
||||
}
|
||||
}
|
||||
|
||||
public class Package1
|
||||
{
|
||||
public class Package1
|
||||
{
|
||||
private const int LegacyStage1Size = 0x4000;
|
||||
private const int ModernStage1Size = 0x7000;
|
||||
private const int MarikoWarmBootPlainTextSectionSize = 0x330;
|
||||
@ -550,5 +550,4 @@ namespace LibHac.Boot
|
||||
{
|
||||
(byte) '2', (byte) '0', (byte) '1', (byte) '8', (byte) '1', (byte) '1', (byte) '0', (byte) '7'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ using LibHac.Util;
|
||||
using System.Diagnostics;
|
||||
#endif
|
||||
|
||||
namespace LibHac.Boot
|
||||
namespace LibHac.Boot;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x200)]
|
||||
public struct Package2Header
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x200)]
|
||||
public struct Package2Header
|
||||
{
|
||||
internal const int Package2SizeMax = (1024 * 1024 * 8) - (1024 * 16); // 8MB - 16KB
|
||||
internal const int PayloadAlignment = 4;
|
||||
internal const int PayloadCount = 3;
|
||||
@ -38,11 +38,11 @@ namespace LibHac.Boot
|
||||
#if DEBUG
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] [FieldOffset(0x00)] private readonly Padding100 PaddingForVsDebugging;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x100)]
|
||||
public struct Package2Meta
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x100)]
|
||||
public struct Package2Meta
|
||||
{
|
||||
public const uint ExpectedMagicValue = 0x31324B50; // PK21
|
||||
|
||||
[FieldOffset(0x00)] private Buffer16 _headerIv;
|
||||
@ -160,5 +160,4 @@ namespace LibHac.Boot
|
||||
#if DEBUG
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] [FieldOffset(0x00)] private readonly Padding100 PaddingForVsDebugging;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Kernel;
|
||||
|
||||
namespace LibHac.Boot
|
||||
namespace LibHac.Boot;
|
||||
|
||||
/// <summary>
|
||||
/// Parses a package2 file and opens the payloads within.
|
||||
/// </summary>
|
||||
public class Package2StorageReader : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Parses a package2 file and opens the payloads within.
|
||||
/// </summary>
|
||||
public class Package2StorageReader : IDisposable
|
||||
{
|
||||
private const int KernelPayloadIndex = 0;
|
||||
private const int IniPayloadIndex = 1;
|
||||
|
||||
@ -266,5 +266,4 @@ namespace LibHac.Boot
|
||||
{
|
||||
return _header.Meta.PayloadSizes[IniPayloadIndex] != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace LibHac
|
||||
namespace LibHac;
|
||||
|
||||
public class Calibration
|
||||
{
|
||||
public class Calibration
|
||||
{
|
||||
public const string ExpectedMagic = "CAL0";
|
||||
|
||||
public string Magic;
|
||||
@ -271,5 +271,4 @@ namespace LibHac
|
||||
stream.Position = 0x4340;
|
||||
ConsoleSixAxisSensorMountType = reader.ReadBytes(0x1);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,10 @@ using LibHac.FsSystem.NcaUtils;
|
||||
using LibHac.Ncm;
|
||||
using ContentType = LibHac.Ncm.ContentType;
|
||||
|
||||
namespace LibHac
|
||||
namespace LibHac;
|
||||
|
||||
public class Cnmt
|
||||
{
|
||||
public class Cnmt
|
||||
{
|
||||
public ulong TitleId { get; }
|
||||
public TitleVersion TitleVersion { get; }
|
||||
public ContentMetaType Type { get; }
|
||||
@ -91,10 +91,10 @@ namespace LibHac
|
||||
Hash = reader.ReadBytes(0x20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtContentEntry
|
||||
{
|
||||
public class CnmtContentEntry
|
||||
{
|
||||
public byte[] Hash { get; set; }
|
||||
public byte[] NcaId { get; set; }
|
||||
public long Size { get; set; }
|
||||
@ -111,10 +111,10 @@ namespace LibHac
|
||||
Type = (ContentType)reader.ReadByte();
|
||||
reader.BaseStream.Position += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtContentMetaEntry
|
||||
{
|
||||
public class CnmtContentMetaEntry
|
||||
{
|
||||
public ulong TitleId { get; }
|
||||
public TitleVersion Version { get; }
|
||||
public ContentType Type { get; }
|
||||
@ -128,10 +128,10 @@ namespace LibHac
|
||||
Type = (ContentType)reader.ReadByte();
|
||||
reader.BaseStream.Position += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtExtended
|
||||
{
|
||||
public class CnmtExtended
|
||||
{
|
||||
public int PrevMetaCount { get; }
|
||||
public int PrevDeltaSetCount { get; }
|
||||
public int DeltaSetCount { get; }
|
||||
@ -202,10 +202,10 @@ namespace LibHac
|
||||
FragmentMap[i] = new FragmentMapEntry(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtPrevMetaEntry
|
||||
{
|
||||
public class CnmtPrevMetaEntry
|
||||
{
|
||||
public ulong TitleId { get; }
|
||||
public TitleVersion Version { get; }
|
||||
public ContentMetaType Type { get; }
|
||||
@ -225,10 +225,10 @@ namespace LibHac
|
||||
CnmtPrevMetaEntryField32 = reader.ReadInt16();
|
||||
CnmtPrevMetaEntryField34 = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtPrevDelta
|
||||
{
|
||||
public class CnmtPrevDelta
|
||||
{
|
||||
public ulong TitleIdOld { get; }
|
||||
public ulong TitleIdNew { get; }
|
||||
public TitleVersion VersionOld { get; }
|
||||
@ -245,10 +245,10 @@ namespace LibHac
|
||||
Size = reader.ReadInt64();
|
||||
CnmtPrevDeltaField20 = reader.ReadInt64();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtDeltaSetInfo
|
||||
{
|
||||
public class CnmtDeltaSetInfo
|
||||
{
|
||||
public ulong TitleIdOld { get; }
|
||||
public ulong TitleIdNew { get; }
|
||||
public TitleVersion VersionOld { get; }
|
||||
@ -265,10 +265,10 @@ namespace LibHac
|
||||
FragmentSetCount = reader.ReadInt64();
|
||||
DeltaContentCount = reader.ReadInt64();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtFragmentSetInfo
|
||||
{
|
||||
public class CnmtFragmentSetInfo
|
||||
{
|
||||
public byte[] NcaIdOld { get; }
|
||||
public byte[] NcaIdNew { get; }
|
||||
public long SizeOld { get; }
|
||||
@ -294,10 +294,10 @@ namespace LibHac
|
||||
DeltaType = (UpdateType)reader.ReadByte();
|
||||
FragmentSetInfoField30 = reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CnmtPrevContent
|
||||
{
|
||||
public class CnmtPrevContent
|
||||
{
|
||||
public byte[] NcaId { get; }
|
||||
public long Size { get; }
|
||||
public ContentType Type { get; }
|
||||
@ -310,10 +310,10 @@ namespace LibHac
|
||||
Type = (ContentType)reader.ReadByte();
|
||||
reader.BaseStream.Position += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FragmentMapEntry
|
||||
{
|
||||
public class FragmentMapEntry
|
||||
{
|
||||
public short ContentIndex { get; }
|
||||
public short FragmentIndex { get; }
|
||||
|
||||
@ -322,5 +322,4 @@ namespace LibHac
|
||||
ContentIndex = reader.ReadInt16();
|
||||
FragmentIndex = reader.ReadInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@ using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a representation of a region of memory as if it were a series of blittable structs
|
||||
/// of type <typeparamref name="T"/>. Also allows viewing the memory as a <see cref="Span{T}"/> of bytes.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The element type.</typeparam>
|
||||
public ref struct BlitSpan<T> where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a representation of a region of memory as if it were a series of blittable structs
|
||||
/// of type <typeparamref name="T"/>. Also allows viewing the memory as a <see cref="Span{T}"/> of bytes.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The element type.</typeparam>
|
||||
public ref struct BlitSpan<T> where T : unmanaged
|
||||
{
|
||||
private readonly Span<T> _buffer;
|
||||
|
||||
/// <summary>
|
||||
@ -106,5 +106,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return Unsafe.SizeOf<T>() * elementCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Handles storing a blittable struct or a series of blittable structs in a byte array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The element type.</typeparam>
|
||||
public readonly struct BlitStruct<T> where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles storing a blittable struct or a series of blittable structs in a byte array.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The element type.</typeparam>
|
||||
public readonly struct BlitStruct<T> where T : unmanaged
|
||||
{
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
public int Length => _buffer.Length / Unsafe.SizeOf<T>();
|
||||
@ -66,5 +66,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return Unsafe.SizeOf<T>() * elementCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,16 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a buffer of 16 bytes.
|
||||
/// Contains functions that assist with common operations on small buffers.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 16)]
|
||||
public struct Buffer16
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a buffer of 16 bytes.
|
||||
/// Contains functions that assist with common operations on small buffers.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 16)]
|
||||
public struct Buffer16
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy0;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy1;
|
||||
|
||||
@ -65,12 +65,12 @@ namespace LibHac.Common
|
||||
{
|
||||
return Bytes.ToHexString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 32)]
|
||||
public struct Buffer32
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 32)]
|
||||
public struct Buffer32
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy0;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy1;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private ulong _dummy2;
|
||||
@ -124,5 +124,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return Bytes.ToHexString();
|
||||
}
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array1<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array1<T>
|
||||
{
|
||||
public const int Length = 1;
|
||||
|
||||
private T _1;
|
||||
@ -18,5 +18,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array1<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array12<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array12<T>
|
||||
{
|
||||
public const int Length = 12;
|
||||
|
||||
private T _1;
|
||||
@ -29,5 +29,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array12<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array128<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array128<T>
|
||||
{
|
||||
public const int Length = 128;
|
||||
|
||||
private Array64<T> _0;
|
||||
@ -28,5 +28,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array128<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array16<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array16<T>
|
||||
{
|
||||
public const int Length = 16;
|
||||
|
||||
private Array8<T> _0;
|
||||
@ -28,5 +28,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array16<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array2<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array2<T>
|
||||
{
|
||||
public const int Length = 2;
|
||||
|
||||
private T _1;
|
||||
@ -19,5 +19,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array2<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array256<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array256<T>
|
||||
{
|
||||
public const int Length = 256;
|
||||
|
||||
private Array128<T> _0;
|
||||
@ -28,5 +28,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array256<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array3<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array3<T>
|
||||
{
|
||||
public const int Length = 3;
|
||||
|
||||
private T _1;
|
||||
@ -20,5 +20,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array3<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array32<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array32<T>
|
||||
{
|
||||
public const int Length = 32;
|
||||
|
||||
private Array16<T> _0;
|
||||
@ -28,5 +28,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array32<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array4<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array4<T>
|
||||
{
|
||||
public const int Length = 4;
|
||||
|
||||
private T _1;
|
||||
@ -21,5 +21,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array4<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array5<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array5<T>
|
||||
{
|
||||
public const int Length = 5;
|
||||
|
||||
private T _1;
|
||||
@ -22,5 +22,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array5<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array64<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array64<T>
|
||||
{
|
||||
public const int Length = 64;
|
||||
|
||||
private Array32<T> _0;
|
||||
@ -28,5 +28,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array64<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common.FixedArrays
|
||||
namespace LibHac.Common.FixedArrays;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array8<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Array8<T>
|
||||
{
|
||||
public const int Length = 8;
|
||||
|
||||
private T _1;
|
||||
@ -25,5 +25,4 @@ namespace LibHac.Common.FixedArrays
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<T>(in Array8<T> value) => value.ItemsRo;
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LibHac.Fs;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal static class HResult
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal static class HResult
|
||||
{
|
||||
public const int ERROR_FILE_NOT_FOUND = unchecked((int)0x80070002);
|
||||
public const int ERROR_PATH_NOT_FOUND = unchecked((int)0x80070003);
|
||||
public const int ERROR_ACCESS_DENIED = unchecked((int)0x80070005);
|
||||
@ -37,5 +37,4 @@ namespace LibHac.Common
|
||||
ERROR_SPACES_NOT_ENOUGH_DRIVES => ResultFs.UsableSpaceNotEnough.Value,
|
||||
_ => ResultFs.UnexpectedInLocalFileSystemE.Value
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// A generic 128-bit ID value.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Id128 : IEquatable<Id128>, IComparable<Id128>, IComparable
|
||||
{
|
||||
/// <summary>
|
||||
/// A generic 128-bit ID value.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Id128 : IEquatable<Id128>, IComparable<Id128>, IComparable
|
||||
{
|
||||
public readonly ulong High;
|
||||
public readonly ulong Low;
|
||||
|
||||
@ -81,5 +81,4 @@ namespace LibHac.Common
|
||||
public static bool operator >(Id128 left, Id128 right) => left.CompareTo(right) > 0;
|
||||
public static bool operator <=(Id128 left, Id128 right) => left.CompareTo(right) <= 0;
|
||||
public static bool operator >=(Id128 left, Id128 right) => left.CompareTo(right) >= 0;
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
internal readonly ref struct InitializationGuard
|
||||
{
|
||||
internal readonly ref struct InitializationGuard
|
||||
{
|
||||
private readonly Ref<nint> _guard;
|
||||
private readonly object _mutex;
|
||||
public bool IsInitialized => _mutex == null;
|
||||
@ -91,5 +91,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return (guard & 1) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable 649
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static unsafe class InteropWin32
|
||||
{
|
||||
public static unsafe class InteropWin32
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern int MultiByteToWideChar(uint codePage, uint dwFlags, byte* lpMultiByteStr,
|
||||
int cbMultiByte, char* lpWideCharStr, int cchWideChar);
|
||||
@ -60,5 +60,4 @@ namespace LibHac.Common
|
||||
public Span<char> FileName => MemoryMarshal.CreateSpan(ref _fileName[0], 260);
|
||||
public Span<char> AlternateFileName => MemoryMarshal.CreateSpan(ref _alternateFileName[0], 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Key128 : IEquatable<Key128>
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
public struct Key128 : IEquatable<Key128>
|
||||
{
|
||||
private readonly ulong _dummy1;
|
||||
private readonly ulong _dummy2;
|
||||
|
||||
@ -42,5 +42,4 @@ namespace LibHac.Common
|
||||
|
||||
public static bool operator ==(Key128 left, Key128 right) => left.Equals(right);
|
||||
public static bool operator !=(Key128 left, Key128 right) => !(left == right);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
internal static partial class DefaultKeySet
|
||||
{
|
||||
internal static partial class DefaultKeySet
|
||||
{
|
||||
private static ReadOnlySpan<byte> RootKeysDev => new byte[] { };
|
||||
private static ReadOnlySpan<byte> RootKeysProd => new byte[] { };
|
||||
private static ReadOnlySpan<byte> KeySeeds => new byte[] { };
|
||||
@ -15,5 +15,4 @@ namespace LibHac.Common.Keys
|
||||
private static ReadOnlySpan<byte> RsaSigningKeysDev => new byte[] { };
|
||||
private static ReadOnlySpan<byte> RsaSigningKeysProd => new byte[] { };
|
||||
private static ReadOnlySpan<byte> RsaKeys => new byte[] { };
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using System.Runtime.InteropServices;
|
||||
|
||||
using Type = LibHac.Common.Keys.KeyInfo.KeyType;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
internal static partial class DefaultKeySet
|
||||
{
|
||||
internal static partial class DefaultKeySet
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="KeySet"/> that contains any keys that have been embedded in the library.
|
||||
/// </summary>
|
||||
@ -177,5 +177,4 @@ namespace LibHac.Common.Keys
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ using LibHac.Fs;
|
||||
using LibHac.Spl;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
public static class ExternalKeyReader
|
||||
{
|
||||
public static class ExternalKeyReader
|
||||
{
|
||||
private const int ReadBufferSize = 1024;
|
||||
|
||||
// Contains info from a specific key being read from a file
|
||||
@ -584,5 +584,4 @@ namespace LibHac.Common.Keys
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ using LibHac.Util;
|
||||
using Type = LibHac.Common.Keys.KeyInfo.KeyType;
|
||||
using RangeType = LibHac.Common.Keys.KeyInfo.KeyRangeType;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
public static class ExternalKeyWriter
|
||||
{
|
||||
public static class ExternalKeyWriter
|
||||
{
|
||||
public static void PrintKeys(KeySet keySet, StringBuilder sb, List<KeyInfo> keys, Type filter, bool isDev)
|
||||
{
|
||||
if (keys.Count == 0) return;
|
||||
@ -169,5 +169,4 @@ namespace LibHac.Common.Keys
|
||||
keySet.SetMode(originalMode);
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using LibHac.Crypto;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
internal static class KeyDerivation
|
||||
{
|
||||
internal static class KeyDerivation
|
||||
{
|
||||
public static void DeriveAllKeys(KeySet keySet, IProgressReport logger = null)
|
||||
{
|
||||
DeriveKeyBlobKeys(keySet);
|
||||
@ -394,5 +394,4 @@ namespace LibHac.Common.Keys
|
||||
srcKek.Data.CopyTo(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ using System.Diagnostics;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
[DebuggerDisplay("{" + nameof(Name) + "}")]
|
||||
public readonly struct KeyInfo
|
||||
{
|
||||
[DebuggerDisplay("{" + nameof(Name) + "}")]
|
||||
public readonly struct KeyInfo
|
||||
{
|
||||
public enum KeyRangeType : byte
|
||||
{
|
||||
Single,
|
||||
@ -163,5 +163,4 @@ namespace LibHac.Common.Keys
|
||||
|
||||
return isValid1 && isValid2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ using LibHac.Crypto;
|
||||
using LibHac.FsSrv;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common.Keys
|
||||
namespace LibHac.Common.Keys;
|
||||
|
||||
public class KeySet
|
||||
{
|
||||
public class KeySet
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
Dev,
|
||||
@ -257,11 +257,11 @@ namespace LibHac.Common.Keys
|
||||
{
|
||||
public Optional<RSAParameters> BetaNca0KeyAreaKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AllKeys
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AllKeys
|
||||
{
|
||||
public RootKeys _rootKeysDev;
|
||||
public RootKeys _rootKeysProd;
|
||||
public KeySeeds _keySeeds;
|
||||
@ -273,11 +273,11 @@ namespace LibHac.Common.Keys
|
||||
public RsaSigningKeys _rsaSigningKeysDev;
|
||||
public RsaSigningKeys _rsaSigningKeysProd;
|
||||
public RsaKeys _rsaKeys;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RootKeys
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RootKeys
|
||||
{
|
||||
// Mariko keys. The AES class keys are currently unused.
|
||||
public AesKey MarikoKek;
|
||||
public AesKey MarikoBek;
|
||||
@ -296,11 +296,11 @@ namespace LibHac.Common.Keys
|
||||
|
||||
// Derived by TSEC. This is the first public root key for >= 6.2.0 Erista
|
||||
public Array32<AesKey> TsecRootKeys;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KeySeeds
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KeySeeds
|
||||
{
|
||||
public Array32<AesKey> KeyBlobKeySources;
|
||||
public AesKey KeyBlobMacKeySource;
|
||||
public Array32<AesKey> MasterKekSources;
|
||||
@ -326,20 +326,20 @@ namespace LibHac.Common.Keys
|
||||
public AesKey SeedUniqueSaveMacKekSource;
|
||||
public AesKey SeedUniqueSaveMacKeySource;
|
||||
public AesXtsKey HeaderKeySource;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds keys that are stored directly in Horizon programs.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct StoredKeys
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds keys that are stored directly in Horizon programs.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct StoredKeys
|
||||
{
|
||||
public AesKey XciHeaderKey;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DerivedKeys
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DerivedKeys
|
||||
{
|
||||
public Array32<AesKey> MasterKeks;
|
||||
public Array32<AesKey> MasterKeys;
|
||||
public Array32<AesKey> Package1MacKeys;
|
||||
@ -350,11 +350,11 @@ namespace LibHac.Common.Keys
|
||||
public AesXtsKey HeaderKey;
|
||||
public AesKey ETicketRsaKek;
|
||||
public AesKey SslRsaKek;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DeviceKeys
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DeviceKeys
|
||||
{
|
||||
public AesKey SecureBootKey;
|
||||
public AesKey TsecKey;
|
||||
public Array32<AesKey> KeyBlobKeys;
|
||||
@ -366,19 +366,18 @@ namespace LibHac.Common.Keys
|
||||
public AesKey SeedUniqueSaveMacKey;
|
||||
public AesKey SdCardEncryptionSeed;
|
||||
public Array3<AesXtsKey> SdCardEncryptionKeys;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RsaSigningKeys
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RsaSigningKeys
|
||||
{
|
||||
public Array2<RsaKey> NcaHeaderSigningKeys;
|
||||
public Array2<RsaKey> AcidSigningKeys;
|
||||
public RsaKey Package2SigningKey;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RsaKeys
|
||||
{
|
||||
public RsaFullKey BetaNca0KeyAreaKey;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RsaKeys
|
||||
{
|
||||
public RsaFullKey BetaNca0KeyAreaKey;
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace LibHac.Common
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableAttribute : Attribute { }
|
||||
namespace LibHac.Common;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableDisposableAttribute : Attribute { }
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Struct)]
|
||||
public sealed class NonCopyableDisposableAttribute : Attribute { }
|
||||
|
@ -1,52 +1,51 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
// In order for the Visual Studio debugger to accurately display a struct, every offset
|
||||
// in the struct that is used for the debugger display must be part of a field.
|
||||
// These padding structs make it easier to accomplish that.
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
internal struct Padding10
|
||||
{
|
||||
// In order for the Visual Studio debugger to accurately display a struct, every offset
|
||||
// in the struct that is used for the debugger display must be part of a field.
|
||||
// These padding structs make it easier to accomplish that.
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
internal struct Padding10
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding00;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding08;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
internal struct Padding20
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
internal struct Padding20
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding00;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding08;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding10;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly ulong Padding18;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
|
||||
internal struct Padding40
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
|
||||
internal struct Padding40
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding20 Padding00;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding20 Padding20;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x80)]
|
||||
internal struct Padding80
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x80)]
|
||||
internal struct Padding80
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding40 Padding00;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding40 Padding40;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x100)]
|
||||
internal struct Padding100
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x100)]
|
||||
internal struct Padding100
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding80 Padding00;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding80 Padding80;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
internal struct Padding200
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x200)]
|
||||
internal struct Padding200
|
||||
{
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding100 Padding000;
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly Padding100 Padding100;
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ using LibHac.Fs;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
internal ref struct PathBuilder
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
internal ref struct PathBuilder
|
||||
{
|
||||
private Span<byte> _buffer;
|
||||
private int _pos;
|
||||
|
||||
@ -120,5 +120,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return StringUtils.Utf8ZToString(_buffer.Slice(0, Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that can store a reference to a value of a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of value to reference.</typeparam>
|
||||
public readonly ref struct Ref<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that can store a reference to a value of a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of value to reference.</typeparam>
|
||||
public readonly ref struct Ref<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The 1-length <see cref="Span{T}"/> instance used to track the target <typeparamref name="T"/> value.
|
||||
/// </summary>
|
||||
@ -68,14 +68,14 @@ namespace LibHac.Common
|
||||
{
|
||||
return reference.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that can store a reference to a value of a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of value to reference.</typeparam>
|
||||
public readonly ref struct ReadOnlyRef<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="struct"/> that can store a reference to a value of a specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of value to reference.</typeparam>
|
||||
public readonly ref struct ReadOnlyRef<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The 1-length <see cref="ReadOnlySpan{T}"/> instance used to track the target <typeparamref name="T"/> value.
|
||||
/// </summary>
|
||||
@ -130,5 +130,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return reference.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,10 +2,10 @@
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public readonly ref struct RentedArray<T>
|
||||
{
|
||||
public readonly ref struct RentedArray<T>
|
||||
{
|
||||
// It's faster to create new smaller arrays than rent them
|
||||
private const int RentThresholdBytes = 512;
|
||||
private static int RentThresholdElements => RentThresholdBytes / Unsafe.SizeOf<T>();
|
||||
@ -37,5 +37,4 @@ namespace LibHac.Common
|
||||
ArrayPool<T>.Shared.Return(Array);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class ResultLibHac
|
||||
{
|
||||
public static class ResultLibHac
|
||||
{
|
||||
public const int ModuleLibHac = 428;
|
||||
|
||||
/// <summary>Error code: 2428-0001; Range: 1-49; Inner value: 0x3ac</summary>
|
||||
@ -92,5 +92,4 @@ namespace LibHac.Common
|
||||
public static Result.Base InvalidPackage1MarikoBodySize => new Result.Base(ModuleLibHac, 1042);
|
||||
/// <summary>Error code: 2428-1043; Inner value: 0x827ac</summary>
|
||||
public static Result.Base InvalidPackage1Pk11Size => new Result.Base(ModuleLibHac, 1043);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class Shared
|
||||
{
|
||||
public static class Shared
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Move<T>(ref T value)
|
||||
{
|
||||
@ -18,5 +18,4 @@ namespace LibHac.Common
|
||||
dest = value;
|
||||
value = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ using LibHac.Diag;
|
||||
|
||||
#pragma warning disable LH0001
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class SharedRefExtensions
|
||||
{
|
||||
public static class SharedRefExtensions
|
||||
{
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref SharedRef<T> Ref<T>(this in SharedRef<T> value) where T : class, IDisposable
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace LibHac.Common
|
||||
IL.Emit.Ret();
|
||||
throw IL.Unreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class RefCount
|
||||
{
|
||||
internal class RefCount
|
||||
{
|
||||
private int _count;
|
||||
private int _weakCount;
|
||||
private IDisposable _value;
|
||||
@ -105,11 +105,11 @@ namespace LibHac.Common
|
||||
_value = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NonCopyableDisposable]
|
||||
public struct SharedRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
[NonCopyableDisposable]
|
||||
public struct SharedRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
// SharedRef and WeakRef should share a base type, but struct inheritance doesn't exist in C#.
|
||||
// This presents a problem because C# also doesn't have friend classes, these two types need to
|
||||
// access each other's fields and we'd rather the fields' visibility stay private. Because the
|
||||
@ -301,11 +301,11 @@ namespace LibHac.Common
|
||||
{
|
||||
throw new ObjectDisposedException(string.Empty, "bad_weak_ptr");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NonCopyableDisposable]
|
||||
public struct WeakRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
[NonCopyableDisposable]
|
||||
public struct WeakRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
private T _value;
|
||||
private RefCount _refCount;
|
||||
|
||||
@ -437,5 +437,4 @@ namespace LibHac.Common
|
||||
|
||||
return sharedRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class SpanExtensions
|
||||
{
|
||||
public static class SpanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the element at the specified zero-based index or gets 0 if the index is out-of-bounds.
|
||||
/// </summary>
|
||||
@ -29,10 +29,10 @@ namespace LibHac.Common
|
||||
{
|
||||
return (uint)i >= (uint)span.Length ? (byte)0 : span[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpanHelpers
|
||||
{
|
||||
public static class SpanHelpers
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Span<T> CreateSpan<T>(ref T reference, int length)
|
||||
{
|
||||
@ -113,5 +113,4 @@ namespace LibHac.Common
|
||||
{
|
||||
return ref MemoryMarshal.Cast<TFrom, TTo>(span)[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly ref struct U8Span
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly ref struct U8Span
|
||||
{
|
||||
private readonly ReadOnlySpan<byte> _buffer;
|
||||
|
||||
public ReadOnlySpan<byte> Value => _buffer;
|
||||
@ -99,5 +99,4 @@ namespace LibHac.Common
|
||||
/// <returns><see langword="true"/> if the span has no buffer or begins with a null terminator.
|
||||
/// Otherwise, <see langword="false"/>.</returns>
|
||||
public bool IsEmpty() => _buffer.IsEmpty || MemoryMarshal.GetReference(_buffer) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly ref struct U8SpanMutable
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly ref struct U8SpanMutable
|
||||
{
|
||||
private readonly Span<byte> _buffer;
|
||||
|
||||
public Span<byte> Value => _buffer;
|
||||
@ -95,5 +95,4 @@ namespace LibHac.Common
|
||||
/// <returns><see langword="true"/> if the span has no buffer or begins with a null terminator.
|
||||
/// Otherwise, <see langword="false"/>.</returns>
|
||||
public bool IsEmpty() => _buffer.IsEmpty || MemoryMarshal.GetReference(_buffer) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ using System.Diagnostics;
|
||||
using System.Text;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly struct U8String
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly struct U8String
|
||||
{
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
public ReadOnlySpan<byte> Value => _buffer;
|
||||
@ -60,5 +60,4 @@ namespace LibHac.Common
|
||||
/// <returns><see langword="true"/> if the string has no buffer or begins with a null terminator.
|
||||
/// Otherwise, <see langword="false"/>.</returns>
|
||||
public bool IsEmpty() => _buffer == null || _buffer.Length < 1 || _buffer[0] == 0;
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ using System.Runtime.CompilerServices;
|
||||
using LibHac.Diag;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public ref struct U8StringBuilder
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public ref struct U8StringBuilder
|
||||
{
|
||||
private const int NullTerminatorLength = 1;
|
||||
|
||||
public Span<byte> Buffer { get; private set; }
|
||||
@ -440,10 +440,10 @@ namespace LibHac.Common
|
||||
}
|
||||
|
||||
public override readonly string ToString() => StringUtils.Utf8ZToString(Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class U8StringBuilderExtensions
|
||||
{
|
||||
public static class U8StringBuilderExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref U8StringBuilder Append(this ref U8StringBuilder sb, ReadOnlySpan<byte> value)
|
||||
{
|
||||
@ -565,5 +565,4 @@ namespace LibHac.Common
|
||||
sb.PadRightInternal(paddingCharacter, paddedLength);
|
||||
return ref sb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class U8StringHelpers
|
||||
{
|
||||
public static class U8StringHelpers
|
||||
{
|
||||
public static U8String ToU8String(this string value)
|
||||
{
|
||||
return new U8String(value);
|
||||
@ -11,5 +11,4 @@
|
||||
{
|
||||
return new U8Span(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ using System.Diagnostics;
|
||||
using System.Text;
|
||||
using LibHac.Util;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly struct U8StringMutable
|
||||
{
|
||||
[DebuggerDisplay("{ToString()}")]
|
||||
public readonly struct U8StringMutable
|
||||
{
|
||||
private readonly byte[] _buffer;
|
||||
|
||||
public Span<byte> Value => _buffer;
|
||||
@ -67,5 +67,4 @@ namespace LibHac.Common
|
||||
/// <returns><see langword="true"/> if the string has no buffer or begins with a null terminator.
|
||||
/// Otherwise, <see langword="false"/>.</returns>
|
||||
public bool IsEmpty() => _buffer == null || _buffer.Length < 1 || _buffer[0] == 0;
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using static InlineIL.IL.Emit;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class UniqueRefExtensions
|
||||
{
|
||||
public static class UniqueRefExtensions
|
||||
{
|
||||
// ReSharper disable once EntityNameCapturedOnly.Global
|
||||
public static ref UniqueRef<T> Ref<T>(this in UniqueRef<T> value) where T : class, IDisposable
|
||||
{
|
||||
@ -13,11 +13,11 @@ namespace LibHac.Common
|
||||
Ret();
|
||||
throw InlineIL.IL.Unreachable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NonCopyableDisposable]
|
||||
public struct UniqueRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
[NonCopyableDisposable]
|
||||
public struct UniqueRef<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
private T _value;
|
||||
|
||||
public readonly T Get => _value;
|
||||
@ -87,5 +87,4 @@ namespace LibHac.Common
|
||||
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace LibHac.Common
|
||||
namespace LibHac.Common;
|
||||
|
||||
public static class UnsafeHelpers
|
||||
{
|
||||
public static class UnsafeHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Bypasses definite assignment rules for a given unmanaged value,
|
||||
/// or zeros a managed value to avoid having invalid references.
|
||||
@ -63,5 +63,4 @@ namespace LibHac.Common
|
||||
SkipParamInit(out value2);
|
||||
SkipParamInit(out value3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ using LibHac.Diag;
|
||||
|
||||
using AesNi = System.Runtime.Intrinsics.X86.Aes;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public static class Aes
|
||||
{
|
||||
public static class Aes
|
||||
{
|
||||
public const int KeySize128 = 0x10;
|
||||
public const int BlockSize = 0x10;
|
||||
|
||||
@ -307,5 +307,4 @@ namespace LibHac.Crypto
|
||||
carry = (byte)((b & 0xff00) >> 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesCbcEncryptor : ICipher
|
||||
{
|
||||
public class AesCbcEncryptor : ICipher
|
||||
{
|
||||
private AesCbcMode _baseCipher;
|
||||
|
||||
public AesCbcEncryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
|
||||
@ -17,10 +17,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesCbcDecryptor : ICipher
|
||||
{
|
||||
public class AesCbcDecryptor : ICipher
|
||||
{
|
||||
private AesCbcMode _baseCipher;
|
||||
|
||||
public AesCbcDecryptor(ReadOnlySpan<byte> key, ReadOnlySpan<byte> iv)
|
||||
@ -33,5 +33,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using System.Runtime.Intrinsics;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesCbcEncryptorNi : ICipherWithIv
|
||||
{
|
||||
public class AesCbcEncryptorNi : ICipherWithIv
|
||||
{
|
||||
private AesCbcModeNi _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||
@ -22,10 +22,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesCbcDecryptorNi : ICipherWithIv
|
||||
{
|
||||
public class AesCbcDecryptorNi : ICipherWithIv
|
||||
{
|
||||
private AesCbcModeNi _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||
@ -40,5 +40,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesCtrCipher : ICipherWithIv
|
||||
{
|
||||
public class AesCtrCipher : ICipherWithIv
|
||||
{
|
||||
private AesCtrMode _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref _baseCipher.Iv;
|
||||
@ -20,5 +20,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Transform(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using System.Runtime.Intrinsics;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesCtrCipherNi : ICipherWithIv
|
||||
{
|
||||
public class AesCtrCipherNi : ICipherWithIv
|
||||
{
|
||||
private AesCtrModeNi _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||
@ -22,5 +22,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Transform(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesEcbEncryptor : ICipher
|
||||
{
|
||||
public class AesEcbEncryptor : ICipher
|
||||
{
|
||||
private AesEcbMode _baseCipher;
|
||||
|
||||
public AesEcbEncryptor(ReadOnlySpan<byte> key)
|
||||
@ -17,10 +17,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesEcbDecryptor : ICipher
|
||||
{
|
||||
public class AesEcbDecryptor : ICipher
|
||||
{
|
||||
private AesEcbMode _baseCipher;
|
||||
|
||||
public AesEcbDecryptor(ReadOnlySpan<byte> key)
|
||||
@ -33,5 +33,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesEcbEncryptorNi : ICipher
|
||||
{
|
||||
public class AesEcbEncryptorNi : ICipher
|
||||
{
|
||||
private AesEcbModeNi _baseCipher;
|
||||
|
||||
public AesEcbEncryptorNi(ReadOnlySpan<byte> key)
|
||||
@ -17,10 +17,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesEcbDecryptorNi : ICipher
|
||||
{
|
||||
public class AesEcbDecryptorNi : ICipher
|
||||
{
|
||||
private AesEcbModeNi _baseCipher;
|
||||
|
||||
public AesEcbDecryptorNi(ReadOnlySpan<byte> key)
|
||||
@ -33,5 +33,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesXtsEncryptor : ICipherWithIv
|
||||
{
|
||||
public class AesXtsEncryptor : ICipherWithIv
|
||||
{
|
||||
private AesXtsMode _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref _baseCipher.Iv;
|
||||
@ -20,10 +20,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesXtsDecryptor : ICipherWithIv
|
||||
{
|
||||
public class AesXtsDecryptor : ICipherWithIv
|
||||
{
|
||||
private AesXtsMode _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref _baseCipher.Iv;
|
||||
@ -38,5 +38,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ using System.Runtime.Intrinsics;
|
||||
using LibHac.Common;
|
||||
using LibHac.Crypto.Impl;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public class AesXtsEncryptorNi : ICipherWithIv
|
||||
{
|
||||
public class AesXtsEncryptorNi : ICipherWithIv
|
||||
{
|
||||
private AesXtsModeNi _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||
@ -22,10 +22,10 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Encrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AesXtsDecryptorNi : ICipherWithIv
|
||||
{
|
||||
public class AesXtsDecryptorNi : ICipherWithIv
|
||||
{
|
||||
private AesXtsModeNi _baseCipher;
|
||||
|
||||
public ref Buffer16 Iv => ref Unsafe.As<Vector128<byte>, Buffer16>(ref _baseCipher.Iv);
|
||||
@ -40,5 +40,4 @@ namespace LibHac.Crypto
|
||||
{
|
||||
_baseCipher.Decrypt(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
internal static class CryptoUtil
|
||||
{
|
||||
internal static class CryptoUtil
|
||||
{
|
||||
public static bool IsSameBytes(ReadOnlySpan<byte> buffer1, ReadOnlySpan<byte> buffer2, int length)
|
||||
{
|
||||
if (buffer1.Length < (uint)length || buffer2.Length < (uint)length)
|
||||
@ -26,5 +26,4 @@ namespace LibHac.Crypto
|
||||
|
||||
return result == 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using LibHac.Common;
|
||||
|
||||
namespace LibHac.Crypto
|
||||
{
|
||||
public interface ICipher
|
||||
{
|
||||
void Transform(ReadOnlySpan<byte> input, Span<byte> output);
|
||||
}
|
||||
namespace LibHac.Crypto;
|
||||
|
||||
public interface ICipherWithIv : ICipher
|
||||
{
|
||||
ref Buffer16 Iv { get; }
|
||||
}
|
||||
public interface ICipher
|
||||
{
|
||||
void Transform(ReadOnlySpan<byte> input, Span<byte> output);
|
||||
}
|
||||
|
||||
public interface ICipherWithIv : ICipher
|
||||
{
|
||||
ref Buffer16 Iv { get; }
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user