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
majorVersionNumberuintThe file format version.
BundleManifest(uint, string)
Creates a new bundle manifest with a specific bundle identifier.
public BundleManifest(uint majorVersionNumber, string bundleId)
Parameters
majorVersionNumberuintThe file format version.
bundleIdstringThe 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
sourceIDataSourceThe 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
databyte[]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
databyte[]The raw contents of the file to read.
offsetulongThe 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
sourceIDataSourceThe 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
sourceIDataSourceThe raw contents of the file to read.
offsetulongThe 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
filePathstringThe 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
readerBinaryStreamReaderThe input stream pointing to the start of the bundle to read.
Returns
- BundleManifest
The read manifest.
FromStream(Stream)
Attempts to automatically locate and parse the bundle header in the provided file.
public static BundleManifest FromStream(Stream stream)
Parameters
streamStreamThe raw contents of the file to read.
Returns
- BundleManifest
The read manifest.
FromStream(Stream, ulong)
Parses the bundle header in the provided file at the provided address.
public static BundleManifest FromStream(Stream stream, ulong offset)
Parameters
streamStreamThe raw contents of the file to read.
offsetulongThe address within the file to start reading the bundle at.
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
sourceIDataSourceThe file to locate the bundle header in.
Returns
- bool
trueif a bundle signature was found,falseotherwise.
TryGetTargetRuntime(out DotNetRuntimeInfo)
Attempts to determine the runtime that the assemblies in the bundle are targeting.
public bool TryGetTargetRuntime(out DotNetRuntimeInfo targetRuntime)
Parameters
targetRuntimeDotNetRuntimeInfoWhen the method returns
true, contains the target runtime.
Returns
- bool
trueif the runtime could be determined,falseotherwise.
WriteManifest(BinaryStreamWriter, bool)
Writes the manifest to an output stream.
public ulong WriteManifest(BinaryStreamWriter writer, bool isArm64Linux)
Parameters
writerBinaryStreamWriterThe output stream to write to.
isArm64Linuxbooltrueif 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
writerBinaryStreamWriterThe output stream to write to.
parametersBundlerParametersThe 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
outputStreamStreamThe output stream to write to.
parametersBundlerParametersThe 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
outputPathstringThe path of the file to write to.
parametersBundlerParametersThe parameters to use for bundling all files into a single executable.