just another MineSweeper Tool

On domingo, 12 de septiembre de 2010 0 comentarios

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 mineMakeGuessint xint 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 mineStepSquareint xint 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<= *(int*)0x10056A8y++ )
        for( 
int x 1<= *(int*)0x10056ACx++ )
        {
            
BYTE bCurr = *(BYTE*)( (BYTE*)0x1005340 + ( + ( 32 ) ) );
            if( 
bCurr != 0x8F && bCurr == 0x0F )
                
mineStepSquarex); // Not a bomb!
            
else
                
mineMakeGuessx); // Was a bomb!
        
}
}
void
ToolThreadLPVOID lpReserved )
{
    
UNREFERENCED_PARAMETERlpReserved );

    while( !
bWantsExit )
    {
        if( 
GetAsyncKeyStateVK_F5 )&)
            
mineSolvePuzzle();
        if( 
GetAsyncKeyStateVK_F6 )&)
            
bWantsExit TRUE;
    }
    
FreeLibraryAndExitThreadhThisModule);
}
BOOL APIENTRY DllMainHMODULE hModuleDWORD dwReasonLPVOID lpReserved )
{
    
UNREFERENCED_PARAMETERlpReserved );

    switch( 
dwReason )
    {
    case 
DLL_PROCESS_ATTACH:
        
DisableThreadLibraryCallshModule );
        
hThisModule hModule;
        
CreateThread00, (LPTHREAD_START_ROUTINE)
ToolThread00);
        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