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 


C++ AOB scan speed

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ifree
How do I cheat?
Reputation: 0

Joined: 22 Feb 2019
Posts: 2

PostPosted: Fri Feb 22, 2019 11:44 am    Post subject: C++ AOB scan speed Reply with quote

Hi, I just implemented a multithread AOB scan using c++.

When I do it scan on DS3, it take almost 10s to get the result, but CE at do it in 1 or 2s.

I just wonder how CE achieve that.

Thanks

P.S.
I do use memory region cache:
Code:

void MemScanner::build_page_cache() {
  page_cache_.clear();

  MEMORY_BASIC_INFORMATION mem_info{};

  for (uintptr_t addr = 0;
       VirtualQueryEx(handle_, reinterpret_cast<LPVOID>(addr), &mem_info,
                      sizeof(MEMORY_BASIC_INFORMATION));
       addr += mem_info.RegionSize) {
    if ((mem_info.State == MEM_COMMIT) &&
        (mem_info.Protect & PAGE_GUARD) == 0 &&
        (mem_info.Protect & PAGE_NOACCESS) == 0 &&
        (mem_info.Type == MEM_IMAGE || mem_info.Type == MEM_PRIVATE) &&
        mem_info.RegionSize < 0x2ffffffff) {
      // follow cheat engine's logic
      bool writable = ((mem_info.Protect & PAGE_READWRITE) > 0) ||
                      ((mem_info.Protect & PAGE_WRITECOPY) > 0) ||
                      ((mem_info.Protect & PAGE_EXECUTE_READWRITE) > 0) ||
                      ((mem_info.Protect & PAGE_EXECUTE_WRITECOPY) > 0);

// ignore it now
      bool executable = ((mem_info.Protect & PAGE_EXECUTE) > 0) ||
                        ((mem_info.Protect & PAGE_EXECUTE_READ) > 0) ||
                        ((mem_info.Protect & PAGE_EXECUTE_READWRITE) > 0) ||
                        ((mem_info.Protect & PAGE_EXECUTE_WRITECOPY) > 0);

      if (writable) {
        page_cache_.emplace_back(
            reinterpret_cast<uintptr_t>(mem_info.BaseAddress),
            mem_info.RegionSize);
      }
    }
  }
}


Just a simple scan
Code:

      uintptr_t addr{};
      std::vector<uintptr_t> address_list{};
      // pm.aob_scan("48 8B 05 * * * * 48 85 C0 * * 48 8b 40 * C3",
      // address_list); addr = address_list[0]; context.BaseA = addr +
      // pm.read<int>(addr + 3) + 7;

      // aobscanmodule(Findit2,DarkSoulsIII.exe,48 8B 1D ?? ?? ?? 04 48 8B F9 48
      // 85 DB ?? ?? 8B 11 85 D2 ?? ?? 8D)
      address_list.clear();
      pm.aob_scan("48 8B 1D * * * 04 48 8B F9 48 85 DB * * 8B 11 85 D2 * * 8D",
                  address_list);
      addr = address_list[0];
      addr = addr + pm.read<int>(addr + 3) + 7;
      addr = pm.read<uintptr_t>(addr);
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 361

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

PostPosted: Fri Feb 22, 2019 1:59 pm    Post subject: Reply with quote

perhaps your aobscan check is parsing the aob string every time ?
Or it doesn't stop comparing all the bytes until the whole string has been scanned ?

You're creating more threads than there are processors ?

You're not splitting up the memory blocks evenly by the number of CPU's and leave one CPU to do 90% of the work ?
You have critical sections around readonly blocks of data ?
You're constantly allocating and freeing memory ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
ifree
How do I cheat?
Reputation: 0

Joined: 22 Feb 2019
Posts: 2

PostPosted: Sat Feb 23, 2019 3:39 am    Post subject: Reply with quote

Thanks for your reply!
I should have done the profiling after ask the stupid question, sorry.

And I found out my issues are, scan address range too big, and memory allocation frequency.

Thanks!
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