Code:
bool redirect(bool enable, void **function, void *redirection)
{
if(DetourTransactionBegin() != NO_ERROR)
{
return false;
}
if(DetourUpdateThread(GetCurrentThread()) != NO_ERROR)
{
return false;
}
if((enable? DetourAttach:DetourDetach)(function, redirection) != NO_ERROR)
{
return false;
}
if(DetourTransactionCommit() == NO_ERROR)
{
return true;
}
DetourTransactionAbort();
return false;
}
typedef int(__stdcall *IsCorrectItem_t)(int);
IsCorrectItem_t g_real_IsCorrectItem = reinterpret_cast<IsCorrectItem_t>(0x005D4A2B);
int __stdcall hooked_IsCorrectItem(int nItemID)
{
return 0;
}
// inside my function
detours::redirect(true, reinterpret_cast<void **>(&g_real_IsCashItem), hooked_IsCorrectItem);
This seems to be perfectly fine on Windows 10, but on Windows 7 it simply doesn't work. I installed the static Detours library through vcpkg.
Code:
This seems to be perfectly fine on Windows 10, but on Windows 7 it simply doesn't work. I installed the static Detours library through vcpkg.