Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. GetLuaEngine().MenuItem5.doClick() -- crear lua output
  2. --------------------------------------------------------------------------------
  3. function check(value)
  4.   if value == nil then
  5.   print("nil")
  6.   else
  7.     print(tostring(value))
  8.   end
  9. end
  10. --------------------------------------------------------------------------------
  11. function init_DotNetInfo()
  12.   -- I didn't found a better way to access "dotnetinfo.lua" local functions
  13.   miDotNetInfoClick(getMainForm()) -- opens ".Net Info" form
  14.   df.Hide() -- hides just opened ".Net Info" form
  15. end
  16. --------------------------------------------------------------------------------
  17. function mono_findClassEx(namespace, classname)
  18.   if namespace==nil then
  19.     print("[mono_findClassEx]: Invalid parameters!" .. namespace .. "." .. classname)
  20.   else
  21.     if classname==nil then
  22.       classname=namespace
  23.       namespace=''
  24.     end
  25.     if DataSource.Domains==nil then
  26.       --print("[mono_findClassEx]: DataSource is not initialized! Open .Net Info once")
  27.       init_DotNetInfo()
  28.     end
  29.     for _, Domain in ipairs(DataSource.Domains) do
  30.       if Domain.Images == nil then
  31.         DataSource.getImages(Domain)
  32.       end
  33.       for _, Image in ipairs(Domain.Images) do
  34.         if Image.Classes == nil then
  35.           Image.Classes = {}
  36.           Image.Classes.Busy = true
  37.           DataSource.getClasses(Image)
  38.           Image.Classes.Busy = nil
  39.         end
  40.         for _, Class in ipairs(Image.Classes) do
  41.           if Class.FullName == classname then return Class.Handle end
  42.         end
  43.       end
  44.     end
  45.   end
  46.   return nil
  47. end
  48. --------------------------------------------------------------------------------
  49. function mono_findMethodEx(namespace, classname, methodname)
  50.   if namespace==nil or classname==nil then
  51.     print("[mono_findMethodEx]: Invalid parameters! " .. namespace .. "." .. classname .. ":" .. methodname)
  52.   else
  53.     if methodname==nil then
  54.       methodname=classname
  55.       classname=namespace
  56.       namespace=''
  57.     end
  58.     local class = mono_findClassEx(namespace, classname)
  59.     if class==nil or class==0 then
  60.       print("[mono_findMethodEx]: Class not found! " .. namespace .. "." .. classname)
  61.     else
  62.       return mono_class_findMethod(class, methodname)
  63.     end
  64.   end
  65.   return nil
  66. end
  67. --------------------------------------------------------------------------------
  68. function mono_symbolLookupCallbackEx(symbol)
  69.   local namespace, classname, methodname = SplitDotNetName(symbol)
  70.   if (methodname=='') or (classname=='') then
  71.     --print("[mono_symbolLookupCallbackEx]: Invalid parameters! " .. namespace .. "." .. classname .. ":" .. methodname)
  72.   else
  73.     if monopipe == nil or monopipe.IL2CPP then
  74.       --print("[mono_symbolLookupCallbackEx]: Unable to use mono features.")
  75.     else
  76.       local method = mono_findMethodEx(namespace, classname, methodname)
  77.       if method==nil or method==0 then
  78.         print("[mono_symbolLookupCallbackEx]: Method not found! " .. namespace .. "." .. classname .. ":" .. methodname)
  79.       else
  80.         local methodaddress = mono_compile_method(method)
  81.         if methodaddress == nil or methodaddress == 0 then
  82.           print("[mono_symbolLookupCallbackEx]: mono_compile_method error!")
  83.         else
  84.           return methodaddress
  85.         end
  86.       end
  87.     end
  88.   end
  89.   return nil
  90. end
  91. --------------------------------------------------------------------------------
  92. function mono_activate()
  93.   if getOpenedProcessID()==0 then
  94.     print("[mono_activate]: No process opened!")
  95.   else
  96.     if monopipe==nil and LaunchMonoDataCollector()==0 then
  97.       print("[mono_activate]: LaunchMonoDataCollector error!")
  98.     else
  99.       if mono_SymbolLookupID~=nil then
  100.         unregisterSymbolLookupCallback(mono_SymbolLookupID)
  101.         mono_SymbolLookupID=nil
  102.       end
  103.       mono_SymbolLookupID=registerSymbolLookupCallback(mono_symbolLookupCallbackEx, slNotSymbol)
  104.     end
  105.   end
  106. end
  107. --------------------------------------------------------------------------------
  108. function mono_deactivate()
  109.   if monopipe then
  110.     monopipe.OnTimeout()
  111.   end
  112. end
  113. --------------------------------------------------------------------------------
  114. -- Scans the memory near <mono_symbol> for <aob> and returns it's address
  115. function mono_AOBScanUnique(aob,mono_symbol)
  116.   local result = nil
  117.   local mono_address = mono_symbolLookupCallbackEx(mono_symbol)
  118.   if mono_address == nil then
  119.     print("[mono_AOBScanUnique]: Mono symbol not found! " .. mono_symbol)
  120.   else
  121.     local ji = mono_getJitInfo(mono_address)
  122.     local start = ji.code_start -- Method start address
  123.     local stop = start + ji.code_size -- Size of the method
  124.  
  125.     local protectionFlags = "*X*C*W"
  126.     local alignmentType = fsmNotAligned
  127.     local alignmentParam = nil
  128.     local isHexadecimalInput = true
  129.     local isNotABinaryString = true
  130.     local isunicodescan = false
  131.     local iscasesensitive = false
  132.     local ms = createMemScan()
  133.  
  134.       ms.firstScan(soExactValue, vtByteArray, nil, aob, nil, start, stop,
  135.       protectionFlags, alignmentType, alignmentParam,
  136.       isHexadecimalInput, isNotABinaryString, isunicodescan, iscasesensitive)
  137.       ms.waitTillDone()
  138.       local fl = createFoundList(ms)
  139.     fl.initialize()
  140.     if ms.FoundList.getCount()==0 then
  141.       print("[mono_aobscan]: AOB [" .. aob .. "] not found near " .. mono_symbol)
  142.     else
  143.       if fl.getCount()>1 then
  144.         print("[mono_aobscan]: AOB [" .. aob .. "] is not unique near " .. mono_symbol)
  145.       else
  146.         result = fl[0]
  147.       end
  148.     end
  149.     fl.deinitialize()
  150.       ms.destroy()
  151.   end
  152.     return result
  153. end
  154. --------------------------------------------------------------------------------
  155. -- Registers <new_symbol> for <aob> near <mono_symbol> with <offset> if needed
  156. function mono_register(new_symbol, aob, mono_symbol, offset)
  157.   if offset == nil then offset = 0 end
  158.   local aob_address = mono_AOBScanUnique(aob, mono_symbol)
  159.   unregisterSymbol(new_symbol)
  160.   if aob_address ~= nil then
  161.     registerSymbol(new_symbol,tonumber(aob_address,16)+offset)
  162.   end
  163. end
  164. --------------------------------------------------------------------------------