Skip to content

Rework and port HookGen from MonoMod - #1152

Open
psyGamer wants to merge 10 commits into
EverestAPI:devfrom
psyGamer:hookgen
Open

Rework and port HookGen from MonoMod#1152
psyGamer wants to merge 10 commits into
EverestAPI:devfrom
psyGamer:hookgen

Conversation

@psyGamer

@psyGamer psyGamer commented Aug 3, 2026

Copy link
Copy Markdown
Member

This ports the HookGen code from MonoMod and adjusts to do avoid running MonoMod over it and instead directly integrates our patches into the generated assembly.
With this port, there are also three notable changes:

  1. IL-hooks now target the orig_ method if available. This avoids breaking mods when Everest starts patching a method, since that will move the vanilla IL instructions into the orig_ method. If the intention is to specifically hook Everest, manual hooks should be used, just like with all other Everest hooks.
  2. Some vanilla methods were inaccessible via HookGen. To further strengthen the above argument, HookGen now generates events for properties, lambdas and state-machines.
  3. The critiria for "Everest-internal" now matches to publicizer in the sense that everything not present inside the vanilla assembly will now be an error. This won't break existing mods, but might require some code changes to compile them again.

There are a handful of mods for which this is a breaking change, those would need to be updated before getting merged.

psyGamer added 10 commits August 2, 2026 17:05
When MonoMod patches a method, the vanilla IL instructions will get moved into an 'orig_' method.
This ensures IL-hooks will still see the vanilla IL, instead of Everest's code.
If the intention is to patch Everest itself, a manual hook is required like with all other Everest internals.
Due to now being directly integrated into HookGen, MMR isn't executed over it anymore and therefore the patches are no longer nessecary.
This primarily includes property getters and setters.
@maddie480-bot maddie480-bot added the 1: review needed This PR needs 2 approvals to be merged (bot-managed) label Aug 3, 2026
maddie480 added a commit to maddie480/ExtendedVariantMode that referenced this pull request Aug 10, 2026
maddie480 added a commit to maddie480/ExtendedVariantMode that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1: review needed This PR needs 2 approvals to be merged (bot-managed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants