View previous topic :: View next topic |
Author |
Message |
MMM-304 Expert Cheater
Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Thu Sep 24, 2020 1:16 am Post subject: Changing String (LENGTH)! |
|
|
if i have a string (unicode)
Code: | str = 'CheatEngine' |
i can print it like and its length
Code: | print(str)
print(#str) |
What I want is to change the length of the string using LUA so that it sets itself to or something like this, WITHOUT actually making
I tried using
Code: | #str = 5 --and
string.len(str) = 5 |
and obviously it doesnt work
|
|
Back to top |
|
 |
n1vX Advanced Cheater
Reputation: 0
Joined: 27 May 2007 Posts: 61
|
Posted: Thu Sep 24, 2020 1:40 am Post subject: |
|
|
Have you tried this :
Code: | string.sub(str,1,5) |
|
|
Back to top |
|
 |
MMM-304 Expert Cheater
Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Thu Sep 24, 2020 1:54 am Post subject: |
|
|
yes thats not what i meant to ask
what i meant was that it would make
like if u do like this
Code: | print(str)--= CheatEngine
--do Changes in length of string then
print(str)--Cheat
|
also not just that, I also want to be able to increase its actual length. although I dont think i can insert Char(s) in string can I?
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25806 Location: The netherlands
|
Posted: Thu Sep 24, 2020 2:47 am Post subject: |
|
|
you can't from within lua (unless you use writeInteger on string specifiers inside lua itself, and I really do not recommend that)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Thu Sep 24, 2020 2:50 am Post subject: |
|
|
Code: |
str = "CheatEngine";
str = str:sub(1,5); -- copy only first 5 characters
print(str);
function subString(s,length)
return tostring(s):sub(1,length or -1);
end
str = "Test! variable";
print(str); -- Test! variable
print(subString(str)); -- Test!
|
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
MMM-304 Expert Cheater
Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Thu Sep 24, 2020 4:26 am Post subject: |
|
|
Actually I was helping someone with this:
Code: | function setString(fdlist)
getCurrentMemscan().waitTillDone()
fdCount = fdlist.Items.Count
for i=0,fdCount-1 do
writeString(fdlist.Items.Item[i].Caption,"HELLO")
end
end
function searchString(stringToSearch,mf)
mf.VarType.ItemIndex = 7
mf.scanvalue.Text = stringToSearch
if mf.btnNewScan.Caption == 'First Scan' then
mf.btnNewScan.doClick()
end
wt = getCurrentMemscan()
wt.waitTillDone()
end
--------------------
theMF = MainForm
getfdlist = theMF.Foundlist3
searchString('My String',theMF)
wait = 0
while wait < 2 do
wait = wait + 1
sleep(500)
end
setString(getfdlist) |
as u can see i was trying to overwrite the string My String with HELLO inside foundlist3 and the result was
Similarly if i was to write a string whose length is bigger than My String, a fraction appeared!
|
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Thu Sep 24, 2020 5:17 am Post subject: |
|
|
Code: | function writeString2(address,str)
if (type(str)=='string') then
local bytesTable = {}
for char in str:gmatch('.') do
bytesTable[#bytesTable+1] = char:byte();
end
bytesTable[#bytesTable+1] = 0 -- \0
writeBytes(address,bytesTable)
end
end |
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Thu Sep 24, 2020 5:24 am Post subject: |
|
|
Or (from old topic somewhere)
Code: | function replaceString(string_in, string_out, ignore_length)
-- ignore_length = true or false
if (not ignore_length) then
if (not(string_in and string_out and #string_in >= #string_out)) then
return print("Not recommended to override shorter string with a longer string");
end
end
local bytes_in = {}
local bytes_out = {}
for i=1,(#string_in >= #string_out and #string_in or #string_out) do
if (i <= #string_in) then
table.insert(bytes_in,string.format("%x", tonumber(string.byte(string.sub(string_in,i,i)))));
end
if (i <= #string_out) then
table.insert(bytes_out,tonumber(string.byte(string.sub(string_out,i,i))));
end
end
local object = AOBScan(table.concat(bytes_in," "))
if object then
for entry = 0, object.Count -1 do
writeBytes(object.getString(entry), unpack(bytes_out));
end
object.destroy();
return true
end
return false
end
replaceString("HELLO", "Whatever", true) |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
MMM-304 Expert Cheater
Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Thu Sep 24, 2020 5:37 am Post subject: |
|
|
wait does that means we can covert string into bytes than overwrite those bytes?
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1526
|
Posted: Thu Sep 24, 2020 5:56 am Post subject: |
|
|
Lua will give you usable examples.
Here are some of them;
Code: | local chr = "Cheat Engine V7.1";
function subString(s, start, length)
s=string.sub(s, start, length)
print("subString: "..start.." - "..length.." = "..s);
end
function CharacterResult1(str)
i, j = string.find(str, str)
print("Result1: find, (str) Start, Finish = "..i, j)
end
function CharacterResult2(str, str1)
print("Result2: '"..str1.."' Start = "..string.find(str, str1))
end
function CharacterResult3(str, str1)
s, f = string.find(str, str1)
print("Result3: '"..str1.."' Start, Finish = "..s, f)
subString(str, s, f)
end
CharacterResult1(chr)
CharacterResult2(chr, "Engine")
CharacterResult3(chr, "Engine")
subString(chr, 6, 15) |
_________________
Last edited by AylinCE on Thu Sep 24, 2020 6:06 am; edited 1 time in total |
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Thu Sep 24, 2020 6:01 am Post subject: |
|
|
MMM-304 wrote: | wait does that means we can covert string into bytes than overwrite those bytes? |
Yes. Memory consists of address and bytes. String, float, double, etc just the types of value.
If want to replace, insert, etc in a string/text then take a look for lua string library or lua string manipulation, example has given by DaSpammer, Aylin.
But if want to manipulate string inside the memory then use byte conversion is more easy.
Correct me if I am wrong.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Thu Sep 24, 2020 6:12 am Post subject: |
|
|
Corroder wrote: | MMM-304 wrote: | wait does that means we can covert string into bytes than overwrite those bytes? |
Yes. Memory consists of address and bytes. String, float, double, etc just the types of value.
If want to replace, insert, etc in a string/text then take a look for lua string library or lua string manipulation, example has given by DaSpammer, Aylin.
But if want to manipulate string inside the memory then use byte conversion is more easy.
Correct me if I am wrong. |
That's exactly what I was doing,
The reason why he couldn't overwrite 'My String' with 'HELLO' because 'HELLO' is missing null terminator
The example I sent, converts characters to bytes and adds null terminator character at the end.
I don't recommend overwriting a string with longer one, as it might override other essential data, would be better to allocate memory and replace the string pointer.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
MMM-304 Expert Cheater
Reputation: 0
Joined: 17 Aug 2020 Posts: 170 Location: Milkey Way
|
Posted: Thu Sep 24, 2020 6:48 am Post subject: |
|
|
hmm.. that makes sense. And u r right, overwriting a string with longer bytes than it already has, without allocating additional memory will most likely corrupt the data
Thanks guys. Appreciate ur help!
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1526
|
Posted: Thu Sep 24, 2020 6:51 am Post subject: |
|
|
If you want to change a order from FoundList without downloading it to AdressList,
It's complicated for me
But when it comes to Lua Script, below is an example code for searching and exchanging.
You only need to specify the characters (text, as strings) to search and replace.
Code: | function TextReplacer(search, change)
local searchTable = {}
for i=1,search:len() do
searchTable[i]=string.format('%X',search:byte(i))
end
local searchHexString = table.concat(searchTable)
local aobs2 = AOBScan(searchHexString)
if(aobs2 ~= nil) then
for i=0,stringlist_getCount(aobs2)-1 do
local address=stringlist_getString(aobs2,i)
writeString('0x'..address,change)
end
object_destroy(aobs2);
aobs2=nil
end
beep()
print("done")
return
end
--Put the activation key below into the code you're calling.
--Note: make sure you put the above code at the top.
TextReplacer("you search", "new change") -- or new change="HELLO" |
_________________
|
|
Back to top |
|
 |
|