ILHookHelperAPI

v1.0.1·Updated 2021-04-04

Implements a functional-styled DSL for working with ILHooks inside C# syntax.

About this mod Author’s original text

Figured I might as well release some of my tooling so others can benefit from it.

Summary

This is a library that adds a functional-style DSL for writing IL hooks.

Wtf is a DSL?

DSL = Domain Specific (programming) Language

In this case, its a fancy term for a set of functions that enable a specific style of programming within your C# code.

Wtf does functional-style mean?

Don't worry about it if you don't know.

All you really need to know is that this style makes your IL hooks much, much, much easier to read and write.

Example code

Simple value swap

static void MyILHook(ILContext il) => new ILCursor(il).Goto(x => x.MatchLdcR4(2.65f)).Delete().Op_LdConst(3.5f);

Swap add for custom function

static void MyILHook(ILContext il) => new ILCursor(il).Goto(x => x.MatchAdd()).Delete().OP_Call>((lhs, rhs) => lhs * rhs + 14);

Store value from one place, reuse it in another

static void MyILHook(ILContext il) => new ILCursor(il).Goto(MoveType.After, x => x.MatchLdfld(nameof(Cheese.goodLevel))).OP_Dup().AddLocal(out var index).OP_StLocal(index).Goto(MoveType.After, x => x.MatchLdfld(nameof(NotCheese.badLevel))).OP_LdLocal(index).OP_Sub();

Spam console with useless text to confuse users

private void MyILHook(ILContext il) => new ILCursor(il).Log(base.Logger.LogError).LogContext(base.Logger.LogFatal);

Why?

Initially I told myself I was releasing this to make life easier for some other people but then I spent 2 hours in paint making this horrible icon. Now I actually have no idea why I released this and am instead left with a profound feeling of self-doubt, confusion, and emptiness.

Changelog

1.0.1

-Fixed nullability of a few cursor functions

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

File & checksum

Filename
ILHookHelperAPI-1.0.1.zip
File size
12.6 KiB
SHA-256
8e865751c9cda851cefd5c9156067836d99e4e466fb3277f20941177c5f9e13a
Stored at
2026-10-12 00:53