diff --git a/dll/base.cpp b/dll/base.cpp index b84cba5..d451206 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -17,13 +17,7 @@ #include "base.h" -#ifdef STEAM_WIN32 -#include -#include - -#define SystemFunction036 NTAPI SystemFunction036 -#include -#undef SystemFunction036 +#ifdef __WINDOWS__ static void randombytes(char * const buf, const size_t size) @@ -46,11 +40,6 @@ std::string get_env_variable(std::string name) #else -#include -#include -#include -#include - static int fd = -1; static void randombytes(char *buf, size_t size) @@ -149,9 +138,19 @@ CSteamID generate_steam_id_lobby() return CSteamID(generate_account_id(), k_unSteamUserDefaultInstance | k_EChatInstanceFlagLobby, k_EUniversePublic, k_EAccountTypeChat); } -#ifndef STEAM_WIN32 -#include -#include +bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout) +{ + if (timeout == 0.0) return true; + + std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now(); + if (std::chrono::duration_cast>(now - old).count() > timeout) { + return true; + } + + return false; +} + +#ifdef __LINUX__ std::string get_lib_path() { std::string dir = "/proc/self/map_files"; DIR *dp; @@ -194,7 +193,7 @@ std::string get_lib_path() { std::string get_full_lib_path() { std::string program_path; -#if defined(STEAM_WIN32) +#if defined(__WINDOWS__) char DllPath[MAX_PATH] = {0}; GetModuleFileName((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath)); program_path = DllPath; @@ -474,8 +473,7 @@ void Auth_Ticket_Manager::Callback(Common_Message *msg) } #ifdef EMU_EXPERIMENTAL_BUILD -#ifdef STEAM_WIN32 -#include "../detours/detours.h" +#ifdef __WINDOWS__ struct ips_test { uint32_t ip_from; @@ -596,13 +594,6 @@ inline bool file_exists (const std::string& name) { return (stat (name.c_str(), &buffer) == 0); } -#ifdef DETOURS_64BIT -#define DLL_NAME "steam_api64.dll" -#else -#define DLL_NAME "steam_api.dll" -#endif - - HMODULE (WINAPI *Real_GetModuleHandleA)(LPCSTR lpModuleName) = GetModuleHandleA; HMODULE WINAPI Mine_GetModuleHandleA(LPCSTR lpModuleName) { @@ -648,12 +639,6 @@ static void load_dll() } } -#ifdef DETOURS_64BIT -#define LUMA_CEG_DLL_NAME "LumaCEG_Plugin_x64.dll" -#else -#define LUMA_CEG_DLL_NAME "LumaCEG_Plugin_x86.dll" -#endif - static void load_lumaCEG() { std::string path = get_full_program_path(); @@ -700,7 +685,6 @@ bool crack_SteamAPI_Init() return false; } -#include HINTERNET (WINAPI *Real_WinHttpConnect)( IN HINTERNET hSession, diff --git a/dll/base.h b/dll/base.h index 25a61f6..646c851 100644 --- a/dll/base.h +++ b/dll/base.h @@ -18,78 +18,14 @@ #ifndef BASE_INCLUDE #define BASE_INCLUDE -#if defined(WIN64) || defined(_WIN64) || defined(__MINGW64__) - #define __WINDOWS_64__ -#elif defined(WIN32) || defined(_WIN32) || defined(__MINGW32__) - #define __WINDOWS_32__ -#endif - -#if defined(__WINDOWS_32__) || defined(__WINDOWS_64__) - #define __WINDOWS__ -#endif - -#if defined(__linux__) || defined(linux) - #if defined(__x86_64__) - #define __LINUX_64__ - #else - #define __LINUX_32__ - #endif -#endif - -#if defined(__LINUX_32__) || defined(__LINUX_64__) - #define __LINUX__ -#endif - -#if defined(__WINDOWS__) -#define STEAM_WIN32 -#ifndef NOMINMAX -# define NOMINMAX -#endif -#endif - -#define STEAM_API_EXPORTS -#include "../sdk_includes/steam_gameserver.h" -#include "../sdk_includes/steamdatagram_tickets.h" - -#include -#include -#include -#include - -//#define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);} -#ifdef STEAM_WIN32 -#include -#include -#include -#include -EXTERN_C IMAGE_DOS_HEADER __ImageBase; -#define PATH_SEPARATOR "\\" -#ifndef EMU_RELEASE_BUILD -#define PRINT_DEBUG(a, ...) do {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t); WSASetLastError(0);} while (0) -#endif -#else -#include -#define PATH_SEPARATOR "/" -#ifndef EMU_RELEASE_BUILD -#define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);} -#endif -#endif -//#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__) -#ifdef EMU_RELEASE_BUILD -#define PRINT_DEBUG(...) -#endif - -#include "settings.h" -#include "local_storage.h" -#include "network.h" - -#include "defines.h" +#include "common_includes.h" #define PUSH_BACK_IF_NOT_IN(vector, element) { if(std::find(vector.begin(), vector.end(), element) == vector.end()) vector.push_back(element); } extern std::recursive_mutex global_mutex; std::string get_env_variable(std::string name); +bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout); class CCallbackMgr { diff --git a/dll/common_includes.h b/dll/common_includes.h new file mode 100644 index 0000000..4096a14 --- /dev/null +++ b/dll/common_includes.h @@ -0,0 +1,172 @@ +/* Copyright (C) 2019 Mr Goldberg + This file is part of the Goldberg Emulator + + The Goldberg Emulator is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + The Goldberg Emulator is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the Goldberg Emulator; if not, see + . */ + +#ifndef __INCLUDED_COMMON_INCLUDES__ +#define __INCLUDED_COMMON_INCLUDES__ + +#if defined(WIN64) || defined(_WIN64) || defined(__MINGW64__) + #define __WINDOWS_64__ +#elif defined(WIN32) || defined(_WIN32) || defined(__MINGW32__) + #define __WINDOWS_32__ +#endif + +#if defined(__WINDOWS_32__) || defined(__WINDOWS_64__) + #define __WINDOWS__ +#endif + +#if defined(__linux__) || defined(linux) + #if defined(__x86_64__) + #define __LINUX_64__ + #else + #define __LINUX_32__ + #endif +#endif + +#if defined(__LINUX_32__) || defined(__LINUX_64__) + #define __LINUX__ +#endif + +#if defined(__WINDOWS__) + #define STEAM_WIN32 + #ifndef NOMINMAX + #define NOMINMAX + #endif +#endif + +#define STEAM_API_EXPORTS + +#if defined(__WINDOWS__) + #include + #include + #include + #include + #include + #include + #include // Include winsock2 before this, or winsock2 iphlpapi will be unavailable + #include + + #define MSG_NOSIGNAL 0 + + #define SystemFunction036 NTAPI SystemFunction036 + #include + #undef SystemFunction036 + + #ifndef EMU_RELEASE_BUILD + #define PRINT_DEBUG(a, ...) do {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t); WSASetLastError(0);} while (0) + #endif + + EXTERN_C IMAGE_DOS_HEADER __ImageBase; + #define PATH_SEPARATOR "\\" + + #ifdef EMU_EXPERIMENTAL_BUILD + #include + + #include "../detours/detours.h" + + #ifdef DETOURS_64BIT + #define LUMA_CEG_DLL_NAME "LumaCEG_Plugin_x64.dll" + #define DLL_NAME "steam_api64.dll" + #else + #define LUMA_CEG_DLL_NAME "LumaCEG_Plugin_x86.dll" + #define DLL_NAME "steam_api.dll" + #endif + #endif + +#elif defined(__LINUX__) + #include + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + + #include + #include + #include + #include + #include + #include + + #define PATH_MAX_STRING_SIZE 512 + + #ifndef EMU_RELEASE_BUILD + #define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);} + #endif + #define PATH_SEPARATOR "/" +#endif +//#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__) +#ifdef EMU_RELEASE_BUILD + #define PRINT_DEBUG(...) +#endif + +// C/C++ includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +// Other libs includes +#include "../json/json.hpp" +#include "../controller/gamepad.h" + +// Steamsdk includes +#include "../sdk_includes/steam_api.h" +#include "../sdk_includes/steam_gameserver.h" +#include "../sdk_includes/steamdatagram_tickets.h" + +// Emulator includes +#include "net.pb.h" +#include "settings.h" +#include "local_storage.h" +#include "network.h" + +// Emulator defines +#define CLIENT_HSTEAMUSER 1 +#define SERVER_HSTEAMUSER 1 + +#define DEFAULT_NAME "Goldberg" +#define PROGRAM_NAME "Goldberg SteamEmu" +#define DEFAULT_LANGUAGE "english" + +#define LOBBY_CONNECT_APPID ((uint32)-2) + +#endif//__INCLUDED_COMMON_INCLUDES__ \ No newline at end of file diff --git a/dll/defines.h b/dll/defines.h deleted file mode 100644 index b7d98c9..0000000 --- a/dll/defines.h +++ /dev/null @@ -1,9 +0,0 @@ -//TODO: put these in a common .h -#define CLIENT_HSTEAMUSER 1 -#define SERVER_HSTEAMUSER 1 - -#define DEFAULT_NAME "Goldberg" -#define PROGRAM_NAME "Goldberg SteamEmu" -#define DEFAULT_LANGUAGE "english" - -#define LOBBY_CONNECT_APPID ((uint32)-2) diff --git a/dll/dll.cpp b/dll/dll.cpp index d6bc0f8..b18827e 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -44,7 +44,6 @@ static char old_inventory[128] = "STEAMINVENTORY_INTERFACE_V001"; static char old_video[128] = "STEAMVIDEO_INTERFACE_V001"; static char old_masterserver_updater[128] = "SteamMasterServerUpdater001"; -#include static void load_old_interface_versions() { static bool loaded = false; diff --git a/dll/flat.cpp b/dll/flat.cpp index 951d035..e054503 100644 --- a/dll/flat.cpp +++ b/dll/flat.cpp @@ -19,7 +19,6 @@ #define STEAM_API_FUNCTIONS_IMPL #include "dll.h" #include "../sdk_includes/steam_api_flat.h" -#include STEAMAPI_API HSteamPipe SteamAPI_ISteamClient_CreateSteamPipe( ISteamClient* self ) { diff --git a/dll/local_storage.cpp b/dll/local_storage.cpp index f1b3d45..6bddb3a 100644 --- a/dll/local_storage.cpp +++ b/dll/local_storage.cpp @@ -17,11 +17,6 @@ #include "local_storage.h" -#include -#include -#include -#include - struct File_Data { std::string name; }; @@ -149,8 +144,7 @@ std::vector Local_Storage::get_filenames_path(std::string path) } #else -#if defined(WIN32) || defined(_WIN32) -#include +#if defined(__WINDOWS__) static BOOL DirectoryExists(LPCSTR szPath) { @@ -176,11 +170,6 @@ static void create_directory(std::string strPath) createDirectoryRecursively(strPath); } -#include -#include -#include - - static std::vector get_filenames(std::string strPath) { std::vector output; @@ -250,14 +239,7 @@ static std::vector get_filenames_recursive(std::string base_pa return output; } -#else -#include -#include -#include -#include -#include - -#define PATH_MAX_STRING_SIZE 512 +#else /* recursive mkdir */ static int mkdir_p(const char *dir, const mode_t mode) { @@ -397,11 +379,6 @@ std::string Local_Storage::get_game_settings_path() return get_program_path().append(game_settings_folder).append(PATH_SEPARATOR); } -#if defined(STEAM_WIN32) -#include -#include -#endif - std::string Local_Storage::get_user_appdata_path() { std::string user_appdata_path = "SAVE"; diff --git a/dll/local_storage.h b/dll/local_storage.h index 394fae2..49fe2d0 100644 --- a/dll/local_storage.h +++ b/dll/local_storage.h @@ -15,14 +15,10 @@ License along with the Goldberg Emulator; if not, see . */ -#include "base.h" -#include - #ifndef LOCAL_STORAGE_INCLUDE #define LOCAL_STORAGE_INCLUDE -#include -#include "../json/json.hpp" +#include "base.h" #define MAX_FILENAME_LENGTH 300 diff --git a/dll/net.proto b/dll/net.proto index e486ae3..5b0f627 100644 --- a/dll/net.proto +++ b/dll/net.proto @@ -79,7 +79,7 @@ message Low_Level { Types type = 1; } -message Network { +message Network_pb { uint32 channel = 1; bytes data = 2; @@ -204,7 +204,7 @@ message Common_Message { Low_Level low_level = 4; Lobby lobby = 5; Lobby_Messages lobby_messages = 6; - Network network = 7; + Network_pb network = 7; Gameserver gameserver = 8; Friend friend = 9; Auth_Ticket auth_ticket = 10; diff --git a/dll/network.cpp b/dll/network.cpp index 3529168..2de7de3 100644 --- a/dll/network.cpp +++ b/dll/network.cpp @@ -17,22 +17,6 @@ #include "network.h" -#if defined(STEAM_WIN32) - -#define MSG_NOSIGNAL 0 - -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - #define MAX_BROADCASTS 16 static int number_broadcasts = -1; static IP_PORT broadcasts[MAX_BROADCASTS]; @@ -45,8 +29,6 @@ static uint32_t upper_range_ips[MAX_BROADCASTS]; #if defined(STEAM_WIN32) -#include - //windows xp support static int inet_pton4(const char *src, uint32_t *dst) @@ -489,18 +471,6 @@ static bool recv_tcp(struct TCP_Socket &socket) return false; } -bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout) -{ - if (timeout == 0.0) return true; - - std::chrono::high_resolution_clock::time_point now = std::chrono::high_resolution_clock::now(); - if (std::chrono::duration_cast>(now - old).count() > timeout) { - return true; - } - - return false; -} - static void socket_timeouts(struct TCP_Socket &socket, double extra_time) { if (check_timedout(socket.last_heartbeat_sent, HEARTBEAT_TIMEOUT / 2.0)) { diff --git a/dll/network.h b/dll/network.h index 793b0f4..015115c 100644 --- a/dll/network.h +++ b/dll/network.h @@ -15,13 +15,10 @@ License along with the Goldberg Emulator; if not, see . */ -#include "base.h" - #ifndef NETWORK_INCLUDE #define NETWORK_INCLUDE -#include "net.pb.h" -#include +#include "base.h" inline bool protobuf_message_equal(const google::protobuf::MessageLite& msg_a, const google::protobuf::MessageLite& msg_b) { @@ -38,8 +35,6 @@ typedef unsigned int sock_t; typedef int sock_t; #endif -bool check_timedout(std::chrono::high_resolution_clock::time_point old, double timeout); - struct IP_PORT { uint32 ip; uint16 port; diff --git a/dll/settings.h b/dll/settings.h index ce4bb76..f813cd9 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -15,12 +15,11 @@ License along with the Goldberg Emulator; if not, see . */ -#include "base.h" -#include - #ifndef SETTINGS_INCLUDE #define SETTINGS_INCLUDE +#include "base.h" + struct DLC_entry { AppId_t appID; std::string name; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index a68d291..67bfb8a 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -16,10 +16,6 @@ . */ #include "settings_parser.h" -#include -#include -#include -#include static void consume_bom(std::ifstream &input) { diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 1f5e89f..818eeed 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -18,8 +18,6 @@ #include "steam_client.h" #include "settings_parser.h" -#include - static std::condition_variable kill_background_thread_cv; static std::atomic_bool kill_background_thread; static void background_thread(Steam_Client *client) diff --git a/dll/steam_client.h b/dll/steam_client.h index 5f98e33..bb5943c 100644 --- a/dll/steam_client.h +++ b/dll/steam_client.h @@ -56,8 +56,6 @@ #include "../overlay_experimental/steam_overlay.h" -#include - enum Steam_Pipe { NO_USER, CLIENT, diff --git a/dll/steam_controller.h b/dll/steam_controller.h index c316c80..835e081 100644 --- a/dll/steam_controller.h +++ b/dll/steam_controller.h @@ -16,8 +16,6 @@ . */ #include "base.h" -#include "../controller/gamepad.h" -#include struct Controller_Map { std::map> active_digital; diff --git a/dll/steam_game_coordinator.h b/dll/steam_game_coordinator.h index 34f0df8..1ba2b88 100644 --- a/dll/steam_game_coordinator.h +++ b/dll/steam_game_coordinator.h @@ -16,7 +16,6 @@ . */ #include "base.h" -#include class Steam_Game_Coordinator : public ISteamGameCoordinator diff --git a/dll/steam_inventory.h b/dll/steam_inventory.h index 2236d1d..df98fba 100644 --- a/dll/steam_inventory.h +++ b/dll/steam_inventory.h @@ -16,7 +16,6 @@ . */ #include "base.h" // For SteamItemDef_t -#include "../json/json.hpp" struct Steam_Inventory_Requests { double timeout = 0.1; diff --git a/dll/steam_networking.h b/dll/steam_networking.h index f225bf5..4a19845 100644 --- a/dll/steam_networking.h +++ b/dll/steam_networking.h @@ -16,7 +16,6 @@ . */ #include "base.h" -#include //packet timeout in seconds for non connections #define ORPHANED_PACKET_TIMEOUT (20) @@ -278,16 +277,16 @@ bool SendP2PPacket( CSteamID steamIDRemote, const void *pubData, uint32 cubData, Common_Message msg; msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); msg.set_dest_id(steamIDRemote.ConvertToUint64()); - msg.set_allocated_network(new Network); + msg.set_allocated_network(new Network_pb); if (!connection_exists(steamIDRemote)) { - msg.mutable_network()->set_type(Network::NEW_CONNECTION); + msg.mutable_network()->set_type(Network_pb::NEW_CONNECTION); network->sendTo(&msg, true); } msg.mutable_network()->set_channel(nChannel); msg.mutable_network()->set_data(pubData, cubData); - msg.mutable_network()->set_type(Network::DATA); + msg.mutable_network()->set_type(Network_pb::DATA); struct Steam_Networking_Connection *conn = get_or_create_connection(steamIDRemote); new_connection_times.erase(steamIDRemote); @@ -914,11 +913,11 @@ void Callback(Common_Message *msg) }PRINT_DEBUG("\n"); #endif - if (msg->network().type() == Network::DATA) { + if (msg->network().type() == Network_pb::DATA) { unprocessed_messages.push_back(Common_Message(*msg)); } - if (msg->network().type() == Network::NEW_CONNECTION) { + if (msg->network().type() == Network_pb::NEW_CONNECTION) { std::lock_guard lock(messages_mutex); auto msg_temp = std::begin(messages); while (msg_temp != std::end(messages)) { diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index 3c28b40..544e0db 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -21,10 +21,6 @@ #include "base.h" #include "../overlay_experimental/steam_overlay.h" -#include -#include -#include "../json/json.hpp" - struct Steam_Leaderboard { std::string name; ELeaderboardSortMethod sort_method; diff --git a/dll/wrap.cpp b/dll/wrap.cpp index 289b217..50defc7 100644 --- a/dll/wrap.cpp +++ b/dll/wrap.cpp @@ -28,18 +28,6 @@ #include "base.h" #include "dll.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #define PATH_SEPARATOR_CHAR '/' #define STEAM_PATH_CACHE_SIZE 4096 diff --git a/lobby_connect.cpp b/lobby_connect.cpp index 8743ecd..8219c36 100644 --- a/lobby_connect.cpp +++ b/lobby_connect.cpp @@ -19,7 +19,7 @@ */ #include "sdk_includes/steam_api.h" -#include "dll/defines.h" +#include "dll/common_includes.h" #include #include diff --git a/overlay_experimental/Base_Hook.h b/overlay_experimental/Base_Hook.h index 54396cf..dd23dba 100644 --- a/overlay_experimental/Base_Hook.h +++ b/overlay_experimental/Base_Hook.h @@ -3,9 +3,6 @@ #ifdef EMU_OVERLAY -#include -#include - #include "../dll/base.h" class Base_Hook diff --git a/overlay_experimental/Renderer_Detector.cpp b/overlay_experimental/Renderer_Detector.cpp index 6655ad4..5768a4d 100644 --- a/overlay_experimental/Renderer_Detector.cpp +++ b/overlay_experimental/Renderer_Detector.cpp @@ -220,7 +220,7 @@ void Renderer_Detector::hook_dx9() IDirect3D9Ex* pD3D = nullptr; IUnknown* pDevice = nullptr; - HMODULE library = GetModuleHandle(DX9_Hook::DLL_NAME); + HMODULE library = GetModuleHandle(DX9_DLL); decltype(Direct3DCreate9Ex)* Direct3DCreate9Ex = nullptr; if (library != nullptr) { @@ -279,7 +279,7 @@ void Renderer_Detector::hook_dx10() IDXGISwapChain* pSwapChain = nullptr; ID3D10Device* pDevice = nullptr; - HMODULE library = GetModuleHandle(DX10_Hook::DLL_NAME); + HMODULE library = GetModuleHandle(DX10_DLL); if (library != nullptr) { decltype(D3D10CreateDeviceAndSwapChain)* D3D10CreateDeviceAndSwapChain = @@ -332,7 +332,7 @@ void Renderer_Detector::hook_dx11() IDXGISwapChain* pSwapChain = nullptr; ID3D11Device* pDevice = nullptr; - HMODULE library = GetModuleHandle(DX11_Hook::DLL_NAME); + HMODULE library = GetModuleHandle(DX11_DLL); if (library != nullptr) { decltype(D3D11CreateDeviceAndSwapChain)* D3D11CreateDeviceAndSwapChain = @@ -391,7 +391,7 @@ void Renderer_Detector::hook_dx12() ID3D12CommandAllocator* pCommandAllocator = nullptr; ID3D12GraphicsCommandList* pCommandList = nullptr; - HMODULE library = GetModuleHandle(DX12_Hook::DLL_NAME); + HMODULE library = GetModuleHandle(DX12_DLL); if (library != nullptr) { decltype(D3D12CreateDevice)* D3D12CreateDevice = @@ -473,7 +473,7 @@ void Renderer_Detector::hook_opengl() { if (!_ogl_hooked && !_renderer_found) { - HMODULE library = GetModuleHandle(OpenGL_Hook::DLL_NAME); + HMODULE library = GetModuleHandle(OPENGL_DLL); decltype(wglMakeCurrent)* wglMakeCurrent = nullptr; OpenGL_Hook::wglSwapBuffers_t wglSwapBuffers = nullptr; if (library != nullptr) @@ -500,15 +500,15 @@ void Renderer_Detector::hook_opengl() void Renderer_Detector::create_hook(const char* libname) { - if (!_stricmp(libname, DX9_Hook::DLL_NAME)) + if (!_stricmp(libname, DX9_DLL)) hook_dx9(); - else if (!_stricmp(libname, DX10_Hook::DLL_NAME)) + else if (!_stricmp(libname, DX10_DLL)) hook_dx10(); - else if (!_stricmp(libname, DX11_Hook::DLL_NAME)) + else if (!_stricmp(libname, DX11_DLL)) hook_dx11(); - else if (!_stricmp(libname, DX12_Hook::DLL_NAME)) + else if (!_stricmp(libname, DX12_DLL)) hook_dx12(); - else if (!_stricmp(libname, OpenGL_Hook::DLL_NAME)) + else if (!_stricmp(libname, OPENGL_DLL)) hook_opengl(); } @@ -519,11 +519,11 @@ void Renderer_Detector::find_renderer_proc(Renderer_Detector* _this) hm.AddHook(_this->rendererdetect_hook); std::vector const libraries = { - OpenGL_Hook::DLL_NAME, - DX12_Hook::DLL_NAME, - DX11_Hook::DLL_NAME, - DX10_Hook::DLL_NAME, - DX9_Hook::DLL_NAME + OPENGL_DLL, + DX12_DLL, + DX11_DLL, + DX10_DLL, + DX9_DLL }; while (!_this->_renderer_found && !_this->stop_retry()) diff --git a/overlay_experimental/windows/DX10_Hook.cpp b/overlay_experimental/windows/DX10_Hook.cpp index 2a122d1..924cc4d 100644 --- a/overlay_experimental/windows/DX10_Hook.cpp +++ b/overlay_experimental/windows/DX10_Hook.cpp @@ -122,7 +122,7 @@ DX10_Hook::DX10_Hook(): ResizeBuffers(nullptr), ResizeTarget(nullptr) { - _library = LoadLibrary(DLL_NAME); + _library = LoadLibrary(DX10_DLL); } DX10_Hook::~DX10_Hook() @@ -154,7 +154,7 @@ DX10_Hook* DX10_Hook::Inst() const char* DX10_Hook::get_lib_name() const { - return DLL_NAME; + return DX10_DLL; } void DX10_Hook::loadFunctions(IDXGISwapChain *pSwapChain) diff --git a/overlay_experimental/windows/DX10_Hook.h b/overlay_experimental/windows/DX10_Hook.h index 2e06e10..55a118d 100644 --- a/overlay_experimental/windows/DX10_Hook.h +++ b/overlay_experimental/windows/DX10_Hook.h @@ -10,7 +10,7 @@ class DX10_Hook : public Base_Hook { public: - static constexpr const char *DLL_NAME = "d3d10.dll"; + #define DX10_DLL "d3d10.dll" private: static DX10_Hook* _inst; diff --git a/overlay_experimental/windows/DX11_Hook.cpp b/overlay_experimental/windows/DX11_Hook.cpp index f458e89..db9c6e5 100644 --- a/overlay_experimental/windows/DX11_Hook.cpp +++ b/overlay_experimental/windows/DX11_Hook.cpp @@ -167,7 +167,7 @@ DX11_Hook::DX11_Hook(): ResizeBuffers(nullptr), ResizeTarget(nullptr) { - _library = LoadLibrary(DLL_NAME); + _library = LoadLibrary(DX11_DLL); } DX11_Hook::~DX11_Hook() @@ -204,7 +204,7 @@ DX11_Hook* DX11_Hook::Inst() const char* DX11_Hook::get_lib_name() const { - return DLL_NAME; + return DX11_DLL; } void DX11_Hook::loadFunctions(IDXGISwapChain *pSwapChain) diff --git a/overlay_experimental/windows/DX11_Hook.h b/overlay_experimental/windows/DX11_Hook.h index 243de79..ae8d932 100644 --- a/overlay_experimental/windows/DX11_Hook.h +++ b/overlay_experimental/windows/DX11_Hook.h @@ -10,7 +10,7 @@ class DX11_Hook : public Base_Hook { public: - static constexpr const char *DLL_NAME = "d3d11.dll"; + #define DX11_DLL "d3d11.dll" private: static DX11_Hook* _inst; diff --git a/overlay_experimental/windows/DX12_Hook.cpp b/overlay_experimental/windows/DX12_Hook.cpp index c89d83f..e626be3 100644 --- a/overlay_experimental/windows/DX12_Hook.cpp +++ b/overlay_experimental/windows/DX12_Hook.cpp @@ -254,7 +254,7 @@ DX12_Hook::DX12_Hook(): ResizeTarget(nullptr), ExecuteCommandLists(nullptr) { - _library = LoadLibrary(DLL_NAME); + _library = LoadLibrary(DX12_DLL); PRINT_DEBUG("DX12 support is experimental, don't complain if it doesn't work as expected.\n"); } @@ -296,7 +296,7 @@ DX12_Hook* DX12_Hook::Inst() const char* DX12_Hook::get_lib_name() const { - return DLL_NAME; + return DX12_DLL; } void DX12_Hook::loadFunctions(ID3D12CommandQueue* pCommandQueue, IDXGISwapChain *pSwapChain) diff --git a/overlay_experimental/windows/DX12_Hook.h b/overlay_experimental/windows/DX12_Hook.h index 39e3ed3..386d32f 100644 --- a/overlay_experimental/windows/DX12_Hook.h +++ b/overlay_experimental/windows/DX12_Hook.h @@ -11,7 +11,7 @@ class DX12_Hook : public Base_Hook { public: - static constexpr const char *DLL_NAME = "d3d12.dll"; + #define DX12_DLL "d3d12.dll" private: static DX12_Hook* _inst; diff --git a/overlay_experimental/windows/DX9_Hook.cpp b/overlay_experimental/windows/DX9_Hook.cpp index bc7710a..a3a65f4 100644 --- a/overlay_experimental/windows/DX9_Hook.cpp +++ b/overlay_experimental/windows/DX9_Hook.cpp @@ -125,7 +125,7 @@ DX9_Hook::DX9_Hook(): PresentEx(nullptr), Reset(nullptr) { - _library = LoadLibrary(DLL_NAME); + _library = LoadLibrary(DX9_DLL); } DX9_Hook::~DX9_Hook() @@ -153,7 +153,7 @@ DX9_Hook* DX9_Hook::Inst() const char* DX9_Hook::get_lib_name() const { - return DLL_NAME; + return DX9_DLL; } void DX9_Hook::loadFunctions(IDirect3DDevice9* pDevice, bool ex) diff --git a/overlay_experimental/windows/DX9_Hook.h b/overlay_experimental/windows/DX9_Hook.h index 5a76f35..ccf57cd 100644 --- a/overlay_experimental/windows/DX9_Hook.h +++ b/overlay_experimental/windows/DX9_Hook.h @@ -10,7 +10,7 @@ class DX9_Hook : public Base_Hook { public: - static constexpr const char *DLL_NAME = "d3d9.dll"; + #define DX9_DLL "d3d9.dll" private: static DX9_Hook* _inst; diff --git a/overlay_experimental/windows/OpenGL_Hook.cpp b/overlay_experimental/windows/OpenGL_Hook.cpp index 51f856a..be1cad8 100644 --- a/overlay_experimental/windows/OpenGL_Hook.cpp +++ b/overlay_experimental/windows/OpenGL_Hook.cpp @@ -108,7 +108,7 @@ OpenGL_Hook::OpenGL_Hook(): hooked(false), wglSwapBuffers(nullptr) { - _library = LoadLibrary(DLL_NAME); + _library = LoadLibrary(OPENGL_DLL); } OpenGL_Hook::~OpenGL_Hook() @@ -136,7 +136,7 @@ OpenGL_Hook* OpenGL_Hook::Inst() const char* OpenGL_Hook::get_lib_name() const { - return DLL_NAME; + return OPENGL_DLL; } void OpenGL_Hook::loadFunctions(wglSwapBuffers_t pfnwglSwapBuffers) diff --git a/overlay_experimental/windows/OpenGL_Hook.h b/overlay_experimental/windows/OpenGL_Hook.h index 60f6d08..58817fc 100644 --- a/overlay_experimental/windows/OpenGL_Hook.h +++ b/overlay_experimental/windows/OpenGL_Hook.h @@ -7,7 +7,7 @@ class OpenGL_Hook : public Base_Hook { public: - static constexpr const char *DLL_NAME = "opengl32.dll"; + #define OPENGL_DLL "opengl32.dll" using wglSwapBuffers_t = BOOL(WINAPI*)(HDC); diff --git a/overlay_experimental/windows/Windows_Hook.cpp b/overlay_experimental/windows/Windows_Hook.cpp index fcbdc42..f273c5e 100644 --- a/overlay_experimental/windows/Windows_Hook.cpp +++ b/overlay_experimental/windows/Windows_Hook.cpp @@ -203,7 +203,7 @@ Windows_Hook* Windows_Hook::Inst() const char* Windows_Hook::get_lib_name() const { - return DLL_NAME; + return WINDOWS_DLL; } #endif//EMU_OVERLAY \ No newline at end of file diff --git a/overlay_experimental/windows/Windows_Hook.h b/overlay_experimental/windows/Windows_Hook.h index d612acc..631edf3 100644 --- a/overlay_experimental/windows/Windows_Hook.h +++ b/overlay_experimental/windows/Windows_Hook.h @@ -9,7 +9,7 @@ class Windows_Hook : public Base_Hook { public: - static constexpr const char* DLL_NAME = "user32.dll"; + #define WINDOWS_DLL "user32.dll" private: static Windows_Hook* _inst;