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 


Faster Pointer Scan (Urgent)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
iPromise
Grandmaster Cheater
Reputation: -1

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Sun Jan 02, 2011 12:26 am    Post subject: Faster Pointer Scan (Urgent) Reply with quote

I currently have a pointer scanner, its extremely slow however compared to CE or MHS. I try to reduce the pointer offset to around 1000 to make the speed faster but that doesn't give me the best results. I don't write my info into a file before hand because I barely find any addresses, so when I do adding them to the listbox won't lag at all or slow down preformance as much.

I currently see if the there if I want to find static only addresses, and if I want to find dynamic one's as well. Before I release my memory engine to the public I want to make sure it is useful and doesn't suck, so I need help guys T_T

here is my code (currently)

Code:


void newps ()
{
   HWND hWndDlg = PointerWND;

   SetWindowTextA ( GetDlgItem ( hWndDlg, IDC_SCAN ), "Scanning, please wait." );
   SendMessageA ( GetDlgItem ( hWndDlg, IDC_LIST1 ), LB_RESETCONTENT, 0, 0 );

   int done_ps = 0;
   int results = 0;

   DWORD TargetFrom = GetCurSel_3 (hWndDlg, IDC_EDIT1);
   DWORD TargetTo   = GetCurSel_3 (hWndDlg, IDC_EDIT2);

   DWORD dwStartAddr  = GetCurSel_3 (hWndDlg, IDC_EDIT3);
   DWORD dwStopAddr   = GetCurSel_3 (hWndDlg, IDC_EDIT4);

   bool Fast   = ( SendMessageA (GetDlgItem(hWndDlg, IDC_CHECKBOX1), BM_GETCHECK, 0, 0) == BST_CHECKED ) ? true : false;
   bool Slow   = ( SendMessageA (GetDlgItem(hWndDlg, IDC_CHECKBOX2), BM_GETCHECK, 0, 0) == BST_CHECKED ) ? true : false;
   bool Static = ( SendMessageA (GetDlgItem(hWndDlg, IDC_CHECKBOX3), BM_GETCHECK, 0, 0) == BST_CHECKED ) ? true : false;

   if ( Static == false )
   {
      for ( DWORD i = dwStartAddr;
               i < dwStopAddr;
               i ++ )
      {
         MEMORY_BASIC_INFORMATION MBI = {0};
         VirtualQuery ((LPCVOID) i, &MBI, sizeof (MEMORY_BASIC_INFORMATION));

         if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

         if ( Fast )
         {
            if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

            if ( ( MBI.State == MEM_COMMIT ) &&
                ( MBI.Type  == MEM_PRIVATE ) &&
                ( MBI.RegionSize > 0 ) )
            {
               if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

               DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - 16;

               for ( DWORD addr = (DWORD) MBI.BaseAddress;
                        addr < (DWORD) dwEndAddr;
                        addr ++ )
               {
                  for ( DWORD pointer = TargetFrom; pointer <= TargetTo; pointer ++ )
                  {
                     void *Read = boo ( pointer );

                     if ( read_void ( addr ) == Read )
                     {
                        ++ results;

                        add_to_list ( addr, hWndDlg );

                        break;
                     }
                  }
               }

               i += (DWORD) MBI.RegionSize;
            }
            else
            {
               i += (DWORD) MBI.RegionSize;
            }
         }

         if ( Slow )
         {
            if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

            if ( ( MBI.Protect == PAGE_READWRITE ) &&
                ( MBI.RegionSize > 0 ) )
            {
               DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - 16;

               for ( DWORD addr = (DWORD) MBI.BaseAddress;
                        addr < (DWORD) dwEndAddr;
                        addr ++ )
               {
                  for ( DWORD pointer = TargetFrom; pointer <= TargetTo; pointer ++ )
                  {
                     void *Read = boo ( pointer );

                     if ( read_void ( addr ) == Read )
                     {
                        ++ results;

                        add_to_list ( addr, hWndDlg );

                        break;
                     }
                  }
               }

               i += (DWORD) MBI.RegionSize;
            }
            else
            {
               i += (DWORD) MBI.RegionSize;
            }
         }
      }
   }
   else
   {
      for ( DWORD i = dwStartAddr;
               i < dwStopAddr;
               i ++ )
      {
         if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

         HMODULE hHandle;
         GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR) i, &hHandle);

         MEMORY_BASIC_INFORMATION MBI = {0};
         VirtualQuery ((LPCVOID) i, &MBI, sizeof (MEMORY_BASIC_INFORMATION));

         if ( Fast )
         {
            if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

            if ( ( MBI.State == MEM_COMMIT ) &&
                ( MBI.Type  == MEM_PRIVATE ) &&
                ( MBI.RegionSize > 0 ) &&
                ( hHandle != NULL ) )
            {
               if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

               DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - 16;

               for ( DWORD addr = (DWORD) MBI.BaseAddress;
                        addr < (DWORD) dwEndAddr;
                        addr ++ )
               {
                  for ( DWORD pointer = TargetFrom; pointer <= TargetTo; pointer ++ )
                  {
                     void *Read = boo ( pointer );

                     if ( read_void ( addr ) == Read )
                     {
                        ++ results;

                        add_to_list ( addr, hWndDlg );

                        break;
                     }
                  }
               }

               i += (DWORD) MBI.RegionSize;
            }
            else
            {
               i += (DWORD) MBI.RegionSize;
            }
         }

         if ( Slow )
         {
            if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

            if ( ( MBI.Protect == PAGE_READWRITE ) &&
                ( MBI.RegionSize > 0 ) &&
                ( hHandle != NULL ) )
            {
               if ( stop_pp_scan == 1 ) { i = dwStopAddr; break; }

               DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - 16;

               for ( DWORD addr = (DWORD) MBI.BaseAddress;
                        addr < (DWORD) dwEndAddr;
                        addr ++ )
               {
                  for ( DWORD pointer = TargetFrom; pointer <= TargetTo; pointer ++ )
                  {
                     void *Read = boo ( pointer );

                     if ( read_void ( addr ) == Read )
                     {
                        ++ results;

                        add_to_list ( addr, hWndDlg );

                        break;
                     }
                  }
               }

               i += (DWORD) MBI.RegionSize;
            }
            else
            {
               i += (DWORD) MBI.RegionSize;
            }
         }
      }
   }

   done_ps = 1;

   SetWindowTextA ( GetDlgItem ( hWndDlg, IDC_SCAN ), "Done scanning, enjoy sir!" );
}



BTW, I check for stop_pp_scan frequently just incase I the user wants to STOP the scan (found results, no need to scan for more and incase chance of possible detection).

Please help me guys.
Back to top
View user's profile Send private message MSN Messenger
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Jan 02, 2011 7:17 am    Post subject: Reply with quote

Either write it out in prose or write out only the relevant code. Good code should have the backing data and its modifiers decoupled from the displaying. Nobody is gonna read that much bad code. Recode it or write out pseduocode/prose.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25833
Location: The netherlands

PostPosted: Sun Jan 02, 2011 8:55 am    Post subject: Reply with quote

Try generating a map that contains all the values of every pointer in the game (one value can have multiple pointers) and then search through that map for pointers that have a value in a specific range
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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