Hi, I have been making a program that searches in another process's memory for a value from the user. It works, but it's very slow. I have used other searchers like TSearch that are really fast. If anyone has a way to make it faster, please help.:-/
Here's my code
#include <windows.h>
#include <iostream>
using namespace std;
int Memory(HWND MyWindow, int long Address, int Value, bool _w)
{
DWORD PROC_ID;
HANDLE PROC_HANDLE;
GetWindowThreadProcessId(MyWindow, &PROC_ID);
PROC_HANDLE = OpenProcess(PROCESS_ALL_ACCESS, false, PROC_ID);
if(_w)
WriteProcessMemory(PROC_HANDLE, (LPVOID)Address, &Value, sizeof(long int), NULL);
else
ReadProcessMemory(PROC_HANDLE, (LPVOID)Address, &Value, sizeof(long int), NULL);
CloseHandle(PROC_HANDLE);
return Value;
}
int main()
{
SetConsoleTitle("Memory Search");
unsigned long long int x;
LPVOID MyLPVOID;
char Caption[1000];
cout << "Enter the caption of the window: ";
cin.getline(Caption, 1000);
HWND Test = FindWindow(NULL, Caption);
if (!Test)
{
cout << "\nCannot find window \"" << Caption << "\"!";
cin.get();
return 0;
}
LPVOID Address;
cout << "\nEnter the address to start at: ";
cin >> Address;
int WhatToFind;
cout << "\nWhat number are you trying to find: ";
cin >> WhatToFind;
for (x = 0; x < 2000000000; x++)
{
int AtAddress = Memory(Test, ((int long)Address + x), 0, false);
if (AtAddress == WhatToFind)
{
cout << "\n\nFound it at address: " << (LPVOID)((int long)Address + x);
cin.ignore();
cin.ignore();
}
}
cout << "\nDone!";
cin.ignore();
cin.ignore();
return 0;
}