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 


Null Terminator after string

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Tue Apr 02, 2024 9:49 am    Post subject: Null Terminator after string Reply with quote

Using CEServer, I'm running a script that searches for something and uses a for loop to replace everything. However, it seems that the for loop specifically kills the ceserver.

Code:
for i=0,FoundList.Count-1 do
  if(readString(FoundList.Address[i]) == one) then
    writeString(FoundList.Address[i],operator);
    writeBytes('FoundList.Address[i]+'..len, 0);
    end
  if(readString(FoundList.Address[i]) == two) then
    writeString(FoundList.Address[i],operator);
    writeBytes('FoundList.Address[i]+'..len, 0);
    end
  if(readString(FoundList.Address[i]) == three) then
    writeString(FoundList.Address[i],operator);
    writeBytes('FoundList.Address[i]+'..len, 0);
    end
  if(readString(FoundList.Address[i]) == four) then
    writeString(FoundList.Address[i],operator);
    writeBytes('FoundList.Address[i]+'..len, 0);
    end
  if(readString(FoundList.Address[i]) == a) then 
    writeString(FoundList.Address[i],skin);
    writeBytes('FoundList.Address[i]+'..len2, 0);
    end
  if(readString(FoundList.Address[i]) == b) then
    writeString(FoundList.Address[i],skin);
    writeBytes('FoundList.Address[i]+'..len2, 0);
    end
  if(readString(FoundList.Address[i]) == c) then
    writeString(FoundList.Address[i],skin);
    writeBytes('FoundList.Address[i]+'..len2, 0);
    end
  if(readString(FoundList.Address[i]) == d) then
    writeString(FoundList.Address[i],skin);
    writeBytes('FoundList.Address[i]+'..len2, 0);
    end
end


I've kinda narrowed the part that makes it crash down to where I write the null terminator within each if statement. Can't seem to figure out why it does this. If anyone has any ideas, any help is much appreciated Smile

It does the same thing without apostrophes around the address, same thing without the plus operator. It works if i remove all the writeByte functions, but then there is no null terminator so what I'm doing doesn't end up working
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1524

PostPosted: Tue Apr 02, 2024 11:43 am    Post subject: Reply with quote

Code:
writeBytes('FoundList.Address[i]+'..len2, 0);


'FoundList.Address[i]+'

Why is it in quotes?

Try this:
Code:
writeBytes(FoundList.Address[i]..'+'..len2, 0);

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
iosufdhgd
Newbie cheater
Reputation: 0

Joined: 04 Jun 2022
Posts: 17

PostPosted: Tue Apr 02, 2024 7:14 pm    Post subject: Reply with quote

AylinCE wrote:
Code:
writeBytes('FoundList.Address[i]+'..len2, 0);


'FoundList.Address[i]+'

Why is it in quotes?

Try this:
Code:
writeBytes(FoundList.Address[i]..'+'..len2, 0);

Wasn't in quotes originally, was just something I tried. Didn't work either way.
ALso, unfortunately that fix doesn't do the job Sad
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4703

PostPosted: Tue Apr 02, 2024 8:04 pm    Post subject: Reply with quote

The "Address" field of the foundlist is a stringlist IIRC. You can't add an integer to a string.
Code:
function writeStringZeroTerm(address, text, widechar)
  local bt
  if widechar then
    bt = wideStringToByteTable(text)
  else
    bt = stringToByteTable(text)
  end

  bt[#bt+1] = 0

  writeBytes(address, bt)
end

-- ...

for i=0,FoundList.Count-1 do
  local addr = getAddress(FoundList.Address[i])

  if addr == one or addr == two or addr == three or addr == 4 then
    writeStringZeroTerm(addr, operator)
  elseif addr == a or addr == b or addr == c or addr == d then
    writeStringZeroTerm(addr, skin)
  end
end

_________________
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
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