GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 18-Aug-2008, 22:16
astropirit astropirit is offline
New Member
 
Join Date: Aug 2008
Posts: 8
astropirit is on a distinguished road
Question

Changing memory values.


Greetings
i need to know how to change values of specific memory addresses in c++. So far i have been using a utility for this job (cheatengine) but thought if i do this in c++ i might actually learn something

say the process name is: "bobdole.exe"
memory address: "04A96990"
memory type: "float"

we know for this value will allways be in the same address every time the program is loaded into memory.

i gave this a try: c++ tut on memory manipulation (site keeps crashing my firefox)
and i cant get the code to compile, gives me 50 errors, maybe because it was writen in c++.net? i am using standard c++.

(you are dealing with a c++ newby )
any help will be greatly appreciated.
  #2  
Old 18-Aug-2008, 23:27
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 802
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: changing memory values.


Are you saying that you want to write a program that
has the ability to change the value stored in memory 'owned' by a different process?
Do you know how to do this within your own program yet?
Quote:
we know for this value will always be in the same address every time
I don't think you can count on that at all...
As I understand it , addresses you see when using pointers etc. are 'virtual addresses'.
I think the OS sets aside a block of memory for your program and gives it a 'virtual' starting address.
The addresses I see are relative to that starting address.....
Last edited by Howard_L : 19-Aug-2008 at 00:07.
  #3  
Old 19-Aug-2008, 00:04
astropirit astropirit is offline
New Member
 
Join Date: Aug 2008
Posts: 8
astropirit is on a distinguished road

Re: Changing memory values.


Quote:
I don't think you can count on that at all...
well, most of the addresses stay the same, they havent changed for the past 3 years, for any of the ppl i know that do this. MOST, some of them do change though, but i am trying to master the ones that do not changed first.
Quote:
Do you know how to do this within your own program yet?
no i do not, this is the first swing i am taking at memory manipulation, with programing...
  #4  
Old 19-Aug-2008, 00:43
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 802
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Changing memory values.


I don't know how to access another programs space but I'm sure others here do.
C is a more straight forward language than C++ which builds on C.
If you are just starting, you might want to start with C and learn the basics by running through an online tutorial or two. Libraries and used books online are good resources as well. Can't beat having a good book close at hand.
I am just starting C++ and am following this for now: cplusplus.com/doc/tutorial
Whichever you choose you will see how data is stored and how we can access storage locations by using 'pointers'.
  #5  
Old 19-Aug-2008, 03:17
astropirit astropirit is offline
New Member
 
Join Date: Aug 2008
Posts: 8
astropirit is on a distinguished road

Re: Changing memory values.


here is the code i found that will achieve this in c++.net
CPP / C++ / C Code:
#include <windows.h>
#include <tlhelp32.h>
#include <conio.h>
#include <stdlib.h>

bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size);

void main()
{
     printf("=== Pinball Trainer Example. Made by <your name here> ===\n\n");
     if(ChangeMemVal("PINBALL.EXE", (void*) 0xA90C62, 100000000, 4))
          printf("The score has been edited successfully.\n");
     else
          printf("An error occured while attempting edit the score.\n");
     system("PAUSE");
     return 0;
}


/* This function modifys a memory address according to its arguments.
   Arguments :
             ProcessName - the process we want to modify
             MemAddress - the memory address we want to modify
             NewVal - the value we want to change the memory address to
             size - the size of the memory address
   Returns :
           the success of the edit.
   */


bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size)
{
     HANDLE hProcessSnap;
     HANDLE hProcess = NULL;
     PROCESSENTRY32 pe32;    
     hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
     pe32.dwSize = sizeof( PROCESSENTRY32 );
     Process32First(hProcessSnap, &pe32);
     do
     {          
          if(!strcmp(pe32.szExeFile, ProcessName))
          {
               hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
               break;
          }
     }
     while(Process32Next(hProcessSnap, &pe32));
     CloseHandle( hProcessSnap );
     if(hProcess != NULL)
     {
          WriteProcessMemory(hProcess, MemAddress, &NewVal, size, NULL);     // write the value          
          CloseHandle(hProcess);    
          return true;
     }    
     return false;
}
  #6  
Old 19-Aug-2008, 07:59
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 802
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Changing memory values.


Well that's definititly a windows program.
I did get this program to compile on a '98 machine using the regular old mingw gcc compiler.
Had to make a few simple changes but ...no .NET was needed. Want to 'learn' how?
What is your OS , your compiler and what EXACLY are the error messages you get.
How did you get that memory address specified in:
CPP / C++ / C Code:
     if(ChangeMemVal("PINBALL.EXE", (void*) 0xA90C62, 100000000, 4))
          printf("The score has been edited successfully.\n");
??? , the 0xA90C62...
hmm, I see the virtual address within the programs' allocation...
btw, cheaters never win
Last edited by Howard_L : 19-Aug-2008 at 09:28.
  #7  
Old 19-Aug-2008, 08:55
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 713
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Changing memory values.


I took the code you posted, pasted it into a .cpp file in visual studio .net and compiled it. First, you need to include <stdio.h> for using printf(). Then, you need to change void main() to int main(). Then, it compiled for me.
  #8  
Old 19-Aug-2008, 15:35
astropirit astropirit is offline
New Member
 
Join Date: Aug 2008
Posts: 8
astropirit is on a distinguished road

Re: Changing memory values.


hhhazzaa!! i got it to work! tnx fakepoo, and Howard_L.
i did wat fakepoo said, and bingo!

ok, now that that we have that done.
for an address that is never the same when the program is executed, i have the address of what writes to this program every time it is executed.
how would one go about changing the value of an address that changes every time the program is executed. knowing "what writes to this address" is allways the same, and never changes.



Quote:
btw, cheaters never win
lol, i want to make this clear, so we dont judge each other. i am not a cheater. I am a moder. i modify existing maps with hex editing. if ppl like my mods i release them. i do not gain unfair advantage in matches using theis things. i could, but i only mod this game to learn, i havent played the game in weeks :-) . its a ps2 game by the way.

Quote:
How did you get that memory address specified in:
using this third party software called cheat engine.
  #9  
Old 19-Aug-2008, 23:16
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 802
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Changing memory values.


So you're able to run that .exe on your ps2? or do you run a ps2 emulator on your pc...?
  #10  
Old 20-Aug-2008, 10:52
astropirit astropirit is offline
New Member
 
Join Date: Aug 2008
Posts: 8
astropirit is on a distinguished road

Re: Changing memory values.


neither. the game has a pc dedicated server. the server has a copy of most of the files in the ps2 game dvd. their is a few files, that the game calls from the server, instead of calling from the dvd. this exe just minipulates the memory of the executible which gets executed, when hosting a server. ex, the game limit is 24 plyers max/server. i changed that to 64 players/server max and stable.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A Complete Guide to SD Memory Cards haulkook Computer Hardware Forum 0 02-Jul-2008 00:27
A Few Tips on Buying Good Memory Cards and other Hi-Tech Electronic Accessories haulkook Computer Hardware Forum 0 02-Jun-2008 04:53
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 20:23
Re: Changing Client Side Memory Values Using Tsearch Zorachus Computer Software Forum - Windows 1 05-Aug-2005 22:03
[Tutorial] Pointers in C (Part I) Stack Overflow C Programming Language 1 08-Apr-2005 19:35

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:28.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.