Page 1 of 1

Getting unexpected value when reading Integer

Posted: Sat Dec 18, 2021 10:30 pm
by naWik
Hello. I wanted to learn more about Lua and Cheat engine so I got a Lua book yesterday and started learning a little on my own.

As a basic first test ever I am simply trying to get the 2 byte value at the address 009188A4 which cheat engine shows as 2400 on the address list but when using ReadSmallInteger I get 1024 instead.

Code: Select all

testaddress = ("[bio4.exe+8388A4]")
value1 = ReadSmallInteger(testaddress)
value2 = ReadInteger(testaddress)
value3 = ReadQword(testaddress)
value4 = ReadFloat(testaddress)
value5 = ReadDouble(testaddress)
value6 = ReadBytes(testaddress)

print("Read Small Integer: ".. value1.."\n","Read Integer: "..value2.."\n","Read Qword: "..value3.."\n","Read Float: ".. value4.."\n","Read Double: "..value5.."\n","Read bytes: ".. value6)
Can someone let me know what I am doing or expecting wrong?

Re: Getting unexpected value when reading Integer

Posted: Sat Dec 18, 2021 11:32 pm
by ShyTwig16
In CE "[ ]" has a special meaning, using "DEADBEEF" as the address CE will look at the acual address "DEADBEEF". But using "[DEEADBEEF]" as the address CE will look at the address stored at "DEEADBEEF" (i.e.: "[DEEADBEEF]" is a pointer with an offset of 0).

Try something like this:

Code: Select all

testaddress = "bio4.exe+8388A4"
value1 = ReadSmallInteger(testaddress)
value2 = ReadInteger(testaddress)
value3 = ReadQword(testaddress)
value4 = ReadFloat(testaddress)
value5 = ReadDouble(testaddress)
value6 = ReadBytes(testaddress, 1)

print("Read Small Integer:", value1)
print("Read Integer:", value2)
print("Read Qword:", value3)
print("Read Float:", value4)
print("Read Double:" value5)
print("Read bytes:", value6)

Re: Getting unexpected value when reading Integer

Posted: Sun Dec 19, 2021 12:13 am
by naWik
Resolved thank you very much. I missed that looking at Wiki cheat engine and didn't pick it up looking at the other LUA threads ><