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 


Cheat Engine Forum Index
PostGo back to topic
mgr.inz.Player
I post too much
Reputation: 218
Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Jul 24, 2012 4:43 am    Post subject: Re: Need help: Create new custom data type

@Csimbi
I made something similar, for structure with floats. I think I can adapt it to doubles.

Stay tuned (approx. few hours).

Edit:

here:
Code:
alloc(TypeName,256)

alloc(ByteSize,4)
alloc(UsesFloat,4)
alloc(PreferedAlignment,4)

alloc(ConvertRoutine,1024)

label(SKIP)

TypeName:
db 'CustomType_for_Csimbi',0

ByteSize:
dd (int)40 // struct has 40 bytes
UsesFloat:
db 01
PreferedAlignment:
db 04

//double dValue;                                        //0x00
//double dKey1;                                         //0x08
//double dKey2;                                         //0x10
//double dChecksum;  // Irrelevant                      //0x18
//double dZero;      // 0 or 1; 0: valid, 1:invalid     //0x20

//dSearchVal = dKey1 - dKey2 + dValue;

define(dValue ,eax+00)
define(dKey1  ,eax+08)
define(dKey2  ,eax+10)
define(dZero_1,eax+20)
define(dZero_2,eax+24)

ConvertRoutine:
push ebp
mov ebp,esp
mov eax,[ebp+8] //place the address that contains the bytes into eax

cmp dword ptr [dZero_1],0
jne SKIP
cmp dword ptr [dZero_2],0
jne SKIP

finit

push eax
fld qword ptr [dKey1]
fadd qword ptr [dValue]
fsub qword ptr [dKey2]
fstp dword ptr [esp]  // store and convert to float
pop eax

//(I used qword three times because values are "double". I used dword at the end because UsesFloat is used)


pop ebp
ret 4

SKIP:
mov eax,7fffffff    // gives NaN, CE will skip it
pop ebp
ret 4



I tested it with this

Code:
[ENABLE]
globalalloc(testing,2048)

testing:
dq (double)123.0
dq (double)50.0
dq (double)40.0
dq (double)44
dq (double)1.0

dq (double)123.0
dq (double)50.0
dq (double)40.0
dq (double)44
dq (double)0.0

[DISABLE]
dealloc(testing)


Searching for value 133.0

results:
It finds second structure at "testing+28",
structure at "testing+00" is skipped.
_________________
Dark Souls II Item Swap and Item List
My Borderlands2 tables

Recent CheatEngine builds
Back to top
View user's profile Send private message MSN Messenger
Post reviews:   Approve 3
Author Review
Dark Byte
Review: Approve
Post reference:
ReviewPosted: Tue Jul 24, 2012 7:15 am

finally a good example/use for define
Back to top
View user's profile Send private message MSN Messenger
Csimbi
Review: Approve
Post reference:
ReviewPosted: Wed Jul 25, 2012 4:19 pm

I could not have possibly figured this out on my own.
Greatly appreciated!

Back to top
View user's profile Send private message
ByTransient
Review: Approve
Post reference:
ReviewPosted: Wed Mar 10, 2021 6:37 am

Thanks
Back to top
View user's profile Send private message
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites