DeltaLoaderDocs
  1. Home
  2. Developer Documentation
  3. Mod lifecycle

Mod lifecycle

What happens from loading to unloading.

Load#

  1. The injector checks the target: 64-bit, the right process name, no anti-cheat module, and the SHA-256 of the game executable.
  2. The DLL is loaded with LoadLibraryW. The game executable is not patched.
  3. The DllMain part of the framework starts your thread and checks the SHA-256 and all byte signatures in memory. If anything is off, sw_mod_start() is not called and the console says why.
  4. sw_mod_start() runs on its own thread. Until you set hooks, your code has no effect on game threads.

Unload#

  1. The loader (or the in-game mod menu) calls the export swmod_shutdown().
  2. The framework sets sw::mod::running() to false, waits for your sw_mod_start() thread to end, calls sw_mod_stop() and removes all hooks of the mod.
  3. It waits until no game thread is still inside a callback of the DLL (sw::Hook::idle()).
  4. Only then is the DLL freed.

If a callback is still busy after up to 5 seconds, the DLL is left loaded: a small leak beats a crash.

Rules#

  • Loops check sw::mod::sleep(ms) or sw::mod::running().
  • Callbacks are short; slow work goes to the mod thread.
  • Do not keep pointers into the DLL after sw_mod_stop().

Documentation for game build 1.15.26. Found a mistake? Open an issue.