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 


String replace script

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

Joined: 18 Feb 2024
Posts: 3

PostPosted: Sun Feb 18, 2024 7:49 pm    Post subject: String replace script Reply with quote

Hi guys,sorry for being so noob but I'm new to CE and not even sure that it's a correct tool for what I need, but anyway
If short I have a game with encryted scripts but I found out that after game load some they are decrypted in memory and I can modify them with CE
So I need some CE script that will search for a string in memory (for every same string) and then replace it(them) with another string, on a background each 10 seconds or on key press (if it's possible)

for example I have string Berifier_Punisher_Do and I wanna to replace it with
Verifier_Punisher_Do



изображение_2024-02-19_024725551.png
 Description:
here I found original strings
 Filesize:  39.01 KB
 Viewed:  835 Time(s)

изображение_2024-02-19_024725551.png



изображение_2024-02-19_024657012.png
 Description:
here I replaced them with new ones manually
but problem is I wanna a script that will do it automatically
 Filesize:  40.48 KB
 Viewed:  835 Time(s)

изображение_2024-02-19_024657012.png


Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Feb 18, 2024 9:16 pm    Post subject: Reply with quote

This will replace all values found in the foundlist after conducting the initial search:
Code:

local string_to_find = 'Berifier_Punisher_Do'
local string_to_write = 'Verifier_Punisher_Do'

local fl = getCurrentMemscan().FoundList
if fl == nil then error('Invalid foundlist.') end
for i = 0, fl.Count  - 1 do
    if fl[i] ~= nil and fl.Value[i] == string_to_find then
         writeString(fl[i], string_to_write, false) -- set to true if widestring
    end
end
Back to top
View user's profile Send private message
Feel_Fried
How do I cheat?
Reputation: 0

Joined: 18 Feb 2024
Posts: 3

PostPosted: Sun Feb 18, 2024 9:49 pm    Post subject: Reply with quote

LeFiXER wrote:
This will replace all values found in the foundlist after conducting the initial search:


If I understand it correctly it will search in scan results from manually runned scan... but how to run scan from lua?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Sun Feb 18, 2024 10:54 pm    Post subject: Reply with quote

This should do the trick:
Code:

local string_to_find = 'Berifier_Punisher_Do'
local string_to_write = 'Verifier_Punisher_Do'

ms = createMemScan()
ms.firstScan(soExactValue, vtString, 0, string_to_find, "" , 0, 0xffffffffffffffff, "", fsmNotAligned, "1", false, false, false, false)
ms.waitTillDone()

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

resultToWrite = stringToByteTable(string_to_write .. string.char(0))

for i = 0, f.Count - 1 do
  writeString(f.Address[i], string_to_write)
  writeBytes(("0x" .. f.Address[i]) + 4, 0)
end

f.destroy()
ms.destroy()


Credits: DB


There is more information in the celua.txt documentation
Back to top
View user's profile Send private message
Feel_Fried
How do I cheat?
Reputation: 0

Joined: 18 Feb 2024
Posts: 3

PostPosted: Mon Feb 19, 2024 12:37 am    Post subject: Reply with quote

Thank you!
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