-
Notifications
You must be signed in to change notification settings - Fork 43
Patch attributes
The page outlines the new added HarmonyX patch attributes. The attributes can be generally applied to methods and classes like the normal HarmonyPatch
attribute.
Example:
[HarmonyPrefix]
[HarmonyWrapSafe]
[HarmonyPatch(typeof(TargetClass), "TargetMethod")]
static void ExamplePrefix();
The attribute will automatically wrap the patch into a generic try
/catch
block that catches all exceptions. Any exceptions thrown by the patch are logged by Harmony as errors but are otherwise skipped. Other patches and original code are unaffected.
Example:
[HarmonyEmitIL("./dumps")]
[HarmonyPrefix]
[HarmonyPatch(typeof(TargetClass), "TargetMethod")]
static void ExamplePrefix();
When the attribute is specified, Harmony will emit a .dll
assembly containing the patched version of the target method into the specified folder.
The patched method is the code that the original method was replaced with and as such contains all prefixes, postfixes, transpilers, finalizers and manipulators applied to the method.
Each generated DLL is named HarmonyDump.<name of the method>.<random id>.dll
.
NOTE:
The emitted patch method does not contain any detours applied by MonoMod.RuntimeDetour. Only Harmony patches and any ILHooks applied prior to Harmony are visible in the emitted DLL.
- 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