Skip to content

Commit de59f2e

Browse files
committed
Return back old CVirtualTable implementation
1 parent d406ef7 commit de59f2e

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

include/dynlibutils/virtual.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,24 @@ constexpr std::ptrdiff_t GetVirtualIndex() noexcept
115115
return DYNLIB_INVALID_VCALL;
116116
}
117117

118-
class CVirtualTable : public CMemoryView<void *>
118+
class CVirtualTable
119119
{
120120
public: // Types.
121-
using CBase = CMemoryView<void *>;
122121
using CThis = CVirtualTable;
123122

124123
public: // Constructors.
125-
CVirtualTable() : CBase(nullptr) {}
126-
template<class T> CVirtualTable(T *pClass) : CBase(*reinterpret_cast<void **>(pClass)) {}
124+
CVirtualTable() : m_pVTFs(nullptr) {}
125+
template<class T> CVirtualTable(T *pClass) : m_pVTFs(*reinterpret_cast<void ***>(pClass)) {}
127126

128127
public: // Getters.
129-
template<typename R> R GetMethod(std::ptrdiff_t nIndex) const { return reinterpret_cast<R>(CBase::Offset(nIndex).GetPtr()); }
128+
template<typename R> R &GetMethod(std::ptrdiff_t nIndex) { return reinterpret_cast<R &>(m_pVTFs[nIndex]); }
129+
template<typename R> R GetMethod(std::ptrdiff_t nIndex) const { return reinterpret_cast<R>(m_pVTFs[nIndex]); }
130130

131131
public: // Callers.
132132
template<typename R, typename... Args> R CallMethod(std::ptrdiff_t nIndex, Args... args) { return GetMethod<R (*)(void *, Args...)>(nIndex)(this, args...); }
133133
template<typename R, typename... Args> R CallMethod(std::ptrdiff_t nIndex, Args... args) const { return const_cast<CThis *>(this)->CallMethod(nIndex, args...); }
134+
135+
void **m_pVTFs;
134136
}; // class CVirtualTable
135137

136138
class VirtualTable final : public CVirtualTable

include/dynlibutils/vthook.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class VTHook
8585
{
8686
assert(!IsHooked());
8787

88-
m_vmpFn = pVTable.Offset(nIndex);
88+
m_vmpFn = &pVTable.GetMethod<void *>(nIndex);
8989
m_pOriginalFn = m_vmpFn.Deref();
9090

9191
HookImpl(pFn);

0 commit comments

Comments
 (0)