The mod works based mostly on function interception/patching/replacement or whatever you want to call it, I haven't been consistent myself. I think people are intimidated by EXE patching because they imagine it involves writing machine code by hand, but I do almost none of that. Instead I write C code and inject it into the executable. The injection process, which is fully automated at this point, works by replacing functions with custom versions in a manner that preserves the original function so that it can be called by its replacement. I wrote about how it's implemented in respose to Tsubasanut here:
https://forums.civfanatics.com/thre...es-in-exe-modding.666881/page-3#post-16049068. This technique is very useful, clearly it can intercept function calls and modify them, but in addition it can:
- intercept function returns by replacing a function, calling the original first thing, then running some code afterward
- track changes in state by replacing every function that potentially modifies some state and check its value after versus before calling the original (for example this is how the disorder warning code detects that the player has signaled an intention to end the turn)
- pass info through a side channel (f.e. if you want function B to get some info from its caller A, intercept A and set a global variable then read it in B)
- alter a single function call by intercepting the callee then running different code depending on the return address
All of this depends on knowledge gained by reverse engineering the executable, naturally you can't replace a function without first figuring out what it does and you can't read or write the game's memory without knowing what's kept where and how.