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 


How to properly scan for strings in memory?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Fri Nov 16, 2018 7:32 pm    Post subject: How to properly scan for strings in memory? Reply with quote

I have been trying to scan and replace strings in memory with Lua.

Just as an example, I want to scan for all strings "hey" and replace them with "bye"

I have tried using the following code, but I noticed that it does not actually return ALL the strings. I have found this out when I scan for "hey" in CE, then run my Lua script, but some results found in CE never get replaced (maybe only 70% of results do)

Probably because I am doing something wrong with parameters, I don't understand most.

Code:
Code:

function scanStr()
  ms=createMemScan()
  ms.firstScan(soExactValue,vtString,"hey","hey",0, 0xffffffffffffffff, "", fsmNotAligned, "1", false, false, false, false)

  ms.onScanDone = function(ms)

  f=createFoundList(ms);
  f.initialize();

  -- .. etc ..
end


As an alternative, I have converted the string to hex byte and use AOB scan, which has always worked correctly, but I notice that it is slower than using regular string scan.

I believe these are the default string scan options I need: (attached)



tmpscreence.PNG
 Description:
settings of CE string scan
 Filesize:  15.97 KB
 Viewed:  2861 Time(s)

tmpscreence.PNG


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

Joined: 06 Jul 2014
Posts: 4711

PostPosted: Fri Nov 16, 2018 10:16 pm    Post subject: Reply with quote

celua.txt:
Quote:
firstScan(scanoption, vartype, roundingtype, input1, input2 ,startAddress ,stopAddress ,protectionflags ,alignmenttype ,"alignmentparam" ,isHexadecimalInput ,isNotABinaryString, isunicodescan, iscasesensitive);

Your code ignores the rounding type parameter which throws all the other parameters off. It's not relevant for a string scan, so just pass rtRounded.

_________________
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