Targeted program: programme test.exe (Comes with T-Searcher, also attached it)
Knowledge: Easy to medium
Needed:
- C++ Compiler
- Memory Scanning/Hacking software.
- A brain
Step 1)
Find the addresses.
I already did that for you, but you just do it yourself also.
Address One : 0x0041D090 (Numbers)
Address Two: 0x0041D094 (Stripes) (Starts at 365 not 0)
Both are static so should work for you.
Step 2)
Start a new empty "Windows Console Application" project
-------------------------------------------------
Now I'll explain pieces of the code and at the end of the tutorial you'll get the full source code.
Code:
int ValueOne=25, ValueTwo=403;
DWORD pid;
^declaring it for further use
Code:
HWND hWnd = FindWindow(NULL, "prog test");
^This searches for the window by the name of the window NOT by the name of the process!
Code:
GetWindowThreadProcessId(hWnd, &pid)
^Get the ProcessID of the window stored in hWnd and store it in pid
Code:
HANDLE phandle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, 0, pid);
^ Create a handle for you process
- PROCESS_VM_OPERATION -> always needed if you want to something
- PROCESS_VM_WRITE -> needed if you want to write to the process
- PROCESS_VM_READ -> needed if you want to read from the process
Code:
WriteProcessMemory(phandle, (LPVOID)addressone, &ValueOne, sizeof(ValueOne), 0);
^
-1- phandle - needed
-2- (LPVOID)addressone - The address you want to change
-3- &ValueOne - The value you want to give it
-4- sizeof(ValueOne) - The byte size of ValueOne (in this case 4)
Code:
system("pause"); // ask the user to press a key to end the program.
return 0; // end it
Full source code:
Code:
#include <windows.h>
#include <iostream>
// Define them so we can use them in the rest of the program
#define addressone 0x0041D090
#define addresstwo 0x0041d094
int main()
{
SetConsoleTitle("C++ Trainer by Erinador"); // Set your consoles title
int ValueOne=25, ValueTwo=403; // Declare these so we can use them
DWORD pid; // Declare this so we can use to store the ProcessID
int i = 1; // Declare this for the infinite loop
do {
/*----Find the window----*/
HWND hWnd = FindWindow(NULL, "prog test"); //find the window by name
if (!hWnd) //then
std::cout << "Window not found!\n"; // if it didn't find the windows name
else
std::cout << "Window found!\n"; // if it found the windows name
//end if
/*----Get the processID of the window you found----*/
if(!GetWindowThreadProcessId(hWnd, &pid)) // Then
std::cout << "Process ID not found!\n"; // not found
else
std::cout << "Process ID found!\n"; //found
//end if
/*----Create a handle----*/
HANDLE phandle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, 0, pid); //Get the needed permissions and open the process for access
if(phandle==INVALID_HANDLE_VALUE) //then
std::cout << "I don't have permissions to open the process!\n";
else
std::cout << "I have persmissions to open the process!\n";
/*----Write to the addresses----*/
WriteProcessMemory(phandle, (LPVOID)addressone, &ValueOne, sizeof(ValueOne), 0); // Set the value of the first address
WriteProcessMemory(phandle, (LPVOID)addresstwo, &ValueTwo, sizeof(ValueTwo), 0); // Set the value of the second address
Sleep(15); // We wouldn't want to lag now do we ;)
system("cls"); // Clear the screen
} while (i=1);
system("pause"); // ask the user to enter a key
return 0;
}
Full source code: (by process name and not caption)
Code:
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
using namespace std;
// Define them so we can use them in the rest of the program
#define addressone 0x0041D090
#define addresstwo 0x0041d094
void GetProcId(char* ProcName);
DWORD ProcId = 0; // THIS IS OUR GLOBAL VARIABLE FOR THE PROC ID;
int main()
{
char* ProcName="programme test.exe";
SetConsoleTitle("C++ Trainer by Erinador"); // Set your consoles title
int ValueOne=25, ValueTwo=403;
int i = 1;
do {
GetProcId(ProcName); // get the proc id from the processes name
cout << "The Process ID of " << ProcName << " is " << ProcId <<endl; // display it to the user
/*----Create a handle----*/
HANDLE phandle = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, 0, ProcId); //Get the needed permissions and open the process for access
if(phandle==INVALID_HANDLE_VALUE) //then
std::cout << "I don't have permissions to open the process!\n";
else
std::cout << "I have persmissions to open the process!\n";
/*----Write to the addresses----*/
WriteProcessMemory(phandle, (LPVOID)addressone, &ValueOne, sizeof(ValueOne), 0); // Set the value of the first address
WriteProcessMemory(phandle, (LPVOID)addresstwo, &ValueTwo, sizeof(ValueTwo), 0); // Set the value of the second address
Sleep(500); // We wouldn't want to lag now do we ;)
system("cls");
}while(i=1);
cin.get(); // to keep console open till we press a key
return 0;
}
void GetProcId(char* ProcName)
{
PROCESSENTRY32 pe32;
HANDLE hSnapshot = NULL;
pe32.dwSize = sizeof( PROCESSENTRY32 );
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( Process32First( hSnapshot, &pe32 ) )
{
do{
if( strcmp( pe32.szExeFile, ProcName ) == 0 )
break;
}while( Process32Next( hSnapshot, &pe32 ) );
}
if( hSnapshot != INVALID_HANDLE_VALUE )
CloseHandle( hSnapshot );
ProcId = pe32.th32ProcessID;
}
I put checks on it
I put it in a loop