   Editing memory?
  I have been trying to find how to edit memory on your system, so say like if I am playing Company of Heros, I can find the memory location where the money is and change it to give me X amount of money, I am not looking for cheats, trainers or hacks, I am wanted to understand how to do this process. I am having a problem finding information on it. I have been doing C++ for 3 years which leads me to my other question could I do it in C++ or do I go straight to C or as low as ASM? Anyone able to point me in a good direction? Thanks.   
  I found this link, and I am running Win7 so I do not have Pinball, so I used SpiderSolitaire as my example, I found the address for the score and I successfully change it in the Cheat Engine program used, but in my program I am unable to change it using the source provided in C++, I even changed a few things as some of the comments stated didn't work before but now they did when they changed "This". Here is my source anyone able to point me in the right direction?Link to tutorial#include <windows.h>#include <tlhelp32.h>#include <conio.h>#include <stdlib.h>#include <iostream>bool ChangeMemVal(const char * ProcessName, LPVOID MemAddress, int NewVal, int size);int main(){    printf("=== Spider Solitaire Trainer Example. Made by <your name here> ===\n\n");    if(ChangeMemVal("SpiderSolitaire.exe", (void*) 00373734, 100, 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 modifyMemAddress - the memory address we want to modifyNewVal - the value we want to change the memory address tosize - 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((const char*)pe32.szExeFile, ProcessName))   {  hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, 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;} [Edited by - wicked357 on April 7, 2010 5:32:28 AM];  Google for ArtMoney.  It's a tool that helps you find things like this. Ultimately it's going to require some reverse engineering.  If you know you have 800 gold, search for the value 800.  Then spend some money, now maybe you have 632 gold.  Now search for 632 among locations that matched previously.  Eventually you should be able to get this down to 1 location that is the potential match.Now begins the hard part.  Every time you shutdown and reload the program, it's in a different location.  There are a couple of reasons for this:a) In the source code for the game, the variable you're trying to find was probably part of a C source file that was compiled to a DLL.  DLLs relocate every time you run the program.  The first time you run the program the DLL could be a different place in memory than the second time.  Addresses are only constant relative to the beginning of the DLL.  ArtMoney will show you a process map though so you can find out the DLL Base Address, so you can compute this offset.b) Memory is often dynamically allocated.  Depending on the order of allocations, you might end up with your health, or gold, or whatever, ending up allocated in a different order and as such with a different address.However, in order for the program to be able to *use* the memory, there has to be some chain of pointer references that lead up to global or static scope.  This is where things start getting hard.  You have to trace the references backwards until you find something which is global scope.  Tracing a pointer backwards is hard.  If you have a pointer, it's easy to follow it.  But given an address X, finding a pointer to X is not as easy.  The problem is complicated further by the fact that there may not even be a pointer to X anywhere.  X might be part of a structure, maybe the gold variable is part of some class, and is at byte offset 0x40 inside the structure.  In that case you'd have to look for a pointer to X-0x40.  But how do you even know that there's a structure at all, and that you need to go back 0x40 bytes to get to the beginning?I recommend reading Reversing: Secrets of Reverse Engineering or something like that to learn more about this, there might also be free resource son the web.  It takes a lot of trial, error, and investigation.   ;Quote:Original post by wicked357I found this link, and I am running Win7 so I do not have Pinball, so I used SpiderSolitaire as my example, I found the address for the score and I successfully change it in the Cheat Engine program used, but in my program I am unable to change it using the source provided in C++, I even changed a few things as some of the comments stated didn't work before but now they did when they changed "This". Here is my source anyone able to point me in the right direction?Link to tutorial*** Source Snippet Removed ***you're more than likely just running into a pointer so the address is changing.cheat engine has a debugging function to help with this and the tutorial covers it as well.   