Instead of using mouse event API you can just use the game functions to handle the mouse clicks. There are several functions that are used but only two to handle the actual events.
Left click - StepSquare(x,y);
Right Click - MakeGuess(x,y);
Using IDA you can get the addresses easily:
StepSquare - 0x01003512
MakeGuess - 0x0100374F
Took a little bit of debugging to find the actual functions used to handle the clicks, but once found you can make a full bot easily like your code, without extra API or taking over the mouse. My example hook code:
PHP Code:
//
// Minesweeper Bot - Wiccaan [wiccaan@live.com] 2008
//
// As seen several times before, a bot to auto-solve
// Minesweeper. However, this version does not take
// control of the users mouse. Instead it makes use
// of the actual game functions to handle click events.
//
#include
HMODULE hThisModule = NULL; // This Module Handle BOOL bWantsExit = FALSE; // Exit Monitor Boolean
//
// mineMakeGuess
//
// This function is used to place a flag or question mark
// at the given coords. This is the event called when a
// player usually right clicks on the game board.
// void mineMakeGuess( int x, int y )
{
_asm push y
_asm push x
_asm mov eax, 0100374Fh
_asm call eax }
//
// mineStepSquare
//
// This function is used to actually click the square at
// the given coords. This is the event called when a player
// usually left clicks on the game board.
// void mineStepSquare( int x, int y )
{
_asm push y
_asm push x
_asm mov eax, 01003512h
_asm call eax }
//
// mineSolvePuzzle
//
// This function is called when a player presses F5 after
// this module has been injected. This function reads the
// play board each step one byte at a time and checks for
// a bomb.
// void mineSolvePuzzle()
{
for( int y = 1; y <= *(int*)0x10056A8; y++ )
for( int x = 1; x <= *(int*)0x10056AC; x++ )
{
BYTE bCurr = *(BYTE*)( (BYTE*)0x1005340 + ( x + ( y * 32 ) ) );
if( bCurr != 0x8F && bCurr == 0x0F )
mineStepSquare( x, y ); // Not a bomb!
else
mineMakeGuess( x, y ); // Was a bomb!
}
}
void
ToolThread( LPVOID lpReserved )
{
UNREFERENCED_PARAMETER( lpReserved );
while( !bWantsExit )
{
if( GetAsyncKeyState( VK_F5 )&1 )
mineSolvePuzzle();
if( GetAsyncKeyState( VK_F6 )&1 )
bWantsExit = TRUE;
}
FreeLibraryAndExitThread( hThisModule, 0 );
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
{
UNREFERENCED_PARAMETER( lpReserved );
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hModule );
hThisModule = hModule;
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)
ToolThread, 0, 0, 0 );
break;
case DLL_PROCESS_DETACH:
bWantsExit = TRUE;
break;
}
return TRUE;
}
You can do the same for the showing bombs Tool. There is a function called ShowBombs located at 0x01002F80, pass it 0xA to show the bombs on the current playing field.
0 comentarios:
Publicar un comentario