VoiceOfDissent
asked on
Change Value of a known memory address?
I got this wild idea to create an editor for one of my favorite games. I can edit the values directly by using other software, but I find it cumbersome. I want to create my own program which would allow me to enter a value into a text box, and assign the value of that text box to the known memory address where the item I want to change is stored.
Example, one of the values I want to change is stored at address 00AF9F90. It's current value is 50, a 4 byte value. What would I do, say, to change the value to 100? Thanks for the patience in dealing with a C++ newbie.
Example, one of the values I want to change is stored at address 00AF9F90. It's current value is 50, a 4 byte value. What would I do, say, to change the value to 100? Thanks for the patience in dealing with a C++ newbie.
Assuming a 32 bit environment
int *IntPtr;
*(int *) &Int = 0x00AF90; // Make pointer point to right address
*IntPtr = 100; // Change integer to 100.
but in a protected mode OS you cannot change memory used by another application. Is this memory in a different application? What OS are you using?
Most game editors don't modify a game's memory directly. Because it woudl be nearly imposible to do safely. They edit data files that the game program uses.
int *IntPtr;
*(int *) &Int = 0x00AF90; // Make pointer point to right address
*IntPtr = 100; // Change integer to 100.
but in a protected mode OS you cannot change memory used by another application. Is this memory in a different application? What OS are you using?
Most game editors don't modify a game's memory directly. Because it woudl be nearly imposible to do safely. They edit data files that the game program uses.
ASKER
To answer, Nietod...
I am running Win98SE. Programs such as GameHack2.0 and their ilk work perfectly, however, as I said, they're overly cumbersome for what I want to do. The program I'm potentially writing would modify the memory address as the game itself is running, as GameHack does.
I am running Win98SE. Programs such as GameHack2.0 and their ilk work perfectly, however, as I said, they're overly cumbersome for what I want to do. The program I'm potentially writing would modify the memory address as the game itself is running, as GameHack does.
ASKER
To answer, Nietod...
I am running Win98SE. Programs such as GameHack2.0 and their ilk work perfectly, however, as I said, they're overly cumbersome for what I want to do. The program I'm potentially writing would modify the memory address as the game itself is running, as GameHack does.
I am running Win98SE. Programs such as GameHack2.0 and their ilk work perfectly, however, as I said, they're overly cumbersome for what I want to do. The program I'm potentially writing would modify the memory address as the game itself is running, as GameHack does.
Good luck.
ASKER
<chuckle> I get a strange sense of foreboding there. Oh well. If it can't be done, so be it...I'll gain what I can out of this anyways.
->but in a protected mode OS you cannot change memory used by another application
========================
nietod,really cannot be done?
What do you mean?
I once wrote a program dynamically change code of a running .exe in another process by setting hooks.It's easy.Why you think it cannot be done?
Regards
W.Yinan
========================
nietod,really cannot be done?
What do you mean?
I once wrote a program dynamically change code of a running .exe in another process by setting hooks.It's easy.Why you think it cannot be done?
Regards
W.Yinan
VoiceOfDissent ,it can be done and there are more than one way.
>> nietod,really cannot be done?
In a true protected mode OS you cannot. Windows is only a semi-protected mode OS. Hooks and other techniques allow you to affect other applications in windows in ways that are clear violation of protection, so windows is not a full fledged protected OS.
>> it's easy.
I admit it can be done in Windows, but I don't think is is ever easy!
In a true protected mode OS you cannot. Windows is only a semi-protected mode OS. Hooks and other techniques allow you to affect other applications in windows in ways that are clear violation of protection, so windows is not a full fledged protected OS.
>> it's easy.
I admit it can be done in Windows, but I don't think is is ever easy!
->I admit it can be done in Windows, but I don't think is is ever easy!
========================
okay,it seems easy when you have done it and relive back.
========================
okay,it seems easy when you have done it and relive back.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also adding to Wyn's solution,
This solution is if you are going to spawn the game code yourself.
For already running process , on Win98 you may have to use the Toolhelp APIs to get the pid of the process and use the OpenProcess() to get the process handle to be used in VirtalProtectEx() etc.
Or FindWindow() and GetWindowThreadProcessId() .
How about using the debugger?
Yes,you can do that by using hook to inject into that process'address and change it.