There are two ways of doing it:
1: Change the memory itself (Easiest if game is unprotected)
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD address =0x063FE94; // This is the address that we want to read from
int change = 1000;
int value = 0; // This will store our value. In my case, its an integer, which is the timer
DWORD address2=0x063FE78;
int change2 = 1000;
int value2= 0;
DWORD pid; //This will store our Process ID, used to read/write into the memory
HWND hwnd; //Finally a handle to our window
hwnd = FindWindow(NULL,"TB"); //Finds the Window called "Minesweeper"
if(!hwnd) //If none, display an error
{
cout <<"Janela nao encontrada!\n";
cin.get();
}
else
{
GetWindowThreadProcessId(hwnd,&pid); //Get the process id and place it in pid
HANDLE phandle = OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE,0,pid); //Get permission to read
cout << "ok , tentando Mostrar valores...\n";
if(!phandle) //Once again, if it fails, tell us
{
cout <<"Could not get handle!\n";
cin.get();
}
else
{
while(1) //Forever, or until you force close the program
{
ReadProcessMemory(phandle,(void*)address,&value,sizeof(value),0); //Read what is in "address" and store it in "value", then what is the size of what we are going to read which is "value",and finally the number of bytes read, but I dont care about that so I put a 0, or NULL
cout <<"HP:"<< value << "\n\n"; //Display it
ReadProcessMemory(phandle,(void*)address2,&value2,sizeof(value2),0);
cout <<"MP:"<<value2<<"\n\n";
if(value == 2)
{
WriteProcessMemory(phandle,(void*)address,&change,sizeof(change),0);
}
if(value2 == 2)
{
WriteProcessMemory(phandle,(void*)address,&change2,sizeof(change2),0);
}
Sleep(5000); //I was reading the timer which increases every second, so I made my program go through that loop every second
}
return 0;
}
}
Change the red stuff with the number you want it to check for before it changes the value.
2: Key Command
Code:
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
DWORD address =0x063FE94; // This is the address that we want to read from
int change = 1000;
int value = 0; // This will store our value. In my case, its an integer, which is the timer
DWORD address2=0x063FE78;
int change2 = 1000;
int value2= 0;
DWORD pid; //This will store our Process ID, used to read/write into the memory
HWND hwnd; //Finally a handle to our window
hwnd = FindWindow(NULL,"TB"); //Finds the Window called "Minesweeper"
if(!hwnd) //If none, display an error
{
cout <<"Janela nao encontrada!\n";
cin.get();
}
else
{
GetWindowThreadProcessId(hwnd,&pid); //Get the process id and place it in pid
HANDLE phandle = OpenProcess(PROCESS_VM_READ,0,pid); //Get permission to read
cout << "ok , tentando Mostrar valores...\n";
if(!phandle) //Once again, if it fails, tell us
{
cout <<"Could not get handle!\n";
cin.get();
}
else
{
while(1) //Forever, or until you force close the program
{
ReadProcessMemory(phandle,(void*)address,&value,sizeof(value),0); //Read what is in "address" and store it in "value", then what is the size of what we are going to read which is "value",and finally the number of bytes read, but I dont care about that so I put a 0, or NULL
cout <<"HP:"<< value << "\n\n"; //Display it
ReadProcessMemory(phandle,(void*)address2,&value2,sizeof(value2),0);
cout <<"MP:"<<value2<<"\n\n";
if(value == 2)
{
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
}
if(value2 == 2)
{
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
}
Sleep(5000); //I was reading the timer which increases every second, so I made my program go through that loop every second
}
return 0;
}
}
Change the red stuff, with the keys for your macro