Tutorial Cheat Engine Visual Value vs. Real Value

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Syntax Error

Coder
Silenced
Meme Tier VIP
Nov 6, 2014
239
2,928
6
So I was making a simple "game" to practice hacking. I made it with the specific intent to be hacked and there's no winning otherwise. I learned a lot by making it and I thought I'd share my experience. Most of you probably knew this but it was a totally mind blowing experience for me. I would always get frustrated when looking for offsets in cheat engine because I would find the "visual" address and become baffled as to why it wouldn't change anything. I had read peoples comment's saying it's just a visual representation of something but I never really understood what they meant or how it worked. My mind set was "if it looks like a duck and it quacks like a duck, then it must be a duck"... I'll get back to this at the end of my little story. Originally this game just had a global variable that stored health. Nothing special but then I got the crazy idea of hey, why don't a I make a pointer to it and that way it wouldn't be so easy to find in cheat engine.

gHealth = 100;
*pHealth = &gHealth;

At the time I thought the pointer would somehow mask the global variable until I read what writes to the address of the pointer. So I fired up cheat engine and searched for 100 hoping only to find the pointer. :/ Nope. They're both just chillin there... mocking me. So then I think to myself, if they're both coming out when I enter in 100. Why don't I set the global one to -100. Ha, I felt so clever. The feeling was short lived as I contemplated the rest of the code.. If pHealth is pointing to gHealth... then... that would mean.. DAMN IT they're both -100. Not to be outdone, I decided I would set *pHealth = gHealth + 200. Ran the code and it broke down. gHealth + 200 isn't a memory address. Go figure. So I changed pHealth to a regular int and I ran the code. This still broke down because I wasn't updating pHealth in the loop. It had just been initialized at the start of the function. Once I fixed that I was pretty happy with myself. I fire up cheat engine and look for 100. It came up and no static address in sight. :D Could this really be it? Did I finally accomplish my quest? I lower my health and sure enough pHealth changes with it. So I double click it and change it value and I'm about to burst with excitement. I lower my health again and WTF!!! Changing pHealths value didn't do shit!!! Finally, I realized what was happening. IT WAS JUST A VISUAL REPRESENTATION OF MY HEALTH and it wasn't actually modifying my real health which i had masked!! Well, I failed my original goal to make a pointer but needless to say, I understand memory/ cheat engine/ and how my computer works a little better. I'm not really sure if this qualifies under the discussion category but I couldn't really think of a better place for this. I felt that it was worth sharing though.

The source
C++:
/*
	A game that's meant to be hacked in order to win.
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>

void death(void);
void battle(int damage);
void win(void);

int playerHealth = -100; /* Static Health Address */

int main(void)
{
	int monsterLevel; /* Store the amount of damage the player will take. */
	int pHealth; /* The Visual address of health*/

	pHealth = playerHealth + 200; 

	srand(time); /* Seed random numbers else rand() == same everytime.*/

	/* Infinite loop*/
	while(1){
		printf("You have %d health.\n", pHealth);

		monsterLevel = (rand() % 5) + 1; /* Random number between 1 & 5 */

		printf("You've stumbled upon a level %d monster!\n", monsterLevel);
		printf("You are about to go into battle.\n\n\n");
		system("PAUSE");

		battle(monsterLevel); /* Player loses health */
		pHealth = playerHealth + 200; /* Update pHealth */

		/* 1. Is pHealth less than or equal to 0? */
		if (pHealth <= 0){
			death();
			system("PAUSE");
			break;
		} /* 2. Is pHealth greater than or equal to 150? */
		else if (pHealth >= 150){
			win();
			system("PAUSE");
			break;
		}

		/* Continue the looping if questions 1 and 2 are false. */
		Sleep(200);
		system("CLS");
	}

	return 0;
}

void battle(int damage)
{
	playerHealth -= damage;
}

/* Called when health goes below 1.*/
void death(void)
{	
	printf("\n\n\aYou have succumbed to death.\n");
	printf("Your health: %d\n\n", playerHealth + 200);
}

/* Called when player hacks the game into giving him more than 149 health. */
void win(void)
{
	printf("\n\n\aYou have beat the game!\n");
	printf("Your health: %d\n\n", playerHealth + 200);
}
 

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
Love posts like these! :D This is what really helps people to actually understand rather than just accept it for a norm. :) Nice work. :)
 

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
Love posts like these! :D This is what really helps people to actually understand rather than just accept it for a norm. :) Nice work. :)
This only works if these threads get marked somehow, so a reader browsing this section can see instantly that this was a good post.
As it is now this thread will be burried between other (probably useless) threads in a few weeks.
 

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
This only works if these threads get marked somehow, so a reader browsing this section can see instantly that this was a good post.
As it is now this thread will be burried between other (probably useless) threads in a few weeks.
Agreed, post is now stickied! :)
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods