Class CodeMatch
A CodeInstruction match
Inherited Members
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public class CodeMatch : CodeInstruction
Constructors
CodeMatch(CodeInstruction, string)
Creates a code match
Declaration
public CodeMatch(CodeInstruction instruction, string name = null)
Parameters
Type | Name | Description |
---|---|---|
CodeInstruction | instruction | The CodeInstruction |
string | name | An optional name |
CodeMatch(Func<CodeInstruction, bool>, string)
Creates a code match
Declaration
public CodeMatch(Func<CodeInstruction, bool> predicate, string name = null)
Parameters
Type | Name | Description |
---|---|---|
Func<CodeInstruction, bool> | predicate | The predicate |
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 |
---|---|---|
Expression<Action> | expression | The lambda expression using the method |
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 |
---|---|---|
LambdaExpression | expression | The lambda expression using the method |
string | name | The optional name |
CodeMatch(OpCode?, object, string)
Creates a code match
Declaration
public CodeMatch(OpCode? opcode = null, object operand = null, string name = null)
Parameters
Type | Name | Description |
---|---|---|
OpCode? | opcode | The optional opcode |
object | operand | The optional operand |
string | name | The optional name |
Fields
jumpsFrom
The jumps from the match
Declaration
public List<int> jumpsFrom
Field Value
Type | Description |
---|---|
List<int> |
jumpsTo
The jumps to the match
Declaration
public List<int> jumpsTo
Field Value
Type | Description |
---|---|
List<int> |
name
The name of the match
Declaration
public string name
Field Value
Type | Description |
---|---|
string |
opcodeSet
The matched opcodes
Declaration
public HashSet<OpCode> opcodeSet
Field Value
Type | Description |
---|---|
HashSet<OpCode> |
operands
The matched operands
Declaration
public List<object> operands
Field Value
Type | Description |
---|---|
List<object> |
predicate
The match predicate
Declaration
public Func<CodeInstruction, bool> predicate
Field Value
Type | Description |
---|---|
Func<CodeInstruction, bool> |
Methods
Branches(string)
Creates a code match for branching
Declaration
public static CodeMatch Branches(string name = null)
Parameters
Type | Name | Description |
---|---|---|
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 |
---|---|---|
Expression<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 |
---|---|---|
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 |
---|---|---|
MethodInfo | method | The method |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsLdarg(int?)
Tests for any form of Ldarg*
Declaration
public static CodeMatch IsLdarg(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
int? | n | The (optional) index |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsLdarga(int?)
Tests for Ldarga/Ldarga_S
Declaration
public static CodeMatch IsLdarga(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
int? | 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 |
---|---|---|
LocalBuilder | variable | The optional local variable |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
IsStarg(int?)
Tests for Starg/Starg_S
Declaration
public static CodeMatch IsStarg(int? n = null)
Parameters
Type | Name | Description |
---|---|---|
int? | 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 |
---|---|---|
LocalBuilder | variable | The optional local variable |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsArgument(bool, string)
Creates a code match for argument loads
Declaration
public static CodeMatch LoadsArgument(bool useAddress = false, string name = null)
Parameters
Type | Name | Description |
---|---|---|
bool | useAddress | Whether to match for address loads |
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 |
---|---|---|
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 |
---|---|---|
Enum | e | The enum |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsConstant(long)
Tests if the code instruction loads an integer constant
Declaration
public static CodeMatch LoadsConstant(long number)
Parameters
Type | Name | Description |
---|---|---|
long | 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 |
---|---|---|
string | str | The string |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsField(FieldInfo, bool)
Tests if the code instruction loads a field
Declaration
public static CodeMatch LoadsField(FieldInfo field, bool byAddress = false)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | field | The field |
bool | byAddress | Set to true if the address of the field is loaded |
Returns
Type | Description |
---|---|
CodeMatch | A new code match |
LoadsLocal(bool, string)
Creates a code match for local loads
Declaration
public static CodeMatch LoadsLocal(bool useAddress = false, string name = null)
Parameters
Type | Name | Description |
---|---|---|
bool | useAddress | Whether to match for address loads |
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 |
---|---|---|
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 |
---|---|---|
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 |
---|---|---|
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 |
---|---|
string | A string representation |
Overrides
WithOpcodes(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 |
---|---|---|
HashSet<OpCode> | opcodes | The opcodes |
object | operand | The optional operand |
string | name | The optional name |
Returns
Type | Description |
---|---|
CodeMatch |