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 


writeString

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 51

PostPosted: Fri Mar 24, 2023 6:46 pm    Post subject: writeString Reply with quote

Code:
local playerName = readString(addr,256,true)  --isWideString
--playerName = 'abcdefg'



writeString(addr,'xyz',true)

--playerName  = 'xyzdefg'
--Why not "xyz". What should I do?

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

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Fri Mar 24, 2023 7:30 pm    Post subject: Reply with quote

CE doesn't write a null terminator.
Code:
function writeStringZero(address, str, wide)
  local t
  if wide then
    t = wideStringToByteTable(s)
    t[#t+1] = 0
    t[#t+1] = 0
  else
    t = stringToByteTable(s)
    t[#t+1] = 0
  end
  return writeBytes(address, t)
end

-- example:
writeStringZero(addr,'xyz',true)


It would be really nice if CE accounted for embedded 0 bytes, but it doesn't.
Code:
-- CE 7.5: doesn't work: only writes 'abc'
writeString(addr, 'abc\0')
Maybe this could be called a bug since embedded 0 bytes work fine in Lua?
_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Fri Mar 24, 2023 7:58 pm    Post subject: Reply with quote

Just an observation ...

Code:
function stringToAob(addr,byt)
local searchTable = {}
search2 = readString(addr,16,true)
print("search2: "..search2)
for i=1,byt do
searchTable[i]=string.format('%X',search2:byte(i))
end
local searchHexString = table.concat(searchTable," ")
return searchHexString
end


print(stringToAob("023AA8BA",6)) -- "abcdef" = "61 62 63 64 65 66"

writeString("023AA8BA",'xyz   ')

print(stringToAob("023AAAEA",6)) --"zxy   " = "78 79 7A 20 20 20"

writeString("023AA8BA",'xyz',true) --"z.x.y." = 78 00 79 00 7A 00

_________________
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
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 51

PostPosted: Sat Apr 01, 2023 10:39 pm    Post subject: Reply with quote

yes, is working.thanks.
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