17 void* pInst =
nullptr;
18 uint16_t fs1 =
'\x64\xA3';
19 uint8_t fs2 = FIELD_OFFSET( NT_TIB, ArbitraryUserPointer );
24 uint16_t jmp1 =
'\xFF\xE0';
32 uint16_t mov1 =
'\x48\xB8';
33 void* pInst =
nullptr;
34 uint32_t fs1 =
'\x65\x48\x89\x04';
36 uint8_t fs3 = FIELD_OFFSET( NT_TIB, ArbitraryUserPointer );
39 uint16_t mov2 =
'\x48\xB8';
41 uint16_t jmp1 =
'\xFF\xE0';
44 void setup(
void* pInstance,
void* pMethod )
53 template<
typename fn,
typename C>
56 template<
typename R,
typename... Args,
typename C>
60 typedef R( C::*TypeMember )(Args...);
61 typedef R( __stdcall* TypeFree )(Args...);
66 , _pInstance( pInstance )
69 VirtualProtect( &_thunk,
sizeof( _thunk ), PAGE_EXECUTE_READWRITE, &dwOld );
70 _thunk.setup(
this, &Win32Thunk::WrapHandler );
80 auto _this =
reinterpret_cast<Win32Thunk*
>(((PNT_TIB)NtCurrentTeb())->ArbitraryUserPointer);
81 return (_this->_pInstance->*_this->_pMethod)(args...);
90 return reinterpret_cast<TypeFree
>(&_thunk);
94 TypeMember _pMethod =
nullptr;
95 C* _pInstance =
nullptr;
static R __stdcall WrapHandler(Args...args)
Redirect call
Definition: Thunk.hpp:78
TypeFree GetThunk()
Get thunk
Definition: Thunk.hpp:88