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