OLD | NEW |
| (Empty) |
1 /* Bra.h -- Branch converters for executables | |
2 2008-10-04 : Igor Pavlov : Public domain */ | |
3 | |
4 #ifndef __BRA_H | |
5 #define __BRA_H | |
6 | |
7 #include "Types.h" | |
8 | |
9 /* | |
10 These functions convert relative addresses to absolute addresses | |
11 in CALL instructions to increase the compression ratio. | |
12 | |
13 In: | |
14 data - data buffer | |
15 size - size of data | |
16 ip - current virtual Instruction Pinter (IP) value | |
17 state - state variable for x86 converter | |
18 encoding - 0 (for decoding), 1 (for encoding) | |
19 | |
20 Out: | |
21 state - state variable for x86 converter | |
22 | |
23 Returns: | |
24 The number of processed bytes. If you call these functions with multiple cal
ls, | |
25 you must start next call with first byte after block of processed bytes. | |
26 | |
27 Type Endian Alignment LookAhead | |
28 | |
29 x86 little 1 4 | |
30 ARMT little 2 2 | |
31 ARM little 4 0 | |
32 PPC big 4 0 | |
33 SPARC big 4 0 | |
34 IA64 little 16 0 | |
35 | |
36 size must be >= Alignment + LookAhead, if it's not last block. | |
37 If (size < Alignment + LookAhead), converter returns 0. | |
38 | |
39 Example: | |
40 | |
41 UInt32 ip = 0; | |
42 for () | |
43 { | |
44 ; size must be >= Alignment + LookAhead, if it's not last block | |
45 SizeT processed = Convert(data, size, ip, 1); | |
46 data += processed; | |
47 size -= processed; | |
48 ip += processed; | |
49 } | |
50 */ | |
51 | |
52 #define x86_Convert_Init(state) { state = 0; } | |
53 SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding
); | |
54 SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); | |
55 SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); | |
56 SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); | |
57 SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); | |
58 SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); | |
59 | |
60 #endif | |
OLD | NEW |