|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Goat Engine Cheater Reputation: 0
Joined: 13 Aug 2018 Posts: 44
|
Posted: Mon Jan 06, 2020 9:24 pm Post subject: Plain English example/explanation for variables in AA? |
|
|
In my coding experience, I've always had an easy time understanding variables. For some reason with CE Auto Assembler scripts, I am lost.
How would I write this in CE language?
Code: | 1.Create a new, empty variable named "777"
2.Move the value of a register into the 777 variable
3.Move the value of 777 into another register
4.And lastly, my expectation is that the variable does not need to be unassigned at the end as it would only be valid inside that AA script anyway, correct? |
Side note - When I search for how CE variables work, I find nothing that even comes close to explaining the above and I'm struggling a lot with this because in the past I've been able to learn HTML, PHP, CSS, BASH, AHK and other forms of coding simply by searching for what I'm wondering. I have the coding mindset, but something here just isn't clicking. Does anyone have any insight as to why that doesn't seem to be the case with CE and Auto Assembly scripts? What wording should I have used in my search to find what I'm asking earlier in the post on my own?
Thanks for any and all help you guys can give!
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4293
|
Posted: Mon Jan 06, 2020 10:59 pm Post subject: |
|
|
Most languages can't deal with names beginning with a number. I doubt CE AA is able to, so I'm going to disregard the name "777" and use "foo" instead.
Code: | alloc(foo,4)
foo:
dd 4 |
The first line allocates 4 byte of memory somewhere and defines the name "foo" to represent the first address in that memory.
The second, "foo:", declares where you want to do something. The text to the left of the colon is an address. Every instruction or pseudoinstruction that follows is written sequentially beginning at this address.
The last, "dd", stands for "define doubleword(s)." A doubleword is some integer that takes up 4 bytes of space. There's also dq for quadwords (8 bytes), dw for words (2 bytes), and db for bytes (1 byte; also used for strings). Multiple integers can be specified separated by spaces and will be written sequentially in memory - e.g., defining arrays.
You can also add "registersymbol(foo)" somewhere to use the name "foo" outside the script- e.g., in the address list. I'd put it near the top after the allocs and before any code for readability.
The variable can also be placed in a bigger block that has other stuff in it if you want. This makes locality to other allocs unambiguous (search for "RIP-relative addressing"). I don't know if two allocs just after each other will always be placed together, but DB said it's fine (source thread).
Most people, including myself, learn how to do this by reading other people's scripts, copying what they do, and observing what happens. Come up with a hypothesis, test it, observe, and repeat until you understand what something does. Eventually, you may need to consult CE's source code on github to find some answers.
There are also other resources that have been getting more comprehensive over time: the CE wiki, youtube videos, other online guides...
For x86/x64 in particular, the only resource I can recommend in good faith is Intel's and/or AMD's Developer's guides/manuals. They aren't for beginners, but everything else I've looked at has deficiencies in correctness to varying degrees. I haven't looked that hard, and even if something is partially wrong, you can still learn from it.
Those languages you listed are pretty high-level. They aren't close to what AA is. Perhaps you should try learning something like C or C++, but you can get by without it.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Goat Engine Cheater Reputation: 0
Joined: 13 Aug 2018 Posts: 44
|
Posted: Tue Jan 07, 2020 2:48 am Post subject: |
|
|
Thank you for the detailed response. It's almost making sense but why is there another 4 after your dd if you already allocated 4 bytes to it in your first line? What's that second 4 doing? Where you put that 4 is where I would have assumed a 4 byte value would be written instead, but I guess not?
alloc(foo,4)
foo:
dd 12345678
Is what I would have thought would make "foo" contain 12345678, so then later somewhere in my script I'd be able to use something like: mov eax, foo ?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25288 Location: The netherlands
|
Posted: Tue Jan 07, 2020 3:21 am Post subject: |
|
|
writes the value 0x00000004 at the address specified by foo
writes the value 0x12345678 at the address specified by foo
you can access this later by doing
which will then load the 4 byte value stored at foo into eax
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Csimbi I post too much Reputation: 94
Joined: 14 Jul 2007 Posts: 3110
|
Posted: Tue Jan 07, 2020 9:27 am Post subject: Re: Plain English example/explanation for variables in AA? |
|
|
Goat Engine wrote: | In my coding experience, I've always had an easy time understanding variables. For some reason with CE Auto Assembler scripts, I am lost.
How would I write this in CE language?
Code: | 1.Create a new, empty variable named "777"
2.Move the value of a register into the 777 variable
3.Move the value of 777 into another register
4.And lastly, my expectation is that the variable does not need to be unassigned at the end as it would only be valid inside that AA script anyway, correct? |
Side note - When I search for how CE variables work, I find nothing that even comes close to explaining the above and I'm struggling a lot with this because in the past I've been able to learn HTML, PHP, CSS, BASH, AHK and other forms of coding simply by searching for what I'm wondering. I have the coding mindset, but something here just isn't clicking. Does anyone have any insight as to why that doesn't seem to be the case with CE and Auto Assembly scripts? What wording should I have used in my search to find what I'm asking earlier in the post on my own?
Thanks for any and all help you guys can give! |
CE AA is based on ASM, which is a low level language - almost the lowest.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4293
|
Posted: Tue Jan 07, 2020 10:14 am Post subject: |
|
|
The 4 in "dd 4" is my bad- it should've been 309 (0x309 = 777; hexadecimal vs. decimal).
"mov eax,foo" would move the address foo was defined to be into eax, which probably isn't what you want. Use square brackets to read the value at an address as DB shows.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Goat Engine Cheater Reputation: 0
Joined: 13 Aug 2018 Posts: 44
|
Posted: Fri Jan 10, 2020 12:36 pm Post subject: |
|
|
Thank you again, guys! Definitely a huge help!
Also...
ParkourPenguin wrote: | "mov eax,foo" would move the address foo was defined to be into eax, which probably isn't what you want. |
In that particular case for what I was doing, it actually was what I wanted.
|
|
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
|
|