Skip to content

Commit 8a71534

Browse files
committed
VT(F)Hook: provide unhook result
1 parent 1ad10c4 commit 8a71534

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

include/dynlibutils/vthook.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,13 @@ class CVTHook : public CMemory
143143
public:
144144
using Function_t = R (*)(Args...); // Is the pointer‐to‐function type matching the signature of the virtual method.
145145

146-
~CVTHook() { Unhook(); }
146+
~CVTHook()
147+
{
148+
if (IsHooked())
149+
{
150+
UnhookImpl();
151+
}
152+
}
147153

148154
bool IsHooked() const noexcept { return IsValid(); } // Returns true if a hook is currently installed (i.e., we have a valid vtable slot pointer).
149155
void Clear() noexcept { SetPtr(nullptr); m_pOriginalFn = nullptr; }
@@ -253,8 +259,11 @@ class CVTFHook : public CVTHook<R, Args...>
253259

254260
void Unhook()
255261
{
256-
CBase::Unhook();
262+
bool bResult = CBase::Unhook();
263+
257264
sm_callback = nullptr;
265+
266+
return bResult;
258267
}
259268

260269
protected:

0 commit comments

Comments
 (0)