Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- int main()
- {
- /*
- * Load library in which we'll be hooking our functions.
- */
- HMODULE dll = LoadLibrary(L"C:\\DXHookDLL.dll");
- if(dll == NULL) {
- printf("The DLL could not be found.\n");
- getchar();
- return -1;
- }
- /*
- * 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");
- while(1) {
- SHORT v = GetKeyState(VK_RETURN);
- bool pressed = (v & 0x8000) != 0;
- if(pressed)
- break;
- }
- UnhookWindowsHookEx(handle);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement