Skip to content

Commit

Permalink
Fixed some small compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EnergyCube committed Dec 26, 2022
1 parent 0328d07 commit 7b85f19
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 34 deletions.
2 changes: 1 addition & 1 deletion EEStats/EEStats/ComputerQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 15 additions & 12 deletions EEStats/EEStats/ComputerQueryPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,67 @@

#include "ComputerQuery.h"
#include "Utils.h"

#include "sha512.h"

#include <thread>
#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 <thread>
#include <process.h>
#define DllExport extern "C" __declspec(dllexport)

DllExport const char* EEStats_getUID()
Expand Down
1 change: 1 addition & 0 deletions EEStats/EEStats/EEStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ std::pair<bool, std::pair<long, std::string>> 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);
Expand Down
4 changes: 2 additions & 2 deletions EEStats/EEStats/EEStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions EEStats/EEStats/EEStats.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{2f0a372f-2e7a-431b-a439-05a82f3a8c56}</ProjectGuid>
<RootNamespace>EEStats</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -88,7 +88,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a_debug.lib</AdditionalDependencies>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a_debug.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -109,7 +109,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a.lib</AdditionalDependencies>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -126,7 +126,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a_debug.lib</AdditionalDependencies>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a_debug.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -147,7 +147,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;curl/libcurl_a.lib</AdditionalDependencies>
<AdditionalDependencies>Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib;wbemuuid.lib;Shell32.lib;curl/libcurl_a.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions EEStats/EEStats/Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

#include <string>
#include <iostream>
#include <ShlObj.h>

#ifndef _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#endif
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;

class Library
{
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion EEStats/EEStats/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions EEStats/EEStats/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include <string>
#include <regex>

static std::wstring getDllPath()
static std::wstring getDllPathUtils()
{
// Dll Name
TCHAR dllPath[MAX_PATH];
HMODULE hModule;
// 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 {
Expand Down
2 changes: 1 addition & 1 deletion EEStats/EEStats/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7b85f19

Please sign in to comment.