Fix AntiCheat plugin resolution and DLL load diagnostics#481
Open
IbrahimAlzaidi wants to merge 1 commit intoGeneralsOnlineDevelopmentTeam:pluginsfrom
Open
Fix AntiCheat plugin resolution and DLL load diagnostics#481IbrahimAlzaidi wants to merge 1 commit intoGeneralsOnlineDevelopmentTeam:pluginsfrom
IbrahimAlzaidi wants to merge 1 commit intoGeneralsOnlineDevelopmentTeam:pluginsfrom
Conversation
Fix the AntiCheat startup path so old or incomplete settings can no longer
produce the invalid DLL path `plugins/.dll`.
Previously, `NGMP_OnlineServicesManager::Init()` built the plugin DLL path
inline from `Settings.GetAnticheatPlugin()`:
plugins/{plugin}/{plugin}.dll
If `plugins.anticheat` was missing, empty, or invalid in `settings.json`, the
settings object could return an empty string and startup attempted to load:
plugins/.dll
That made the real failure hard to diagnose and also relied on process current
working directory behavior for DLL loading.
This change makes AntiCheat startup deterministic, self-diagnosing, and safer:
- Add `AnticheatPluginResolver`
- Centralizes AntiCheat plugin path resolution.
- Defaults missing/empty settings to `easyanticheat`.
- Resolves approved candidates from the game executable directory.
- Restricts candidates to the `<exe dir>/plugins` directory.
- Records selected path, tried paths, defaulting state, and diagnostic notes.
- Produces both detailed log text and user-facing failure text.
- Normalize AntiCheat settings
- Add `GenOnlineSettings::DEFAULT_ANTICHEAT_PLUGIN`.
- Default `m_Plugins_Anticheat` to `easyanticheat`.
- Make `GetAnticheatPlugin()` return the default as a final safety net.
- Normalize the value after loading settings.
- Normalize again before saving so empty values are not persisted.
- Track whether the setting was healed/defaulted so diagnostics can explain
old or missing config files accurately.
- Use resolver during online services startup
- Ensure settings are initialized before resolving the plugin.
- Replace inline `std::format("plugins/{}/{}.dll", ...)` path construction.
- Log the complete AntiCheat resolution result.
- Show a user-visible AntiCheat error if no approved plugin file is found.
- Fail closed by quitting instead of allowing online play without AntiCheat.
- Improve DLL loading
- Change `AnticheatPlugInterface::LoadPlugin()` to return `bool`.
- Add an optional failure-reason output string.
- Load the plugin from the resolved absolute path with `LoadLibraryExA`.
- Use `LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR` and
`LOAD_LIBRARY_SEARCH_DEFAULT_DIRS` for controlled dependency search.
- Capture `GetLastError()` and convert it with `FormatMessageA`.
- Report missing required exports as explicit load failures.
- Reset function pointers on failure.
- Track the last load path and Win32 load error.
- Unload any already-loaded plugin module before reloading.
The user now gets actionable failures instead of the old generic
`plugins/.dll` load error. Missing files show the exact approved paths checked.
DLL load failures show the resolved plugin path plus the formatted Windows error,
which helps distinguish missing plugin files from missing dependency DLLs,
architecture mismatches, quarantined files, or service/install issues.
Verified with:
cmake --preset win32 \
-DRTS_BUILD_GENERALS=OFF \
-DRTS_BUILD_ZEROHOUR=ON \
-DRTS_BUILD_CORE_TOOLS=OFF \
-DRTS_BUILD_ZEROHOUR_TOOLS=OFF \
-DRTS_BUILD_CORE_EXTRAS=OFF \
-DRTS_BUILD_ZEROHOUR_EXTRAS=OFF \
-DRTS_INSTALL_PREFIX_ZEROHOUR="C:/sys/Zero Hour Standalone"
cmake --build build/win32 --config Release --target z_generals --parallel 8
Build completed successfully:
[1107/1107] Linking CXX executable GeneralsMD\Release\GeneralsOnlineZH.exe
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the AntiCheat startup path so old or incomplete settings can no longer produce the invalid DLL path
plugins/.dll.Previously,
NGMP_OnlineServicesManager::Init()built the plugin DLL path inline fromSettings.GetAnticheatPlugin():If
plugins.anticheatwas missing, empty, or invalid insettings.json, the settings object could return an empty string and startup attempted to load:That made the real failure hard to diagnose and also relied on process current working directory behavior for DLL loading.
This change makes AntiCheat startup deterministic, self-diagnosing, and safer:
Add
AnticheatPluginResolvereasyanticheat.<exe dir>/pluginsdirectory.Normalize AntiCheat settings
GenOnlineSettings::DEFAULT_ANTICHEAT_PLUGIN.m_Plugins_Anticheattoeasyanticheat.GetAnticheatPlugin()return the default as a final safety net.Use resolver during online services startup
std::format("plugins/{}/{}.dll", ...)path construction.Improve DLL loading
AnticheatPlugInterface::LoadPlugin()to returnbool.LoadLibraryExA.LOAD_LIBRARY_SEARCH_DLL_LOAD_DIRandLOAD_LIBRARY_SEARCH_DEFAULT_DIRSfor controlled dependency search.GetLastError()and convert it withFormatMessageA.The user now gets actionable failures instead of the old generic
plugins/.dllload error. Missing files show the exact approved paths checked. DLL load failures show the resolved plugin path plus the formatted Windows error, which helps distinguish missing plugin files from missing dependency DLLs, architecture mismatches, quarantined files, or service/install issues.Verified with:
Build completed successfully: