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 


Finding 4 byte forward value

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

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Mar 05, 2016 10:09 am    Post subject: Finding 4 byte forward value Reply with quote

I'm trying to find a 4 byte value x bytes from a location.
readInteger, may be too small
readQword, is too long
readBytes,4, gives the right bytes but I need the value of those four bytes

So what code will give me the correct value at the forward address?
Back to top
View user's profile Send private message Yahoo Messenger
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sat Mar 05, 2016 10:16 am    Post subject: Reply with quote

How is "readInteger" too small for a 4byte value???
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Mar 05, 2016 10:19 am    Post subject: Reply with quote

The value MAY be larger than an integer.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 05, 2016 10:41 am    Post subject: Reply with quote

You're not making much sense. Explain what bytes you want.
01 02 03 04 05 06 07 08

If you want to convert bytes back into their 4-byte integer:
Code:
local bytes = { 0x01, 0x02, 0x03, 0x04 }
print(byteTableToDword(bytes))
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Mar 05, 2016 10:47 am    Post subject: Reply with quote

Zanzer wrote:
You're not making much sense. Explain what bytes you want.
01 02 03 04 05 06 07 08

That entry is too large only looking for 4 bytes i.e.
72 227 122 02

EDIT:
Code:
local bytes = { 0x01, 0x02, 0x03, 0x04 }
 print(byteTableToDword(bytes))


That would work if the values from readBytes were in the form of 0x01,0x02,0x03,0x04 but the output from readBytes is in the form of
01,02,03,04 as my example above 72 227 122 02


Last edited by bknight2602 on Sat Mar 05, 2016 10:56 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sat Mar 05, 2016 10:50 am    Post subject: Reply with quote

You said you're trying to find a 4byte value (your very first sentence!), so why do you now say that the entry would be larger as 4byte?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 05, 2016 10:54 am    Post subject: Reply with quote

The value you listed is 41608008. Is that all you needed?
Code:
local bytes = { 72, 227, 122, 2 }
print(byteTableToDword(bytes))
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Mar 05, 2016 10:59 am    Post subject: Reply with quote

hhhuut wrote:
You said you're trying to find a 4byte value (your very first sentence!), so why do you now say that the entry would be larger as 4byte?

I never stated the value would be larger than a 4 byte, what I indicated it MAY be larger than an integer, of course it may be smaller than the largest integer value.
For example the value MIGHT be 1000000. This value is larger than an integer but is within a 4 byte value.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 05, 2016 11:01 am    Post subject: Reply with quote

What programming language are you dealing with that 1,000,000 is not an integer? Smile
An integer goes from -2,147,483,648 to 2,147,483,647.
Unless it's unsigned, which goes from 0 to 4,294,967,295.

If the game does not show 1,000,000 correctly, then it's being stored as a 2-byte value, not 4-bytes.
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sat Mar 05, 2016 11:04 am    Post subject: Reply with quote

But an integer (no matter if signed or unsigned) is always four bytes big ...

The only difference is how you handle the returned value ...
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Sat Mar 05, 2016 11:05 am    Post subject: Reply with quote

bknight2602 wrote:
I never stated the value would be larger than a 4 byte, what I indicated it MAY be larger than an integer, of course it may be smaller than the largest integer value.
For example the value MIGHT be 1000000. This value is larger than an integer but is within a 4 byte value.

An integer is 4-bytes long. It's range of values is 0-4,294,967,295 (unsigned), or -2,147,483,648 - 2,147,483,647 (signed). readInteger(address) is what you want.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 586

PostPosted: Sat Mar 05, 2016 11:07 am    Post subject: Reply with quote

Zanzer wrote:
The value you listed is 41608008. Is that all you needed?
Code:
local bytes = { 72, 227, 122, 2 }
print(byteTableToDword(bytes))

Ok, I input
Code:
bytes = byteTableToDword( readBytes(Addr + offset,4) )
print(bytes)

and the output is: 72 227 122 2

EDIT:
Ok guys the readInteger will work, my bad as I was using 65535 as the definition.
Thanks for all the definitions.


Last edited by bknight2602 on Sat Mar 05, 2016 11:14 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 05, 2016 11:10 am    Post subject: Reply with quote

Code:
value = byteTableToDword( readBytes(Addr + offset, 4, true) )
print(value)
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