Class BundleManifest
- Namespace
- AsmResolver.DotNet.Bundles
- Assembly
- AsmResolver.DotNet.dll
Represents a set of bundled files embedded in a .NET application host or single-file host.
public class BundleManifest
- Inheritance
-
BundleManifest
- Derived
- Inherited Members
Constructors
BundleManifest()
Initializes an empty bundle manifest.
protected BundleManifest()
BundleManifest(uint)
Creates a new bundle manifest.
public BundleManifest(uint majorVersionNumber)
Parameters
majorVersionNumber
uintThe file format version.
BundleManifest(uint, string)
Creates a new bundle manifest with a specific bundle identifier.
public BundleManifest(uint majorVersionNumber, string bundleId)
Parameters
majorVersionNumber
uintThe file format version.
bundleId
stringThe unique bundle manifest identifier.
Properties
BundleID
Gets or sets the unique identifier for the bundle manifest.
public string? BundleID { get; set; }
Property Value
Remarks
When this property is set to null
, the bundle identifier will be generated upon writing the manifest
based on the contents of the manifest.
Files
Gets a collection of files stored in the bundle.
public IList<BundleFile> Files { get; }
Property Value
Flags
Gets or sets flags associated to the bundle.
public BundleManifestFlags Flags { get; set; }
Property Value
MajorVersion
Gets or sets the major file format version of the bundle.
public uint MajorVersion { get; set; }
Property Value
Remarks
Version numbers recognized by the CLR are:
- 1 for .NET Core 3.1
- 2 for .NET 5.0
- 6 for .NET 6.0
MinorVersion
Gets or sets the minor file format version of the bundle.
public uint MinorVersion { get; set; }
Property Value
Remarks
This value is ignored by the CLR and should be set to 0.
Methods
FindBundleManifestAddress(IDataSource)
Attempts to find the start of the bundle header in the provided file.
public static long FindBundleManifestAddress(IDataSource source)
Parameters
source
IDataSourceThe file to locate the bundle header in.
Returns
- long
The offset, or -1 if none was found.
FromBytes(byte[])
Attempts to automatically locate and parse the bundle header in the provided file.
public static BundleManifest FromBytes(byte[] data)
Parameters
data
byte[]The raw contents of the file to read.
Returns
- BundleManifest
The read manifest.
FromBytes(byte[], ulong)
Parses the bundle header in the provided file at the provided address.
public static BundleManifest FromBytes(byte[] data, ulong offset)
Parameters
data
byte[]The raw contents of the file to read.
offset
ulongThe address within the file to start reading the bundle at.
Returns
- BundleManifest
The read manifest.
FromDataSource(IDataSource)
Attempts to automatically locate and parse the bundle header in the provided file.
public static BundleManifest FromDataSource(IDataSource source)
Parameters
source
IDataSourceThe raw contents of the file to read.
Returns
- BundleManifest
The read manifest.
FromDataSource(IDataSource, ulong)
Parses the bundle header in the provided file at the provided address.
public static BundleManifest FromDataSource(IDataSource source, ulong offset)
Parameters
source
IDataSourceThe raw contents of the file to read.
offset
ulongThe address within the file to start reading the bundle at.
Returns
- BundleManifest
The read manifest.
FromFile(string)
Attempts to automatically locate and parse the bundle header in the provided file.
public static BundleManifest FromFile(string filePath)
Parameters
filePath
stringThe path to the file to read.
Returns
- BundleManifest
The read manifest.
FromReader(BinaryStreamReader)
Parses the bundle header from the provided input stream.
public static BundleManifest FromReader(BinaryStreamReader reader)
Parameters
reader
BinaryStreamReaderThe input stream pointing to the start of the bundle to read.
Returns
- BundleManifest
The read manifest.
GenerateDeterministicBundleID()
Generates a bundle identifier based on the SHA-256 hashes of all files in the manifest.
public string GenerateDeterministicBundleID()
Returns
- string
The generated bundle identifier.
GetFiles()
Obtains the list of files stored in the bundle.
protected virtual IList<BundleFile> GetFiles()
Returns
- IList<BundleFile>
The files
Remarks
This method is called upon initialization of the Files property.
GetTargetRuntime()
Determines the runtime that the assemblies in the bundle are targeting.
public DotNetRuntimeInfo GetTargetRuntime()
Returns
- DotNetRuntimeInfo
The runtime.
Exceptions
- ArgumentException
Occurs when the runtime could not be determined.
IsBundledAssembly(IDataSource)
Gets a value indicating whether the provided data source contains a conventional bundled assembly signature.
public static bool IsBundledAssembly(IDataSource source)
Parameters
source
IDataSourceThe file to locate the bundle header in.
Returns
- bool
true
if a bundle signature was found,false
otherwise.
TryGetTargetRuntime(out DotNetRuntimeInfo)
Attempts to determine the runtime that the assemblies in the bundle are targeting.
public bool TryGetTargetRuntime(out DotNetRuntimeInfo targetRuntime)
Parameters
targetRuntime
DotNetRuntimeInfoWhen the method returns
true
, contains the target runtime.
Returns
- bool
true
if the runtime could be determined,false
otherwise.
WriteManifest(BinaryStreamWriter, bool)
Writes the manifest to an output stream.
public ulong WriteManifest(BinaryStreamWriter writer, bool isArm64Linux)
Parameters
writer
BinaryStreamWriterThe output stream to write to.
isArm64Linux
booltrue
if the application host is a Linux ELF binary targeting ARM64.
Returns
- ulong
The address of the bundle header.
Remarks
This does not necessarily produce a working executable file, it only writes the contents of the entire manifest,
without a host application that invokes the manifest. If you want to produce a runnable executable, use one
of the WriteUsingTemplate
methods instead.
WriteUsingTemplate(BinaryStreamWriter, BundlerParameters)
Constructs a new application host file based on the bundle manifest.
public void WriteUsingTemplate(BinaryStreamWriter writer, BundlerParameters parameters)
Parameters
writer
BinaryStreamWriterThe output stream to write to.
parameters
BundlerParametersThe parameters to use for bundling all files into a single executable.
WriteUsingTemplate(Stream, in BundlerParameters)
Constructs a new application host file based on the bundle manifest.
public void WriteUsingTemplate(Stream outputStream, in BundlerParameters parameters)
Parameters
outputStream
StreamThe output stream to write to.
parameters
BundlerParametersThe parameters to use for bundling all files into a single executable.
WriteUsingTemplate(string, in BundlerParameters)
Constructs a new application host file based on the bundle manifest.
public void WriteUsingTemplate(string outputPath, in BundlerParameters parameters)
Parameters
outputPath
stringThe path of the file to write to.
parameters
BundlerParametersThe parameters to use for bundling all files into a single executable.