Show / Hide Table of Contents

Class PatchProcessor

A PatchProcessor handles patches on a method/constructor

Inheritance
System.Object
PatchProcessor
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class PatchProcessor

Constructors

| Improve this Doc View Source

PatchProcessor(Harmony, MethodBase)

Creates a new PatchProcessor.

Declaration
public PatchProcessor(Harmony instance, MethodBase original)
Parameters
Type Name Description
Harmony instance

The Harmony instance

System.Reflection.MethodBase original

The original method/constructor

Methods

| Improve this Doc View Source

AddFinalizer(HarmonyMethod)

Adds a finalizer

Declaration
public PatchProcessor AddFinalizer(HarmonyMethod finalizer)
Parameters
Type Name Description
HarmonyMethod finalizer

The finalizer as a HarmonyMethod

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddFinalizer(MethodInfo)

Adds a finalizer

Declaration
public PatchProcessor AddFinalizer(MethodInfo fixMethod)
Parameters
Type Name Description
System.Reflection.MethodInfo fixMethod

The finalizer method

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddInfix(HarmonyMethod)

Adds an infix

Declaration
public PatchProcessor AddInfix(HarmonyMethod infix)
Parameters
Type Name Description
HarmonyMethod infix

The infix as a HarmonyMethod

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddInfix(MethodInfo)

Adds a postfix

Declaration
public PatchProcessor AddInfix(MethodInfo fixMethod)
Parameters
Type Name Description
System.Reflection.MethodInfo fixMethod

The infix method

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddPostfix(HarmonyMethod)

Adds a postfix

Declaration
public PatchProcessor AddPostfix(HarmonyMethod postfix)
Parameters
Type Name Description
HarmonyMethod postfix

The postfix as a HarmonyMethod

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddPostfix(MethodInfo)

Adds a postfix

Declaration
public PatchProcessor AddPostfix(MethodInfo fixMethod)
Parameters
Type Name Description
System.Reflection.MethodInfo fixMethod

The postfix method

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddPrefix(HarmonyMethod)

Adds a prefix

Declaration
public PatchProcessor AddPrefix(HarmonyMethod prefix)
Parameters
Type Name Description
HarmonyMethod prefix

The prefix as a HarmonyMethod

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddPrefix(MethodInfo)

Adds a prefix

Declaration
public PatchProcessor AddPrefix(MethodInfo fixMethod)
Parameters
Type Name Description
System.Reflection.MethodInfo fixMethod

The prefix method

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddTranspiler(HarmonyMethod)

Adds a transpiler

Declaration
public PatchProcessor AddTranspiler(HarmonyMethod transpiler)
Parameters
Type Name Description
HarmonyMethod transpiler

The transpiler as a HarmonyMethod

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

AddTranspiler(MethodInfo)

Adds a transpiler

Declaration
public PatchProcessor AddTranspiler(MethodInfo fixMethod)
Parameters
Type Name Description
System.Reflection.MethodInfo fixMethod

The transpiler method

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

CreateILGenerator()

Creates a new empty System.Reflection.Emit.ILGenerator to use when reading method bodies

Declaration
public static ILGenerator CreateILGenerator()
Returns
Type Description
System.Reflection.Emit.ILGenerator

A new System.Reflection.Emit.ILGenerator

| Improve this Doc View Source

CreateILGenerator(MethodBase)

Creates a new System.Reflection.Emit.ILGenerator matching the method/constructor to use when reading method bodies

Declaration
public static ILGenerator CreateILGenerator(MethodBase original)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method/constructor to copy method information from

Returns
Type Description
System.Reflection.Emit.ILGenerator

A new System.Reflection.Emit.ILGenerator

| Improve this Doc View Source

GetAllPatchedMethods()

Gets all patched original methods in the appdomain

Declaration
public static IEnumerable<MethodBase> GetAllPatchedMethods()
Returns
Type Description
System.Collections.Generic.IEnumerable<System.Reflection.MethodBase>

An enumeration of patched method/constructor

| Improve this Doc View Source

GetCurrentInstructions(MethodBase, Int32, ILGenerator)

Returns the methods current list of code instructions after all existing transpilers have been applied

Declaration
public static List<CodeInstruction> GetCurrentInstructions(MethodBase original, int maxTranspilers = 2147483647, ILGenerator generator = null)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method/constructor

System.Int32 maxTranspilers

Apply only the first count of transpilers

System.Reflection.Emit.ILGenerator generator

Optionally an existing generator that will be used to create all local variables and labels contained in the result (if not specified, an internal generator is used)

Returns
Type Description
System.Collections.Generic.List<CodeInstruction>

A list of CodeInstruction

| Improve this Doc View Source

GetCurrentInstructions(MethodBase, out ILGenerator, Int32)

Returns the methods current list of code instructions after all existing transpilers have been applied

Declaration
public static List<CodeInstruction> GetCurrentInstructions(MethodBase original, out ILGenerator generator, int maxTranspilers = 2147483647)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method/constructor

System.Reflection.Emit.ILGenerator generator

A new generator that now contains all local variables and labels contained in the result

System.Int32 maxTranspilers

Apply only the first count of transpilers

Returns
Type Description
System.Collections.Generic.List<CodeInstruction>

A list of CodeInstruction

| Improve this Doc View Source

GetOriginalInstructions(MethodBase, ILGenerator)

Returns the methods unmodified list of code instructions

Declaration
public static List<CodeInstruction> GetOriginalInstructions(MethodBase original, ILGenerator generator = null)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method/constructor

System.Reflection.Emit.ILGenerator generator

Optionally an existing generator that will be used to create all local variables and labels contained in the result (if not specified, an internal generator is used)

Returns
Type Description
System.Collections.Generic.List<CodeInstruction>

A list containing all the original CodeInstruction

| Improve this Doc View Source

GetOriginalInstructions(MethodBase, out ILGenerator)

Returns the methods unmodified list of code instructions

Declaration
public static List<CodeInstruction> GetOriginalInstructions(MethodBase original, out ILGenerator generator)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method/constructor

System.Reflection.Emit.ILGenerator generator

A new generator that now contains all local variables and labels contained in the result

Returns
Type Description
System.Collections.Generic.List<CodeInstruction>

A list containing all the original CodeInstruction

| Improve this Doc View Source

GetPatchInfo(MethodBase)

Gets patch information on an original

Declaration
public static Patches GetPatchInfo(MethodBase method)
Parameters
Type Name Description
System.Reflection.MethodBase method

The original method/constructor

Returns
Type Description
Patches

The patch information as Patches

| Improve this Doc View Source

GetSortedPatchMethods(MethodBase, Patch[])

Sort patch methods by their priority rules

Declaration
public static List<MethodInfo> GetSortedPatchMethods(MethodBase original, Patch[] patches)
Parameters
Type Name Description
System.Reflection.MethodBase original

The original method

Patch[] patches

Patches to sort

Returns
Type Description
System.Collections.Generic.List<System.Reflection.MethodInfo>

The sorted patch methods

| Improve this Doc View Source

Patch()

Applies all registered patches

Declaration
public MethodInfo Patch()
Returns
Type Description
System.Reflection.MethodInfo

The generated replacement method

| Improve this Doc View Source

ReadMethodBody(MethodBase)

A low level way to read the body of a method. Used for quick searching in methods

Declaration
public static IEnumerable<KeyValuePair<OpCode, object>> ReadMethodBody(MethodBase method)
Parameters
Type Name Description
System.Reflection.MethodBase method

The original method

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Reflection.Emit.OpCode, System.Object>>

All instructions as opcode/operand pairs

| Improve this Doc View Source

ReadMethodBody(MethodBase, ILGenerator)

A low level way to read the body of a method. Used for quick searching in methods

Declaration
public static IEnumerable<KeyValuePair<OpCode, object>> ReadMethodBody(MethodBase method, ILGenerator generator)
Parameters
Type Name Description
System.Reflection.MethodBase method

The original method

System.Reflection.Emit.ILGenerator generator

An existing generator that will be used to create all local variables and labels contained in the result

Returns
Type Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Reflection.Emit.OpCode, System.Object>>

All instructions as opcode/operand pairs

| Improve this Doc View Source

Unpatch(HarmonyPatchType, String)

Unpatches patches of a given type and/or Harmony ID

Declaration
public PatchProcessor Unpatch(HarmonyPatchType type, string harmonyID)
Parameters
Type Name Description
HarmonyPatchType type

The HarmonyPatchType patch type

System.String harmonyID

Harmony ID or * for any

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

Unpatch(MethodInfo)

Unpatches a specific patch

Declaration
public PatchProcessor Unpatch(MethodInfo patch)
Parameters
Type Name Description
System.Reflection.MethodInfo patch

The method of the patch

Returns
Type Description
PatchProcessor

A PatchProcessor for chaining calls

| Improve this Doc View Source

VersionInfo(out Version)

Gets Harmony version for all active Harmony instances

Declaration
public static Dictionary<string, Version> VersionInfo(out Version currentVersion)
Parameters
Type Name Description
System.Version currentVersion

[out] The current Harmony version

Returns
Type Description
System.Collections.Generic.Dictionary<System.String, System.Version>

A dictionary containing assembly version keyed by Harmony ID

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX