docs/api/HarmonyLib.CodeMatch.html
A CodeInstruction match
System.Object
CodeMatch
[CodeInstruction.Call(Type, String, Type[], Type[])](HarmonyLib.CodeInstruction.html#HarmonyLib_CodeInstruction_Call_System_Type_System_String_System_Type System_Type )
[CodeInstruction.Call(String, Type[], Type[])](HarmonyLib.CodeInstruction.html#HarmonyLib_CodeInstruction_Call_System_String_System_Type System_Type )
CodeInstruction.Call(Expression<Action>)
[CodeInstruction.Call<T>(Expression<Action<T>>)](HarmonyLib.CodeInstruction.html#HarmonyLib_CodeInstruction_Call 1_System_Linq_Expressions_Expression_System_Action_ 0___)
[CodeInstruction.Call<T, TResult>(Expression<Func<T, TResult>>)](HarmonyLib.CodeInstruction.html#HarmonyLib_CodeInstruction_Call 2_System_Linq_Expressions_Expression_System_Func_ 0 1 )
CodeInstruction.Call(LambdaExpression)
[CodeInstruction.CallClosure<T>(T)](HarmonyLib.CodeInstruction.html#HarmonyLib_CodeInstruction_CallClosure 1_ 0_)
CodeInstruction.LoadField(Type, String, Boolean)
CodeInstruction.StoreField(Type, String)
CodeInstruction.LoadLocal(Int32, Boolean)
CodeInstruction.StoreLocal(Int32)
CodeInstruction.LoadArgument(Int32, Boolean)
CodeInstruction.StoreArgument(Int32)
CodeInstruction.HasBlock(ExceptionBlockType)
public class CodeMatch : CodeInstruction
Creates a code match
public CodeMatch(CodeInstruction instruction, string name = null)
| Type | Name | Description |
|---|---|---|
| CodeInstruction | instruction |
The CodeInstruction
| | System.String | name |
An optional name
|
Creates a code match
public CodeMatch(Func<CodeInstruction, bool> predicate, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Func<CodeInstruction, System.Boolean> | predicate |
The predicate
| | System.String | name |
An optional name
|
Creates a code match that calls a method
public CodeMatch(Expression<Action> expression, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression\ | expression |
The lambda expression using the method
| | System.String | name |
The optional name
|
Creates a code match that calls a method
public CodeMatch(LambdaExpression expression, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.LambdaExpression | expression |
The lambda expression using the method
| | System.String | name |
The optional name
|
Creates a code match
public CodeMatch(OpCode? opcode = default(OpCode? ), object operand = null, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Nullable\ | opcode |
The optional opcode
| | System.Object | operand |
The optional operand
| | System.String | name |
The optional name
|
The jumps from the match
public List<int> jumpsFrom
| Type | Description |
|---|---|
| System.Collections.Generic.List\ |
The jumps to the match
public List<int> jumpsTo
| Type | Description |
|---|---|
| System.Collections.Generic.List\ |
The name of the match
public string name
| Type | Description |
|---|---|
| System.String |
The matched opcodes
public HashSet<OpCode> opcodeSet
| Type | Description |
|---|---|
| System.Collections.Generic.HashSet\ |
The matched operands
public List<object> operands
| Type | Description |
|---|---|
| System.Collections.Generic.List\ |
The match predicate
public Func<CodeInstruction, bool> predicate
| Type | Description |
|---|---|
| System.Func<CodeInstruction, System.Boolean> |
Creates a code match for branching
public static CodeMatch Branches(string name = null)
| Type | Name | Description |
|---|---|---|
| System.String | name |
An optional name
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match that calls a method
public static CodeMatch Calls(Expression<Action> expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression\ | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match that calls a method
public static CodeMatch Calls(LambdaExpression expression)
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.LambdaExpression | expression |
The lambda expression using the method
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction calls the method/constructor
public static CodeMatch Calls(MethodInfo method)
| Type | Name | Description |
|---|---|---|
| System.Reflection.MethodInfo | method |
The method
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests for any form of Ldarg*
public static CodeMatch IsLdarg(int? n = default(int? ))
| Type | Name | Description |
|---|---|---|
| System.Nullable\ | n |
The (optional) index
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests for Ldarga/Ldarga_S
public static CodeMatch IsLdarga(int? n = default(int? ))
| Type | Name | Description |
|---|---|---|
| System.Nullable\ | n |
The (optional) index
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests for any form of Ldloc*
public static CodeMatch IsLdloc(LocalBuilder variable = null)
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.LocalBuilder | variable |
The optional local variable
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests for Starg/Starg_S
public static CodeMatch IsStarg(int? n = default(int? ))
| Type | Name | Description |
|---|---|---|
| System.Nullable\ | n |
The (optional) index
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests for any form of Stloc*
public static CodeMatch IsStloc(LocalBuilder variable = null)
| Type | Name | Description |
|---|---|---|
| System.Reflection.Emit.LocalBuilder | variable |
The optional local variable
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match for argument loads
public static CodeMatch LoadsArgument(bool useAddress = false, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Boolean | useAddress |
Whether to match for address loads
| | System.String | name |
An optional name
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads a constant
public static CodeMatch LoadsConstant()
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads a floating point constant
public static CodeMatch LoadsConstant(double number)
| Type | Name | Description |
|---|---|---|
| System.Double | number |
The floating point constant
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads an enum constant
public static CodeMatch LoadsConstant(Enum e)
| Type | Name | Description |
|---|---|---|
| System.Enum | e |
The enum
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads an integer constant
public static CodeMatch LoadsConstant(long number)
| Type | Name | Description |
|---|---|---|
| System.Int64 | number |
The integer constant
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads a string constant
public static CodeMatch LoadsConstant(string str)
| Type | Name | Description |
|---|---|---|
| System.String | str |
The string
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction loads a field
public static CodeMatch LoadsField(FieldInfo field, bool byAddress = false)
| Type | Name | Description |
|---|---|---|
| System.Reflection.FieldInfo | field |
The field
| | System.Boolean | byAddress |
Set to true if the address of the field is loaded
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match for local loads
public static CodeMatch LoadsLocal(bool useAddress = false, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Boolean | useAddress |
Whether to match for address loads
| | System.String | name |
An optional name
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match for argument stores
public static CodeMatch StoresArgument(string name = null)
| Type | Name | Description |
|---|---|---|
| System.String | name |
An optional name
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Tests if the code instruction stores a field
public static CodeMatch StoresField(FieldInfo field)
| Type | Name | Description |
|---|---|---|
| System.Reflection.FieldInfo | field |
The field
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Creates a code match for local stores
public static CodeMatch StoresLocal(string name = null)
| Type | Name | Description |
|---|---|---|
| System.String | name |
An optional name
|
| Type | Description |
|---|---|
| CodeMatch |
A new code match
|
Returns a string that represents the match
public override string ToString()
| Type | Description |
|---|---|
| System.String |
A string representation
|
Creates a code match
public static CodeMatch WithOpcodes(HashSet<OpCode> opcodes, object operand = null, string name = null)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.HashSet\ | opcodes |
The opcodes
| | System.Object | operand |
The optional operand
| | System.String | name |
The optional name
|
| Type | Description |
|---|---|
| CodeMatch |
CodeInstructionExtensions.OperandIs(CodeInstruction, Object)
CodeInstructionExtensions.OperandIs(CodeInstruction, MemberInfo)
CodeInstructionExtensions.Is(CodeInstruction, OpCode, Object)
CodeInstructionExtensions.Is(CodeInstruction, OpCode, MemberInfo)
CodeInstructionExtensions.IsLdarg(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsLdarga(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsStarg(CodeInstruction, Nullable<Int32>)
CodeInstructionExtensions.IsLdloc(CodeInstruction, LocalBuilder)
CodeInstructionExtensions.IsStloc(CodeInstruction, LocalBuilder)
CodeInstructionExtensions.Branches(CodeInstruction, out Nullable<Label>)
CodeInstructionExtensions.Calls(CodeInstruction, MethodInfo)
CodeInstructionExtensions.LoadsConstant(CodeInstruction)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Int64)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Double)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, Enum)
CodeInstructionExtensions.LoadsConstant(CodeInstruction, String)
CodeInstructionExtensions.LoadsField(CodeInstruction, FieldInfo, Boolean)
CodeInstructionExtensions.StoresField(CodeInstruction, FieldInfo)
CodeInstructionExtensions.LocalIndex(CodeInstruction)
CodeInstructionExtensions.ArgumentIndex(CodeInstruction)
CodeInstructionExtensions.WithLabels(CodeInstruction, Label[])
CodeInstructionExtensions.WithLabels(CodeInstruction, IEnumerable<Label>)
CodeInstructionExtensions.ExtractLabels(CodeInstruction)
CodeInstructionExtensions.MoveLabelsTo(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.MoveLabelsFrom(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.WithBlocks(CodeInstruction, ExceptionBlock[])
CodeInstructionExtensions.WithBlocks(CodeInstruction, IEnumerable<ExceptionBlock>)
CodeInstructionExtensions.ExtractBlocks(CodeInstruction)
CodeInstructionExtensions.MoveBlocksTo(CodeInstruction, CodeInstruction)
CodeInstructionExtensions.MoveBlocksFrom(CodeInstruction, CodeInstruction)