As of now I’m using a while(true) method to detect changes in memory. The problem with this is it’s kill the applications performance. I have a list of 30 pointers that need checked as rapidly as possible for changes, without sacrificing a huge performance loss. Anyone have ideas on this?
EDIT** The idea of this is to detect changed in memory caused by certain applications while running an online shooter game. Not really an anti-cheat, but it’s along those lines.
memScan = new Thread(ScanMem);
public static void ScanMem()
{
int i = addy.Length;
while (true)
{
Thread.Sleep(30000); //I do this to cut down on cpu usage
for (int j = 0; j < i; j++)
{
string[] values = addy[j].Split(new char[] { Convert.ToChar(",") });
//MessageBox.Show(values[2]);
try
{
if (Memory.Scanner.getIntFromMem(hwnd, (IntPtr)Convert.ToInt32(values[0], 16), 32).ToString() != values[1].ToString())
{
//Ok, it changed lets do our work
//work
if (Globals.Working)
return;
SomeFunction("Results: " + values[2].ToString(), "Memory");
Globals.Working = true;
}//end if
}//end try
catch { }
}//end for
}//end while
}//end void
You need not check all the elements at once. You can implement pipelining. So that in every iteration you end up checking only one element at a time. This way you will not face any performance related issues and you will end up checking all elements in 30 iterations. So just reduce your sleep and move it inside the inner for loop as shown below. I think should improve your performance.