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 


how to return the result of the work AOBScan of function?

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

Joined: 27 Jun 2013
Posts: 11
Location: Russian Federation

PostPosted: Sun Jul 21, 2013 8:36 am    Post subject: how to return the result of the work AOBScan of function? Reply with quote

All good health.
I have a problem, I wrote a function, but the result is stored only inside it. What you need to do that would result could be used outside the function.I need to pass the returned result in the Label.

Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="16">
  <Forms>
    <UDF1 Class="TCEForm" Encoding="Ascii85">ZH}JRf-n=7OF[Wk.1;]@U5vOpXq7l%FahJ;RG_n7[7bS!zx,aZ$*HZXy+WAe93[N.le5$UvUi_)DCeDHD:v!#med1F={?-yIe.8Xqe}izM1Dycp{9zbt1UbsS/1NhutxVCSdWtoN}Vn*dpoKg[Y/fzz1cJq))B[cy_GO1-?d@76inL!vn#.,A.8#pTR*[HHeXxDi5B%=0vQxK]gN^4XZYV}56+%A5,WK!1uILdqNT,[STQ[#wD[jp</UDF1>
  </Forms>
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>function FormShow(sender)

end
function FormClose(sender)

return caHide --Possible options: caHide, caFree, caMinimize, caNone
end
function ByteScan(signature)
  local results = AOBScan(signature) --, "+X-C-W")
  if (results == nil) then
        messageDialog("Error. Introduction of address was not found. \n\r Continuation of the program can not be!",1, 2)
        return
  end

  local address = stringlist_getString(results, 0)
  print("seal inside the function:     Status= "..address)
  return address
end
form_show(UDF1)
control_setCaption(UDF1_CELabel2, "no value...")
print(" ")
print('string 35 uncommented out: print("Status=" ..address)')
print(" ")
print("---------------------------------------AOBScan----------------------------------")
status = "2000****00000000****0000000000000000000000000000F412****"
ByteScan(status)
print("-----------------------------------------------------------------------------------")
--name = string.format('0x%08X', address)
print("ByteScan(status)="..status)
print("-----------------------------------------------------------------------------------")
print()

control_setCaption(UDF1_CELabel2, address)
print("Status= "..address)
</LuaScript>
</CheatTable>

address exists only inside ByteSсan (). How to pass the value variable address in Label
Unfortunately
Sorry, but you can't post url's yet
Screenshot -> http ://pixs.ru/showimage/AOBScanbmp_8660613_8519123.jpg
Back to top
View user's profile Send private message Send e-mail
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Jul 21, 2013 9:29 am    Post subject: Reply with quote

Define the ByteScan(status) as any var.. or don't use local in the ByteScan function, so it'll be global and you'll be able to access it from any function.
And don't forget destroying the aobscan results.

Code:
function ByteScan(signature)
  local results = AOBScan(signature) --, "+X-C-W")
  if (results == nil) then
        messageDialog("Error. Introduction of address was not found. \n\r Continuation of the program can not be!",1, 2)
        return nil
  end

  local address = stringlist_getString(results, 0)
  print("seal inside the function:     Status= "..address)
  object_destroy(results);
  return address
end

form_show(UDF1)
control_setCaption(UDF1_CELabel2, "no value...")

AddressResult = ByteScan(status) -- Defines Address as AddressResult

if AddressResult~=nil then
   print(" ")
   print('string 35 uncommented out: print("Status=" ..address)')
   print(" ")
   print("---------------------------------------AOBScan----------------------------------")
   status = "2000****00000000****0000000000000000000000000000F412****"
   print("-----------------------------------------------------------------------------------")
   --name = string.format('0x%08X', AddressResult)
   print("ByteScan(status)="..status)
   print("-----------------------------------------------------------------------------------")
   print()
   control_setCaption(UDF1_CELabel2, AddressResult)
   print("Status= "..AddressResult)
end

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Megaladon
Newbie cheater
Reputation: 0

Joined: 27 Jun 2013
Posts: 11
Location: Russian Federation

PostPosted: Sun Jul 21, 2013 9:51 am    Post subject: Reply with quote

Thanks, it works.
another question, why do we need and what options do +X-C-W ?

They had to be commented out, since they refused to work oabscan.

I understand that they need to scan the protected memory block or blocks of code from executing. how to use these parameters?
Back to top
View user's profile Send private message Send e-mail
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Jul 21, 2013 9:53 am    Post subject: Reply with quote

are you sure?
I never use +X-C-W.

Post here what you tried.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Megaladon
Newbie cheater
Reputation: 0

Joined: 27 Jun 2013
Posts: 11
Location: Russian Federation

PostPosted: Sun Jul 21, 2013 10:42 am    Post subject: Reply with quote

I did it based on the example.

There Autor used the syntax local results = AOBScan (signature, "+X-C-W").

But I have Aobscan as such refused to work.

I resulted to form local results = AOBScan (signature) commenting out "+X-C-W"
Back to top
View user's profile Send private message Send e-mail
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Jul 21, 2013 11:17 am    Post subject: Reply with quote

Dunno,
Here's a working script, works perfectly for me.
Code:
function ByteScan(ArrayOfByte)
   local Results = AOBScan(ArrayOfByte)
   if Results~=nil then
      local AddressTable = {}
      local count = stringlist_getCount(Results)
      for i = 1, count do
         address = stringlist_getString(Results,i-1)
         AddressTable[i] = address
      end
      object_destroy(Results);
    return AddressTable, count
    end
end
function unpack2(t, i)
   i = i or 1
   if t[i] ~= nil then
      return "Address : "..t[i], unpack(t, i + 1)
   end
end
Table,ResultsCount = ByteScan("00 00 00 00 11 22 0F 00 00 00 00") -- Example
--[[
    ByteScan,
    Will return us a table with all addresses.
    We can use unpack command to get all address in 1 single line.
    instead of doing Table[1] .. Table[10] and etc.
    Beaware, I defined Table to to get AddressTable from ByteScan
    You may change it whatever you want.

    Also, if you only define 1 var for Bytescan, that var will only obtain AddressTable
    Theres no other var that'll receive Count.
    So pay attention to it.

    P.S
    You can use unpack(Table) to receive all addresses
    Or use unpack2(Table), so you won't get confused between address to other address
    Unpack will return you this (If you print it ofcourse), but different addressese
    05BB3EFB 05BB3F1B 0F219709 0F219729
    Unpack2 will return you this
    Address : 05BB3EFB Address : 05BB3F1B Address : 0F219709 Address : 0F219729

    You can edit unpack2 function,
    And replace
    "Address : "..t[i]
    with
    "Address : "..t[i].."\n"
    Which will return each address in new line
    You won't notice that its as a new line if you print it.
    But if you copy paste, it'll paste you each address in new line like this
    Address : 05BB3EFB
    Address : 05BB3F1B
    Address : 0F219709
    Address : 0F219729
   
   Ofcourse you can print all address separately by executing this command
   for i = 1, #Table do --> Table = the var who received AddressTable
      print("Address : "..Table[i]
   end
--]]

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
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