CodyOebel -2 Junior Poster in Training

Ok I have the hwnd to a process I am wanting to perform my memory scan on. Here is the problem and why I am making this program. I am looking for address X??????? which contains value 5555 the problem is address X??????? constantly changes when the program is executed. So my program scans from the base address all the way through all 14 million addresses until it finds what it's looking for. The problem is it takes 2-4 hours before it finds it. I am using a dissasembler called cheat engine, which can quickly scan through addresses. So I know there must be a way for me to speed this process up. I have tried using external programs to "speed" up the timing of the program (speed hacking it) but same slow scanning issue. Any help would be greatly appreciated.

   unsigned long pID;
   GetWindowThreadProcessId(hwndDC,&pID);
   HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE,pID);
   int x = 2207289488u;
   unsigned int x2;
   for(int i = 0; i<15000000;i++)
   {
    Sleep(1);
    DWORD LH = 0x001ed900+i;
    std::cout<<std::hex<<LH<<"\n";
    //MessageBox(0,"Found it","MB FINDER",0);
    ReadProcessMemory(hProcess, (LPVOID)LH, &x2, 4, NULL);
    if(x2 == 2198867081u)
    {
     Beep(1000,1000);
     Beep(1000,1000);Beep(1000,1000);Beep(1000,1000);Beep(1000,1000);
     WriteProcessMemory(hProcess, (LPVOID)LH, &x, 4, NULL);
     MessageBox(hwndDC,"FOUND IT","LIGHT HACK",0);
    break;
    };
   };
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.