Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change Value of a known memory address?

Posted on 2000-03-09
14
Medium Priority
?
269 Views
Last Modified: 2010-04-02
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.
0
Comment
Question by:VoiceOfDissent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +2
14 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2601473
You mean dynamically?

Yes,you can do that by using hook to inject into that process'address and change it.

0
 
LVL 22

Expert Comment

by:nietod
ID: 2601740
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.
0
 

Author Comment

by:VoiceOfDissent
ID: 2601771
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:VoiceOfDissent
ID: 2601789
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.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2601800
Good luck.
0
 

Author Comment

by:VoiceOfDissent
ID: 2601818
<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.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2601825
->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
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2601834
VoiceOfDissent ,it can be done and there are more than one way.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2601842
>> 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!
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2601870
->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.
0
 
LVL 5

Accepted Solution

by:
Wyn earned 800 total points
ID: 2601978
VoiceOfDissent ,under windows ,right?
I give you the easiest way but you must start that game in your program :
void main()
{
   STARTUPINFO si;
   memset(&si,0,sizeof(si));
   si.cb=sizeof(si);
   PROCESS_INFORMATION pi;
   if(CreateProcess(0,"game.exe",0,0,FALSE,CREATE_SUSPENDED,0,0,&si,&pi)) {
      DWORD buf=4;
      LPVOID lp=LPVOID(0x00AF90);
      DWORD protection;
      VirtualProtectEx(pi.hProcess,lp,sizeof(DWORD),PAGE_READWRITE,
         &protection);
      WriteProcessMemory(pi.hProcess,lp,&buf,4,&protection);
   }
ResumeThread(pi.hThread);
}

If you need to change at will when it is running,it 's harder and tell me if you want to do.
Regards
W.Yinan
0
 
LVL 3

Expert Comment

by:ufolk123
ID: 2603386

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.

0
 
LVL 5

Expert Comment

by:Wyn
ID: 2603421
Or FindWindow() and GetWindowThreadProcessId().
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2604344
How about using the debugger?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question