#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
/*
* Load library in which we'll be hooking our functions.
*/
HMODULE dll = LoadLibrary(L"test_dll.dll");
if(dll == NULL) {
DWORD err = GetLastError();
printf("The DLL could not be found.\n");
getchar();
return -1;
}
//__asm int 3;
/*
* Get the address of the function inside the DLL.
*/
HOOKPROC addr = (HOOKPROC)GetProcAddress(dll, "meconnect");
if(addr == NULL) {
printf("The function was not found.\n");
getchar();
return -1;
}
/*
* Hook the function.
*/
HHOOK handle = SetWindowsHookEx(WH_KEYBOARD, addr, dll, 0);
if(handle == NULL) {
printf("The KEYBOARD could not be hooked.\n");
}
/*
* Unhook the function.
*/
printf("Program successfully hooked.\nPress enter to unhook the function and stop the program.\n");
getchar();
UnhookWindowsHookEx(handle);
return 0;
}
setwindowhookex
最新推荐文章于 2023-02-20 14:42:11 发布