hooking_test/src/hooking_test.cpp
2024-04-08 17:03:58 +02:00

45 lines
976 B
C++

//============================================================================
// Name : hooking_test.cpp
// Author :Attila Body
//============================================================================
#include <stdint.h>
#include <iostream>
#include <stdio.h>
using namespace std;
class C
{
public:
C() = default;
virtual ~C() = default;
void foo(int bar)
{
printf("%p -> %d\n", this, bar);
}
virtual void fooo(int bar)
{
printf("%p -> %d\n", this, bar);
}
};
typedef void (C::*cvifptr_t)(int);
typedef void (*vifptr_t)(int, int);
int main(int argc, char **argv)
{
C c;
cvifptr_t zup = &C::foo;
vifptr_t baz = reinterpret_cast<vifptr_t>(zup);
vifptr_t biz = reinterpret_cast<vifptr_t>(c.*&C::foo);
printf("%p\n", reinterpret_cast<void *>(baz));
printf("%p\n", reinterpret_cast<void *>(biz));
(c.*zup)(123);
(*baz)(0x1234, 321);
(*biz)(0x4321, 432);
return 0;
}