 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25978 Location: The netherlands
|
Posted: Tue Feb 28, 2012 1:47 pm Post subject: |
|
|
Are you looking for module data or allocated data?
If moduledata the the easiest is CreateToolhelp32Snapshot and module32first/module32next (search msdn)
If allocated data look into virtualquery _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Shalvaid95 How do I cheat?
Reputation: 0
Joined: 26 Feb 2012 Posts: 9
|
Posted: Tue Feb 28, 2012 2:14 pm Post subject: |
|
|
I'm not completely sure about the differences between each one, but I think is the module data. Now I'm reading in msdn the api calls you told me.
For example, cheat engine starts always searching from x00000000? Or does it start from the base address of the process selected to make it faster?
I would like to do something like that, to improve the performance. |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25978 Location: The netherlands
|
Posted: Tue Feb 28, 2012 4:25 pm Post subject: |
|
|
Cheat Engine starts from 00000000, but it uses VirtualQueryEx to pinpoint memory regions that are unreadable and skip that
The main tip for performance is to never do RPM calls smaller than 4KB. Read first, scan later _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Shalvaid95 How do I cheat?
Reputation: 0
Joined: 26 Feb 2012 Posts: 9
|
Posted: Tue Feb 28, 2012 5:43 pm Post subject: |
|
|
Well, you were right Dark Byte. Thank you so much... I know i suck
My loop took 5 or more minutes, now is taking seconds !!!!
I did something like you told me:
| Code: | //////////////////////////////////////////////////////////////////
// ReadString from a certain Address and return as string type (4kb)
//////////////////////////////////////////////////////////////////
std::string ReadString(int Point)
{
//char *value = (char*)malloc(Len+1) = {0};
char value[4097] = {0}; //1KB (1024 BYTES) * 4 = 4KB (4096)
SIZE_T numBytesRead;
if (ReadProcessMemory(hProcess, (LPVOID)Point, value, 4096, &numBytesRead) == 0)
{
DWORD lastError = GetLastError();
return "";
// error - return an empty string
}
return std::string(value, numBytesRead);
}
//////////////////////////////////////////////////////////////////
// Search a Certain String in a process
//////////////////////////////////////////////////////////////////
int _stdcall SearchString(char *Text)
{
size_t found;
std::string Find;
long int x;
Find = std::string(Text,7);
// 80000000 / 4096 = 19532,...
for(x = 0; x < 19532; x++)
{
found=ReadString(x * 4096).find(Find);
if (found!=std::string::npos )
{
return (x * 4096) + found; // Return the address we found
}
}
return 0; //Error Return zero
} |
What happens if my string gets in the middle of a search ? Hahaha I hope it never happens. Anyway is FAAASTEER !!! than my last code.
How I can search and do the same for int (4bytes) values (to search pointers). And also find and verify if it's the value which i'm looking for.
I guess in arrays, but i'm not sure.
Thank you booss! |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Tue Feb 28, 2012 9:14 pm Post subject: |
|
|
Here's an example using Unicode strings since its the only thing on my laptop I could think to use to test this with lol:
| Code: |
#include <Windows.h>
#include <iostream>
#include <string>
DWORD_PTR _scan_string( HANDLE hProcHandle, const wchar_t* pwszInput )
{
if (hProcHandle == INVALID_HANDLE_VALUE)
return -1;
MEMORY_BASIC_INFORMATION mbi = { 0 };
LPVOID lpStartAddress = NULL;
SYSTEM_INFO sysInfo = { 0 };
GetSystemInfo( &sysInfo );
lpStartAddress = sysInfo.lpMinimumApplicationAddress;
while( VirtualQueryEx( hProcHandle, lpStartAddress, &mbi, sizeof( mbi ) ) )
{
if ((mbi.State & MEM_COMMIT) && (mbi.Protect & ( PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY )))
{
std::cout << "region: " << std::hex << mbi.BaseAddress << std::endl;
unsigned char szBuffer[ 4096 ] = { 0 };
ReadProcessMemory( hProcHandle, mbi.BaseAddress, &szBuffer, 4096, NULL );
for( int x = 0; x < 4096; x++ )
{
if (memcmp( (LPVOID)&szBuffer[ x ], pwszInput, wcslen( pwszInput ) ) == 0)
return ( ( DWORD_PTR )mbi.BaseAddress + x );
}
}
lpStartAddress = ( LPVOID )( ( DWORD_PTR )( lpStartAddress ) + mbi.RegionSize );
}
return 0;
}
int __cdecl main( int argc, TCHAR* argv[] )
{
HWND hWndWindow = FindWindow( NULL, L"Minesweeper" );
if (hWndWindow == NULL)
return ERROR_INVALID_HANDLE;
DWORD dwProcessId = 0;
GetWindowThreadProcessId( hWndWindow, &dwProcessId );
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_READ, FALSE, dwProcessId );
if (hProcess == NULL)
return ERROR_INVALID_HANDLE;
int nTest = _scan_string( hProcess, L"Minesweeper" );
std::cout << "Scan results: " << nTest;
CloseHandle( hProcess );
return ERROR_SUCCESS;
}
|
For original Windows XP Minesweeper. _________________
- Retired. |
|
| 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
|
|