BranchARM.c 579 B

1234567891011121314151617181920212223242526
  1. /* BranchARM.c */
  2. #include "BranchARM.h"
  3. UInt32 ARM_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
  4. {
  5. UInt32 i;
  6. for (i = 0; i + 4 <= size; i += 4)
  7. {
  8. if (data[i + 3] == 0xEB)
  9. {
  10. UInt32 dest;
  11. UInt32 src = (data[i + 2] << 16) | (data[i + 1] << 8) | (data[i + 0]);
  12. src <<= 2;
  13. if (encoding)
  14. dest = nowPos + i + 8 + src;
  15. else
  16. dest = src - (nowPos + i + 8);
  17. dest >>= 2;
  18. data[i + 2] = (Byte)(dest >> 16);
  19. data[i + 1] = (Byte)(dest >> 8);
  20. data[i + 0] = (Byte)dest;
  21. }
  22. }
  23. return i;
  24. }