From d78b1a852a472ba2828a32d6177c1ceee5a2f893 Mon Sep 17 00:00:00 2001 From: Attila Body Date: Mon, 8 Apr 2024 16:52:54 +0200 Subject: [PATCH] Play harder --- src/hooking_test.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/hooking_test.cpp b/src/hooking_test.cpp index 74c8f60..5cdd493 100644 --- a/src/hooking_test.cpp +++ b/src/hooking_test.cpp @@ -5,15 +5,23 @@ #include #include +#include using namespace std; class C { public: + C() = default; + virtual ~C() = default; + void foo(int bar) { - cout << reinterpret_cast(this) << " -> " << bar << endl; + printf("%p -> %d\n", this, bar); + } + virtual void fooo(int bar) + { + printf("%p -> %d\n", this, bar); } }; @@ -24,10 +32,15 @@ int main(int argc, char **argv) { C c; cvifptr_t zup = &C::foo; - cout << zup << endl; vifptr_t baz = reinterpret_cast(zup); - cout << baz << endl; + void (C::*mfp)(int) = &C::foo; + vifptr_t biz = reinterpret_cast(c.*mfp); + + printf("%p\n", reinterpret_cast(baz)); + printf("%p\n", reinterpret_cast(biz)); (c.*zup)(123); - (*baz)(1234, 321); + (*baz)(0x1234, 321); + (*biz)(0x4321, 432); + return 0; }