Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. // FindWindow();
  5. // GetWindowThreadProcessId();
  6. // OpenProcess();
  7. // WriteProcessMemory();
  8. // CloseHandle();
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.     int newValue = 0;
  15.  
  16.     HWND hWnd = FindWindow(0, "ENG");
  17.     if (hWnd == 0)
  18.     {
  19.         cerr << "Cannot find window." << endl;
  20.     }
  21.     else
  22.     {
  23.         DWORD pId;
  24.         GetWindowThreadProcessId(hWnd, &pId);
  25.  
  26.         HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
  27.  
  28.         if (!hProc)
  29.         {
  30.             cerr << "Cannot open process." << endl;
  31.         }
  32.         else
  33.         {
  34.             int isSuccessful = WriteProcessMemory(hProc, (LPVOID)0x151F485C, &newValue, (DWORD)sizeof(newValue), NULL);
  35.  
  36.             if (isSuccessful > 0)
  37.             {
  38.                 clog << "Process memory written." << endl;
  39.             }
  40.             else
  41.             {
  42.                 cerr << "Cannot write process memory." << endl;
  43.             }
  44.             CloseHandle(hProc);
  45.         }
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement