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 


Scanning String with lua and result will be in ListBox[HELP]

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

Joined: 01 Jul 2017
Posts: 67

PostPosted: Thu Dec 21, 2017 12:38 am    Post subject: Scanning String with lua and result will be in ListBox[HELP] Reply with quote

How to scan a string using Lua and the result will be inside ListBox
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 31

Joined: 09 Aug 2013
Posts: 765

PostPosted: Thu Dec 21, 2017 10:34 pm    Post subject: Reply with quote

Not really sure what you mean, you can use an aobscan if you find the bytes or you can use a memscan and provide the appropriate values to scan for the string, neither will automatically put the result in a ListBox for you however, you'd need to take the result from the StringList or FoundList and put it in a ListBox after the scan is finished.
Back to top
View user's profile Send private message
Lynxz Gaming
Advanced Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 67

PostPosted: Fri Dec 22, 2017 5:00 am    Post subject: Reply with quote

FreeER wrote:
Not really sure what you mean, you can use an aobscan if you find the bytes or you can use a memscan and provide the appropriate values to scan for the string, neither will automatically put the result in a ListBox for you however, you'd need to take the result from the StringList or FoundList and put it in a ListBox after the scan is finished.

sorry for my bad english xD, i want CEEdit scan a string, and the scan result will be on CEListBox.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 31

Joined: 09 Aug 2013
Posts: 765

PostPosted: Fri Dec 22, 2017 7:44 am    Post subject: Reply with quote

Not so much your English as the actual explanation but I suppose that's enough to work with... I'd expect something like this to work. Oh, if you're not certain whether the strings will always be wide strings / unicode or not you'll probably want to provide a checkbox for the user to tell you
Code:
-- get string from editbox
local string = CETrainer.CEEdit1.Text

-- if edit box is empty, do nothing. Could do more checks for if it's just whitespace but...
if string == "" then return end

-- use checkbox to determine which function to use to get bytes
-- if you know it's always one or the other then just use the proper one :)
local byteFunction = CETrainer.CECheckbox1.Checked and wideStringToByteTable or stringToByteTable

-- get the bytes
local bytes = byteFunction(string)

-- turn byte table into hex string
local bytestring = ''
for k,v in ipairs(bytes) do
  bytestring = bytestring .. ('%x'):format(v)
end

-- scan for bytes
local results = AOBScan(bytestring)

-- if not found show message and quit
if not results then
  ShowMessage('No results found')
  return
end

-- otherwise, update list box
CETrainer.CEListBox1.Items = results


Replace "CETrainer" with whatever your form name is, pretty sure CETrainer is the default for trainers that CE generates for you but if you create your own then it's probably UDF1, for User Defined Form, or something like that by default.

Replace "CEEdit1" with the name of your edit box, "CEListBox1" with the name of your list box, and "CECheckbox1" with the name of your checkbox, all of those are the defaults for the first ones created.
Back to top
View user's profile Send private message
Lynxz Gaming
Advanced Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 67

PostPosted: Fri Dec 22, 2017 10:48 pm    Post subject: Reply with quote

Thank you for reply! and it works! Very Happy
but what if the result is a string too?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 31

Joined: 09 Aug 2013
Posts: 765

PostPosted: Sat Dec 23, 2017 12:31 am    Post subject: Reply with quote

results, the return value of AOBScan, will be either nil if nothing is found or a StringList object which contains strings. Since most things in CE happen to be strings that shouldn't be an issue most of the time, but if you do need to convert one from a hex string to a number you can use tonumber(thestring, 16) or getAddress/getAddressSafe (which can also handle symbol names like modules and registered symbols, the "safe" version will simply return nil if you give it something it can't figure out).
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