Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Pointer "next scan" function help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sun Apr 25, 2010 3:41 pm    Post subject: Pointer "next scan" function help Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Apr 25, 2010 4:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sun Apr 25, 2010 4:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Apr 25, 2010 5:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites