From 8d2d825be65d49d4fd99eb3055b1ba7ad5c690d1 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 31 Aug 2016 02:00:01 +0200 Subject: [PATCH] Fix code analysis warnings --- src/Components/Modules/AntiCheat.cpp | 23 +++++++++++++++-------- src/Components/Modules/News.cpp | 10 ++++++++++ src/Utils/Cryptography.hpp | 2 +- src/Utils/String.cpp | 15 ++++++++++----- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index cc2e6ebb..ed4c3515 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -136,18 +136,25 @@ namespace Components static uint8_t loadLibWStr[] = { 0xB3, 0x90, 0x9E, 0x9B, 0xB3, 0x96, 0x9D, 0x8D, 0x9E, 0x8D, 0x86, 0xA8 }; // LoadLibraryW HMODULE kernel32 = GetModuleHandleA(Utils::String::XOR(std::string(reinterpret_cast(kernel32Str), sizeof kernel32Str), -1).data()); - FARPROC loadLibA = GetProcAddress(kernel32, Utils::String::XOR(std::string(reinterpret_cast(loadLibAStr), sizeof loadLibAStr), -1).data()); - FARPROC loadLibW = GetProcAddress(kernel32, Utils::String::XOR(std::string(reinterpret_cast(loadLibWStr), sizeof loadLibWStr), -1).data()); + if (kernel32) + { + FARPROC loadLibA = GetProcAddress(kernel32, Utils::String::XOR(std::string(reinterpret_cast(loadLibAStr), sizeof loadLibAStr), -1).data()); + FARPROC loadLibW = GetProcAddress(kernel32, Utils::String::XOR(std::string(reinterpret_cast(loadLibWStr), sizeof loadLibWStr), -1).data()); + + if (loadLibA && loadLibW) + { #ifdef DEBUG_LOAD_LIBRARY - AntiCheat::LoadLibHook[0].Initialize(loadLibA, LoadLibaryAStub, HOOK_JUMP); - AntiCheat::LoadLibHook[1].Initialize(loadLibW, LoadLibaryWStub, HOOK_JUMP); + AntiCheat::LoadLibHook[0].Initialize(loadLibA, LoadLibaryAStub, HOOK_JUMP); + AntiCheat::LoadLibHook[1].Initialize(loadLibW, LoadLibaryWStub, HOOK_JUMP); #else - AntiCheat::LoadLibHook[0].Initialize(loadLibA, loadLibStub, HOOK_JUMP); - AntiCheat::LoadLibHook[1].Initialize(loadLibW, loadLibStub, HOOK_JUMP); + AntiCheat::LoadLibHook[0].Initialize(loadLibA, loadLibStub, HOOK_JUMP); + AntiCheat::LoadLibHook[1].Initialize(loadLibW, loadLibStub, HOOK_JUMP); #endif - //AntiCheat::LoadLibHook[2].Initialize(LoadLibraryExA, loadLibExStub, HOOK_JUMP); - //AntiCheat::LoadLibHook[3].Initialize(LoadLibraryExW, loadLibExStub, HOOK_JUMP); + //AntiCheat::LoadLibHook[2].Initialize(LoadLibraryExA, loadLibExStub, HOOK_JUMP); + //AntiCheat::LoadLibHook[3].Initialize(LoadLibraryExW, loadLibExStub, HOOK_JUMP); + } + } } void AntiCheat::ReadIntegrityCheck() diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index c084663e..755ed14b 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -53,6 +53,16 @@ namespace Components CreateProcessA("updater.exe", NULL, NULL, NULL, false, CREATE_NO_WINDOW, NULL, NULL, &sInfo, &pInfo); + if (pInfo.hThread && pInfo.hThread != INVALID_HANDLE_VALUE) + { + CloseHandle(pInfo.hThread); + } + + if (pInfo.hProcess && pInfo.hProcess != INVALID_HANDLE_VALUE) + { + CloseHandle(pInfo.hProcess); + } + TerminateProcess(GetCurrentProcess(), exitCode); } diff --git a/src/Utils/Cryptography.hpp b/src/Utils/Cryptography.hpp index 4adda3e7..494c894a 100644 --- a/src/Utils/Cryptography.hpp +++ b/src/Utils/Cryptography.hpp @@ -20,7 +20,7 @@ namespace Utils } else { - for (unsigned int i = (this->TokenString.size() - 1); i >= 0; i--) + for (int i = static_cast(this->TokenString.size() - 1); i >= 0; i--) { if (this->TokenString[i] == 0xFF) { diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 5d33b7ef..f303014d 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -159,12 +159,17 @@ namespace Utils { // Generate UUID data UUID uuid; - UuidCreate(&uuid); + if (!UuidCreate(&uuid)) + { + // Convert to string representation + char* strdata = nullptr; + if (!UuidToStringA(&uuid, reinterpret_cast(&strdata))) + { + return std::string(strdata); + } + } - // Convert to string representation - char* strdata = nullptr; - UuidToStringA(&uuid, reinterpret_cast(&strdata)); - return std::string(strdata); + return ""; } } }