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 


registerCustomTypeLua with QWord read/write wrong values

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 77

PostPosted: Mon May 23, 2022 7:03 am    Post subject: registerCustomTypeLua with QWord read/write wrong values Reply with quote

Code:
function Money_bytestovalue(b1,b2,b3,b4,b5,b6,b7,b8,address)
 local iMoney = byteTableToQword({b1,b2,b3,b4,b5,b6,b7,b8})/1000
 return iMoney
end

function Money_valuetobytes(i,address)
 local bBytes = qwordToByteTable(i*1000)
 return bBytes[1],bBytes[2],bBytes[3],bBytes[4],bBytes[5],bBytes[6],bBytes[7],bBytes[8]
end

function MyCustomType()
 local typename = "Money"
 local bytecount = 8
 local isFloat = false
 registerCustomTypeLua(typename, bytecount, Money_bytestovalue, Money_valuetobytes, isFloat)
end


Hi.

At high values displays this function wrong values.

Example:
I enter 4800000000, the func should convert it to 4800000000000 and write it to memory (00 80 4B 96 5D 04 00 00).
But currently, if i enter 4800000000 the memrec shows 505032704 and write to memory 505032704000 (00 80 4B 96 75 00 00 00)

If i enter 480000000 there are no problems.

What i'm doing wrong?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Mon May 23, 2022 10:29 am    Post subject: Reply with quote

input is only in 32-bit
4800000000 is 11E1A3000 so that won't fit (will be 1E1A3000 so 505032704)

if you change the formula to do *10000 you can get a correct result with the value 480000000

you can of course device other ways to input higher bit values, like if it's 480000000 it's *1000 and if it's 480000001 it's *10000 after stripping the 1, and 480000002 it'd be *100000 (after stripping the 2)
just requires a bit more thought

_________________
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
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 77

PostPosted: Tue May 24, 2022 7:07 am    Post subject: Reply with quote

Thanks Smile

I change the formula to 1000000 (MoneyInK).

Is it possible to implement a 64-Bit input in future updates? By the way, is it posible to implement string-support to display/format values as date, time or money (e.g. 1.234.567 €)?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue May 24, 2022 8:53 am    Post subject: Reply with quote

Typing in 64-bit values is kinda silly for custom types (the reason for custom types is to get human readable values from chaotic data).

But I will add float support to lua custom type so you can enter 4800000000 which then gets converted to a float (e.g 4.8E9) and then if you do 4.8E9 * 1000 it turns into 4.8E12 (4800000000000)
and then instead of converting the float to a float in memory you can convert the float to a 64-bit integer bytetable and write that. (you'll have to do the converting of fpu to integer based bytes yourself, or math.floor)


as for strings, I can add that I guess, but you will be responsible for converting the value to a string. And likely there will be a string limit

_________________
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
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 77

PostPosted: Thu May 26, 2022 2:51 am    Post subject: Reply with quote

Stupid question: does the exponent convert only the 0 (4.8E9) or convert it e.g. 4812123123 to 4.812123123E9?

@strings:
Yes, converting the value to a string and back ist not the problem. Displaying the value in a way that I can easily edit it. Currently i convert a int datevalue (e.g. 245233 = 07.11.2022) to a hex-string like "07112022" (DDMMYYYY) and return the integer of it. After that I only have to select the option "show as Hex". This works for date but not for time or everything else. I hope you understand me with my bad english Embarassed .

And BIG THX for support!! Smile
Back to top
View user's profile Send private message
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 77

PostPosted: Sun Apr 30, 2023 1:47 am    Post subject: Reply with quote

Hi.

At the current version of CE you added string based custom types. How can i use it? Is there a new parameter like isString or so? At the Wiki i cant found anything.
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 Lua Scripting 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