Advertisement
EliteAnax17

Untitled

Mar 28th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. -- range search script --
  2.  
  3. RAM_START = 0x02000000
  4. RAM_SIZE = 0x7E4000
  5. result_table = {}
  6. result_count = 0
  7.  
  8. -- values to check. usually an address range. --
  9. range1 = 0x027E3300
  10. range2 = 0x027E3300
  11.  
  12. local file = assert(io.open("output.txt", "w"))
  13.  
  14. -- 3 functions copied from interwebs
  15. function table.val_to_str ( v )
  16. if "string" == type( v ) then
  17. v = string.gsub( v, "\n", "\\n" )
  18. if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
  19. return "'" .. v .. "'"
  20. end
  21. return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
  22. else
  23. return "table" == type( v ) and table.tostring( v ) or
  24. tostring( v )
  25. end
  26. end
  27.  
  28. function table.key_to_str ( k )
  29. if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
  30. return k
  31. else
  32. return "[" .. table.val_to_str( k ) .. "]"
  33. end
  34. end
  35.  
  36. function table.tostring( tbl )
  37. local result, done = {}, {}
  38. for k, v in ipairs( tbl ) do
  39. table.insert( result, table.val_to_str( v ) )
  40. done[ k ] = true
  41. end
  42. for k, v in pairs( tbl ) do
  43. if not done[ k ] then
  44. table.insert( result,
  45. table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
  46. end
  47. end
  48. return "{" .. table.concat( result, "," ) .. "}"
  49. end
  50.  
  51. if (range1 - 1) < range2 then
  52. for N = 0, RAM_SIZE do
  53. local getvar = memory.readdword(RAM_START + N)
  54. if getvar + 1 > range1 then
  55. if getvar - 1 < range2 then
  56. result_count = result_count + 1
  57. result_table[result_count] = string.format('0x%08X', (RAM_START + N)) -- update table with the pointer to the value, not the value.
  58. end
  59. end
  60. N = N + 4
  61. end
  62. else
  63. print("You cannot have range 1 greater than range 2.")
  64. end
  65.  
  66. file:write(table.tostring(result_table))
  67.  
  68. print("RAM search finished. Result written to output.txt.")
  69.  
  70. file:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement