Class AssemblyPatcher

Worker class which is used for loading and patching entire folders of assemblies, or alternatively patching and loading assemblies one at a time.

Inheritance
System.Object AssemblyPatcher
Implements
System.IDisposable
Inherited Members
System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace: BepInEx.Preloader.Core.Patching
Assembly: BepInEx.Preloader.Core.dll
Syntax
public class AssemblyPatcher : IDisposable

Constructors

AssemblyPatcher(Func<Byte[], String, Assembly>)

Declaration
public AssemblyPatcher(Func<byte[], string, Assembly> assemblyLoader)
Parameters
Type Name Description
System.Func<System.Byte[], System.String, System.Reflection.Assembly> assemblyLoader

Properties

PatcherContext

The context of this assembly patcher instance that is passed to all patcher plugins.

Declaration
public PatcherContext PatcherContext { get; }
Property Value
Type Description
PatcherContext

Methods

AddPatchersFromDirectory(String)

Adds all patchers from all managed assemblies specified in a directory.

Declaration
public void AddPatchersFromDirectory(string directory)
Parameters
Type Name Description
System.String directory

Directory to search patcher DLLs from.

Dispose()

Performs work to dispose collection objects.

Declaration
public void Dispose()

LoadAssemblyDirectories(IEnumerable<String>, IEnumerable<String>)

Adds all assemblies in given directories to be patched and loaded by this patcher instance. Non-managed assemblies are skipped.

Declaration
public void LoadAssemblyDirectories(IEnumerable<string> directories, IEnumerable<string> assemblyExtensions)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> directories

The directory to search.

System.Collections.Generic.IEnumerable<System.String> assemblyExtensions

The file extensions to attempt to load.

LoadAssemblyDirectories(String[])

Adds all .dll assemblies in given directories to be patched and loaded by this patcher instance. Non-managed assemblies are skipped.

Declaration
public void LoadAssemblyDirectories(params string[] directories)
Parameters
Type Name Description
System.String[] directories

The directories to search.

PatchAndLoad()

Applies patchers to all assemblies loaded into this assembly patcher and then loads patched assemblies into memory.

Declaration
public void PatchAndLoad()

TryLoadAssembly(String, out AssemblyDefinition)

Attempts to load a managed assembly as an . Returns true if successful.

Declaration
public static bool TryLoadAssembly(string path, out AssemblyDefinition assembly)
Parameters
Type Name Description
System.String path

The path of the assembly.

AssemblyDefinition assembly

The loaded assembly. Null if not successful in loading.

Returns
Type Description
System.Boolean

Implements

System.IDisposable