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 


Reading/Writing Index breaks with readString

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Kelso
How do I cheat?
Reputation: 0

Joined: 20 Mar 2022
Posts: 4

PostPosted: Sun Mar 20, 2022 6:50 pm    Post subject: Reading/Writing Index breaks with readString Reply with quote

I made a script to increment up a list of specific values in an array, when I use:
Code:
local Alloc = readString("TargetAddr")

it doesn't work

When I use:
Code:
local Alloc = "7FF3D8981B30"

it works

I initialize it like so:
Code:
alloc(TargetAddr,12)
registersymbol(TargetAddr)



What I mean but "it does/doesn't work" I mean while it is incrementing up this array, the index number continues to count up like normal, but the spot in the array gets stuck on the 34th slot and doesn't change.

The script itself works perfectly how I intended it, but when using the readString method it stops working once that 34th slot is reached. Any suggestions?
Back to top
View user's profile Send private message
YoucefHam
Cheater
Reputation: 5

Joined: 19 Mar 2015
Posts: 39
Location: Algeria

PostPosted: Sun Mar 20, 2022 8:51 pm    Post subject: Re: Reading/Writing Index breaks with readString Reply with quote

Kelso wrote:
I made a script to increment up a list of specific values in an array, when I use:
Code:
local Alloc = readString("TargetAddr")

it doesn't work

When I use:
Code:
local Alloc = "7FF3D8981B30"

it works

I initialize it like so:
Code:
alloc(TargetAddr,12)
registersymbol(TargetAddr)



What I mean but "it does/doesn't work" I mean while it is incrementing up this array, the index number continues to count up like normal, but the spot in the array gets stuck on the 34th slot and doesn't change.

The script itself works perfectly how I intended it, but when using the readString method it stops working once that 34th slot is reached. Any suggestions?


Hi, use getAddress("TargetAddr")

Code:
local Alloc = readString(getAddress("TargetAddr"))
Back to top
View user's profile Send private message Send e-mail
Kelso
How do I cheat?
Reputation: 0

Joined: 20 Mar 2022
Posts: 4

PostPosted: Sun Mar 20, 2022 9:46 pm    Post subject: Reply with quote

Ok I actually went ahead and used that but I guess I should have mentioned this other quirk:

Code:
local Alloc = readString("TargetAddr")

Code:
local Alloc = readString(getAddress("TargetAddr"))


Both of these actually work unless it's using that address, if I use another address like "2AEA88C0038" it magically starts working, and then setting the target address back to "7FF3D8981B30" breaks it again.

Note: Alloc = "7FF3D8981B30" works regardless of region, but if I use the readString function then the 7FF address stops working but the 2AE address will work like normal.
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Sun Mar 20, 2022 10:19 pm    Post subject: Reply with quote

What are you setting "TargetAddr" with? If it's the default (all zeros). readString will return an empty string since it hits a null byte (zero) on the first byte.
_________________
Back to top
View user's profile Send private message Visit poster's website
Kelso
How do I cheat?
Reputation: 0

Joined: 20 Mar 2022
Posts: 4

PostPosted: Mon Mar 21, 2022 4:35 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
What are you setting "TargetAddr" with? If it's the default (all zeros). readString will return an empty string since it hits a null byte (zero) on the first byte.


I have it set up where TargetAddr is addressed in the table like shown in the attached image. The "7FF3D8981B30" address in this example is the one it writes to successfully until it reaches the 34th slot in the index.

If I use another address like "2AEA88C0038" as the target address in that header it will count past the 34th slot just fine and works normally endlessly, so something about the address or how readString works or how it's stored is causing an issue.



doesnt work.png
 Description:
 Filesize:  16.69 KB
 Viewed:  1388 Time(s)

doesnt work.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Mar 21, 2022 4:48 pm    Post subject: Reply with quote

You need to include a null byte if you're storing a string.
Code:
assert(autoAssemble[[
globalalloc(TargetAddr,13)
TargetAddr:
  db '7FF3D8981B30',0
]])

assert(readString'TargetAddr' == '7FF3D8981B30')

Or just store the address as an integer like you should be doing in most cases.
Code:
assert(autoAssemble[[
globalalloc(TargetAddr,8)
TargetAddr:
  dq 7FF3D8981B30
]])

assert(readPointer'TargetAddr' == 0x7FF3D8981B30)

_________________
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
Kelso
How do I cheat?
Reputation: 0

Joined: 20 Mar 2022
Posts: 4

PostPosted: Mon Mar 21, 2022 5:03 pm    Post subject: Reply with quote

Quote:
You need to include a null byte if you're storing a string.


Ok, this was the issue, the script works normally now. Thank you, I wasn't aware this was necessary for it to work.
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