Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void wrapper(SomeClass const *_this, int param)
- {
- // Get some stuff done before
- std::cout << "Pre call to SomeClass::mem_fn()" << std::endl
- << " this = " << _this << std::endl
- << " param = " << param << std::endl;
- // Get and call orig
- Hook<SomeClass>::call_once<2>(_this, param);
- // Get some stuff done after
- std::cout << "Post call to SomeClass::mem_fn()" << std::endl;
- }
- // This example will print:
- //
- // $ ./class-test
- // Pre call to SomeClass::mem_fn()
- // this = 0x1d8ec20
- // param = 42
- // Original SomeClass::mem_fn()
- // this = 0x1d8ec20
- // param = 42
- // Post call to SomeClass::mem_fn()
- int main()
- {
- // Create object instance
- SomeClass *some_object = new SomeClass;
- // Hook
- Hook<SomeClass>::install<2>(some_object, wrapper);
- // Wrapped call
- some_object->mem_fn(42);
- // Delete object instance
- delete some_object;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement