Gerome wrote:
Code:
p := 1000
r := NumGet(p)
msgbox %p%, %r% ; ==> 1000, 808464433
and
jimD wrote:
Code:
hex dump of p (a normal AHK variable, stored as an ASCII STRING)
0000: 31 30 30 30 | 00 00 00 00 | - 1000....
0x31 = 1 0x30 = 0 0x30 = 0 0x30 = 0
hex dump of var (1000 stored as a BINARY value by the use of numput)
0000: E8 03 00 00 | 00 00 00 00 | - è.......
0x03E8 = 1000
Bienvenue, Gérôme. I am absolutely positive, that you will buy into a statement that it took me nearly two months to go figure out the answer. De toute façon you can tell that the other gentlemen don't have a
handle on this topic either. They have come to learn what works just like you will.
First and foremost, the Intel processor architecture is little-endian. Meaning that in a memory block it is the leftmost number that is multiplied with 2 raised to the power of zero.
Now, jimD used a memory scanner and posted an output fragment in abbreviated form. Taking his hint that AHK variables are of type str, one searches for those 4 =strlen(p) adjacent bytes in memory. A p-ointer stores the memory address at which this data is to be found at its own memory address. This is the
Pointertoa
Pointer
Variable argument in VTable().
Here comes the crux. You casted what is meant to be a str as an int by calling numGet(). Thereby you have the computer calculate 30 30 30 31 as a decimal. He does it by summing 16^(8-pos) *(# @the pos), i.e.
3 x 16^7 +
0 x 16^6 +
3 x 16^5 +
0 x 16^4 +
3 x 16^3 +
0 x 16^2 +
3 x 16^1 +
1 x 16^0.
Do the math or enter 30303031 in the hexadecimal field
here. You could have instructed numGet to fetch a short: numGet(p, 0, "short") and it would have taken the first two bytes from the left and casted them as a decimal. The result is? Going down this path the solution offers itself as
Code:
loop % strlen(p)
Msgbox % str.=a_space char := chr(numGet(p, a_index-1, "char"))
Had you tried p = 10009, why would the outcome of a call to numGet() have been no different from 808,464,433? Because an int ends after
32 bits.
Gentlemen, drop the secrecy, take to empowering those people.