Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- char Title[] = "TargetApp";
- int main()
- {
- HWND hwnd = FindWindowA(NULL, Title);
- if (hwnd == NULL)
- {
- cout << "Target application not found!" << endl;
- Sleep(3000);
- exit(-1);
- }
- else
- {
- DWORD ProcID;
- GetWindowThreadProcessId(hwnd, &ProcID);
- HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcID);
- if (Handle == NULL)
- {
- cout << "Unable to create a handle for the process!" << endl;
- Sleep(3000);
- exit(-1);
- }
- else
- {
- /*DWORD MemAddress;
- cin >> MemAddress;
- LPVOID LPMemAddress = (LPVOID)MemAddress;
- PBYTE* PBMemAddress = (PBYTE*)MemAddress;*/
- int ReadValue, NewValue;
- while (true)
- {
- cout << "Action\n1) Read memory\n2) Write memory\n3) Exit\nOption> ";
- char Opt;
- cin >> Opt;
- cout << endl;
- if (Opt == '1')
- {
- ReadProcessMemory(Handle, (PBYTE*)0x002DB138, &ReadValue, sizeof(int), 0);
- cout << "Memory read = 0x002DB138" << " = " << ReadValue << endl;
- }
- else if (Opt == '2')
- {
- //int WriteData;
- //cin >> WriteData;
- //int NewValue = 50;
- int NewValue;
- cin >> (int)NewValue;
- WriteProcessMemory(Handle, (LPVOID)0x002DB138, &NewValue, sizeof(NewValue), 0);
- cout << "Written " << NewValue << " to 0x002DB138" << endl;
- }
- else if (Opt == '3')
- {
- exit(0);
- }
- else
- {
- continue;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement