PlotinusRedux
Warlord
- Joined
- Jul 11, 2013
- Messages
- 196
[EDIT: This entire project has been rendered unnecessary by the Window patch]
So, I finally got my DLL injection working with Civ6 from the time it starts, despite steamapi.dll's attempts to prevent it, which let me see exactly when the game is loading files and reloading or not reloading them.
As I suspected, most of the files people are having to manually copy to the game's directory to work with mods are only loaded once, before the game even gets to the Main Menu.
Specifically, all the .xml files under Base/Assets/UI/Icons; some (though not all, but including the all important units.artdef) of the .artdef files; and of course the XML files dealing with the main menu itself.
Possible Workaround
This means I could use my DLL injection, which is redirecting the CreateFile() API (for those that don't know, CreateFile() despite its name is also the Windows function to open existing files) to trap all the calls to open files and redirect them to the files under enabled mods when those exist, preventing people from having to copy files to their base install.
The problem is, since the files are only loaded at start up, any time you changed the mods that were enabled or wanted to load a save game with different mods enabled, you'd have to restart the game to get the new files loaded. That's not ideal, but it's what people are already having to do after manually copying the files to the base directory, so it would at least be an improvement.
Another problem would likely be, Windows Defender seems happy to allow my DLL injection without complaint, but I imagine it would set off all kinds of alarms for real anti-virus software, as it's exactly the kind of thing a virus would be doing, and there's no way for the anti-virus to know that in this case it's beneficial rather than harmful. Though I could work around that by altering the .exe itself--I did that with my Alpha Centauri patch and no one ever reported any anti-virus alarms.
Without knowing how long it will be before Firaxis addresses this, I may go ahead and do that--the hard part (getting the DLL injected) is already done.
Research Notes
I played around with @Deliverator 's Moar Units mod to see what I could do just with the .modinfo file itself. Adding his Civ6.dep file under <Components><ModArt>, I can see it really is loading that file from the mod directory. Unfortunately, after that, it isn't reloading Units.artdef, nor is it loading his Moar_Units.artdef file defined in his Civ6.dep, even if I add them to <ImportFiles>, etc. Since his .dep file is referring to Moar_Units.artdef which isn't being loaded, and the logs are showing no errors, I can only conclude the code is incomplete and they got as far as loading it then did nothing with it (probably because they realized it would require reloading .artdef files they're going to have to rework other code to allow).
Sadly, a number of .artdef files *are* reloaded when you create a game--Districts.artdef, Buildings.artdef, etc. But none of the Unit*.artdef files and no .artdef files you've added.
For anyone interested, here are the files that are loaded at each point, with the first set being files that would require a restart to redirect after a mod change, and the second set being files that could be changed without reloading:
Files loaded on startup before getting to the main menu: http://qskoz.com/Civ6/Civ6Loaded_BeforeMainMenu.txt
Files loaded during game creation: http://qskoz.com/Civ6/Civ6Loaded_DuringGameCreation.txt
Note Mods/MoarUnitsTest/Base/Civ6.dep is in that last set, though it seems to be ignored.
So, I finally got my DLL injection working with Civ6 from the time it starts, despite steamapi.dll's attempts to prevent it, which let me see exactly when the game is loading files and reloading or not reloading them.
As I suspected, most of the files people are having to manually copy to the game's directory to work with mods are only loaded once, before the game even gets to the Main Menu.
Specifically, all the .xml files under Base/Assets/UI/Icons; some (though not all, but including the all important units.artdef) of the .artdef files; and of course the XML files dealing with the main menu itself.
Possible Workaround
This means I could use my DLL injection, which is redirecting the CreateFile() API (for those that don't know, CreateFile() despite its name is also the Windows function to open existing files) to trap all the calls to open files and redirect them to the files under enabled mods when those exist, preventing people from having to copy files to their base install.
The problem is, since the files are only loaded at start up, any time you changed the mods that were enabled or wanted to load a save game with different mods enabled, you'd have to restart the game to get the new files loaded. That's not ideal, but it's what people are already having to do after manually copying the files to the base directory, so it would at least be an improvement.
Another problem would likely be, Windows Defender seems happy to allow my DLL injection without complaint, but I imagine it would set off all kinds of alarms for real anti-virus software, as it's exactly the kind of thing a virus would be doing, and there's no way for the anti-virus to know that in this case it's beneficial rather than harmful. Though I could work around that by altering the .exe itself--I did that with my Alpha Centauri patch and no one ever reported any anti-virus alarms.
Without knowing how long it will be before Firaxis addresses this, I may go ahead and do that--the hard part (getting the DLL injected) is already done.
Research Notes
I played around with @Deliverator 's Moar Units mod to see what I could do just with the .modinfo file itself. Adding his Civ6.dep file under <Components><ModArt>, I can see it really is loading that file from the mod directory. Unfortunately, after that, it isn't reloading Units.artdef, nor is it loading his Moar_Units.artdef file defined in his Civ6.dep, even if I add them to <ImportFiles>, etc. Since his .dep file is referring to Moar_Units.artdef which isn't being loaded, and the logs are showing no errors, I can only conclude the code is incomplete and they got as far as loading it then did nothing with it (probably because they realized it would require reloading .artdef files they're going to have to rework other code to allow).
Sadly, a number of .artdef files *are* reloaded when you create a game--Districts.artdef, Buildings.artdef, etc. But none of the Unit*.artdef files and no .artdef files you've added.
For anyone interested, here are the files that are loaded at each point, with the first set being files that would require a restart to redirect after a mod change, and the second set being files that could be changed without reloading:
Files loaded on startup before getting to the main menu: http://qskoz.com/Civ6/Civ6Loaded_BeforeMainMenu.txt
Files loaded during game creation: http://qskoz.com/Civ6/Civ6Loaded_DuringGameCreation.txt
Note Mods/MoarUnitsTest/Base/Civ6.dep is in that last set, though it seems to be ignored.
Last edited: