Class AssemblyContext
Bundles a loaded assembly with the dnlib helpers needed to modify it: importer, injector, entry point information, module static constructor and resources.
public class AssemblyContext
- Inheritance
-
AssemblyContext
- Inherited Members
Constructors
AssemblyContext(ModuleDefMD)
Initializes a new instance of the AssemblyContext class for the given module.
public AssemblyContext(ModuleDefMD module)
Parameters
moduleModuleDefMDThe loaded module to build the context for.
Properties
Assembly
Gets the assembly that owns the module.
public AssemblyDef Assembly { get; }
Property Value
- AssemblyDef
EntryPointMethod
Gets the entry point method, or null if the module has none.
public MethodDef EntryPointMethod { get; }
Property Value
- MethodDef
EntryPointType
Gets the type declaring the entry point, or null if the module has none.
public TypeDef EntryPointType { get; }
Property Value
- TypeDef
GlobalType
Gets the global <Module> type of the module.
public TypeDef GlobalType { get; }
Property Value
- TypeDef
GlobalTypeStaticConstructor
Gets the static constructor of GlobalType, created if it did not exist.
public MethodDef GlobalTypeStaticConstructor { get; }
Property Value
- MethodDef
Importer
Gets the importer that brings foreign references into Module.
public Importer Importer { get; }
Property Value
- Importer
Injector
Gets the injector that copies types into Module.
public Injector Injector { get; }
Property Value
Module
Gets the manifest module of Assembly.
public ModuleDef Module { get; }
Property Value
- ModuleDef
ModuleMD
Gets the module this context was created from.
public ModuleDefMD ModuleMD { get; }
Property Value
- ModuleDefMD
Resources
Gets the helper used to add, replace and read embedded resources of the module.
public ResourceManagement Resources { get; }
Property Value
Methods
GetAssemblyRefUser(string)
Creates an assembly reference for the assembly located at the given path.
public AssemblyRefUser GetAssemblyRefUser(string path)
Parameters
pathstringPath to the assembly file. The assembly is loaded into the current process to read its name.
Returns
- AssemblyRefUser
A new dnlib.DotNet.AssemblyRefUser for that assembly.
GetAssemblyRefs()
Gets the assemblies referenced by the module.
public IEnumerable<AssemblyRef> GetAssemblyRefs()
Returns
- IEnumerable<AssemblyRef>
The module's assembly references.
GetTypeDef(Type)
Gets the dnlib definition of a runtime type.
public TypeDef GetTypeDef(Type type)
Parameters
typeTypeThe runtime type to look up.
Returns
- TypeDef
The dnlib.DotNet.TypeDef describing
type.
Merge(Type)
Injects a runtime type into the module.
public TypeDef Merge(Type source)
Parameters
sourceTypeThe runtime type to inject.
Returns
- TypeDef
The injected type, or null if injection failed or the type was already injected.
Merge(TypeDef)
Injects a type definition into the module.
public TypeDef Merge(TypeDef source)
Parameters
sourceTypeDefThe type to inject.
Returns
- TypeDef
The injected type, or null if injection failed or the type was already injected.
Merge(TypeDef, string)
Injects a type definition into the module and renames the copy.
public TypeDef Merge(TypeDef source, string name)
Parameters
sourceTypeDefThe type to inject.
namestringThe name given to the injected type.
Returns
- TypeDef
The injected type, or null if injection failed or the type was already injected.
Merge(TypeDef, string, string)
Injects a type definition into the module and renames the copy and its namespace.
public TypeDef Merge(TypeDef source, string name, string nameSpace)
Parameters
sourceTypeDefThe type to inject.
namestringThe name given to the injected type.
nameSpacestringThe namespace given to the injected type.
Returns
- TypeDef
The injected type, or null if injection failed or the type was already injected.