Hey everyone,
After SC4Fix, I went on a hiatus for college and decided to turn my attention to loading DLLs into the game using native methods. SC4Fix works but uses a really hackish method where it overwrites bits of code that would unload DLLs the game doesn't recognize. This is something that I've wanted to do for six years since Paul Pedriana (very graciously) sent me some incomplete but critical code for making proper SC4 DLLs.
I recently threw out all of the code I wrote and started from scratch with Paul's code as a starting point. Using the Aspyr port of the game for cross-checking (since it holds a lot of debug information that the Windows version doesn't have), I finally managed to create a DLL that the game can load, recognize, and communicate with. This also essentially gives us the foundation of the SimCity 4 SDK that would be needed for accomplishing more advanced tasks.
Source Code
Test DLL
What I have right now is pretty basic: SC4 can load the DLL, recognize it as a real framework DLL, and our code can subscribe to game events like PostAppInit, PostFrameWorkInit, PreAppShutdown, and others. I feel that the next step would be to expand the code to replicate the functionality of the Extra Cheats DLL. Buggi has partial source code that includes the most crucial components aside from the rest of the SDK, and I've managed to assemble a basic SDK to work with, so this should be done pretty soon.
The best part about having this kind of DLL is that it works with every Windows version of SC4 at least, and probably works with the Mac version (but I haven't tested this) — v610, v638, v640, and v641 should all be able to use this with no problem because the API never changes.
---
As an aside, while investigating how DLLs are loaded by the game, I also learned that you can create INI files that tell the game whether or not to load certain DLLs.
You can create a file in the Plugins folder called DLLName.ini (where DLLName corresponds to the filename of the DLL minus the file extension) with the following content:
Changing "true" to "false" stops the game from loading the DLL, and changing it back to true allows it to load again. Pretty neat in my opinion, and I hadn't seen this documented anywhere else, so I figured I'd share it here.
---
Final aside, I'm planning on making this a general development thread for myself so I don't have to make a new thread for everything I find. Once I have more to report on I'll probably change the title of this thread.