Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 05:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++] Source: Minesweeper Bot

Discussion on [C++] Source: Minesweeper Bot within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
BlackFog's Avatar
 
elite*gold: 105
Join Date: Mar 2007
Posts: 5,073
Received Thanks: 558
[C++] Source: Minesweeper Bot

Moin,
Hier mal einen Minesweeper Bot den ich geschrieben habe. Wer sich ein bisschen mit ReadProcessMemory beschäftigen möchte, kann, denke ich, etwas aus dem Source lernen.

Quote:
#include <iostream>
#include <windows.h>

using namespace std;

class cMineMain
{
public:
int x_size;
int y_size;
int mines;


public:
int ReadXSize(HWND hWnd);
int ReadYSize(HWND hWnd);
int ReadMines(HWND hWnd);
int MineCheck(HWND hWnd,int x_coord,int y_coord);
void FirstClick(HWND hWnd,int win_x_pos,int win_y_pos,int screen_x,int screen_y);
void ClickTehShit(HWND hWnd,int x,int y,int screen_x,int screen_y,int win_x_pos,int win_y_pos);



};




int main ( void )
{

cMineMain MineBot;
HWND hWnd;
RECT *rect; // Rect Pointer für GetWindowRect
hWnd = FindWindow(0,"MineSweeper");
int screen_x = GetSystemMetrics(SM_CXSCREEN);
int screen_y = GetSystemMetrics(SM_CYSCREEN);

if (!hWnd)
{
cout << "MineSweeper nicht gefunden!" << endl;

}

else
{
GetWindowRect(hWnd,rect);
MineBot.x_size = MineBot.ReadXSize(hWnd);
MineBot.y_size = MineBot.ReadYSize(hWnd);
MineBot.mines = MineBot.ReadMines(hWnd);
cout << screen_x << endl;
cout << screen_y << endl;
cout << "X-Felder: " << MineBot.x_size << endl;
cout << "Y-Felder: " << MineBot.y_size << endl;
cout << "Anzahl der Minen: " << MineBot.mines << endl;
cout << "X-Position: " << rect->left << endl;
cout << "Y-Position: " << rect->top << endl;

MineBot.FirstClick(hWnd,rect->left,rect->top,screen_x,screen_y);


// Ausgabe !!!
int x = 0;
int y = 0;

do
{
for(x;x < MineBot.x_size;x++)
{
if (MineBot.MineCheck(hWnd,x,y) == 0)
{
cout << "x " ;
MineBot.ClickTehShit(hWnd,x,y,screen_x,screen_y,re ct->left,rect->top);
Sleep(0);
continue;

}
else
{
cout << "B " ;


}

}

y++;
x = 0;
cout << endl;
}while (y < MineBot.y_size);

cout << "Got teh Shit !!!" << endl;
// Ausgabe!!!






}


cin.get();

}







// Read X Size //
// Parameter : hWnd //
// Rückgabewert : Größe des Feldes in X Richtung //
int cMineMain::ReadXSize(HWND hWnd)
{
// Variablen
DWORD procid;
HANDLE mine_handle;
unsigned const address = 0x1005334;
int buf = 0;

GetWindowThreadProcessId(hWnd,&procid);
mine_handle = OpenProcess(PROCESS_ALL_ACCESS,false,procid);
ReadProcessMemory(mine_handle,LPCVOID(address),&bu f,sizeof(buf),NULL);
CloseHandle(mine_handle);
return buf;
}



// Read Y Size //
// Parameter : hWnd //
// Rückgabewert : Größe des Feldes in Y Richtung //
int cMineMain::ReadYSize(HWND hWnd)
{
// Variablen
DWORD procid;
HANDLE mine_handle;

unsigned const address =0x10056A8 ;
int buf = 0;

GetWindowThreadProcessId(hWnd,&procid);
mine_handle = OpenProcess(PROCESS_ALL_ACCESS,false,procid);
ReadProcessMemory(mine_handle,LPCVOID(address),&bu f,sizeof(buf),NULL);
CloseHandle(mine_handle);
return buf;
}

// Read Mines Number //
// Parameter : hWnd //
// Rückgabewert : Anzahl der Minen im Feld //

int cMineMain::ReadMines(HWND hWnd)
{
DWORD procid;
HANDLE mine_handle;
unsigned const address = 0x1005194;
int buf = 0;

GetWindowThreadProcessId(hWnd,&procid);
mine_handle = OpenProcess(PROCESS_ALL_ACCESS,false,procid);
ReadProcessMemory(mine_handle,LPCVOID(address),&bu f,sizeof(buf),NULL);
CloseHandle(mine_handle);
return buf;
}

// Mine Check //
// Parameter: hWnd , x-Koordinate , y- Koordinate //
// Rückgabewert : 1 = Mine ; 0 = Keine Mine //

int cMineMain::MineCheck(HWND hWnd,int x_coord,int y_coord)
{
DWORD procid;
HANDLE mine_handle;
unsigned address =(0x1005340) + (32 * (y_coord+1)) + (x_coord+1);
int buf = 0;

GetWindowThreadProcessId(hWnd,&procid);
mine_handle = OpenProcess(PROCESS_ALL_ACCESS,false,procid);
ReadProcessMemory(mine_handle,LPCVOID(address),&bu f,1,NULL);

if (buf == 0x8f)
{
return 1;
}
else
{
return 0;
}
CloseHandle(mine_handle);
}



void cMineMain::FirstClick(HWND hWnd,int win_x_pos,int win_y_pos,int screen_x, int screen_y)
{
float x_pixel = 65535/screen_x;
float y_pixel = 65535/screen_y;
float complete_winx = x_pixel * static_cast<float>(win_x_pos)+ x_pixel*23;
float complete_winy = y_pixel * static_cast<float>(win_y_pos)+ y_pixel*110;

SetForegroundWindow(hWnd);
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, complete_winx,complete_winy,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);


}

void cMineMain::ClickTehShit(HWND hWnd,int x,int y,int screen_x,int screen_y,int win_x_pos,int win_y_pos)
{

const float pixel_per_field = 16.0;
float x_pixel = 65535/screen_x;
float y_pixel = 65535/screen_y;
float complete_winx = x_pixel * static_cast<float>(win_x_pos)+ x_pixel*23;
float complete_winy = y_pixel * static_cast<float>(win_y_pos)+ y_pixel*110;
SetForegroundWindow(hWnd);
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, complete_winx+(x*pixel_per_field*x_pixel) ,complete_winy+(y*pixel_per_field*y_pixel),0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);




}







100% von mir geschrieben . Bei Fragen -> PM oder hier im Thread.
BlackFog is offline  
Thanks
3 Users
Reply


Similar Threads Similar Threads
Sell Source Binary v3.5, The Strongest Source in the world of private server
03/20/2011 - Conquer Online 2 Trading - 3 Replies
http://i797.photobucket.com/albums/yy253/aymanelkb er/vmwvhk.gif Wolves Private Server http://www.monsterup.com/upload/1258602276638.jpg Some Info About Source 2- Full Transalite 100% 3- Reborn ( 1 , 2 , 3 , 4) With Ninja Full work 100% 4- Plus ( +1 To +20 )
[Tuturial] einen Minesweeper "wallhack" erstellen
08/31/2010 - Coding Tutorials - 10 Replies
Hallo leute heute zeig ich euch wie ihr ein minesweeper "wallhack" erstellt. da dies mein erstes Tuturial ist nicht wundern wenn es nicht so gut erklärt ist. ;) Was ihr braucht: -AutoIt v3 den editor (am besten noch Koda fürs design) -Cheat Engine am besten v5.6 -Minesweeper (start ->alle Programme ->spiele -> minesweeper ( müsste bei den meisten windows PCs drauf sein ;) ) -"NomadMemory.au3" (downloadet es euch geht in euren AutoIt ordner geht dort auf den Ordner "Include" und fügt...
[question] minesweeper with cheat engine
06/04/2010 - General Coding - 1 Replies
i understand how to find the address for changeing the flags...and changing the time...but how do i figure out what address stores the values of the bombs? if the value never changes?
[Release]How To Make Tq Source Work + Working Source + Server ByBass + Commands
12/08/2008 - CO2 PServer Guides & Releases - 15 Replies
1: How To Make The Server Work In fact, before other people did not just let ACC now with hi EACC Columbia landing on the settlement of the issue, and the rest is our own how to improve the content of those interested can improve the next. MY MY set and the same. INI MAP INI files and MAP with the client-to-date coverage of the account. server.dat ! And then as long as the client will be able to modify server.dat! 127.0.0.1 192.168.0.1 192.168.1.1 IP。 Please do generally use...



All times are GMT +1. The time now is 05:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.