Advertisement
EliteAnax17

Untitled

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