Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Sun Jun 13, 2010 12:43 am Post subject: [FIXED]Small problem, please help.[FIXED] |
|
|
Here is a code i wrote for a mmory reader/writer.
| Code: | #include <iostream>
#include <windows.h>
using namespace std;
int MemoryRW(char Window[], long int Address, int Value, char RW)
{
//Variables
HWND hwnd;
DWORD pid;
HANDLE proc_handle;
int changeValue;
//Initialization
hwnd = FindWindow(NULL, (LPCTSTR)Window);
GetWindowThreadProcessId(hwnd, &pid);
proc_handle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
//Actions
if (RW == 'r' || RW == 'R')
{
ReadProcessMemory(proc_handle, (LPVOID)Address, &Value, sizeof(long int), NULL);
cout << "\nThe value is: " << Value;
}
else if (RW == 'w' || RW == 'W')
{
cout << "\nWhat is the new value:";
cin >> changeValue;
WriteProcessMemory(proc_handle, (LPVOID)Address, &changeValue, sizeof(int), NULL);
}
}
int main()
{
char whatAction;
char winName[100];
long int address;
int value = 0;
cout << "What window do you wish to opperate on: ";
cin >> winName;
cout << "\nWhat action do you with to perform, READ or WRITE? [r/w]";
cin >> whatAction;
cout << "\nWhat address do you wish to opperate on:";
cin >> hex >> address;
MemoryRW(winName, address, value, whatAction);
//Closing
cout << "\nPress any key to exit";
cin.get();
return 0;
}
|
Everything works like a DREAM (thanks to slovach) but i am running into one minor annoyance.
Whenever i write to an address, my number is interpreted and added as a hex, so if i use the value 35, i get 53 in the target program. How do i prevent this from happening?
Also, feel free to use that MemoryRW function if you feel so inclined.
EDIT: FIXED...had to set cin back to dec. "cin >> dec >> changeValue"
|
|