Advertisement
Guest User

FindHelper.lua for MMExtension

a guest
Jan 1st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. local i4, i2, i1, u4, u2, u1, i8, u8 = mem.i4, mem.i2, mem.i1, mem.u4, mem.u2, mem.u1, mem.i8, mem.u8
  2. local format = string.format
  3.  
  4. function FR(p, p1, start, stop)
  5.     p1 = p1 or p + 1
  6.     local t = {}
  7.     local t1 = {}
  8.  
  9.     local last
  10.     for i = (start or 0x401000), (stop or select(Game.Version - 5, 0x4B9000, 0x4D8000, 0x508000)) do
  11.         local n = mem.GetInstructionSize(i)
  12.         local _, IsJump = mem.GetHookSize(i)
  13.         if not IsJump then
  14.             local op = u1[i]
  15.             for i = i + 1, i + n - 4 do
  16.                 local v = u4[i]
  17.                 if v >= p and v < p1 then
  18.                     if i ~= last then
  19.                         local t = (op ~= 0x68 and t or t1)  -- put "push XXX" in t1
  20.                         t[#t+1], last = format("0x%X", i), i
  21.                     end
  22.                 end
  23.             end
  24.         end
  25.     end
  26.     return "Ref{".._G.table.concat(t, ", ").."}", "Ref{".._G.table.concat(t1, ", ").."}"
  27. end
  28.  
  29. function FR1(p, p1, start, stop)
  30.     p1 = p1 or p + 1
  31.     local t = {}
  32.     local t1 = {}
  33.  
  34.     local last
  35.     for i = (start or 0x401000), (stop or select(Game.Version - 5, 0x4B9000, 0x4D8000, 0x508000)) do
  36.         local n, IsJump = mem.GetInstructionSize(i)
  37.         if not IsJump then
  38.             local op = u1[i]
  39.             for i = i + 1, i + n - 1 do
  40.                 local v = u1[i]
  41.                 if v >= p and v < p1 then
  42.                     if i ~= last then
  43.                         local t = (op ~= 0x68 and t or t1)  -- put "push XXX" in t1
  44.                         t[#t+1], last = format("0x%X", i), i
  45.                     end
  46.                 end
  47.             end
  48.         end
  49.     end
  50.     return "Ref{".._G.table.concat(t, ", ").."}", "Ref{".._G.table.concat(t1, ", ").."}"
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement