From e38172dc1bf246e7963d6ce0beae0041481c673b Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Fri, 24 May 2024 05:51:59 +0300 Subject: [PATCH] fix steamclient_experimental compilation with mingw --- dll/base.cpp | 24 ++++++++++++------------ dll/dll/common_includes.h | 1 + premake5.lua | 6 ++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/dll/base.cpp b/dll/base.cpp index b85d5573..c02157e2 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -458,7 +458,7 @@ static void redirect_crackdll() { DetourTransactionBegin(); DetourUpdateThread( GetCurrentThread() ); - DetourAttach( &(PVOID &)Real_GetModuleHandleA, Mine_GetModuleHandleA ); + DetourAttach( reinterpret_cast(&Real_GetModuleHandleA), reinterpret_cast(Mine_GetModuleHandleA) ); DetourTransactionCommit(); } @@ -466,7 +466,7 @@ static void unredirect_crackdll() { DetourTransactionBegin(); DetourUpdateThread( GetCurrentThread() ); - DetourDetach( &(PVOID &)Real_GetModuleHandleA, Mine_GetModuleHandleA ); + DetourDetach( reinterpret_cast(&Real_GetModuleHandleA), reinterpret_cast(Mine_GetModuleHandleA) ); DetourTransactionCommit(); } @@ -604,16 +604,16 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) PRINT_DEBUG("Hooking lan only functions"); DetourTransactionBegin(); DetourUpdateThread( GetCurrentThread() ); - DetourAttach( &(PVOID &)Real_SendTo, Mine_SendTo ); - DetourAttach( &(PVOID &)Real_Connect, Mine_Connect ); - DetourAttach( &(PVOID &)Real_WSAConnect, Mine_WSAConnect ); + DetourAttach( reinterpret_cast(&Real_SendTo), reinterpret_cast(Mine_SendTo) ); + DetourAttach( reinterpret_cast(&Real_Connect), reinterpret_cast(Mine_Connect) ); + DetourAttach( reinterpret_cast(&Real_WSAConnect), reinterpret_cast(Mine_WSAConnect) ); HMODULE winhttp = GetModuleHandleA("winhttp.dll"); if (winhttp) { Real_WinHttpConnect = (decltype(Real_WinHttpConnect))GetProcAddress(winhttp, "WinHttpConnect"); - DetourAttach( &(PVOID &)Real_WinHttpConnect, Mine_WinHttpConnect ); + DetourAttach( reinterpret_cast(&Real_WinHttpConnect), reinterpret_cast(Mine_WinHttpConnect) ); // Real_WinHttpOpenRequest = (decltype(Real_WinHttpOpenRequest))GetProcAddress(winhttp, "WinHttpOpenRequest"); - // DetourAttach( &(PVOID &)Real_WinHttpOpenRequest, Mine_WinHttpOpenRequest ); + // DetourAttach( reinterpret_cast(&Real_WinHttpOpenRequest), reinterpret_cast(Mine_WinHttpOpenRequest) ); } DetourTransactionCommit(); @@ -628,12 +628,12 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) if (network_functions_attached) { DetourTransactionBegin(); DetourUpdateThread( GetCurrentThread() ); - DetourDetach( &(PVOID &)Real_SendTo, Mine_SendTo ); - DetourDetach( &(PVOID &)Real_Connect, Mine_Connect ); - DetourDetach( &(PVOID &)Real_WSAConnect, Mine_WSAConnect ); + DetourDetach( reinterpret_cast(&Real_SendTo), reinterpret_cast(Mine_SendTo) ); + DetourDetach( reinterpret_cast(&Real_Connect), reinterpret_cast(Mine_Connect) ); + DetourDetach( reinterpret_cast(&Real_WSAConnect), reinterpret_cast(Mine_WSAConnect) ); if (Real_WinHttpConnect) { - DetourDetach( &(PVOID &)Real_WinHttpConnect, Mine_WinHttpConnect ); - // DetourDetach( &(PVOID &)Real_WinHttpOpenRequest, Mine_WinHttpOpenRequest ); + DetourDetach( reinterpret_cast(&Real_WinHttpConnect), reinterpret_cast(Mine_WinHttpConnect) ); + // DetourDetach( reinterpret_cast(&Real_WinHttpOpenRequest), reinterpret_cast(Mine_WinHttpOpenRequest) ); } DetourTransactionCommit(); } diff --git a/dll/dll/common_includes.h b/dll/dll/common_includes.h index ced60026..cbb0845e 100644 --- a/dll/dll/common_includes.h +++ b/dll/dll/common_includes.h @@ -101,6 +101,7 @@ #ifdef EMU_EXPERIMENTAL_BUILD #include + #include // MinGW cannot find DWordMult() #include "detours/detours.h" #endif diff --git a/premake5.lua b/premake5.lua index 24820916..56b34a67 100644 --- a/premake5.lua +++ b/premake5.lua @@ -359,6 +359,12 @@ filter { "action:gmake*" , "files:*.cpp or *.cc or *.hpp", } buildoptions { "-fno-char8_t", -- GCC gives a warning when a .c file is compiled with this } +-- MinGw on Windows cannot compile 'creatwth.cpp' from Detours lib (error: 'DWordMult' was not declared in this scope) +-- because intsafe.h isn't included by default +filter { "system:windows", "action:gmake*", } + buildoptions { + "-include intsafe.h" + } filter {} -- reset the filter and remove all active keywords