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 


So... I made this

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Mon Oct 12, 2015 2:53 pm    Post subject: So... I made this This post has 1 review(s) Reply with quote

Hey guys, so I've been teaching myself some LUA, and thanks to the many of you that helped me out, I was able to make this function. I actually had it up before but it was quite broken at the time so I took it down, but now I think its pretty ok. It's just my own version of an AOB scan using LUA, with an added parameter. So the syntax is as follows:

lua_aobscan("aob_name","aob_module","aob",#)

1) aob_name is just what you want your aob to be called, the same as what you'd enter in aobscan(____,90 90 90 90) and registersymbol(____)

2) aob_module is the module name, here's the cool part, there is only one syntax for this function. If the aob_module field is left as "" then it will perform a normal LUA aobscan, but if you put in a module name however, it'll perform a LUA equivalent of the aobscanmodule (faster).

3) aob is just your array of bytes

4) My little touch of salt, an indexing function. Say you want a really specific injection point, but when you scan for the aob you get more than one result, and yours happens to not be the first on the list, or in some cases the aob is just not unique at all. You use this parameter to pick the one you want. If your aob IS unique, leave this a value of 1, but if your aob ISN'T unique and appears say, 4th on a list of aobs, you'd enter a value of 4.

This function registers the symbol for you automatically, and has some error prevention. If you mistyped the AOB, and it's not found, LUA will print a message saying it wasn't found. If you mis-type a module name, it will also print a error saying the module wasn't found. If everything is fine, it won't say anything. The errors print BEFORE you close the asm window, so you'd know something was wrong even before you assigned it to the cheat table, or before you close it from editing a current script.

Just a comparison of each:

normal aobscan:
Code:
[Enable]

aobscan(my_aob1,12 34 56 78)
registersymbol(my_aob1)

my aobscan:
Code:
[Enable]

luaCall(lua_aobscan("my_aob1","","12 34 56 78",1)

normal aobscanmodule:
Code:
[Enable]
aobscanmodule(my_aob1,module.exe,12 34 56 78)
registersymbol(my_aob1)

my aobscanmodule
Code:
[Enable]

luaCall(lua_aobscan("my_aob1","module.exe","12 34 56 78",1)

So all in all, you save ONE LINE OF CODE Shocked Throw this in your C.E "autorun" folder if you wanna play around with it, or just have it in case you might need it one day.



luaScripts.lua
 Description:

Download
 Filename:  luaScripts.lua
 Filesize:  1.15 KB
 Downloaded:  1825 Time(s)



Last edited by vng21092 on Mon Oct 12, 2015 5:23 pm; edited 2 times in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 161

Joined: 07 Nov 2008
Posts: 4358
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Oct 12, 2015 3:03 pm    Post subject: Reply with quote

Should be helpful for beginners Very Happy
Lua script also looks good.

Nice.

PS: write new topic in "Cheat Engine Lua Scripting" sub-forum.

PSS: suggestion:

Code:
function lua_aobscan(name,module,bytes,index)
  if index==nil then index=1 end
...
...
        registerSymbol(name,resultSet[index-1])
...
...
          registerSymbol(name,memFoundList.Address[index-1])
...
...
end



So,

lua_aobscan("my_aob1","module.exe","12 34 56 78") will be the same as this
lua_aobscan("my_aob1","module.exe","12 34 56 78",1)

_________________
Back to top
View user's profile Send private message MSN Messenger
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Mon Oct 12, 2015 4:32 pm    Post subject: Reply with quote

hmm that's not a bad idea actually, but I like to see the index. Thanks for the suggestion though Very Happy
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 123

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Oct 12, 2015 7:36 pm    Post subject: Reply with quote

registerSymbol() has a third argument that, when true, will prevent the name from being saved to the table.
This will prevent the name from already being registered when the table opens.
Don't think you'd need all the unregisterSymbol() calls after that.

It would also be nice to have a Lua failure prevent the {$asm} execution of the script too.
Not sure if someone else has a better idea, but assert(false) halts the script.

To coincide with not requiring the index, you could allow them to leave off the module name as well. Smile
Code:
function lua_aobscan(...)
  local i = #arg
  -- check minimum arguments
  if i < 2 then
    showMessage("lua_aobscan failed: strings name and bytes are required")
    assert(false)
  end
  -- declare local variables
  local name, module, bytes, index
  -- initialize index
  if type(arg[i]) == "number" then
    index = arg[i] - 1
    i = i - 1
  else
    index = 0
  end
  -- initialize bytes
  if i == 0 or type(arg[i]) ~= "string" then
    showMessage("lua_aobscan failed: strings name and bytes are required")
    assert(false)
  else
    bytes = arg[i]
    i = i - 1
  end
  -- initialize name
  if i == 0 or type(arg[1]) ~= "string" then
    showMessage("lua_aobscan failed: strings name and bytes are required")
    assert(false)
  else
    name = arg[1]
  end
  -- initialize module
  if i == 2 then
    module = arg[i]
  end
  print("Name: "..name)
  print("Module: "..(module or "no module"))
  print("Bytes: "..bytes)
  print("Index: "..index)
  -- etc. etc. etc.
end
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Mon Oct 12, 2015 8:11 pm    Post subject: Reply with quote

yea I saw that third argument in main.lua, but that isn't why I put the unregisters there. luaCall executes the code when I assign the script to the cheat table or when I press OK after editing it, registering the symbol. So when I actually want to activate the cheat I get an error saying "aob_1 already exists", so I found putting an unregister before registering it removes that problem.
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 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