Class CodeMatch
A CodeInstruction match
Inherited Members
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class CodeMatch : CodeInstruction
Constructors
| Improve this Doc View SourceCodeMatch(CodeInstruction, String)
Creates a code match
Declaration
public CodeMatch(CodeInstruction instruction, string name = null)
Parameters
Type | Name | Description |
---|---|---|
CodeInstruction | instruction | The CodeInstruction |
System.String | name | An optional name |
CodeMatch(Func<CodeInstruction, Boolean>, String)
Creates a code match
Declaration
public CodeMatch(Func<CodeInstruction, bool> predicate, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<CodeInstruction, System.Boolean> | predicate | The predicate |
System.String | name | An optional name |
CodeMatch(Expression<Action>, String)
Creates a code match that calls a method
Declaration
public CodeMatch(Expression<Action> expression, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Action> | expression | The lambda expression using the method |
System.String | name | The optional name |
CodeMatch(LambdaExpression, String)
Creates a code match that calls a method
Declaration
public CodeMatch(LambdaExpression expression, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | The lambda expression using the method |
System.String | name | The optional name |
CodeMatch(Nullable<OpCode>, Object, String)
Creates a code match
Declaration
public CodeMatch(OpCode? opcode = null, object operand = null, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Reflection.Emit.OpCode> | opcode | The optional opcode |
System.Object | operand | The optional operand |
System.String | name | The optional name |
Fields
| Improve this Doc View SourcejumpsFrom
The jumps from the match
Declaration
public List<int> jumpsFrom
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Int32> |
jumpsTo
The jumps to the match
Declaration
public List<int> jumpsTo
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Int32> |
name
The name of the match
Declaration
public string name
Field Value
Type | Description |
---|---|
System.String |
opcodeSet
The matched opcodes
Declaration
public HashSet<OpCode> opcodeSet
Field Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.Reflection.Emit.OpCode> |
operands
The matched operands
Declaration
public List<object> operands
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Object> |
predicate
The match predicate
Declaration
public Func<CodeInstruction, bool> predicate
Field Value
Type | Description |
---|---|
System.Func<CodeInstruction, System.Boolean> |
Properties
| Improve this Doc View Sourceopcodes
The matched opcodes
Declaration
[Obsolete("Use opcodeSet instead")]
public List<OpCode> opcodes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.Reflection.Emit.OpCode> |
Methods
| Improve this Doc View SourceBranches(String)
Creates a code match for branching
Declaration
public static CodeMatch Branches(string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | An optional name |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
Calls(Expression<Action>)
Creates a code match that calls a method
Declaration
public static CodeMatch Calls(Expression<Action> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Action> | expression | The lambda expression using the method |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
Calls(LambdaExpression)
Creates a code match that calls a method
Declaration
public static CodeMatch Calls(LambdaExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | The lambda expression using the method |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
Calls(MethodInfo)
Tests if the code instruction calls the method/constructor
Declaration
public static CodeMatch Calls(MethodInfo method)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.MethodInfo | method | The method |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsLdarg(Nullable<Int32>)
Tests for any form of Ldarg*
Declaration
public static CodeMatch IsLdarg(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | n | The (optional) index |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsLdarga(Nullable<Int32>)
Tests for Ldarga/Ldarga_S
Declaration
public static CodeMatch IsLdarga(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | n | The (optional) index |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsLdloc(LocalBuilder)
Tests for any form of Ldloc*
Declaration
public static CodeMatch IsLdloc(LocalBuilder variable = null)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Emit.LocalBuilder | variable | The optional local variable |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsStarg(Nullable<Int32>)
Tests for Starg/Starg_S
Declaration
public static CodeMatch IsStarg(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | n | The (optional) index |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsStloc(LocalBuilder)
Tests for any form of Stloc*
Declaration
public static CodeMatch IsStloc(LocalBuilder variable = null)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Emit.LocalBuilder | variable | The optional local variable |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsArgument(Boolean, String)
Creates a code match for argument loads
Declaration
public static CodeMatch LoadsArgument(bool useAddress = false, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | useAddress | Whether to match for address loads |
System.String | name | An optional name |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant()
Tests if the code instruction loads a constant
Declaration
public static CodeMatch LoadsConstant()
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant(Double)
Tests if the code instruction loads a floating point constant
Declaration
public static CodeMatch LoadsConstant(double number)
Parameters
Type | Name | Description |
---|---|---|
System.Double | number | The floating point constant |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant(Enum)
Tests if the code instruction loads an enum constant
Declaration
public static CodeMatch LoadsConstant(Enum e)
Parameters
Type | Name | Description |
---|---|---|
System.Enum | e | The enum |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant(Int64)
Tests if the code instruction loads an integer constant
Declaration
public static CodeMatch LoadsConstant(long number)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | number | The integer constant |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant(String)
Tests if the code instruction loads a string constant
Declaration
public static CodeMatch LoadsConstant(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The string |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsField(FieldInfo, Boolean)
Tests if the code instruction loads a field
Declaration
public static CodeMatch LoadsField(FieldInfo field, bool byAddress = false)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | field | The field |
System.Boolean | byAddress | Set to true if the address of the field is loaded |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsLocal(Boolean, String)
Creates a code match for local loads
Declaration
public static CodeMatch LoadsLocal(bool useAddress = false, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | useAddress | Whether to match for address loads |
System.String | name | An optional name |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
StoresArgument(String)
Creates a code match for argument stores
Declaration
public static CodeMatch StoresArgument(string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | An optional name |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
StoresField(FieldInfo)
Tests if the code instruction stores a field
Declaration
public static CodeMatch StoresField(FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | field | The field |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
StoresLocal(String)
Creates a code match for local stores
Declaration
public static CodeMatch StoresLocal(string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | An optional name |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
ToString()
Returns a string that represents the match
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation |
Overrides
| Improve this Doc View SourceWithOpcodes(HashSet<OpCode>, Object, String)
Creates a code match
Declaration
public static CodeMatch WithOpcodes(HashSet<OpCode> opcodes, object operand = null, string name = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.HashSet<System.Reflection.Emit.OpCode> | opcodes | The opcodes |
System.Object | operand | The optional operand |
System.String | name | The optional name |
Returns
Type | Description |
---|---|
CodeMatch |