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 


Big Endian Float / Double

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Kuwaga
Newbie cheater
Reputation: 0

Joined: 21 Apr 2012
Posts: 11

PostPosted: Sat Apr 21, 2012 6:04 pm    Post subject: Big Endian Float / Double Reply with quote

How to make a custom type that's Big Endian Float / Double?
How to even make a custom type that's float at all?
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Apr 21, 2012 6:26 pm    Post subject: Reply with quote

Wait for CE6.2 (for now, we have CE6.2Beta6)

then "Value Type" right click, choose "Define new custom type AA". Now you can define your custom type.

Do not forget to use:
Code:

alloc(UsesFloat,4)

UsesFloat:
db 01


Edit:
Big Endian Float - full AA script
Code:
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(UsesFloat,4)

TypeName:
db 'Float Big Endian',0
ByteSize:
dd 4
UsesFloat:
db 01

ConvertRoutine:
[32-bit]
push ebp
mov ebp,esp
mov eax,[ebp+8] //place the address that contains the bytes into eax
mov eax,[eax]   //place the bytes into eax
bswap eax
pop ebp
ret 4
[/32-bit]

[64-bit]
//rcx=address of input
mov eax,[rcx] //eax now contains the bytes 'input' pointed to
bswap eax
ret
[/64-bit]

ConvertBackRoutine:
[32-bit]
push ebp
mov ebp,esp
//[ebp+8]=input
//[ebp+c]=address of output
push eax
push ebx
mov eax,[ebp+8] //load the value into eax
mov ebx,[ebp+c] //load the address into ebx
bswap eax
mov [ebx],eax //write the value into the address
pop ebx
pop eax

pop ebp
ret 8
[/32-bit]

[64-bit]
//ecx=input
//rdx=address of output
bswap ecx
mov [rdx],ecx //place the integer the 4 bytes pointed to by rdx
ret
[/64-bit]






Big Endian Double - full AA script (it's not a perfect conversion)
Code:
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(UsesFloat,4)
alloc(PreferedAlignment,4)
alloc(TEMPVAL,8)

TypeName:
db 'Double Big Endian',0
ByteSize:
dd 08
UsesFloat:
dd 01
PreferedAlignment:
dd 04
TEMPVAL:
dq 00

ConvertRoutine:
[32-bit]
push ebp
mov ebp,esp
//[ebp+8]=input
//example:
mov eax,[ebp+8] //place the address that contains the bytes into eax
mov eax,[eax]
bswap eax
mov [TEMPVAL+4],eax

mov eax,[ebp+8] //place the address that contains the bytes into eax
mov eax,[eax+4]
bswap eax
mov [TEMPVAL],eax

finit
fld qword ptr [TEMPVAL]
fstp dword ptr [TEMPVAL]
mov eax,[TEMPVAL]

pop ebp
ret 4
[/32-bit]

[64-bit]
//rcx=address of input
mov rcx,[rcx] //rcx now contains the bytes 'input' pointed to
bswap rcx
mov [TEMPVAL],rcx

finit
fld qword ptr [TEMPVAL]
fstp dword ptr [TEMPVAL]
mov eax,[TEMPVAL]

ret
[/64-bit]

ConvertBackRoutine:
[32-bit]
push ebp
mov ebp,esp
//[ebp+8]=input
//[ebp+c]=address of output
//example:
push eax
push ebx
mov ebx,[ebp+c] //load the address into ebx

finit
fld dword ptr [ebp+8]
fstp qword ptr [TEMPVAL]

mov eax,[TEMPVAL+4]
bswap eax
mov [ebx],eax //write the value into the address

mov eax,[TEMPVAL]
bswap eax
mov [ebx+4],eax //write the value into the address

pop ebx
pop eax

pop ebp
ret 8
[/32-bit]

[64-bit]
//ecx=input
//rdx=address of output
mov [TEMPVAL],ecx

finit
fld dword ptr [TEMPVAL]
fstp qword ptr [TEMPVAL]

mov rax,[TEMPVAL]
bswap rax

mov [rdx],rax //place the integer the 8 bytes pointed to by rdx
ret
[/64-bit]

_________________


Last edited by mgr.inz.Player on Sun Apr 22, 2012 6:59 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
Kuwaga
Newbie cheater
Reputation: 0

Joined: 21 Apr 2012
Posts: 11

PostPosted: Sat Apr 21, 2012 10:08 pm    Post subject: Reply with quote

Thanks a bunch, worked like a charm!
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Apr 22, 2012 5:08 am    Post subject: Reply with quote

Gr8.

Script for "Big Endian Double", it's not a perfect conversion. It uses FPU to convert from float to double, then I convert double to "bigendian double" by using bswap, "mov dst+4,src" and "mov dst,src+4".

And vice versa.

For example try this value: 1500100900
it should change to 1500100864


So if you want use it for searching addresses, choose "scan type":
"value between", "smaller than" or "bigger than".
For example finding health or stamina address, and you know it is 55.0 do this:
1) scan type: value between
2) left value: 54 right value: 56, do scan
3) loose health, now you have 30.0
4) scan type: value between, left value: 29, right value: 31, do next scan

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25791
Location: The netherlands

PostPosted: Sun Apr 22, 2012 6:28 am    Post subject: Reply with quote

Actually, because floating points are inaccurate all the time, cheat engine never looks for the specific value you've entered

doing an exact value scan for a float type is ALWAYS an inbetween range scan

When searching for 56:
rounded default: Finds all values between 56 and 56.5
rounded extreme: Finds all values between 55.5 and 56.5
rounded truncated: Finds all values between 56 and 56.9999

(Also, your big endian double script terminates ce as soon as an entry with that type is added on 64-bit)

_________________
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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Apr 22, 2012 6:47 am    Post subject: Reply with quote

Dark Byte wrote:
(Also, your big endian double script terminates ce as soon as an entry with that type is added on 64-bit)


Didn't tested it under 64bit. (don't have win7 64bit installed)

Probably I have to handle rcx register with push and pop.:
Quote:
[64-bit]
//rcx=address of input
mov rcx,[rcx] //rcx now contains the bytes 'input' pointed to
bswap rcx
mov [TEMPVAL],rcx


finit
fld qword ptr [TEMPVAL]
fstp dword ptr [TEMPVAL]
mov eax,[TEMPVAL]

ret
[/64-bit]



And rax register here:
Quote:
[64-bit]
//ecx=input
//rdx=address of output
mov [TEMPVAL],ecx

finit
fld dword ptr [TEMPVAL]
fstp qword ptr [TEMPVAL]

mov rax,[TEMPVAL]
bswap rax


mov [rdx],rax //place the integer the 8 bytes pointed to by rdx
ret
[/64-bit]

_________________
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat May 19, 2012 9:05 am    Post subject: Reply with quote

I've just seen this:
revision 1359, "fix fld in 64-bit assembly" . So after that fix, are my "64bit convert routines" good?

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25791
Location: The netherlands

PostPosted: Sat May 19, 2012 9:17 am    Post subject: Reply with quote

perhaps, it's one of he causes for the crash, but havn't tested this yet. The whole floating point unit instruction set isn't recommended in 64-bit , use sse instead
But perhaps it'll work

_________________
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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat May 19, 2012 9:32 am    Post subject: Reply with quote

So,
Code:
cvtss2sd xmm0,qword ptr [TEMPVAL]
movsd dword ptr [TEMPVAL],xmm0


instead
Code:
finit
fld qword ptr [TEMPVAL]
fstp dword ptr [TEMPVAL]

_________________
Back to top
View user's profile Send private message MSN Messenger
theboy181
Advanced Cheater
Reputation: 0

Joined: 26 Jan 2018
Posts: 91

PostPosted: Tue Oct 22, 2019 7:30 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message
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