View previous topic :: View next topic |
Author |
Message |
Rydian Grandmaster Cheater Supreme Reputation: 31
Joined: 17 Sep 2012 Posts: 1358
|
Posted: Mon May 25, 2015 9:11 pm Post subject: Display an integer value as signed. |
|
|
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 |
|
|
sir-gunny Advanced Cheater Reputation: 0
Joined: 15 Mar 2012 Posts: 80
|
Posted: Tue May 26, 2015 4:41 am Post subject: |
|
|
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 |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Tue May 26, 2015 5:49 am Post subject: |
|
|
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 |
|
|
Rydian Grandmaster Cheater Supreme Reputation: 31
Joined: 17 Sep 2012 Posts: 1358
|
Posted: Tue May 26, 2015 7:31 am Post subject: |
|
|
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 |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue May 26, 2015 9:57 am Post subject: |
|
|
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 |
|
|
|