How could I know where the variables in a certain opcode come from?

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
wannaknow
Novice Cheater
Novice Cheater
Posts: 16
Joined: Thu Mar 17, 2022 7:31 am
Reputation: 0

How could I know where the variables in a certain opcode come from?

Post by wannaknow »

I was reading the script for Inf.health(or Godmode whatever) of a certain game.

the principle of Inf.health script for that game was like below:

1. get a value of the variable that saves or manages the health of the player.
2. compare the value with another value of a variable at the address in health subtraction function part.
3. if the values of the variables are the same, make it skip the health subtraction function
4. so the result is that player's health is not subtracted and the monsters' health is normally subtracted.

My question is, how could the writer of that script trace the variables?

The location of the address of player's health information was not near that of the health subtraction function part.

I think he could trace the variables and I wanna know that.

Let's simply say the opcode of health subtraction function was "sub edi,(int)100"
and let's say the edi was saving player's health at the moment.
So I want to know where that edi comes from so that I could know where the player's health is managed.

Is it possible to trace?

And one more thing, if there's some kind of variables like edi,rax,eax or whatever, those variables indicate the same thing? from 000000 to FFFFFFF?
For example, the rax in 0000ABC is the same rax in 512ABC3?

Pre-thanks to all replies!

User avatar
Marc
Table Makers
Table Makers
Posts: 378
Joined: Mon Mar 26, 2018 2:35 pm
Reputation: 377

Re: How could I know where the variables in a certain opcode come from?

Post by Marc »

First of all: I'd really recommend starting with
a) the inbuild tutorial of cheat engine
b) the [Link] and 200 on youtube.
c) for more extensive teaching on the methods, take a look at [Link].

This would push you much forward and especially clear a lot of questions up in front :)
My question is, how could the writer of that script trace the variables?
Usual way is to find the current value in memory with the search function of cheat engine, add it to the address list, mark it and press F6. At the next time the game writes to the found address, Cheat Engine will show you the code place(s) which are writing to the found address.
The location of the address of player's health information was not near that of the health subtraction function part.
That's quite normal. Data and code are rarely next to each other, on the contrary.
So I want to know where that edi comes from so that I could know where the player's health is managed.
Depending on the game, the found code is already specific to the player, then you're done.
Or it is a generic code, which would for example calculcate the damage to player, enemies and buildings alike. In that case, you need to either find a way to differ between player and the rest or trace back to the code which calls the writing code.
For example, the rax in 0000ABC is the same rax in 512ABC3?
Yep, the CPU has several registers and they are unique. Which is sometimes handy, sometimes annyoing.

good luck,
Marc

wannaknow
Novice Cheater
Novice Cheater
Posts: 16
Joined: Thu Mar 17, 2022 7:31 am
Reputation: 0

Re: How could I know where the variables in a certain opcode come from?

Post by wannaknow »

Or it is a generic code, which would for example calculcate the damage to player, enemies and buildings alike. In that case, you need to either find a way to differ between player and the rest or trace back to the code which calls the writing code.
Yes. I also think it's easy with codes specific to the player only, but it was a generic code so that i need to know how to differ between player and the rest as you said.
I wanted detailed explanation about that "how to differ"

Anyway the link you gave me seems really helpful to learn of it

Thanks so much!!

jgoemat
Table Makers
Table Makers
Posts: 66
Joined: Fri Jul 21, 2017 6:47 pm
Reputation: 68

Re: How could I know where the variables in a certain opcode come from?

Post by jgoemat »

For cases like that you generally have to find something that *is* specific to the player, then store the player pointer and do the compare. For instance if you find player health and 'Find out what accesses this address', you might find a few places in code that loads it each frame. One of those might be called to load the player's health for displaying in the HUD. If you can find a spot like that which is only for the player, you can store the pointer for that. Another code might be called when damage is taken, but for player and enemies. If you compare that pointer to the player pointer you've stored, you can zero the damage for the player and make the damage huge for a one-hit-kill cheat at the same time.

Post Reply

Who is online

Users browsing this forum: No registered users