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 


[Fixed] Scanning string in script then printing scanned item

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

Joined: 24 Oct 2016
Posts: 14
Location: Gilbert, AZ

PostPosted: Sat Mar 25, 2017 1:29 am    Post subject: [Fixed] Scanning string in script then printing scanned item Reply with quote

ok so i have a string that i need to scan in a script but then from there i need to get the address of the scanned string so i can then add 83 bytes to the address and get the string address i need (due to it being dynamic), and then i need to print the string from the final address (after the 83 bytes was added to the address gathered from the string search) as the correct length of the string, which is 456 bytes long. I can do it manually, but i have 0 clues as to how to go about doing it via a script automatically. if someone could help me that'd be great, and if you need a better / further explanation, feel free to ask, or if you need any clarification on what i'm asking for / a part of what i'm asking for, feel free to ask. I'll try to respond as fast as possible. Razz

thanks again for helping me if you decide to. (Also, sorry for the long paragraph)

here's the initial search: https :// gyazo . com /c9d291fc10c4980c1e4aefc6a3ec6083

here's how the search is modified: https :// gyazo . com /4818ffad8c97489d1610c891f45f1aa3

so basically i want it to search for a string then go 83 bytes ahead and print that string into the lua engine. I don't usually do value modifications so i don't know how i would go about doing this

edit: forgot to mention, any of the addresses found will work since they contain the exact same string, but in the screenshots i just chose the top one to show as an example because it was closest to my mouse.


(sorry darkbyte for going around the filtering towards posting urls, pls no hate Sad thnx )

_________________
will edit later


Last edited by Mortalkombatman2 on Tue Apr 04, 2017 7:20 pm; edited 4 times in total
Back to top
View user's profile Send private message Send e-mail
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Mar 25, 2017 5:05 am    Post subject: Reply with quote

Maybe something like this :

Code:
baseAddress = getAddress("cheatengine-i386.exe")

function findString(str)
  local len = string.len(str)
  local chunkSize = 4096
  local chunkStep = chunkSize - len
  print('Found '..str..' at: ')

  for address = baseAddress, (baseAddress + 0x2ffffff), chunkStep do
      local chunk = readBytes(address, chunkSize, true)
       if (not chunk) then
        break
       end
        for c = 0, chunkSize-len do
            checkForString(address, chunk, c, str, len)
        end
  end
end

function checkForString(address, chunk, start, str, len)
  for i = 1, len do
      if (chunk[start+i] ~= string.byte(str, i)) then
         return false
      end
  end
  print(string.format('\t0x%x', address + start))
end

-- use :
findString('cheat')

result : [[

Found cheat at: 
   0x958230
   0x96ceaf
   0x96d108
   0x96d4e5
   0x96dbf5
   0x96dd93
   0x96ec9f
   0x96fce0
   0x96ffb3
   0x97acaa
   0x97b100
   0x97d840
   0x98e981
   0x991b4f
   0x991b84
   0x993465
   0x993481
   0x9934a5
   0x994e95
   0x9a31ab
   0x9a42f7
   0x9a4315
   0x9aa343
   0x9bd7cc
   0x9bd7fe
   0x9bd9c7
   0x9bdae3
   0x9bdb09
   0x9bdb3d
   0x9c0128
   0x9c03be
   0x9c11e3
   0x9c1256
   0x9c2b3b
   0x9c2b62
   0x9c2b86
   0x9c67ac
   0x9f1cf3
   0xa24cde
   0xa263b1
   0xa29651
   0xa29fc4
   0xa2b570
   0xa5bb97
   0xa5d30d
   0xa5d365
   0xa5d541
   0xa5d84f
   0xa5d873
   0xa5d8c8
   0xa5d903
   0xa5d914
   0xa5d94b
   0xa5d959
   0xa5d9ca
   0xa5e0e7
   0xa5e122
   0xa5e207
   0xa5e341
   0xa5e5e9
   0xa5fb79
   0xa5fbb4
   0xa601ea
   0xa6027d
   0xa6040e
   0xa60ad3
   0xa622d8
   0xa67038
   0xa6711c
   0xa67160
   0xa671e4
   0xa6959a
   0xa69aeb
   0xa69b03
   0xa6bfe0
   0xa6bff8
   0xa6c018
   0xa74ff1
   0xa7ac0e
   0xa82b3c
   0xa82b58
   0xa82b74
   0xa82b94
   0xa82bb4
   0xa82bd0
   0xa82bec
   0xa82c10
   0xa82c34
   0xa82c54
   0xa82c74
   0xa82c90
   0xbeec16

]]
Back to top
View user's profile Send private message
Mortalkombatman2
Newbie cheater
Reputation: 0

Joined: 24 Oct 2016
Posts: 14
Location: Gilbert, AZ

PostPosted: Sat Mar 25, 2017 10:39 am    Post subject: Reply with quote

Corroder wrote:
Maybe something like this :

Code:
baseAddress = getAddress("cheatengine-i386.exe")

function findString(str)
  local len = string.len(str)
  local chunkSize = 4096
  local chunkStep = chunkSize - len
  print('Found '..str..' at: ')

  for address = baseAddress, (baseAddress + 0x2ffffff), chunkStep do
      local chunk = readBytes(address, chunkSize, true)
       if (not chunk) then
        break
       end
        for c = 0, chunkSize-len do
            checkForString(address, chunk, c, str, len)
        end
  end
end

function checkForString(address, chunk, start, str, len)
  for i = 1, len do
      if (chunk[start+i] ~= string.byte(str, i)) then
         return false
      end
  end
  print(string.format('\t0x%x', address + start))
end

-- use :
findString('cheat')

result : [[

Found cheat at: 
   0x958230
   0x96ceaf
   0x96d108
   0x96d4e5
   0x96dbf5
   0x96dd93
   0x96ec9f
   0x96fce0
   0x96ffb3
   0x97acaa
   0x97b100
   0x97d840
   0x98e981
   0x991b4f
   0x991b84
   0x993465
   0x993481
   0x9934a5
   0x994e95
   0x9a31ab
   0x9a42f7
   0x9a4315
   0x9aa343
   0x9bd7cc
   0x9bd7fe
   0x9bd9c7
   0x9bdae3
   0x9bdb09
   0x9bdb3d
   0x9c0128
   0x9c03be
   0x9c11e3
   0x9c1256
   0x9c2b3b
   0x9c2b62
   0x9c2b86
   0x9c67ac
   0x9f1cf3
   0xa24cde
   0xa263b1
   0xa29651
   0xa29fc4
   0xa2b570
   0xa5bb97
   0xa5d30d
   0xa5d365
   0xa5d541
   0xa5d84f
   0xa5d873
   0xa5d8c8
   0xa5d903
   0xa5d914
   0xa5d94b
   0xa5d959
   0xa5d9ca
   0xa5e0e7
   0xa5e122
   0xa5e207
   0xa5e341
   0xa5e5e9
   0xa5fb79
   0xa5fbb4
   0xa601ea
   0xa6027d
   0xa6040e
   0xa60ad3
   0xa622d8
   0xa67038
   0xa6711c
   0xa67160
   0xa671e4
   0xa6959a
   0xa69aeb
   0xa69b03
   0xa6bfe0
   0xa6bff8
   0xa6c018
   0xa74ff1
   0xa7ac0e
   0xa82b3c
   0xa82b58
   0xa82b74
   0xa82b94
   0xa82bb4
   0xa82bd0
   0xa82bec
   0xa82c10
   0xa82c34
   0xa82c54
   0xa82c74
   0xa82c90
   0xbeec16

]]


With that script I replaced the process with the process it's on, and the "cheat" string to the wanted string, but when it scans for the string it just says this: "Found LOGIN at: " and nothing else.

_________________
will edit later
Back to top
View user's profile Send private message Send e-mail
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Sat Mar 25, 2017 3:55 pm    Post subject: Reply with quote

Hi,

I may be wrong, but it seems you want to find an address (a1) of a known string (s1), then from that address to obtain another result address (a2) and/or another string(s2) that may be changed per every run (dynamic)?

It may help to clarify by some screenshots of your manual search, or some visual to show the relationship, eg:
Code:

memory -> content
0a0010  -> "KnownString"
0a0010 + 83 -> [address of another string]
[address of another string] -> "SomeDynamicString"(456 bytes long)

_________________
- Retarded.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 25, 2017 5:02 pm    Post subject: Reply with quote

Use CE and find your initial string. Then execute this Lua:
Code:
local found = getCurrentMemscan().FoundList
for i = 0, found.Count - 1 do
  local address = tonumber(found.Address[i], 16)
  address = address + 83
  local other = readString(address, 456)
  print(other)
end
Back to top
View user's profile Send private message
Mortalkombatman2
Newbie cheater
Reputation: 0

Joined: 24 Oct 2016
Posts: 14
Location: Gilbert, AZ

PostPosted: Sun Mar 26, 2017 1:30 am    Post subject: Reply with quote

panraven wrote:
Hi,

I may be wrong, but it seems you want to find an address (a1) of a known string (s1), then from that address to obtain another result address (a2) and/or another string(s2) that may be changed per every run (dynamic)?

It may help to clarify by some screenshots of your manual search, or some visual to show the relationship, eg:
Code:

memory -> content
0a0010  -> "KnownString"
0a0010 + 83 -> [address of another string]
[address of another string] -> "SomeDynamicString"(456 bytes long)


alright i'll edit the thread with that.

-----------------------------------------------------------------

Zanzer wrote:
Use CE and find your initial string. Then execute this Lua:
Code:
local found = getCurrentMemscan().FoundList
for i = 0, found.Count - 1 do
  local address = tonumber(found.Address[i], 16)
  address = address + 83
  local other = readString(address, 456)
  print(other)
end

_________________
will edit later
Back to top
View user's profile Send private message Send e-mail
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Sun Mar 26, 2017 3:34 am    Post subject: Reply with quote

Zanzer's script should work , just change
address = address + 83
to
address = address + 0x83 .

_________________
- Retarded.
Back to top
View user's profile Send private message
Mortalkombatman2
Newbie cheater
Reputation: 0

Joined: 24 Oct 2016
Posts: 14
Location: Gilbert, AZ

PostPosted: Sun Mar 26, 2017 4:14 am    Post subject: Reply with quote

panraven wrote:
Zanzer's script should work , just change
address = address + 83
to
address = address + 0x83 .


his script worked however i was wondering if there was a way to make it just take the first address found out of the scanned items instead of all of them

_________________
will edit later
Back to top
View user's profile Send private message Send e-mail
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sun Mar 26, 2017 5:02 am    Post subject: Reply with quote

no for loop and just use found.Address[0]

or use the memscan class directly and tell it to find only one result

_________________
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
View user's profile Send private message MSN Messenger
Mortalkombatman2
Newbie cheater
Reputation: 0

Joined: 24 Oct 2016
Posts: 14
Location: Gilbert, AZ

PostPosted: Sun Mar 26, 2017 5:22 am    Post subject: Reply with quote

Dark Byte wrote:
no for loop and just use found.Address[0]

or use the memscan class directly and tell it to find only one result


okay thanks that helped, i fixed that part, but is there a way to make the script also do the search too?

_________________
will edit later
Back to top
View user's profile Send private message Send e-mail
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Mar 26, 2017 7:16 am    Post subject: Reply with quote

Code:
local myvalue = "blahblah"
local memscan = createMemScan()
memscan.OnlyOneResult = true
memscan.firstScan(
  soExactValue, vtString, rtRounded,
  myvalue, nil, 0x0, 0xffffffffffffffff, "+W*X",
  fsmNotAligned, "1", false, false, false, false)
memscan.waitTillDone()
local address = memscan.Result
if address then
  address = address + 0x83
  local other = readString(address, 456)
  print(other)
else
  print("Not found")
end
memscan.Destroy()
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Mar 26, 2017 7:51 am    Post subject: Reply with quote

Zanzer wrote:
Code:
local myvalue = "blahblah"
local memscan = createMemScan()
memscan.OnlyOneResult = true
memscan.firstScan(
  soExactValue, vtString, rtRounded,
  myvalue, nil, 0x0, 0xffffffffffffffff, "+W*X",
  fsmNotAligned, "1", false, false, false, false)
memscan.waitTillDone()
local address = memscan.Result
if address then
  address = address + 0x83
  local other = readString(address, 456)
  print(other)
else
  print("Not found")
end
memscan.Destroy()


I wonder if this work for roblo game. I hope this will work properly and it will great...

Smile Regards

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Sun Mar 26, 2017 9:35 am    Post subject: This post has 1 review(s) Reply with quote

Alternative,
Code:

function GetOrFindCode()
  local function checkAndGet(addy)
    addy = readInteger(addy)and GetAddress(addy)
    local code = addy and addy~=0 and readString(addy,456) or 'shit!'
    return code:len()==456 and code or nil
  end
  if not checkAndGet"[_CodePos]" then
    autoAssemble[[
globalalloc(_CodePos,16)
aobscan(aobpos, 2E 52 4F 42 4C 4F 53 45 43 55 52 49 54 59)// .ROBLOSECURITY
_CodePos:
dq aobpos+83
    ]]
  end
  return checkAndGet"[_CodePos]"
end


The function return nil in case no right process attached, or 1st '.ROLOX...' not lead to a 456 length String. If use with a EditBox, can be use like:
Code:

EditBox.Text = GetOrFindCode() or 'oops,shit!'

The address for a memory record should set as:
normal : [_CodePos]
pointer : base= _CodePos, offset1=0

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