Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
1,257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <Windows.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.     /*
  11.     * Load library in which we'll be hooking our functions.
  12.     */
  13.     HMODULE dll = LoadLibrary(L"C:\\DXHookDLL.dll");
  14.     if(dll == NULL) {
  15.         printf("The DLL could not be found.\n");
  16.         getchar();
  17.         return -1;
  18.     }
  19.  
  20.     /*
  21.     * Get the address of the function inside the DLL.
  22.     */
  23.     HOOKPROC addr = (HOOKPROC)GetProcAddress(dll, "meconnect");
  24.     if(addr == NULL) {
  25.         printf("The function was not found.\n");
  26.         getchar();
  27.         return -1;
  28.     }
  29.  
  30.     /*
  31.     * Hook the function.
  32.     */
  33.     HHOOK handle = SetWindowsHookEx(WH_KEYBOARD, addr, dll, 0);
  34.     if(handle == NULL) {
  35.         printf("The KEYBOARD could not be hooked.\n");
  36.     }
  37.  
  38.     /*
  39.     * Unhook the function.
  40.     */
  41.     printf("Program successfully hooked.\nPress enter to unhook the function and stop the program.\n");
  42.    
  43.     while(1) {
  44.         SHORT v = GetKeyState(VK_RETURN);
  45.         bool pressed = (v & 0x8000) != 0;
  46.         if(pressed)
  47.             break;
  48.     }
  49.  
  50.     UnhookWindowsHookEx(handle);
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement