 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
CodyOebel How do I cheat?
Reputation: 0
Joined: 22 Nov 2009 Posts: 3
|
Posted: Sun May 08, 2011 10:45 am Post subject: A few c++ questions. |
|
|
Ok.. heres what I am trying to do.
In the game I am attemping to develop a hack for which is an MMORPG game. The game has a day\night pallette shift of colors. In attempt to make it so that whether I am in caves or outside and it's night time in the game I want it to always be daylight. Or "Light Hack" the game.
Using cheat engine I can use a torch in the game to turn light on and off and narrow down to a few addresses.
I double click an address, then in the bottom list box I right click the entry and select 'Find out what
writes to this address'. A new window will open, I then right click the top line that starts with 'mov' and
select 'Replace with code that does nothing'.
Then the lighthack is acheived. However I am a novice programmer and am diving into windows API and getting a bit better with pointers etc.. and I am trying to figure out how I could I acheive this with c++ code alone for the custom application I am developing to share with others once finished?
Daylight is always an increasing value, and nighttime or darkness is decreasing. So my program without me manually finding the addresses will need to accomplish this task without my intervention in attempt to share my program with others who know less than myself.
-------SECOND PROBLEM AND QUESTION-----------------------
Using windows handles etc... and ReadProcessMemory() after locating the address where my characters hitpoints is located in memory I can use that address and read it's value using basic winAPI functions.
for example:
| Code: |
/*
The code below with the HEALTH variable manually declared to the address found using cheat engine allows this program to now read the hit points value of the in game character.
*/
//memory addresses
/*
DWORD HEALTH = 0x012E1B7C; //<-- I got this addy manually using CE
int main(int argc, char *argv[])
{
int x;
unsigned long IDHealth;
HWND hwndDC = FindWindow(0,"My Online RPG");
// Better use ClassName
GetWindowThreadProcessId(hwndDC, &IDHealth);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, IDHealth); PROCESS_ALL_ACCESS
// Another parameter to process is PROCESS_VM_READ
// I think PROCESS_VM_READ is enough
ReadProcessMemory(hProcess, (LPVOID)PLAYER_X, &x, 4, NULL);
.
std::cout<< x << "\n";
return 0;
}
|
The problem is DMA. When I kill the games client window. Then re-launch the game. The executable in tech talk I beleive allocates a new heap of memory? So without visiting this forum for such fine brains to help me. I am figuring I have to get a base address maybe? Kind of like a grid or when you slap a program in a hex editor and look at it's makeup. I'm assuming here, but my way of thinking from what I did research I would have to do this??
1. Locate the address to the hit points value using CE.
2. Make a program to do a count from the base address until it locates the address I am interested in. With this "Counter var" I would then use that value as my way of always locating that address whenever the client.exe gets re-launched???? Kind of like a memory coordinates system????
I'm not sure if thats the approach and thats why I am asking for help here.
Again I am guessing here and trying to make some logical thought, but maybe there is an easier way. Any help, sample code, etcetra would be highly appreciated. I am just now diving into data shoveling so forgive my ignorance I am trying to my best, but need a greater more experienced programmer to help clear things up.
Does Cheat Engine have any automated output of C code when I perform a task ?? E.g Code generator, or application builder which outputs a .exe to perform the same routine task such as this light hack routine I manually do, but will do this each time the application is launched? I know I know it's avoiding code which is the best educational route for me, but wouldnt hurt to get this going for my users fast as possible.
Thanks,
-COEBEL
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Sun May 08, 2011 1:16 pm Post subject: |
|
|
Your first question is asking how to modify code. Code addresses usually should not change. Your code address is best represented as : module_base_address + offset. eg. explorer.exe + 0x10C4 or something.
If injecting a DLL you can:
- Use GetModuleHandle() to get the base address
- Add your offset
- Use VirtualProtect/Ex() to change protections so the page containing the memory you are interested in modifying is writable
- Write your NOPs ( 0x90 )
- Use VirtualProtect/Ex() to restore the original protections
If working from an external executable:
- Get PID with whatever method, EnumProcesses()/FindWindow()/GetWindowThreadProcessId()/CreateToolhelp32Snapshot()/Process32First/Next(), etc.
- Use CreateToolhelp32Snapshot() and Module32First/Next() to get a handle to the base address
- Add offset
- Use VirtualProtectEx() to change protections as above
- Use WriteProcessMemory() to write NOPs
- Use VirtualProtectEx() to restore protections
For your point on dynamic memory allocation, yes you pretty much have it. How it works is the game allocates a new block of memory. The pointer to the start of this new block ( base address ) is then saved somewhere. Let us call the location where it is saved as X. Somewhere along the new block, in the middle maybe there is the address we are interested in. Each time the game restarts X has a different value because when the memory is allocated, it can be allocated anywhere by the OS. However, how far along the address is into the new block is fixed. Also the LOCATION of X is fixed.
To reiterate, X holds the same address but a different value. Things can keep going down several levels like this ( eg. X is also a piece of memory inside another allocated block ), in which case you have a multilevel pointer. Essentially, the address of X is our pointer. And then how far we are into the middle is the offset from the base address.
Hence to get the address we are interested in dynamically we would dereference X giving us the base address. Then you add your offset. You should do the CheatEngine tutorial. It includes this sorta stuff.
For 'code generation', CE has a trainer maker which you could use.
|
|
| Back to top |
|
 |
CodyOebel How do I cheat?
Reputation: 0
Joined: 22 Nov 2009 Posts: 3
|
Posted: Wed May 11, 2011 7:52 am Post subject: THANKS A LOTTTTTT |
|
|
SlugSnacK,
Man thanks for the time you took to write that for me.
I copied it to my email so I dont forget the psuedo ever, but this is EXACTLY what I was looking for. At first you were explaining DLL injection, and I was over whelmed a bit, but focussed in that I thought I was going to start data shoveling in some complex fashion, but then understood you were regarding DLL injection using Cheat Engine.
Then you shined the light on exactly what I am wanting to do in that I am doing this from an external.exe, and pasted its directions out for me on a platter. Almost short of giving me source . I will go about learning, and may inquire you if you dont mind should I run into a problem that I cannot seek out after much frustration.
Second Question: I have done the tutorial program with CE, but if the Trainer you are talking about is what I am hoping it is then it is just what I need. Could you please explain to me what the trainer is? I will look for this myself, but I like your style of assistance in that you are thorough, and know how to generate a curiosity that will have me accomplishing this task much easier. This is said, that you are simply crafted, and I once again appreciate the time you took to write that up for me.
-Cody
|
|
| 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
|
|