Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how to make variables in AA script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Fri Apr 10, 2020 9:21 am    Post subject: how to make variables in AA script Reply with quote

Normally in Assembly we do

.data

var db 0

and we can do

add var,5 //not sure about this, forgot assembly xD

I want to do something like this in an AA script

there is a pointer(say [eax+10]) pointing to some value and that value is being written into an xmm0 register through instruction movq xmm0,[eax+10]

now what I want to do is make a copy of the value [eax+10], add (float)5 into it, then write it into xmm0 register, I dont want to make any change in here->[eax+10]

so how I see it, I make a variable, copy [eax+10] value in it, add my value in it, then movq xmm0,var

edit: another question, instead of making a variable, how about copying that value in some other register say ECX(but I dont think it will work or probably I dont know how to store floating points into register xD)
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Fri Apr 10, 2020 3:58 pm    Post subject: Reply with quote

first you should know what is the data type pointed by EAX+10, is it QWORD integer or double precision floating point value or 2-packed single precision floating point value. (it can be a packed DWORD but the upper dword is empty)

because you cant just randomly place whatever data anywhere, you must verify it type then based on that you can figure out how to manipulate it.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Sat Apr 11, 2020 1:02 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
first you should know what is the data type pointed by EAX+10, is it QWORD integer or double precision floating point value or 2-packed single precision floating point value. (it can be a packed DWORD but the upper dword is empty)

because you cant just randomly place whatever data anywhere, you must verify it type then based on that you can figure out how to manipulate it.

eax+10 points to floating values like -294.35645 etc so I guess its single precious floating point value
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sat Apr 11, 2020 6:54 am    Post subject: Reply with quote

Thunder_Bird wrote:
eax+10 points to floating values like -294.35645 etc so I guess its single precious floating point value

you cant guess, single precision and double precision are encoded differently.

but lets assume a pack of two signles:
Code:
newmem:
add dword ptr [eax+10],(float)5.0
{
you should keep in mind, you did not provide enough info
and in case it was a packed SP-FP and the value you are interested in is the upper dword then you must use EAX+14
}

originalcode:
movq xmm0,[eax+10]


just change it directly, there is no need to use variables nor registers.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Sat Apr 11, 2020 10:06 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
Thunder_Bird wrote:
eax+10 points to floating values like -294.35645 etc so I guess its single precious floating point value

you cant guess, single precision and double precision are encoded differently.

but lets assume a pack of two signles:
Code:
newmem:
add dword ptr [eax+10],(float)5.0
{
you should keep in mind, you did not provide enough info
and in case it was a packed SP-FP and the value you are interested in is the upper dword then you must use EAX+14
}

originalcode:
movq xmm0,[eax+10]


just change it directly, there is no need to use variables nor registers.
Bro I did that already what you just wrote, I mentioned I dont want to make any change in [eax+10] I want to copy [eax+10]'s value+5 into XMM without writing anything in eax+10
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sat Apr 11, 2020 10:38 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
Code:
label(myvar)

newmem:

// add dword ptr [eax+10],(float)5.0
{
you should keep in mind, you did not provide enough info
and in case it was a packed SP-FP and the value you are interested in is the upper dword then you must use EAX+14
}

originalcode:
movq xmm0,[eax+10]
movss xmm0,[myvar]
...

myvar:
dd (float)5.0

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Thunder_Bird
Cheater
Reputation: 0

Joined: 27 Apr 2018
Posts: 33
Location: pakistan

PostPosted: Sun Apr 12, 2020 1:51 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
OldCheatEngineUser wrote:
Code:
label(myvar)

newmem:

// add dword ptr [eax+10],(float)5.0
{
you should keep in mind, you did not provide enough info
and in case it was a packed SP-FP and the value you are interested in is the upper dword then you must use EAX+14
}

originalcode:
movq xmm0,[eax+10]
movss xmm0,[myvar]
...

myvar:
dd (float)5.0

it says movss xmm0,[00000000] cant be compiled ^_^, I dont think label(myvar) actually allocates memory or be treated as a variable.
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Sun Apr 12, 2020 4:51 am    Post subject: Reply with quote

1. i accidentally typed movss instead of addss

2. its a valid label and memory location

3. its your fault to just copy and paste without actually letting CE generate the AA script for you and allocate memory for the entire script.

4. remember to change movss to addss

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites