 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sun Apr 25, 2010 3:41 pm Post subject: Pointer "next scan" function help |
|
|
Code: | void PointerScan::NextScan(HWND hList, int DlgItem, unsigned int value, DWORD dwScanType)
{
HWND hWndList = GetDlgItem(hList, DlgItem);
char * buf = (char*)GlobalAlloc(GPTR, 512);
DWORD dwAddr = 0;
for(int i = 0; i < SendMessage(hList, DlgItem, LB_GETCOUNT, 0); i++)
{
ZeroMemory(buf, 512);
SendMessage(hWndList, LB_GETTEXT, i, (LPARAM)buf);
sscanf(buf, "%x", &dwAddr);
if((!dwScanType && *(BYTE*)dwAddr != (BYTE)value)
|| (dwScanType == 1 && *(WORD*)dwAddr != (WORD)value)
|| (dwScanType == 2 && *(DWORD*)dwAddr != (DWORD)value))
{
SendMessage(hWndList, LB_DELETESTRING, i, 0);
}
}
dwAddr = 0;
GlobalFree((HANDLE)buf);
} |
Oddly, this doesn't work for some reason :S
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Apr 25, 2010 4:11 pm Post subject: |
|
|
imagine when you delete index 0. so we then go to next iteration of for loop. and i is then 1. but actually because you deleted an item already, the one you are reading is no longer index 1. ie. your 'i' value no longer matches your intended index
|
|
Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sun Apr 25, 2010 4:51 pm Post subject: |
|
|
Oh god, my eyes. Why are you mixing GUI with logic in a single class? Not to mention templates exist for a reason.
Also, what Slugsnack said. Splitting up your code will stop stupid mistakes like this in the future.
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun Apr 25, 2010 5:08 pm Post subject: |
|
|
Expanding on what Flyte said, here are some concepts you might like to look into, void :
- Don't Talk To Strangers/Law of Demeter
- MVC
Try to read up on coupling and cohesion to understand why and how you can produce good code. Otherwise, iPromise 'engineered' a 'memory scanner'. Perhaps if you asked him nicely, he might show you his source. You guys could collaborate as a team.
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|