|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
jgrochoski How do I cheat? Reputation: 0
Joined: 04 Nov 2009 Posts: 9
|
Posted: Tue Mar 04, 2014 7:38 pm Post subject: Byte Reading Error/Mistake |
|
|
I'm now trying to rewrite my table as a LUA script and I'm getting weird results with readBytes. When I look in the memory viewer the memory block I'm looking at says 2C CB F3 00 but when I readBytes that I get back 112, 135, 105, 0 or 0x70, 0x87, 0x69, 0x00
Here is the entire LUA - it's a bit messy because I've been trying stuff out but I'm stuck. I did comment the error location with "-->READBYTES ERROR HERE" to make it a little easier to find. Note that I'm not getting an error in the script; it just isn't functioning the way I expect it to.
Code: | function GetDesc(index)
return lookupTable[index]
end
function DEC_HEX(IN)
if IN<=0 then
return '0'
end
local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
while IN>0 do
I=I+1
IN,D=math.floor(IN/B),math.mod(IN,B)+1
OUT=string.sub(K,D,D)..OUT
end
return OUT
end
function HexDumpBytes(IN)
for _,String in pairs(IN) do --> for each entry and entry in the table IN do..
local Hex = DEC_HEX(String) --> convert each byte and byte that stored in the IN Table
if Hex:len()==1 then
Hex = '0' .. Hex --> Just incase, making the bytes 2 character length
end
IN[_] = '0x' .. Hex --> Making it writeable
end
return IN
end
function CreateRecord(index, address)
local List=getAddressList()
local NewRec=List.createMemoryRecord()
local baseOffset = index*8
local valueOffset = baseOffset+4
local baseAddress = "00"
baseAddress = address
NewRec.setAddress(address)
NewRec.setOffsetCount(1)
NewRec.setOffset(0, valueOffset)
local lookupAddress = '[' .. baseAddress .. ']+' .. baseOffset
lookupVal=readInteger(lookupAddress)
NewRec.setDescription(getDesc(lookupVal))
NewRec.Type=vtDWord
end
function BuildList()
local PlayerStruct=AOBScan("2c cb f3 00 04 01 00 00 01 * * * 00 00 80 3f * * * * 18 00 00 00 16 00 00 00 * * * * 02 00 00 00", "*X-C+W")
local PlayerAddress=PlayerStruct[0]
local StoreHouseStartAddress='[' .. PlayerAddress .. ']'-->+23c' -->572
local StoreHouseEndAddress='[' .. PlayerAddress .. ']+240' -->576
print(StoreHouseStartAddress)
print(StoreHouseEndAddress)
pStoreHouse1Start=readBytes(StoreHouseStartAddress,4,true) -->READBYTES ERROR HERE
pStoreHouse1End=readBytes(StoreHouseEndAddress,4,true) -->READBYTES ERROR HERE
print(pStoreHouse1Start[1]..' '..pStoreHouse1Start[2]..' '..pStoreHouse1Start[3]..' '..pStoreHouse1Start[4])
print(pStoreHouse1End[1]..' '..pStoreHouse1End[2]..' '..pStoreHouse1End[3]..' '..pStoreHouse1End[4])
-->local iStoreHouse1Start=tonumber(pStoreHouse1Start,16)
local iStoreHouse1Start=HexDumpBytes(pStoreHouse1Start)
-->local iStoreHouse1End=tonumber(pStoreHouse1End,16)
local iStoreHouse1End=HexDumpBytes(pStoreHouse1End)
print(iStoreHouse1Start[1]..' '..iStoreHouse1Start[2]..' '..iStoreHouse1Start[3]..' '..iStoreHouse1Start[4])
print(iStoreHouse1End[1]..' '..iStoreHouse1End[2]..' '..iStoreHouse1End[3]..' '..iStoreHouse1End[4])
size=0-0
itemCount=size/8
print(size)
print(itemCount)
--> for tempCount=1,itemCount do
--> CreateRecord(tempCount-1, pStoreHouse1Start)
--> end
object_destroy(PlayerStruct)
return 1
end
lookupTable = {"a", "b", "c", "d", "animal", "beer", "book", "bread", "cloth", "coal", "coin", "fish", "flour", "garment", "gold", "grain", "horse", "iron", "ironore", "jewelry", "meat", "paper", "plank", "stone", "tools", "water", "weapon", "wheel", "wood", "wool"};
BuildList() |
|
|
Back to top |
|
|
Gniarf Grandmaster Cheater Supreme Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
Posted: Thu Mar 06, 2014 1:50 am Post subject: |
|
|
readBytes(PlayerAddress,4,true) means "return the 4 bytes at address PlayerAddress" and should give 2c cb f3 00.
readBytes("["..PlayerAddress.."]",4,true) means "read the 4 bytes at address PlayerAddress, interpret this (2c cb f3 00) as an address, and return the 4 bytes there (=at 0x00f3cb2c)".
_________________
DO NOT PM me if you want help on making/fixing/using a hack. |
|
Back to top |
|
|
jgrochoski How do I cheat? Reputation: 0
Joined: 04 Nov 2009 Posts: 9
|
|
Back to top |
|
|
|
|
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
|
|