Procedure.cpp 956 B

1234567891011121314151617181920212223242526272829303132
  1. #include "Procedure.h"
  2. #include "project.h"
  3. #include "scanner.h"
  4. //FunctionType *Function::getFunctionType() const
  5. //{
  6. // return &m_type;
  7. //}
  8. /* Does some heuristic pruning. Looks for ptrs. into the table
  9. * and for addresses that don't appear to point to valid code.
  10. */
  11. void JumpTable::pruneEntries(uint16_t cs)
  12. {
  13. PROG *prg(Project::get()->binary());
  14. for (uint32_t i = start; i < finish; i += 2)
  15. {
  16. uint32_t target = cs + LH(&prg->image()[i]);
  17. if (target < finish && target >= start)
  18. finish = target;
  19. else if (target >= (uint32_t)prg->cbImage)
  20. finish = i;
  21. }
  22. ICODE _Icode; // used as scan input
  23. for (uint32_t i = start; i < finish; i += 2)
  24. {
  25. uint32_t target = cs + LH(&prg->image()[i]);
  26. /* Be wary of 00 00 as code - it's probably data */
  27. if (! (prg->image()[target] || prg->image()[target+1]) || scan(target, _Icode))
  28. finish = i;
  29. }
  30. }