Back to Harmony

Class PatchProcessor

docs/api/HarmonyLib.PatchProcessor.html

2.4.2.015.1 KB
Original Source

Class PatchProcessor

A PatchProcessor handles patches on a method/constructor

Inheritance

System.Object

PatchProcessor

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

Constructors

PatchProcessor(Harmony, MethodBase)

Creates a new PatchProcessor

Declaration
public PatchProcessor(Harmony instance, MethodBase original)
Parameters
TypeNameDescription
Harmonyinstance

The Harmony instance

| | System.Reflection.MethodBase | original |

The original method/constructor

|

Methods

AddFinalizer(HarmonyMethod)

Adds a finalizer

Declaration
public PatchProcessor AddFinalizer(HarmonyMethod finalizer)
Parameters
TypeNameDescription
HarmonyMethodfinalizer

The finalizer as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddFinalizer(MethodInfo)

Adds a finalizer

Declaration
public PatchProcessor AddFinalizer(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The finalizer method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddInnerPostfix(HarmonyMethod)

Adds an inner postfix

Declaration
public PatchProcessor AddInnerPostfix(HarmonyMethod innerPostfix)
Parameters
TypeNameDescription
HarmonyMethodinnerPostfix

The inner postfix as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddInnerPostfix(MethodInfo)

Adds an inner postfix

Declaration
public PatchProcessor AddInnerPostfix(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The inner postfix method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddInnerPrefix(HarmonyMethod)

Adds an inner prefix

Declaration
public PatchProcessor AddInnerPrefix(HarmonyMethod innerPrefix)
Parameters
TypeNameDescription
HarmonyMethodinnerPrefix

The inner prefix as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddInnerPrefix(MethodInfo)

Adds an inner prefix

Declaration
public PatchProcessor AddInnerPrefix(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The inner prefix method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddPostfix(HarmonyMethod)

Adds a postfix

Declaration
public PatchProcessor AddPostfix(HarmonyMethod postfix)
Parameters
TypeNameDescription
HarmonyMethodpostfix

The postfix as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddPostfix(MethodInfo)

Adds a postfix

Declaration
public PatchProcessor AddPostfix(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The postfix method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddPrefix(HarmonyMethod)

Adds a prefix

Declaration
public PatchProcessor AddPrefix(HarmonyMethod prefix)
Parameters
TypeNameDescription
HarmonyMethodprefix

The prefix as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddPrefix(MethodInfo)

Adds a prefix

Declaration
public PatchProcessor AddPrefix(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The prefix method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddTranspiler(HarmonyMethod)

Adds a transpiler

Declaration
public PatchProcessor AddTranspiler(HarmonyMethod transpiler)
Parameters
TypeNameDescription
HarmonyMethodtranspiler

The transpiler as a HarmonyMethod

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

AddTranspiler(MethodInfo)

Adds a transpiler

Declaration
public PatchProcessor AddTranspiler(MethodInfo fixMethod)
Parameters
TypeNameDescription
System.Reflection.MethodInfofixMethod

The transpiler method

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

CreateILGenerator()

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

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

A new System.Reflection.Emit.ILGenerator

|

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
TypeNameDescription
System.Reflection.MethodBaseoriginal

The original method/constructor to copy method information from

|

Returns
TypeDescription
System.Reflection.Emit.ILGenerator

A new System.Reflection.Emit.ILGenerator

|

GetAllPatchedMethods()

Gets all patched original methods in the appdomain

Declaration
public static IEnumerable<MethodBase> GetAllPatchedMethods()
Returns
TypeDescription
System.Collections.Generic.IEnumerable\

An enumeration of patched method/constructor

|

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
TypeNameDescription
System.Reflection.MethodBaseoriginal

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
TypeDescription
System.Collections.Generic.List<CodeInstruction>

A list of CodeInstruction

|

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
TypeNameDescription
System.Reflection.MethodBaseoriginal

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
TypeDescription
System.Collections.Generic.List<CodeInstruction>

A list of CodeInstruction

|

GetOriginalInstructions(MethodBase, ILGenerator)

Returns the methods unmodified list of code instructions

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

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
TypeDescription
System.Collections.Generic.List<CodeInstruction>

A list containing all the original CodeInstruction

|

GetOriginalInstructions(MethodBase, out ILGenerator)

Returns the methods unmodified list of code instructions

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

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
TypeDescription
System.Collections.Generic.List<CodeInstruction>

A list containing all the original CodeInstruction

|

GetPatchInfo(MethodBase)

Gets patch information on an original

Declaration
public static Patches GetPatchInfo(MethodBase method)
Parameters
TypeNameDescription
System.Reflection.MethodBasemethod

The original method/constructor

|

Returns
TypeDescription
Patches

The patch information as Patches

|

GetSortedPatchMethods(MethodBase, Patch[])

Sort patch methods by their priority rules

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

The original method

| | Patch[] | patches |

Patches to sort

|

Returns
TypeDescription
System.Collections.Generic.List\

The sorted patch methods

|

Patch()

Applies all registered patches

Declaration
public MethodInfo Patch()
Returns
TypeDescription
System.Reflection.MethodInfo

The generated replacement method

|

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
TypeNameDescription
System.Reflection.MethodBasemethod

The original method

|

Returns
TypeDescription
System.Collections.Generic.IEnumerable\>

All instructions as opcode/operand pairs

|

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
TypeNameDescription
System.Reflection.MethodBasemethod

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
TypeDescription
System.Collections.Generic.IEnumerable\>

All instructions as opcode/operand pairs

|

Unpatch(HarmonyPatchType, String)

Unpatches patches of a given type and/or Harmony ID

Declaration
public PatchProcessor Unpatch(HarmonyPatchType type, string harmonyID)
Parameters
TypeNameDescription
HarmonyPatchTypetype

The HarmonyPatchType patch type

| | System.String | harmonyID |

Harmony ID or * for any

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

Unpatch(MethodInfo)

Unpatches a specific patch

Declaration
public PatchProcessor Unpatch(MethodInfo patch)
Parameters
TypeNameDescription
System.Reflection.MethodInfopatch

The method of the patch

|

Returns
TypeDescription
PatchProcessor

A PatchProcessor for chaining calls

|

VersionInfo(out Version)

Gets Harmony version for all active Harmony instances

Declaration
public static Dictionary<string, Version> VersionInfo(out Version currentVersion)
Parameters
TypeNameDescription
System.VersioncurrentVersion

[out] The current Harmony version

|

Returns
TypeDescription
System.Collections.Generic.Dictionary\

A dictionary containing assembly version keyed by Harmony ID

|