docs/api/HarmonyLib.PatchProcessor.html
A PatchProcessor handles patches on a method/constructor
System.Object
PatchProcessor
public class PatchProcessor
Creates a new PatchProcessor
public PatchProcessor(Harmony instance, MethodBase original)
| Type | Name | Description |
|---|---|---|
| Harmony | instance |
The Harmony instance
| | System.Reflection.MethodBase | original |
The original method/constructor
|
Adds a finalizer
public PatchProcessor AddFinalizer(HarmonyMethod finalizer)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | finalizer |
The finalizer as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a finalizer
public PatchProcessor AddFinalizer(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The finalizer method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds an inner postfix
public PatchProcessor AddInnerPostfix(HarmonyMethod innerPostfix)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | innerPostfix |
The inner postfix as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds an inner postfix
public PatchProcessor AddInnerPostfix(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The inner postfix method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds an inner prefix
public PatchProcessor AddInnerPrefix(HarmonyMethod innerPrefix)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | innerPrefix |
The inner prefix as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds an inner prefix
public PatchProcessor AddInnerPrefix(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The inner prefix method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a postfix
public PatchProcessor AddPostfix(HarmonyMethod postfix)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | postfix |
The postfix as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a postfix
public PatchProcessor AddPostfix(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The postfix method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a prefix
public PatchProcessor AddPrefix(HarmonyMethod prefix)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | prefix |
The prefix as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a prefix
public PatchProcessor AddPrefix(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The prefix method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a transpiler
public PatchProcessor AddTranspiler(HarmonyMethod transpiler)
| Type | Name | Description |
|---|---|---|
| HarmonyMethod | transpiler |
The transpiler as a HarmonyMethod
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Adds a transpiler
public PatchProcessor AddTranspiler(MethodInfo fixMethod)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | fixMethod |
The transpiler method
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Creates a new empty System.Reflection.Emit.ILGenerator to use when reading method bodies
public static ILGenerator CreateILGenerator()
| Type | Description |
|---|---|
| System.Reflection.Emit.ILGenerator |
A new System.Reflection.Emit.ILGenerator
|
Creates a new System.Reflection.Emit.ILGenerator matching the method/constructor to use when reading method bodies
public static ILGenerator CreateILGenerator(MethodBase original)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodBase | original |
The original method/constructor to copy method information from
|
| Type | Description |
|---|---|
| System.Reflection.Emit.ILGenerator |
A new System.Reflection.Emit.ILGenerator
|
Gets all patched original methods in the appdomain
public static IEnumerable<MethodBase> GetAllPatchedMethods()
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable\ |
An enumeration of patched method/constructor
|
Returns the methods current list of code instructions after all existing transpilers have been applied
public static List<CodeInstruction> GetCurrentInstructions(MethodBase original, int maxTranspilers = 2147483647, ILGenerator generator = null)
| 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)
|
| Type | Description |
|---|---|
| System.Collections.Generic.List<CodeInstruction> |
A list of CodeInstruction
|
Returns the methods current list of code instructions after all existing transpilers have been applied
public static List<CodeInstruction> GetCurrentInstructions(MethodBase original, out ILGenerator generator, int maxTranspilers = 2147483647)
| 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
|
| Type | Description |
|---|---|
| System.Collections.Generic.List<CodeInstruction> |
A list of CodeInstruction
|
Returns the methods unmodified list of code instructions
public static List<CodeInstruction> GetOriginalInstructions(MethodBase original, ILGenerator generator = null)
| 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)
|
| Type | Description |
|---|---|
| System.Collections.Generic.List<CodeInstruction> |
A list containing all the original CodeInstruction
|
Returns the methods unmodified list of code instructions
public static List<CodeInstruction> GetOriginalInstructions(MethodBase original, out ILGenerator generator)
| 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
|
| Type | Description |
|---|---|
| System.Collections.Generic.List<CodeInstruction> |
A list containing all the original CodeInstruction
|
Gets patch information on an original
public static Patches GetPatchInfo(MethodBase method)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodBase | method |
The original method/constructor
|
| Type | Description |
|---|---|
| Patches |
The patch information as Patches
|
Sort patch methods by their priority rules
public static List<MethodInfo> GetSortedPatchMethods(MethodBase original, Patch[] patches)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodBase | original |
The original method
| | Patch[] | patches |
Patches to sort
|
| Type | Description |
|---|---|
| System.Collections.Generic.List\ |
The sorted patch methods
|
Applies all registered patches
public MethodInfo Patch()
| Type | Description |
|---|---|
| System.Reflection.MethodInfo |
The generated replacement method
|
A low level way to read the body of a method. Used for quick searching in methods
public static IEnumerable<KeyValuePair<OpCode, object>> ReadMethodBody(MethodBase method)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodBase | method |
The original method
|
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable\> |
All instructions as opcode/operand pairs
|
A low level way to read the body of a method. Used for quick searching in methods
public static IEnumerable<KeyValuePair<OpCode, object>> ReadMethodBody(MethodBase method, ILGenerator generator)
| 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
|
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable\> |
All instructions as opcode/operand pairs
|
Unpatches patches of a given type and/or Harmony ID
public PatchProcessor Unpatch(HarmonyPatchType type, string harmonyID)
| Type | Name | Description |
|---|---|---|
| HarmonyPatchType | type |
The HarmonyPatchType patch type
| | System.String | harmonyID |
Harmony ID or * for any
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Unpatches a specific patch
public PatchProcessor Unpatch(MethodInfo patch)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | patch |
The method of the patch
|
| Type | Description |
|---|---|
| PatchProcessor |
A PatchProcessor for chaining calls
|
Gets Harmony version for all active Harmony instances
public static Dictionary<string, Version> VersionInfo(out Version currentVersion)
| Type | Name | Description |
|---|---|---|
| System.Version | currentVersion |
[out] The current Harmony version
|
| Type | Description |
|---|---|
| System.Collections.Generic.Dictionary\ |
A dictionary containing assembly version keyed by Harmony ID
|