-
Notifications
You must be signed in to change notification settings - Fork 44
Patching
Andreas Pardeike edited this page Jan 13, 2017
·
26 revisions
Each prefix and postfix gets all parameters of the original method as well as the instance (if original method is not static) and the return value. In order to patch a method your patches need to follow the following principles when defining them:
- Prefix and postfix are static methods
- A prefix must return a boolean
- If original method is not static, prefix and postfix get the instance as the first parameter
- A prefix gets a reference to the return value
- Prefix and postfix get all original parameters as references
- Prefix will not get any out parameters
// original method in class Customer
private List<string> getNames(int count, out Error error)
// prefix
static bool Prefix(Customer instance, ref List<string> result, ref int count)
// postfix
static void Postfix(Customer customer, ref List<string> result, ref int count, ref Error error)
- Basic usage
-
HarmonyX extensions
1.1. Patching and unpatching
1.2. Prefixes are flowthrough
1.3. Targeting multiple methods with one patch
1.4. Patching enumerators
1.5. Transpiler helpers
1.6. ILManipulators
1.7. Extended patch targets
1.8. New patch attributes -
Extending HarmonyX
2.1. Custom patcher backends -
Misc
4.1. Patch parameters - Implementation differences from Harmony