-
Notifications
You must be signed in to change notification settings - Fork 44
Home
A library for patching, replacing and decorating .NET methods during runtime powered by MonoMod.
NOTE: The documentation here is still incomplete. Refer to the Harmony 2 documentation for more detail, however keep in mind that some features may not have been ported to HarmonyX.
If you develop in C# and your code is loaded as a module/plugin into a host application, you can use HarmonyX (later referred to as Harmony) to alter the functionality of all the available assemblies of that application. Where other patch libraries simply allow you to replace the original method, Harmony goes one step further and gives you:
- A way to keep the original method intact
- Execute your code before and/or after the original method
- Modify the original with IL code processors
- Multiple Harmony patches co-exist and don't conflict with each other
HarmonyX builds on top the original Harmony library, extending and streamlining its features. Most importantly, you get
- Streamlined exception messages
- Better logging
- New Harmony 2 features while keeping compatibility with Harmony 1 (reverse patching to be added at a later date)
At the same time, HarmonyX is based on MonoMod, a robust tool for patching .NET assemblies. With it, you get additional additional features such as
- Ability to target methods marked with
extern
- Ability to use HarmonyX in environments where dynamic code generation is not supported (e.g. Unity's .NET Standard 2.0 API)
- Interop with MonoMod patches
HarmonyX works on any games that support running code in .NET. Currently HarmonyX is built against the following targets:
- .NET Framework 3.5
- .NET Framework 4.0
- .NET Standard 2.0
HarmonyX has been tested mainly on Unity games and has been confirmed to work on all Unity versions (even ones with dynamic code generation disabled).
HarmonyX supports patching on all architectures that MonoMod supports. At the time of the writing, that is x86, x64, ARM, ARM64.
- 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