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 


Display an integer value as signed.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Mon May 25, 2015 9:11 pm    Post subject: Display an integer value as signed. Reply with quote

So this seems like it should be easy but I can't figure it out what function or argument to use if I want the output of readInteger() to be displayed as signed.
_________________
Back to top
View user's profile Send private message
sir-gunny
Advanced Cheater
Reputation: 0

Joined: 15 Mar 2012
Posts: 80

PostPosted: Tue May 26, 2015 4:41 am    Post subject: Reply with quote

Correct me if i'm wrong but I think readInteger() return always signed (signed = −2.147.483.648 to 2.147.483.647)?!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue May 26, 2015 5:49 am    Post subject: Reply with quote

That's something that needs to be decided

in 6.4 readInteger() will read ff ff ff ff as -1 (ffffffffffffffff)
But in 6.5 readInteger will read ff ff ff ff as 4294967295 (00000000ffffffff)

So, should it get sign extended or not ?


(That is was sign extended was a bug that got fixed here: https://github.com/cheat-engine/cheat-engine/commit/97d65da53614c70c33736169f33c2ae7e21072de ) but not sure if people actually used this unwanted sign extension

_________________
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
Rydian
Grandmaster Cheater Supreme
Reputation: 31

Joined: 17 Sep 2012
Posts: 1358

PostPosted: Tue May 26, 2015 7:31 am    Post subject: Reply with quote

Oh, it currently does. I guess was judging based on the default for the table list or something.

Default unsigned, optional argument for signed?

_________________
Back to top
View user's profile Send private message
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 May 26, 2015 9:57 am    Post subject: Reply with quote

readInteger in CE64 is bugged (as DB mentioned it). It already reads values as signed, 32bit value is sign-extended into 64bit.

In CE6.5 (from current SVN), 32bit value is zero-extended into 64bit.


I prefer zero-extend to 64bit, because...



...we can always convert from unsigned to signed (check readIntegerSigned function):
Code:
//fix readInteger in CE6.4. We want values from 0-ffffffff to be positive.
if oldRI==nil then oldRI=readInteger end
function readInteger(addr)
  local val=oldRI(addr)
  return val~=nil and val%0x100000000 or nil
end



// to read values as signed
function readIntegerSigned(addr)
  local val=readInteger(addr)
  local sign=bAnd(val,0x80000000)
  return sign==0 and val or val-0x100000000
end





// set at address 400514 some values to test functions below

print('unsigned\t\t',     readInteger'400514')
print('signed\t\t',       readIntegerSigned'400514')

_________________
Back to top
View user's profile Send private message MSN Messenger
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