Procedure.cpp 1.0 KB

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