View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Mar 05, 2016 10:09 am Post subject: Finding 4 byte forward value |
|
|
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 |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Sat Mar 05, 2016 10:16 am Post subject: |
|
|
How is "readInteger" too small for a 4byte value???
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Mar 05, 2016 10:19 am Post subject: |
|
|
The value MAY be larger than an integer.
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 05, 2016 10:41 am Post subject: |
|
|
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 |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Mar 05, 2016 10:47 am Post subject: |
|
|
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 |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Sat Mar 05, 2016 10:50 am Post subject: |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 05, 2016 10:54 am Post subject: |
|
|
The value you listed is 41608008. Is that all you needed?
Code: | local bytes = { 72, 227, 122, 2 }
print(byteTableToDword(bytes)) |
|
|
Back to top |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Mar 05, 2016 10:59 am Post subject: |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 05, 2016 11:01 am Post subject: |
|
|
What programming language are you dealing with that 1,000,000 is not an integer?
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 |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Sat Mar 05, 2016 11:04 am Post subject: |
|
|
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 |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4703
|
Posted: Sat Mar 05, 2016 11:05 am Post subject: |
|
|
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 |
|
 |
bknight2602 Grandmaster Cheater
Reputation: 0
Joined: 08 Oct 2012 Posts: 586
|
Posted: Sat Mar 05, 2016 11:07 am Post subject: |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 05, 2016 11:10 am Post subject: |
|
|
Code: | value = byteTableToDword( readBytes(Addr + offset, 4, true) )
print(value) |
|
|
Back to top |
|
 |
|