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