doitsujin / vtable-hook

C++ Vtable Hooking Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vtable-hook

C++ Vtable Hooking Library. Only requires a header.

Supports Windows and Linux.

Example

#include "vtablehook.h"
#include <stdio.h>

class Object {
        public:
        int member;

        Object(int init) {
                member = init;
        }

        virtual void Foo() {
                printf("Bar\n");
        }
};

#ifdef WIN32
void __fastcall FooHook(Object* that) {
#elif __linux__
void FooHook(Object* that) {
#endif
        printf("Hooked %i\n", that->member);
}

int main() {
        Object* o = new Object(123);
        o->Foo(); // prints Bar

        vtablehook_hook(o, (void*)FooHook, 0);
        o->Foo(); // prints Hooked 123

        return 0;
}

About

C++ Vtable Hooking Library

License:MIT License


Languages

Language:C 82.8%Language:C++ 17.2%