I want to use the repo detours.net in my project to hook native win32 api functions. It is working create for x64 applications but not for x86 applications. So I have changed to CMakeList.txt in the detours directory to -E env DETOURS_TARGET_PROCESSOR=X86
and creating the Visual Studio Project File with this command: cmake -G "Visual Studio 16 2019" -A Win32 ..\detours.net
. After trying to build the solution i get an error in this line:
return DetourEnumerateImportsEx(hModule, &context, nullptr, Unsandbox);
Severity Code Description Project File Line Suppression State
Error C2664 'BOOL DetourEnumerateImportsEx(HMODULE,PVOID,PF_DETOUR_IMPORT_FILE_CALLBACK,PF_DETOUR_IMPORT_FUNC_CALLBACK_EX)': cannot convert argument 4 from 'BOOL (__cdecl *)(PVOID,DWORD,LPCSTR,PVOID *)' to 'PF_DETOUR_IMPORT_FUNC_CALLBACK_EX' DetoursDll C:\Users\sebastian\source\repos\de32\detours.net\detours.net\DetoursDll\src\DetoursDll.cpp 30
But the definition of PF_DETOUR_IMPORT_FILE_CALLBACK to the function 'Unsandbox' seems correct:
typedef BOOL (CALLBACK *PF_DETOUR_IMPORT_FUNC_CALLBACK_EX)(_In_opt_ PVOID pContext,
_In_ DWORD nOrdinal,
_In_opt_ LPCSTR pszFunc,
_In_opt_ PVOID* ppvFunc);
static BOOL Unsandbox(_In_opt_ PVOID pContext, _In_ DWORD nOrdinal, _In_opt_ LPCSTR pszFunc, _In_opt_ PVOID* ppvFunc)
It's building without any problems for x64 but not for x86. Did I miss anything?