Skip to content

nelfo/PGHooker

Repository files navigation

PGHooker

Function hooking example

#include <iostream>

#include "PGHooker.hpp"

int WINAPI hkMessageBoxA( HWND hWnd,
    LPCSTR lpText,
    LPCSTR lpCaption,
    UINT uType )
{
    printf( "MessageBoxA hook called !!! \n" );

    PGHooker::DisableHookForOnce( MessageBoxA );
    return MessageBoxA( hWnd, lpText, lpCaption, uType );
}

int main( )
{
    PGHooker::Initialize( );
    PGHooker::CreateHook( MessageBoxA, hkMessageBoxA );

    printf( "Calling MessageBoxA \n" );

    MessageBoxA( NULL, "Text", "Caption", MB_ICONINFORMATION );
    
    printf( "End! \n" );

    return 0;
}

Console output

Calling MessageBoxA
MessageBoxA hook called !!!
End!

About

PAGE_GUARD based hooking library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages