 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Thu Jan 06, 2011 10:30 am Post subject: [C++] Program to Hack Fast and Easy in your way [updated V3] |
|
|
Aka HEMP - Hacking in Easy Mode like a Pro
Hello!
i made this program to make things easier, have some functions() that help me allot!
i use it to create different hacks fast, like moving the character, checking gold etc...
see comments for function description
The Code:
Code: |
// HEMP: Hacking in Easy Mode like a Proffesional
// v3
#include <windows.h>
#include <cstdio>
#include <iostream>
#include <psapi.h>
using namespace std;
HWND hWindow;
DWORD dwPID;
HANDLE hProcess;
void Clean () {system("CLS");} // To clean the screen ^^
void* P (int address,int offset); // For pointer addresses, using read()
int AttachHelper (); // Show options to attach, return 1 if sucess else 0
int AttachToWindow (char* name); // Attach to the desired window name, return 1 if sucess else 0
int AttachToPID (int PIDtoLook); // Attach to the desired PID, return 1 if sucess else 0
int AttachToProcess (char* pName); // Attach to the desired process, return 1 if sucess else 0
void ShowProcessList (int mode); // mode: 1-Show process with name / 0-Show all
void Hack (void* address,int value); // Change the value in address to value
int Read (void* address); // Return the value in address
void Script (); // A place to put your script
int action;
int cont;
int main()
{
Clean();
AttachHelper(); //or any other attach function
Script();
cout << "\nEnter 1 to continue or 0 to exit";
cin >> cont;
if (cont==0){CloseHandle(hProcess);exit(0);}
else main();
}
void Script()
{
//Here goes your code!
//bla bla bla
//bla bla bla
//bla bla bla
}
//fuctions
int AttachHelper()
{
Clean();
cout << "Enter desired action:\n\n1 - Show Process List (Simple)\n";
cout << "2 - Show Process List (All)\n3 - Attach to Window (Not Working!)\n4 - Attach to Process\n5 - Attach to PID\n";
cin >> action;
switch (action)
{
case 1:
{
Clean();
ShowProcessList(1);
break;
}
case 2:
{
Clean();
ShowProcessList(0);
break;
}
case 3:
{
char wName[64];
cout << "Enter Window Name:\n";
cin >> wName;
Clean();
AttachToWindow(wName);
break;
}
case 4:
{
char PName[64];
cout << "Enter Process Name:\n";
cin >> PName;
Clean();
AttachToProcess(PName);
break;
}
case 5:
{
int nPID;
cout << "Enter PID:\n";
cin >> nPID;
Clean();
AttachToPID(nPID);
break;
}
}
}
int AttachToWindow(char* name)
{
hWindow = FindWindow(0, name);
if(hWindow == NULL)
{
cout << "Error fiding the window" << endl;
return 0;
}
GetWindowThreadProcessId(hWindow, &dwPID);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
if(hProcess == NULL)
{
cout << "Error opening the window process." << endl;
return 0;
}
else
{
cout << name << " opened!" << endl;
return 1;
}
}
int AttachToPID(int PIDtoLook)
{
dwPID=PIDtoLook;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
if(!dwPID || !hProcess)
{
cout << "Error opening PID." << endl;
return 0;
}
else
{
cout << (void*)PIDtoLook << " opened!" << endl;
return 1;
}
}
void ShowProcessList(int mode)
{
unsigned long aProcesses[1024], cbNeeded, cProcesses;
if(!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
{
cout << "Error browsing the process." << endl;
}
cProcesses = cbNeeded / sizeof(int);
cout << "PID:\tNAME:\n";
for(unsigned int i = 0; i < cProcesses; i++)
{
if(aProcesses[i] == 0)
continue;
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
char buffer[50];
GetModuleBaseName(hProcess, 0, buffer, 50);
CloseHandle(hProcess);
if (mode==1)if(buffer[0]!=0x3F)cout << aProcesses[i] << "\t" << buffer << endl;
if (mode==0)cout << aProcesses[i] << "\t" << buffer << endl;
}
}
int AttachToProcess(char* pName)
{
unsigned long aProcesses[1024], cbNeeded, cProcesses;
if(!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
{
cout << "Error browsing the process." << endl;
return 0;
}
cProcesses = cbNeeded / sizeof(unsigned long);
for(unsigned int i = 0; i < cProcesses; i++)
{
if(aProcesses[i] == 0)
continue;
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
char buffer[50];
GetModuleBaseName(hProcess, 0, buffer, 50);
CloseHandle(hProcess);
if(pName == string(buffer))
{
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, aProcesses[i]);
cout << pName << " Opened!" << endl;
return 1;
}
}
cout << "Error opening " << pName << endl;
return 0;
}
void Hack(void* address,int value)
{
WriteProcessMemory(hProcess, address, &value, sizeof(value), NULL);
cout << "[" << address << "] Changed to " << value << endl;
}
int Read(void* address)
{
int value;
ReadProcessMemory(hProcess, address, &value, sizeof(value), NULL);
return value;
}
void* P(int address,int offset)
{
void* new_address=(void*)(Read((void*)address)+offset);
return new_address;
}
|
update to v3, now you can attach ti PID or a Process.
added AttachHelper(); will help you attaching to something
IMPORTANT:
this should compile fine with MSVC++, but if you use DevCpp, so u have to link the libpsapi.a to the project. here is the project with libpsapi linked:
http://ifile.it/t5fdzl4
Have fun!
suggestions welcome!
_________________
"I finally started thinking outside of the box, only to find myself in a larger box."
Last edited by educofu on Fri Jan 14, 2011 4:35 pm; edited 5 times in total |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jan 06, 2011 11:59 am Post subject: |
|
|
what happens if i want to read or write a float ?
|
|
Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Thu Jan 06, 2011 2:28 pm Post subject: |
|
|
Slugsnack wrote: | what happens if i want to read or write a float ? |
or anything else besides 4 bytes?
Do know that this is most of the time uselss, most online games have protection thing which hook these functions, RPM/WPM/Openprocess().
|
|
Back to top |
|
 |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Thu Jan 06, 2011 6:43 pm Post subject: |
|
|
this is something i still need to implement. ( a float > int and inverse)
but by now you must have the array of bytes(4) of the desired float number.
example:
hack(address_f,0x40A00000) 5-float
read(address_f)=0x40A00000
im currently using it to hack simple online games, and it shows to be very versatile
_________________
"I finally started thinking outside of the box, only to find myself in a larger box." |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Jan 06, 2011 6:53 pm Post subject: |
|
|
how about double ?
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8580 Location: 127.0.0.1
|
Posted: Thu Jan 06, 2011 8:43 pm Post subject: |
|
|
There is no error checking if the window fails to open. None of the reading/write functions check if the handle is even set etc. and don't give any information upon failing.
Also avoid system() all together. If you need to pause the console, which you shouldn't anyway since its a console, use something like:
Code: | std::cin.sync();
std::cin.ignore(); |
Or
_________________
- Retired. |
|
Back to top |
|
 |
M.CORP Grandmaster Cheater Supreme
Reputation: 28
Joined: 28 Oct 2009 Posts: 1010
|
Posted: Fri Jan 07, 2011 12:09 am Post subject: |
|
|
Wiccaan wrote: | There is no error checking if the window fails to open. None of the reading/write functions check if the handle is even set etc. and don't give any information upon failing.
Also avoid system() all together. If you need to pause the console, which you shouldn't anyway since its a console, use something like:
Code: | std::cin.sync();
std::cin.ignore(); |
Or
|
Why should we avoid system()?
_________________
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8580 Location: 127.0.0.1
|
|
Back to top |
|
 |
M.CORP Grandmaster Cheater Supreme
Reputation: 28
Joined: 28 Oct 2009 Posts: 1010
|
Posted: Fri Jan 07, 2011 1:14 am Post subject: |
|
|
Wiccaan wrote: | http://www.gidnetwork.com/b-61.html |
K, Thanks...
On Topic:
I also have my own source : but never needed it...
Code: | #include <windows.h>
#include <iostream>
using namespace std;
int main()
{
LONG address = 0x400589C0;//rhog ammo for haloce in bloodgulch
int newvalue = 999; //value to send to game
HWND hwnd;
HANDLE phandle;
DWORD pid;
hwnd = FindWindow(NULL, "Halo"); //what window to find
if (hwnd != 0) {
cout << "HaloCE is running. Press enter to hack it.";//just a option
SetWindowText(NULL,"HaloCE Hack"); //name of program window
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
cin.get();
} else {
cout << "Open HaloCE"; //shows if game is not running
cin.get();
return 0;
}
if (phandle != 0) {
WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);
cout << "Done";//says done if it worked
cin.get();
} else {
cout << "Failed"; //if it didn't work it says failed
cin.get();
}
} |
It's a Halo Combat Evolved trainer that i made ages ago.... Also i got an Alien Shooter Trainer(That does not really work becoz each time i launch it, the addresses change) too...:
Code: |
//Based on my Halo CE trainer....
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
a:
long address = 0x0C314468;//rhog ammo for haloce in bloodgulch
int newvalue = 9999999; //value to send to game
HWND hwnd;
HANDLE phandle;
DWORD pid;
hwnd = FindWindow(NULL, "AlienShooter"); //what window to find
if (hwnd != 0) {
cout << "Alien Shooter. Press enter to hack it.";//just a option
SetWindowText(NULL,"AlienShooter Trainer"); //name of program window
GetWindowThreadProcessId(hwnd, &pid);
phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
cout << "Please select the number of the cheat" << '\n' << " you want to use: " << '\n';
cout << "1) Money Cheat" << '\n';
cout << "2) Armor Cheat"<<'\n';
cout << "3) Health Cheat"<<'\n';
int cheat;
cin >> cheat;
switch(cheat){
case 1:
address = 0x1A2988E0;
break;
case 2:
address = 0x1AD6BB84;
break;
case 3:
address = 0x1AD880A4;
break;
default:
cout << "Please select one of the integers above!" << '\n';
goto a;
break;
}
} else {
cout << "Unable to find AlienShooter.exe!" << '\n' <<"Please launch the game before launching trainer!" << '\n'; //shows if game is not running
cin.get();
return 0;
}
if (phandle != 0) {
WriteProcessMemory(phandle, (LPVOID)address, (LPVOID) &newvalue, 4, 0);
cout << "Done.";//says done if it worked
cin.get();
goto a;
} else {
cout << "Failed!"; //if it didn't work it says failed
cin.get();
}
}
|
_________________
|
|
Back to top |
|
 |
NoMercy Master Cheater
Reputation: 1
Joined: 09 Feb 2009 Posts: 289
|
Posted: Fri Jan 07, 2011 2:49 am Post subject: |
|
|
Why are you coding everything in 1 big function?
I believe FindWindow() + GetWindowThread() is not a very good way, you should use create32toolsnapshot() +next etc. Google knows everything about those.
EDIT:
HWND hwnd;
hwnd = FindWindow()
why not?
HWND hwnd = FindWindow() , or does VC automatically fix this?
same as
i = i+ x
i += x, is just better?
|
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Jan 07, 2011 7:33 am Post subject: |
|
|
There's no difference in both of your examples. It's down to personal preference. At the end. Compiled code will be same. Only difference is that by declaring without initialising you can set the scope yourself.
|
|
Back to top |
|
 |
educofu Expert Cheater
Reputation: 3
Joined: 21 Aug 2009 Posts: 171 Location: Brazil,MG,OP
|
Posted: Fri Jan 07, 2011 10:01 pm Post subject: |
|
|
Wiccaan wrote: | There is no error checking if the window fails to open. None of the reading/write functions check if the handle is even set etc. and don't give any information upon failing.
Also avoid system() all together. If you need to pause the console, which you shouldn't anyway since its a console, use something like:
Code: | std::cin.sync();
std::cin.ignore(); |
Or
|
actually it does check if the windows is sucessfully opened:
Code: | if(!hWindow || !hProcess)cout << "Error opening the process" << endl; |
but it for sure ill be better if i changed the function to return or modify a variable according if it successfully attached to create the main loop.
thanks for the info on system("pause") ^^ going to change that
_________________
"I finally started thinking outside of the box, only to find myself in a larger box." |
|
Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Fri Jan 07, 2011 10:06 pm Post subject: |
|
|
He means to say you call GetWindowThreadProcessId without doing the check for whether the window is actually available.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8580 Location: 127.0.0.1
|
Posted: Fri Jan 07, 2011 11:41 pm Post subject: |
|
|
educofu wrote: | Wiccaan wrote: | There is no error checking if the window fails to open. None of the reading/write functions check if the handle is even set etc. and don't give any information upon failing.
Also avoid system() all together. If you need to pause the console, which you shouldn't anyway since its a console, use something like:
Code: | std::cin.sync();
std::cin.ignore(); |
Or
|
actually it does check if the windows is sucessfully opened:
Code: | if(!hWindow || !hProcess)cout << "Error opening the process" << endl; |
but it for sure ill be better if i changed the function to return or modify a variable according if it successfully attached to create the main loop.
thanks for the info on system("pause") ^^ going to change that |
All you are doing is printing a message, the flow still continues as if the functions never failed.
_________________
- Retired. |
|
Back to top |
|
 |
iPromise Grandmaster Cheater
Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Sat Jan 08, 2011 11:41 pm Post subject: |
|
|
What if my program had no reliable window name? What then?
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|