Вы находитесь на странице: 1из 2

/* Bra.

h -- Branch converters for executables


2009-02-07 : Igor Pavlov : Public domain */
#ifndef __BRA_H
#define __BRA_H
#include "Types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
These functions convert relative addresses to absolute addresses
in CALL instructions to increase the compression ratio.
In:
data
size
ip
state
encoding

Out:
state

- state variable for x86 converter

data buffer
size of data
current virtual Instruction Pinter (IP) value
state variable for x86 converter
0 (for decoding), 1 (for encoding)

Returns:
The number of processed bytes. If you call these functions with multiple cal
ls,
you must start next call with first byte after block of processed bytes.
Type

Endian Alignment LookAhead

x86
ARMT
ARM
PPC
SPARC
IA64

little
little
little
big
big
little

1
2
4
4
4
16

4
2
0
0
0
0

size must be >= Alignment + LookAhead, if it's not last block.


If (size < Alignment + LookAhead), converter returns 0.
Example:
UInt32 ip = 0;
for ()
{
; size must be >= Alignment + LookAhead, if it's not last block
SizeT processed = Convert(data, size, ip, 1);
data += processed;
size -= processed;
ip += processed;
}
*/
#define x86_Convert_Init(state) { state = 0; }
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding
);
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);

SizeT
SizeT
SizeT
SizeT

ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);


PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);

#ifdef __cplusplus
}
#endif
#endif

Вам также может понравиться