AutoHookGenPatcher

版本 v1.1.1·更新於 2026-05-02

Automatically generates MonoMod.RuntimeDetour.HookGen's MMHOOK files during the BepInEx preloader phase.

模組介紹 作者原文

AutoHookGenPatcher

Automatically generates MonoMod.RuntimeDetour.HookGen's MMHOOK files during the BepInEx preloader phase.

Manual Installation:

Move the BepInEx folder from the ZIP file to the BepInEx folder of the game.

This project is not officially linked with BepInEx nor with MonoMod.

This software is based off of HookGenPatcher by HarbingerOfMe, which is also licensed under MIT.

Differences to the original HookGenPatcher

  • Instead of only having a fixed list of files to generate MMHOOK files for, AutoHookGenPatcher will get the MMHOOK file references from installed plugins, and generates those MMHOOK files if possible.
  • AutoHookGenPatcher makes use of a cache file to quickly check if everything is still up to date, without needing to check every MMHOOK file for that information.
  • Hook Generation is now multithreaded, meaning that generating multiple MMHOOK files takes less time. For example, generating an MMHOOK file for every file in the Managed directory of Lethal Company takes about 22.5 seconds instead of 40.0 seconds it would take with no multithreading, on my machine.

Usage For Developers

Note: By default, AutoHookGenPatcher already generates an MMHOOK assembly for Assembly-CSharp.dll. So if you only need MMHOOK_Assembly-CSharp.dll, you don't need to do anything.

Using AutoHookGenPatcher is really simple, and the only thing you need to do is tell it to generate the MMHOOK files you want in the first place. This can be by editing the config file AutoHookGenPatcher.cfg, and setting the [Generate MMHOOK File for All Plugins] setting's Enabled value to true:

[Generate MMHOOK File for All Plugins]

If enabled, AutoHookGenPatcher will generate MMHOOK files for all plugins

even if their MMHOOK files were not referenced by other plugins.

Use this for getting the MMHOOK files you need for your plugin.

Setting type: Boolean

Default value: false

Enabled = true

Automatically disable the above setting after the MMHOOK files have been generated.

Setting type: Boolean

Default value: true

Disable After Generating = true

When you publish your mod, make sure to add AutoHookGenPatcher as a dependency in the package you upload.

Q&A

How does AutoHookGenPatcher figure out which MMHOOK files my mod references?

  • During the BepInEx Preloader phase, AutoHookGenPatcher will open\* and read the metadata of every DLL file for referenced assemblies and looks for references that start with MMHOOK_. It will then check if any installed assemblies match the rest of the name, and will run MonoMod's HookGen on those assemblies if they exist.

\This is only done if the date modified* metadata of the assembly on disk is newer than previous known date in AutoHookGenPatcher's cache file. Referenced MMHOOK assemblies are also saved in the cache.

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPackHamunii-DetourContext_Dispose_Fix

檔案與校驗

檔案名稱
AutoHookGenPatcher-1.1.1.zip
檔案大小
74.3 KiB