From 7b85f19d258a76af09453c1676737c22c441871d Mon Sep 17 00:00:00 2001 From: EnergyCube Date: Mon, 26 Dec 2022 01:10:32 +0100 Subject: [PATCH] Fixed some small compilation issues --- EEStats/EEStats/ComputerQuery.cpp | 2 +- EEStats/EEStats/ComputerQueryPrivate.cpp | 27 +++++++++++++----------- EEStats/EEStats/EEStats.cpp | 1 + EEStats/EEStats/EEStats.h | 4 ++-- EEStats/EEStats/EEStats.vcxproj | 26 +++++++++++------------ EEStats/EEStats/Library.h | 14 ++++++++++-- EEStats/EEStats/Logger.h | 11 +++++++++- EEStats/EEStats/Utils.h | 4 ++-- EEStats/EEStats/dllmain.cpp | 2 +- 9 files changed, 57 insertions(+), 34 deletions(-) diff --git a/EEStats/EEStats/ComputerQuery.cpp b/EEStats/EEStats/ComputerQuery.cpp index 5161e57..08fb07e 100644 --- a/EEStats/EEStats/ComputerQuery.cpp +++ b/EEStats/EEStats/ComputerQuery.cpp @@ -313,7 +313,7 @@ int ComputerQuery::getDirectX_MajorVersion() return 11; case WinVista: { auto updIds = _wmiHelper->queryWMI("SELECT HotFixID FROM Win32_QuickFixEngineering", L"HotFixID"); - for (auto iter = updIds.begin(); iter != updIds.end();) + for (auto iter = updIds.begin(); iter != updIds.end(); ++iter) if (iter->compare(L"KB971644") == 0) // Nice one MS return 11; return 10; diff --git a/EEStats/EEStats/ComputerQueryPrivate.cpp b/EEStats/EEStats/ComputerQueryPrivate.cpp index d17d262..0dbc247 100644 --- a/EEStats/EEStats/ComputerQueryPrivate.cpp +++ b/EEStats/EEStats/ComputerQueryPrivate.cpp @@ -2,64 +2,67 @@ #include "ComputerQuery.h" #include "Utils.h" - #include "sha512.h" +#include +#include "Logger.h" + std::string ComputerQuery::getBiosSerial() { - return ""; + return ""; } + std::string ComputerQuery::getWindowsDiskSerial() { - return ""; + return ""; } std::string ComputerQuery::getComputerSerial() { - return ""; + return ""; } std::string ComputerQuery::getUID() { - return ""; + return ""; } bool ComputerQuery::runInVirtualPC() // Who use that ? { - return false; + return false; } - bool ComputerQuery::runInVMWare() { - return false; + return false; } bool ComputerQuery::runInVirtualBox() { - return false; + return false; } bool ComputerQuery::runInParallelsDesktop() { - return false; + return false; } bool ComputerQuery::runInOtherVM() { - return false; + return false; } bool ComputerQuery::runInVM() { - if (runInOtherVM() || runInVMWare() || runInVirtualBox() || runInVirtualPC() || runInParallelsDesktop()) + if (runInOtherVM() || runInVMWare() || runInVirtualBox() || runInVirtualPC() /*|| runInParallelsDesktop() don't work*/) return true; return false; } /// DLL EXPORT FOR EE COMMUNITY SETUP #include +#include #define DllExport extern "C" __declspec(dllexport) DllExport const char* EEStats_getUID() diff --git a/EEStats/EEStats/EEStats.cpp b/EEStats/EEStats/EEStats.cpp index 71cfa67..2ed6ddb 100644 --- a/EEStats/EEStats/EEStats.cpp +++ b/EEStats/EEStats/EEStats.cpp @@ -458,6 +458,7 @@ std::pair> EEStats::sendRequest(std::string p curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &replyTxt); curl_easy_setopt(curl, CURLOPT_USERAGENT, ("EmpireEarthStats/" + _lib_version).c_str()); + curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 1000L); #ifdef _DEBUG // WARN: Using freopen_s to redirect to a file will crash curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); diff --git a/EEStats/EEStats/EEStats.h b/EEStats/EEStats/EEStats.h index 39907b3..f866772 100644 --- a/EEStats/EEStats/EEStats.h +++ b/EEStats/EEStats/EEStats.h @@ -9,10 +9,10 @@ #include "ComputerQuery.h" // EES VERSION -static const std::string EES_VERSION_STR = "1.0.3"; +static const std::string EES_VERSION_STR = "1.0.4"; static const unsigned int EES_VERSION_MAJOR = 1; static const unsigned int EES_VERSION_MINOR = 0; -static const unsigned int EES_VERSION_PATCH = 3; +static const unsigned int EES_VERSION_PATCH = 4; // END EES VERSION // EES HARD-CODED SETTINGS diff --git a/EEStats/EEStats/EEStats.vcxproj b/EEStats/EEStats/EEStats.vcxproj index 7148021..8414f80 100644 --- a/EEStats/EEStats/EEStats.vcxproj +++ b/EEStats/EEStats/EEStats.vcxproj @@ -23,38 +23,38 @@ Win32Proj {2f0a372f-2e7a-431b-a439-05a82f3a8c56} EEStats - 10.0 + 7.0 DynamicLibrary true - v143 + v141_xp Unicode - Static + false DynamicLibrary false - v143 + v141_xp true Unicode - Static + false DynamicLibrary true - v143 + v141_xp Unicode - Static + false DynamicLibrary false - v143 + v141_xp true Unicode - Static + false @@ -88,7 +88,7 @@ Windows true false - Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a_debug.lib + Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a_debug.lib @@ -109,7 +109,7 @@ true true false - Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a.lib + Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a.lib @@ -126,7 +126,7 @@ Windows true false - Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a_debug.lib + Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a_debug.lib @@ -147,7 +147,7 @@ true true false - Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a.lib + Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a.lib diff --git a/EEStats/EEStats/Library.h b/EEStats/EEStats/Library.h index 299ca13..8c4a168 100644 --- a/EEStats/EEStats/Library.h +++ b/EEStats/EEStats/Library.h @@ -4,6 +4,13 @@ #include #include +#include + +#ifndef _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING + #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +#endif +#include +namespace fs = std::experimental::filesystem; class Library { @@ -16,7 +23,7 @@ class Library { Logger::showMessage("Loading...", "Library"); - _dllPath = getDllPath(); + _dllPath = getDllPathUtils(); // EE Stats _ees = new EEStats(EES_SETTINGS_URL, EES_VERSION_STR); @@ -68,8 +75,10 @@ class Library { Logger::showMessage("The remains of a completed update have been found, cleaning...", "Library"); - if (DeleteFile(oldFile.c_str())) + if (DeleteFile(oldFile.c_str())) { + SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, fs::current_path().c_str(), NULL); // Refresh explorer Logger::showMessage("The cleaning was successful!", "Library"); + } else Logger::showMessage("Unable to clean!", "Library", true); } @@ -88,6 +97,7 @@ class Library Logger::showMessage("An update is pending, deactivating the current version and activating the new one...", "Library"); if (MoveFile(currentFile.c_str(), oldFile.c_str()) && MoveFile(updateFile.c_str(), currentFile.c_str())) { + SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH | SHCNF_FLUSHNOWAIT, fs::current_path().c_str(), NULL); // Refresh explorer Logger::showMessage("The update seems to be installed, the next boot will start the new one and remove the old version!", "Library"); } else { diff --git a/EEStats/EEStats/Logger.h b/EEStats/EEStats/Logger.h index 9d12d5e..5b5e289 100644 --- a/EEStats/EEStats/Logger.h +++ b/EEStats/EEStats/Logger.h @@ -18,7 +18,16 @@ class Logger public: Logger() = default; - ~Logger() = default; + ~Logger() { + if (_ofs) { + _ofs.flush(); + _ofs.close(); + } + + if (_f) { + fclose(_f); + } + } static Logger& getInstance() { static Logger logger; diff --git a/EEStats/EEStats/Utils.h b/EEStats/EEStats/Utils.h index 2b94b8b..de40124 100644 --- a/EEStats/EEStats/Utils.h +++ b/EEStats/EEStats/Utils.h @@ -9,7 +9,7 @@ #include #include -static std::wstring getDllPath() +static std::wstring getDllPathUtils() { // Dll Name TCHAR dllPath[MAX_PATH]; @@ -17,7 +17,7 @@ static std::wstring getDllPath() // Passing a static function to recover the DLL Module Handle if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - (LPWSTR)&getDllPath, &hModule)) { + (LPWSTR)&getDllPathUtils, &hModule)) { throw std::exception("Unable to get module handle of an internal function"); } else { diff --git a/EEStats/EEStats/dllmain.cpp b/EEStats/EEStats/dllmain.cpp index d1ae52d..7c41931 100644 --- a/EEStats/EEStats/dllmain.cpp +++ b/EEStats/EEStats/dllmain.cpp @@ -15,7 +15,7 @@ bool __stdcall Attach() { if (GameQuery().getProductType() == GameQuery::PT_Unknown) return true; // Loaded by another program than the game, no need to do anything. - std::wstring dllPath = getDllPath(); + std::wstring dllPath = getDllPathUtils(); std::wstring dllName = getFileName(dllPath, false); // Instant create mutex to avoid multiple load if the DLL stop for some reasons during game startup