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 


how do i...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
AwayTheWInd
Master Cheater
Reputation: 0

Joined: 11 Sep 2007
Posts: 450

PostPosted: Wed Apr 16, 2008 7:10 pm    Post subject: how do i... Reply with quote

how do i use C++ to scan for values? like.. i want to scan for the value 27 or 26. i think i have an idea, but it would include a huge database of stuff...
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Apr 16, 2008 8:52 pm    Post subject: Reply with quote

ReadProcessMemory
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Thu Apr 17, 2008 7:02 am    Post subject: Reply with quote

Code:
BOOL WINAPI ReadProcessMemory(
  __in   HANDLE hProcess,
  __in   LPCVOID lpBaseAddress,
  __out  LPVOID lpBuffer,
  __in   SIZE_T nSize,
  __out  SIZE_T* lpNumberOfBytesRead
);


Code:
HANDLE WINAPI OpenProcess(
  __in  DWORD dwDesiredAccess,
  __in  BOOL bInheritHandle,
  __in  DWORD dwProcessId
);

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Apr 17, 2008 7:33 am    Post subject: Reply with quote

Horny AZN boy, what about GetWindowThreadProcessId() and CloseHandle() ?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 17, 2008 7:40 am    Post subject: Reply with quote

If you are injecting a DLL you can dump a location of memory into an array using memcpy then loop the array and compare each byte using memcmp.

Don't hold me to this code, I just made it in Notepad, don't have access to Visual Studio to make a dll to test it, but this should be something similar to what you want:

Code:
BYTE* ScanMemory( BYTE* btBaseAddr, DWORD dwSize, BYTE btScanByte )
{
   //
   BYTE* btAddressFound = NULL;

   // Create Array For Memory Dump
   char* szMemDump = new char[dwSize+1];

   // Copy Memory Into Dump
   memcpy( szMemDump, btBaseAddr, dwSize );

   // Loop And To Find Byte
   for( int x=0; x<dwSize; x++ )
   {
      if( memcmp( (BYTE*)&szMemDump[x], btScanByte, 1 ) == 0 )
      {
         btAddressFound = btBaseAddress+x;
         break;
      }
   }

   // Delete Memory Dump
   delete[] szMemDump;

   // Return Result
   return btBaseAddr;
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 472

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

PostPosted: Thu Apr 17, 2008 8:24 am    Post subject: Reply with quote

Toy don't even have to copy the memory first when using a dll. You can just read the memory directly
_________________
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
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Apr 17, 2008 2:39 pm    Post subject: Reply with quote

Dark Byte wrote:
Toy don't even have to copy the memory first when using a dll. You can just read the memory directly


Yeah but if the value changes during the scan he's screwed. Easier to dump it that second and have it scan through the dump in case the memory changes during the loop. Bigger loops can take a second or two which could lead to missing the value all together.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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