Add asserts to detours

This is to make it easy to catch detour errors.
This commit is contained in:
Kawe Mazidjatari 2023-07-19 15:53:20 +02:00
parent d860c43f79
commit a2d30e45f9

View File

@ -882,9 +882,12 @@ template<
LONG DetourAttach(_Inout_ T *ppPointer, LONG DetourAttach(_Inout_ T *ppPointer,
_In_ T pDetour) noexcept _In_ T pDetour) noexcept
{ {
return DetourAttach( LONG result = DetourAttach(
reinterpret_cast<void**>(ppPointer), reinterpret_cast<void**>(ppPointer),
reinterpret_cast<void*>(pDetour)); reinterpret_cast<void*>(pDetour));
assert(result == NO_ERROR);
return result;
} }
template< template<
@ -896,12 +899,15 @@ LONG DetourAttachEx(_Inout_ T *ppPointer,
_Out_opt_ T *ppRealTarget, _Out_opt_ T *ppRealTarget,
_Out_opt_ T *ppRealDetour) noexcept _Out_opt_ T *ppRealDetour) noexcept
{ {
return DetourAttachEx( LONG result = DetourAttachEx(
reinterpret_cast<void**>(ppPointer), reinterpret_cast<void**>(ppPointer),
reinterpret_cast<void*>(pDetour), reinterpret_cast<void*>(pDetour),
ppRealTrampoline, ppRealTrampoline,
reinterpret_cast<void**>(ppRealTarget), reinterpret_cast<void**>(ppRealTarget),
reinterpret_cast<void**>(ppRealDetour)); reinterpret_cast<void**>(ppRealDetour));
assert(result == NO_ERROR);
return result;
} }
template< template<
@ -910,9 +916,12 @@ template<
LONG DetourDetach(_Inout_ T *ppPointer, LONG DetourDetach(_Inout_ T *ppPointer,
_In_ T pDetour) noexcept _In_ T pDetour) noexcept
{ {
return DetourDetach( LONG result = DetourDetach(
reinterpret_cast<void**>(ppPointer), reinterpret_cast<void**>(ppPointer),
reinterpret_cast<void*>(pDetour)); reinterpret_cast<void*>(pDetour));
assert(result == NO_ERROR);
return result;
} }
#endif // __cplusplus >= 201103L || _MSVC_LANG >= 201103L #endif // __cplusplus >= 201103L || _MSVC_LANG >= 201103L