Guest User

Untitled

a guest
Jul 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import time
  2.  
  3. def pway ():
  4. all = set(Functions(MinEA(), MaxEA()))
  5. leaf = all.copy()
  6.  
  7. for ea in all:
  8. for xref in CodeRefsTo(ea, 1):
  9. func = GetFunctionAttr(ea, FUNCATTR_START)
  10. try:
  11. leaf.remove(func)
  12. except KeyError, e:
  13. # already removed.
  14. pass
  15.  
  16. return leaf
  17.  
  18. def away ():
  19. ea = SegByName(".text")
  20. end = SegEnd(ea)
  21.  
  22. allFuncs = list(Functions(ea, end))
  23.  
  24. while True:
  25. if ea > end:
  26. break
  27.  
  28. call = FindBinary(ea, SEARCH_DOWN, "E8", 16)
  29.  
  30. if call == -1:
  31. print "wtf -1\n"
  32. break
  33.  
  34. funcStart = GetFunctionAttr(call, FUNCATTR_START)
  35.  
  36. try:
  37. allFuncs.remove(funcStart)
  38. ea = GetFunctionAttr(call, FUNCATTR_END)
  39. except ValueError:
  40. ea = call+1
  41. pass
  42.  
  43. return allFuncs
  44.  
  45.  
  46. start = time.clock()
  47. for i in xrange(100):
  48. away()
  49. print "away took %.2f clock cycles" % (time.clock() - start)
  50.  
  51. start = time.clock()
  52. for i in xrange(100):
  53. pway()
  54. print "pway took %.2f clock cycles" % (time.clock() - start)
Add Comment
Please, Sign In to add comment