Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "HookTemplate.h"
- stdext::Hook < int (__thiscall*)(int) >* fooHook;
- class Foo
- {
- int mValue;
- public:
- Foo(int value) : mValue(value) {
- }
- int foo(int arg) {
- return arg * mValue;
- }
- };
- class Bar
- {
- public:
- int hookFoo(int arg) {
- int retOrig = fooHook->callOrig(this, arg);
- retOrig *= 2;
- return retOrig;
- }
- };
- int main() {
- void* origFoo = stdext::__detail::HookImpl::union_cast<void*>(&Foo::foo);
- fooHook = new stdext::Hook < int (__thiscall*) (int) >(origFoo, &Bar::hookFoo);
- fooHook->enable();
- Foo* foo = new Foo(5);
- foo->foo(2);
- }
Advertisement
Add Comment
Please, Sign In to add comment