Skip to content

This library can do Global Windows API Hook. And use Code Injection instead of DLL injection.

License

Notifications You must be signed in to change notification settings

jungjin0003/GlobalWinHook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GlobalWinHook

This library can do Global Windows API Hook. And use Code Injection instead of DLL injection.

Example Code

/* wchar_t(Wide Char) is not supported yet */
#include <stdio.h>
#include <windows.h>
#include "Global_WinHook.h"

typedef int(__stdcall *MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT);

typedef struct _Data
{
    char text[10];
    MESSAGEBOXA NewMessageBoxA;
} Data;

int __stdcall NewMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
    Data *data;
    #ifdef _WIN64
    data = 0xCCCCCCCCCCCCCCCC;
    #else
    data = 0xCCCCCCCC;
    #endif
    return ((MESSAGEBOXA)data->NewMessageBoxA)(hWnd, data->text, data->text, uType);
}

int main()
{
    Data data;
    WINAPI_BASIC_GLOBAL_HOOK_DATAA WBGHD;
    WBGHD.CopyOrigin_Parameter_Offset = offsetof(Data, NewMessageBoxA);
    strcpy(WBGHD.DllName, "user32.dll");
    WBGHD.dwSizeNewFunction = (Address)main - (Address)NewMessageBoxA;
    WBGHD.dwSizeParameter = sizeof(Data);
    WBGHD.lpNewFunction = NewMessageBoxA;
    WBGHD.lpOrigin = GetProcAddress(LoadLibraryA("user32.dll"), "MessageBoxA");
    WBGHD.lpParameter = &data;
    WBGHD.Parameter = TRUE;
    strcpy(data.text, "Hooked!");
    HookA(&WBGHD);
    system("pause");
}

About

This library can do Global Windows API Hook. And use Code Injection instead of DLL injection.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages