New method for IDetour

This will deprecate IDetour::Attach and IDetour::Detatch. This should reduce the chances of potential errors caused by using the wrong function in the wrong method (e.g. using DetourAttach in IDetour::Detatch).
This commit is contained in:
Kawe Mazidjatari 2023-11-26 11:42:26 +01:00
parent fa2a005d34
commit e0a60a14e5
2 changed files with 14 additions and 0 deletions

View File

@ -15,6 +15,18 @@ public:
virtual void Attach(void) const = 0;
virtual void Detach(void) const = 0;
//virtual void Detour(const bool bAttach) const = 0;
template<
typename T,
typename std::enable_if<DetoursIsFunctionPointer<T>::value, int>::type = 0>
LONG Setup(_Inout_ T* ppPointer, _In_ T pDetour, const bool bAttach) const
{
if (bAttach)
return DetourAttach(ppPointer, pDetour);
else
return DetourDetach(ppPointer, pDetour);
}
};
extern std::vector<IDetour*> g_DetourVec;

View File

@ -6,6 +6,8 @@
#include <cassert>
#include <vector>
#include <unordered_set>
#include <Windows.h>
#include "../include/detours.h"
#include "../include/idetour.h"
//-----------------------------------------------------------------------------