Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. using namespace std;
  4.  
  5. char Title[] = "TargetApp";
  6.  
  7. int main()
  8. {
  9.     HWND hwnd = FindWindowA(NULL, Title);
  10.     if (hwnd == NULL)
  11.     {
  12.         cout << "Target application not found!" << endl;
  13.         Sleep(3000);
  14.         exit(-1);
  15.     }
  16.     else
  17.     {
  18.         DWORD ProcID;
  19.         GetWindowThreadProcessId(hwnd, &ProcID);
  20.         HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcID);
  21.         if (Handle == NULL)
  22.         {
  23.             cout << "Unable to create a handle for the process!" << endl;
  24.             Sleep(3000);
  25.             exit(-1);
  26.         }
  27.         else
  28.         {
  29.             /*DWORD MemAddress;
  30.             cin >> MemAddress;
  31.             LPVOID LPMemAddress = (LPVOID)MemAddress;
  32.             PBYTE* PBMemAddress = (PBYTE*)MemAddress;*/
  33.             int ReadValue, NewValue;
  34.             while (true)
  35.             {
  36.                 cout << "Action\n1) Read memory\n2) Write memory\n3) Exit\nOption> ";
  37.                 char Opt;
  38.                 cin >> Opt;
  39.                 cout << endl;
  40.                 if (Opt == '1')
  41.                 {
  42.                     ReadProcessMemory(Handle, (PBYTE*)0x002DB138, &ReadValue, sizeof(int), 0);
  43.                     cout << "Memory read = 0x002DB138" << " = " << ReadValue << endl;
  44.                 }
  45.                 else if (Opt == '2')
  46.                 {
  47.                     //int WriteData;
  48.                     //cin >> WriteData;
  49.                     //int NewValue = 50;
  50.                     int NewValue;
  51.                     cin >> (int)NewValue;
  52.                     WriteProcessMemory(Handle, (LPVOID)0x002DB138, &NewValue, sizeof(NewValue), 0);
  53.                     cout << "Written " << NewValue << " to 0x002DB138" << endl;
  54.                 }
  55.                 else if (Opt == '3')
  56.                 {
  57.                     exit(0);
  58.                 }
  59.                 else
  60.                 {
  61.                     continue;
  62.                 }
  63.             }
  64.         }
  65.     }
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement