Blame | Last modification | View Log | RSS feed
/* Bra.h -- Branch converters for executables2008-10-04 : Igor Pavlov : Public domain */#ifndef __BRA_H#define __BRA_H#include "Types.h"/*These functions convert relative addresses to absolute addressesin CALL instructions to increase the compression ratio.In:data - data buffersize - size of dataip - current virtual Instruction Pinter (IP) valuestate - state variable for x86 converterencoding - 0 (for decoding), 1 (for encoding)Out:state - state variable for x86 converterReturns:The number of processed bytes. If you call these functions with multiple calls,you must start next call with first byte after block of processed bytes.Type Endian Alignment LookAheadx86 little 1 4ARMT little 2 2ARM little 4 0PPC big 4 0SPARC big 4 0IA64 little 16 0size 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 blockSizeT 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 ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);#endif