Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created September 27, 2015 03:22
Show Gist options
  • Save kumatti1/d986c736fbfe553eaf4b to your computer and use it in GitHub Desktop.
Save kumatti1/d986c736fbfe553eaf4b to your computer and use it in GitHub Desktop.
#define UNICODE
#include <windows.h>
#include <stdio.h>
DWORD OldProtect;
void Proto2(DWORD *Addr)
{
MessageBoxW(0, L"", L"Proto", MB_OK);
}
void Sub2()
{
MessageBoxW(0, L"", L"Callback", MB_OK);
}
void StarteHook()
{
DWORD* dwProc = (DWORD*)Proto2;
if (VirtualProtect(dwProc, 8, PAGE_EXECUTE_READWRITE, &OldProtect))
{
DWORD** tmp = &dwProc;
BYTE b1 = 0xFF505958;
memcpy(tmp, &b1, 4);
tmp++;
BYTE b2 = 0xE1;
memcpy(tmp, &b2, 1);
}
DWORD* t = (DWORD*)Sub2;
Proto2(t);
}
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
StarteHook();
MessageBoxA(0, "", "hoge", MB_OK);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment