mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 16:50:06 +00:00 
			
		
		
		
	Merge pull request #338 from dpaulat/hotfix/warn-on-nahimic-dll
Add check for NahimicOSD.dll
This commit is contained in:
		
						commit
						d81f187d88
					
				
					 7 changed files with 153 additions and 16 deletions
				
			
		|  | @ -51,9 +51,11 @@ find_package(Qt${QT_VERSION_MAJOR} | ||||||
| set(SRC_EXE_MAIN source/scwx/qt/main/main.cpp) | set(SRC_EXE_MAIN source/scwx/qt/main/main.cpp) | ||||||
| 
 | 
 | ||||||
| set(HDR_MAIN source/scwx/qt/main/application.hpp | set(HDR_MAIN source/scwx/qt/main/application.hpp | ||||||
|              source/scwx/qt/main/main_window.hpp) |              source/scwx/qt/main/main_window.hpp | ||||||
|  |              source/scwx/qt/main/process_validation.hpp) | ||||||
| set(SRC_MAIN source/scwx/qt/main/application.cpp | set(SRC_MAIN source/scwx/qt/main/application.cpp | ||||||
|              source/scwx/qt/main/main_window.cpp) |              source/scwx/qt/main/main_window.cpp | ||||||
|  |              source/scwx/qt/main/process_validation.cpp) | ||||||
| set(UI_MAIN  source/scwx/qt/main/main_window.ui) | set(UI_MAIN  source/scwx/qt/main/main_window.ui) | ||||||
| set(HDR_CONFIG source/scwx/qt/config/county_database.hpp | set(HDR_CONFIG source/scwx/qt/config/county_database.hpp | ||||||
|                source/scwx/qt/config/radar_site.hpp) |                source/scwx/qt/config/radar_site.hpp) | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #include <scwx/qt/config/county_database.hpp> | #include <scwx/qt/config/county_database.hpp> | ||||||
| #include <scwx/qt/config/radar_site.hpp> | #include <scwx/qt/config/radar_site.hpp> | ||||||
| #include <scwx/qt/main/main_window.hpp> | #include <scwx/qt/main/main_window.hpp> | ||||||
|  | #include <scwx/qt/main/process_validation.hpp> | ||||||
| #include <scwx/qt/main/versions.hpp> | #include <scwx/qt/main/versions.hpp> | ||||||
| #include <scwx/qt/manager/log_manager.hpp> | #include <scwx/qt/manager/log_manager.hpp> | ||||||
| #include <scwx/qt/manager/radar_product_manager.hpp> | #include <scwx/qt/manager/radar_product_manager.hpp> | ||||||
|  | @ -113,6 +114,9 @@ int main(int argc, char* argv[]) | ||||||
|    // Theme
 |    // Theme
 | ||||||
|    ConfigureTheme(args); |    ConfigureTheme(args); | ||||||
| 
 | 
 | ||||||
|  |    // Check process modules for compatibility
 | ||||||
|  |    scwx::qt::main::CheckProcessModules(); | ||||||
|  | 
 | ||||||
|    // Run initial setup if required
 |    // Run initial setup if required
 | ||||||
|    if (scwx::qt::ui::setup::SetupWizard::IsSetupRequired()) |    if (scwx::qt::ui::setup::SetupWizard::IsSetupRequired()) | ||||||
|    { |    { | ||||||
|  | @ -170,7 +174,8 @@ static void ConfigureTheme(const std::vector<std::string>& args) | ||||||
|    QGuiApplication::styleHints()->setColorScheme(qtColorScheme); |    QGuiApplication::styleHints()->setColorScheme(qtColorScheme); | ||||||
| 
 | 
 | ||||||
|    std::optional<std::string> paletteFile; |    std::optional<std::string> paletteFile; | ||||||
|    if (uiStyle == scwx::qt::types::UiStyle::FusionCustom) { |    if (uiStyle == scwx::qt::types::UiStyle::FusionCustom) | ||||||
|  |    { | ||||||
|       paletteFile = generalSettings.theme_file().GetValue(); |       paletteFile = generalSettings.theme_file().GetValue(); | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|  |  | ||||||
							
								
								
									
										109
									
								
								scwx-qt/source/scwx/qt/main/process_validation.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								scwx-qt/source/scwx/qt/main/process_validation.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,109 @@ | ||||||
|  | #include <scwx/qt/main/process_validation.hpp> | ||||||
|  | #include <scwx/util/logger.hpp> | ||||||
|  | 
 | ||||||
|  | #if defined(_WIN32) | ||||||
|  | #   include <scwx/qt/settings/general_settings.hpp> | ||||||
|  | 
 | ||||||
|  | #   include <wtypes.h> | ||||||
|  | #   include <Psapi.h> | ||||||
|  | 
 | ||||||
|  | #   include <boost/algorithm/string/predicate.hpp> | ||||||
|  | #   include <boost/locale.hpp> | ||||||
|  | #   include <fmt/ranges.h> | ||||||
|  | #   include <QCheckBox> | ||||||
|  | #   include <QMessageBox> | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | namespace scwx::qt::main | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | static const std::string logPrefix_ = "scwx::qt::main::process_validation"; | ||||||
|  | static const auto        logger_    = util::Logger::Create(logPrefix_); | ||||||
|  | 
 | ||||||
|  | void CheckProcessModules() | ||||||
|  | { | ||||||
|  | #if defined(_WIN32) | ||||||
|  |    HANDLE  process = GetCurrentProcess(); | ||||||
|  |    HMODULE modules[1024]; | ||||||
|  |    DWORD   cbNeeded = 0; | ||||||
|  | 
 | ||||||
|  |    std::vector<std::string> incompatibleDlls {}; | ||||||
|  |    std::vector<std::string> descriptions {}; | ||||||
|  | 
 | ||||||
|  |    auto& processModuleWarningsEnabled = | ||||||
|  |       settings::GeneralSettings::Instance().process_module_warnings_enabled(); | ||||||
|  | 
 | ||||||
|  |    if (EnumProcessModules(process, modules, sizeof(modules), &cbNeeded)) | ||||||
|  |    { | ||||||
|  |       std::uint32_t numModules = cbNeeded / sizeof(HMODULE); | ||||||
|  |       for (std::uint32_t i = 0; i < numModules; ++i) | ||||||
|  |       { | ||||||
|  |          char modulePath[MAX_PATH]; | ||||||
|  |          if (GetModuleFileNameExA(process, modules[i], modulePath, MAX_PATH)) | ||||||
|  |          { | ||||||
|  |             std::string path = modulePath; | ||||||
|  | 
 | ||||||
|  |             logger_->trace("DLL Found: {}", path); | ||||||
|  | 
 | ||||||
|  |             if (boost::algorithm::iends_with(path, "NahimicOSD.dll")) | ||||||
|  |             { | ||||||
|  |                std::string description = | ||||||
|  |                   QObject::tr( | ||||||
|  |                      "ASUS Sonic Studio injects a Nahimic driver, which causes " | ||||||
|  |                      "Supercell Wx to hang. It is suggested to disable the " | ||||||
|  |                      "Nahimic service, or to uninstall ASUS Sonic Studio and " | ||||||
|  |                      "the Nahimic driver.") | ||||||
|  |                      .toStdString(); | ||||||
|  | 
 | ||||||
|  |                logger_->warn("Incompatible DLL found: {}", path); | ||||||
|  |                logger_->warn("{}", description); | ||||||
|  | 
 | ||||||
|  |                // Only populate vectors for the message box if warnings are
 | ||||||
|  |                // enabled
 | ||||||
|  |                if (processModuleWarningsEnabled.GetValue()) | ||||||
|  |                { | ||||||
|  |                   incompatibleDlls.push_back(path); | ||||||
|  |                   descriptions.push_back(description); | ||||||
|  |                } | ||||||
|  |             } | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    if (!incompatibleDlls.empty()) | ||||||
|  |    { | ||||||
|  |       const std::string header = | ||||||
|  |          QObject::tr( | ||||||
|  |             "The following DLLs have been injected into the Supercell Wx " | ||||||
|  |             "process:") | ||||||
|  |             .toStdString(); | ||||||
|  |       const std::string defaultMessage = | ||||||
|  |          QObject::tr( | ||||||
|  |             "Supercell Wx is known to not run correctly with these DLLs " | ||||||
|  |             "injected. We suggest stopping or uninstalling these services if " | ||||||
|  |             "you experience crashes or unexpected behavior while using " | ||||||
|  |             "Supercell Wx.") | ||||||
|  |             .toStdString(); | ||||||
|  | 
 | ||||||
|  |       std::string message = fmt::format("{}\n\n{}\n\n{}\n\n{}", | ||||||
|  |                                         header, | ||||||
|  |                                         fmt::join(incompatibleDlls, "\n"), | ||||||
|  |                                         defaultMessage, | ||||||
|  |                                         fmt::join(descriptions, "\n")); | ||||||
|  | 
 | ||||||
|  |       QMessageBox dialog(QMessageBox::Icon::Warning, | ||||||
|  |                          QObject::tr("Supercell Wx"), | ||||||
|  |                          QString::fromStdString(message)); | ||||||
|  |       QCheckBox*  checkBox = | ||||||
|  |          new QCheckBox(QObject::tr("Don't show this message again"), &dialog); | ||||||
|  |       dialog.setCheckBox(checkBox); | ||||||
|  |       dialog.exec(); | ||||||
|  | 
 | ||||||
|  |       // Stage the result of the checkbox. This value will be committed on
 | ||||||
|  |       // shutdown.
 | ||||||
|  |       processModuleWarningsEnabled.StageValue(!checkBox->isChecked()); | ||||||
|  |    } | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace scwx::qt::main
 | ||||||
							
								
								
									
										8
									
								
								scwx-qt/source/scwx/qt/main/process_validation.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								scwx-qt/source/scwx/qt/main/process_validation.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | namespace scwx::qt::main | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | void CheckProcessModules(); | ||||||
|  | 
 | ||||||
|  | } // namespace scwx::qt::main
 | ||||||
|  | @ -69,6 +69,7 @@ public: | ||||||
|       nmeaBaudRate_.SetDefault(9600); |       nmeaBaudRate_.SetDefault(9600); | ||||||
|       nmeaSource_.SetDefault(""); |       nmeaSource_.SetDefault(""); | ||||||
|       positioningPlugin_.SetDefault(defaultPositioningPlugin); |       positioningPlugin_.SetDefault(defaultPositioningPlugin); | ||||||
|  |       processModuleWarningsEnabled_.SetDefault(true); | ||||||
|       showMapAttribution_.SetDefault(true); |       showMapAttribution_.SetDefault(true); | ||||||
|       showMapCenter_.SetDefault(false); |       showMapCenter_.SetDefault(false); | ||||||
|       showMapLogo_.SetDefault(true); |       showMapLogo_.SetDefault(true); | ||||||
|  | @ -162,12 +163,14 @@ public: | ||||||
|    SettingsVariable<std::int64_t> nmeaBaudRate_ {"nmea_baud_rate"}; |    SettingsVariable<std::int64_t> nmeaBaudRate_ {"nmea_baud_rate"}; | ||||||
|    SettingsVariable<std::string>  nmeaSource_ {"nmea_source"}; |    SettingsVariable<std::string>  nmeaSource_ {"nmea_source"}; | ||||||
|    SettingsVariable<std::string>  positioningPlugin_ {"positioning_plugin"}; |    SettingsVariable<std::string>  positioningPlugin_ {"positioning_plugin"}; | ||||||
|    SettingsVariable<bool>         showMapAttribution_ {"show_map_attribution"}; |    SettingsVariable<bool>         processModuleWarningsEnabled_ { | ||||||
|    SettingsVariable<bool>         showMapCenter_ {"show_map_center"}; |       "process_module_warnings_enabled"}; | ||||||
|    SettingsVariable<bool>         showMapLogo_ {"show_map_logo"}; |    SettingsVariable<bool>        showMapAttribution_ {"show_map_attribution"}; | ||||||
|    SettingsVariable<std::string>  theme_ {"theme"}; |    SettingsVariable<bool>        showMapCenter_ {"show_map_center"}; | ||||||
|    SettingsVariable<std::string>  themeFile_ {"theme_file"}; |    SettingsVariable<bool>        showMapLogo_ {"show_map_logo"}; | ||||||
|    SettingsVariable<bool>         trackLocation_ {"track_location"}; |    SettingsVariable<std::string> theme_ {"theme"}; | ||||||
|  |    SettingsVariable<std::string> themeFile_ {"theme_file"}; | ||||||
|  |    SettingsVariable<bool>        trackLocation_ {"track_location"}; | ||||||
|    SettingsVariable<bool> updateNotificationsEnabled_ {"update_notifications"}; |    SettingsVariable<bool> updateNotificationsEnabled_ {"update_notifications"}; | ||||||
|    SettingsVariable<std::string> warningsProvider_ {"warnings_provider"}; |    SettingsVariable<std::string> warningsProvider_ {"warnings_provider"}; | ||||||
|    SettingsVariable<bool>        cursorIconAlwaysOn_ {"cursor_icon_always_on"}; |    SettingsVariable<bool>        cursorIconAlwaysOn_ {"cursor_icon_always_on"}; | ||||||
|  | @ -197,6 +200,7 @@ GeneralSettings::GeneralSettings() : | ||||||
|                       &p->nmeaBaudRate_, |                       &p->nmeaBaudRate_, | ||||||
|                       &p->nmeaSource_, |                       &p->nmeaSource_, | ||||||
|                       &p->positioningPlugin_, |                       &p->positioningPlugin_, | ||||||
|  |                       &p->processModuleWarningsEnabled_, | ||||||
|                       &p->showMapAttribution_, |                       &p->showMapAttribution_, | ||||||
|                       &p->showMapCenter_, |                       &p->showMapCenter_, | ||||||
|                       &p->showMapLogo_, |                       &p->showMapLogo_, | ||||||
|  | @ -316,6 +320,11 @@ SettingsVariable<std::string>& GeneralSettings::positioning_plugin() const | ||||||
|    return p->positioningPlugin_; |    return p->positioningPlugin_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | SettingsVariable<bool>& GeneralSettings::process_module_warnings_enabled() const | ||||||
|  | { | ||||||
|  |    return p->processModuleWarningsEnabled_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| SettingsVariable<bool>& GeneralSettings::show_map_attribution() const | SettingsVariable<bool>& GeneralSettings::show_map_attribution() const | ||||||
| { | { | ||||||
|    return p->showMapAttribution_; |    return p->showMapAttribution_; | ||||||
|  | @ -374,6 +383,7 @@ bool GeneralSettings::Shutdown() | ||||||
|    dataChanged |= p->loopDelay_.Commit(); |    dataChanged |= p->loopDelay_.Commit(); | ||||||
|    dataChanged |= p->loopSpeed_.Commit(); |    dataChanged |= p->loopSpeed_.Commit(); | ||||||
|    dataChanged |= p->loopTime_.Commit(); |    dataChanged |= p->loopTime_.Commit(); | ||||||
|  |    dataChanged |= p->processModuleWarningsEnabled_.Commit(); | ||||||
|    dataChanged |= p->trackLocation_.Commit(); |    dataChanged |= p->trackLocation_.Commit(); | ||||||
| 
 | 
 | ||||||
|    return dataChanged; |    return dataChanged; | ||||||
|  | @ -407,6 +417,8 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs) | ||||||
|            lhs.p->nmeaBaudRate_ == rhs.p->nmeaBaudRate_ && |            lhs.p->nmeaBaudRate_ == rhs.p->nmeaBaudRate_ && | ||||||
|            lhs.p->nmeaSource_ == rhs.p->nmeaSource_ && |            lhs.p->nmeaSource_ == rhs.p->nmeaSource_ && | ||||||
|            lhs.p->positioningPlugin_ == rhs.p->positioningPlugin_ && |            lhs.p->positioningPlugin_ == rhs.p->positioningPlugin_ && | ||||||
|  |            lhs.p->processModuleWarningsEnabled_ == | ||||||
|  |               rhs.p->processModuleWarningsEnabled_ && | ||||||
|            lhs.p->showMapAttribution_ == rhs.p->showMapAttribution_ && |            lhs.p->showMapAttribution_ == rhs.p->showMapAttribution_ && | ||||||
|            lhs.p->showMapCenter_ == rhs.p->showMapCenter_ && |            lhs.p->showMapCenter_ == rhs.p->showMapCenter_ && | ||||||
|            lhs.p->showMapLogo_ == rhs.p->showMapLogo_ && |            lhs.p->showMapLogo_ == rhs.p->showMapLogo_ && | ||||||
|  |  | ||||||
|  | @ -45,12 +45,13 @@ public: | ||||||
|    SettingsVariable<std::int64_t>&               nmea_baud_rate() const; |    SettingsVariable<std::int64_t>&               nmea_baud_rate() const; | ||||||
|    SettingsVariable<std::string>&                nmea_source() const; |    SettingsVariable<std::string>&                nmea_source() const; | ||||||
|    SettingsVariable<std::string>&                positioning_plugin() const; |    SettingsVariable<std::string>&                positioning_plugin() const; | ||||||
|    SettingsVariable<bool>&                       show_map_attribution() const; |    SettingsVariable<bool>&        process_module_warnings_enabled() const; | ||||||
|    SettingsVariable<bool>&                       show_map_center() const; |    SettingsVariable<bool>&        show_map_attribution() const; | ||||||
|    SettingsVariable<bool>&                       show_map_logo() const; |    SettingsVariable<bool>&        show_map_center() const; | ||||||
|    SettingsVariable<std::string>&                theme() const; |    SettingsVariable<bool>&        show_map_logo() const; | ||||||
|    SettingsVariable<std::string>&                theme_file() const; |    SettingsVariable<std::string>& theme() const; | ||||||
|    SettingsVariable<bool>&                       track_location() const; |    SettingsVariable<std::string>& theme_file() const; | ||||||
|  |    SettingsVariable<bool>&        track_location() const; | ||||||
|    SettingsVariable<bool>&        update_notifications_enabled() const; |    SettingsVariable<bool>&        update_notifications_enabled() const; | ||||||
|    SettingsVariable<std::string>& warnings_provider() const; |    SettingsVariable<std::string>& warnings_provider() const; | ||||||
|    SettingsVariable<bool>&        cursor_icon_always_on() const; |    SettingsVariable<bool>&        cursor_icon_always_on() const; | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| Subproject commit 0d085b1df59045e14ca996982b4907b1a0da4fdb | Subproject commit 24ececcd183d3b8961e5638da89f0eb36309cd6b | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat