ROSE 0.11.145.147
Enumerations | Functions
Rose::BinaryAnalysis::ByteOrder Namespace Reference

Description

Definitions dealing with byte order.

Enumerations

enum  Endianness {
  ORDER_UNSPECIFIED =0 ,
  ORDER_LSB ,
  ORDER_MSB ,
  BE = ORDER_MSB ,
  EL = ORDER_LSB
}
 Byte order. More...
 

Functions

Endianness hostOrder ()
 Byte order of host machine.
 
void convert (void *bytes, size_t nbytes, Endianness from, Endianness to)
 Convert data from one byte order to another in place.
 
template<class T >
std::enable_if< std::is_integral< T >::value, T >::type swapBytes (const T &x)
 Reverse bytes.
 
template<class T >
std::enable_if< std::is_integral< T >::value, T >::type leToHost (const T &x)
 Convert a little-endian integer to host order.
 
template<class T >
std::enable_if< std::is_integral< T >::value, T >::type beToHost (const T &x)
 Convert a big-endian integer to host order.
 
template<class T >
std::enable_if< std::is_integral< T >::value, T >::type diskToHost (Endianness sex, const T &x)
 Convert specified order to host order.
 
template<class Source , class Destination >
void hostToDisk (Endianness sex, const Source &src, Destination *dst, typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *=nullptr)
 Convert host value to specified endianness.
 
Endianness host_order ()
 
int8_t swap_bytes (int8_t n)
 
uint8_t swap_bytes (uint8_t n)
 
int16_t swap_bytes (int16_t n)
 
uint16_t swap_bytes (uint16_t n)
 
int32_t swap_bytes (int32_t n)
 
uint32_t swap_bytes (uint32_t n)
 
int64_t swap_bytes (int64_t n)
 
uint64_t swap_bytes (uint64_t n)
 
int8_t le_to_host (int8_t n)
 
uint8_t le_to_host (uint8_t n)
 
int16_t le_to_host (int16_t n)
 
uint16_t le_to_host (uint16_t n)
 
int32_t le_to_host (int32_t n)
 
uint32_t le_to_host (uint32_t n)
 
int64_t le_to_host (int64_t n)
 
uint64_t le_to_host (uint64_t n)
 
void host_to_le (unsigned h, uint8_t *n)
 
void host_to_le (unsigned h, uint16_t *n)
 
void host_to_le (unsigned h, uint32_t *n)
 
void host_to_le (rose_addr_t h, uint64_t *n)
 
void host_to_le (int h, int8_t *n)
 
void host_to_le (int h, int16_t *n)
 
void host_to_le (int h, int32_t *n)
 
void host_to_le (int64_t h, int64_t *n)
 
void host_to_le (RelativeVirtualAddress h, uint32_t *n)
 
void host_to_le (RelativeVirtualAddress h, uint64_t *n)
 
uint8_t be_to_host (uint8_t n)
 
uint16_t be_to_host (uint16_t n)
 
uint32_t be_to_host (uint32_t n)
 
uint64_t be_to_host (uint64_t n)
 
int8_t be_to_host (int8_t n)
 
int16_t be_to_host (int16_t n)
 
int32_t be_to_host (int32_t n)
 
int64_t be_to_host (int64_t n)
 
void host_to_be (unsigned h, uint8_t *n)
 
void host_to_be (unsigned h, uint16_t *n)
 
void host_to_be (unsigned h, uint32_t *n)
 
void host_to_be (rose_addr_t h, uint64_t *n)
 
void host_to_be (int h, int8_t *n)
 
void host_to_be (int h, int16_t *n)
 
void host_to_be (int h, int32_t *n)
 
void host_to_be (int64_t h, int64_t *n)
 
void host_to_be (RelativeVirtualAddress h, uint32_t *n)
 
void host_to_be (RelativeVirtualAddress h, uint64_t *n)
 
uint8_t disk_to_host (Endianness sex, uint8_t n)
 
uint16_t disk_to_host (Endianness sex, uint16_t n)
 
uint32_t disk_to_host (Endianness sex, uint32_t n)
 
uint64_t disk_to_host (Endianness sex, uint64_t n)
 
int8_t disk_to_host (Endianness sex, int8_t n)
 
int16_t disk_to_host (Endianness sex, int16_t n)
 
int32_t disk_to_host (Endianness sex, int32_t n)
 
int64_t disk_to_host (Endianness sex, int64_t n)
 
void host_to_disk (Endianness sex, unsigned h, uint8_t *np)
 
void host_to_disk (Endianness sex, unsigned h, uint16_t *np)
 
void host_to_disk (Endianness sex, unsigned h, uint32_t *np)
 
void host_to_disk (Endianness sex, rose_addr_t h, uint64_t *np)
 
void host_to_disk (Endianness sex, RelativeVirtualAddress h, uint64_t *np)
 
void host_to_disk (Endianness sex, int h, int8_t *np)
 
void host_to_disk (Endianness sex, int h, int16_t *np)
 
void host_to_disk (Endianness sex, int h, int32_t *np)
 
void host_to_disk (Endianness sex, int64_t h, int64_t *np)
 
template<class Source , class Destination >
void hostToLe (const Source &src, Destination *dst, typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *=nullptr)
 Convert host order to little-endian.
 
template<class T >
void hostToLe (const RelativeVirtualAddress &in, T *out)
 Convert host order to little-endian.
 
template<class Source , class Destination >
void hostToBe (const Source &src, Destination *dst, typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *=nullptr)
 Convert host order to big-endian.
 
template<class T >
void hostToBe (const RelativeVirtualAddress &in, T *out)
 Convert host order to big-endian.
 

Enumeration Type Documentation

◆ Endianness

Byte order.

Enumerator
ORDER_UNSPECIFIED 

Endianness is unspecified and unknown.

ORDER_LSB 

Least significant byte first, i.e., little-endian.

ORDER_MSB 

Most significant byte first, i.e., big-endian.

BE 

Big-endian.

EL 

Little-endian.

Definition at line 19 of file ByteOrder.h.

Function Documentation

◆ swapBytes()

template<class T >
std::enable_if< std::is_integral< T >::value, T >::type Rose::BinaryAnalysis::ByteOrder::swapBytes ( const T &  x)

Reverse bytes.

Definition at line 37 of file ByteOrder.h.

References Rose::BitOps::reverseBytes().

◆ leToHost()

template<class T >
std::enable_if< std::is_integral< T >::value, T >::type Rose::BinaryAnalysis::ByteOrder::leToHost ( const T &  x)

Convert a little-endian integer to host order.

Definition at line 44 of file ByteOrder.h.

References Rose::BitOps::fromLittleEndian(), and leToHost().

Referenced by leToHost().

◆ beToHost()

template<class T >
std::enable_if< std::is_integral< T >::value, T >::type Rose::BinaryAnalysis::ByteOrder::beToHost ( const T &  x)

Convert a big-endian integer to host order.

Definition at line 51 of file ByteOrder.h.

References Rose::BitOps::fromBigEndian().

◆ diskToHost()

template<class T >
std::enable_if< std::is_integral< T >::value, T >::type Rose::BinaryAnalysis::ByteOrder::diskToHost ( Endianness  sex,
const T &  x 
)

Convert specified order to host order.

Definition at line 58 of file ByteOrder.h.

References Rose::BitOps::fromBigEndian(), Rose::BitOps::fromLittleEndian(), and ORDER_LSB.

◆ hostToLe() [1/2]

template<class Source , class Destination >
void Rose::BinaryAnalysis::ByteOrder::hostToLe ( const Source &  src,
Destination *  dst,
typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *  = nullptr 
)

Convert host order to little-endian.

The source value is first converted to the type of the destination argument and an exception is raised if the source value is not representable as the destination type. Then the converted source value is byte swapped if necessary as it is stored in the destination argument.

Definition at line 71 of file ByteOrder.h.

References Rose::BitOps::toLittleEndian().

Referenced by hostToLe().

◆ hostToLe() [2/2]

template<class T >
void Rose::BinaryAnalysis::ByteOrder::hostToLe ( const RelativeVirtualAddress in,
T *  out 
)

Convert host order to little-endian.

The source value is first converted to the type of the destination argument and an exception is raised if the source value is not representable as the destination type. Then the converted source value is byte swapped if necessary as it is stored in the destination argument.

Definition at line 79 of file ByteOrder.h.

References hostToLe(), and Rose::BinaryAnalysis::RelativeVirtualAddress::rva().

◆ hostToBe() [1/2]

template<class Source , class Destination >
void Rose::BinaryAnalysis::ByteOrder::hostToBe ( const Source &  src,
Destination *  dst,
typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *  = nullptr 
)

Convert host order to big-endian.

The source value is first converted to the type of the destination argument and an exception is raised if the source value is not representable as the destination type. Then the converted source value is byte swapped if necessary as it is stored in the destination argument.

Definition at line 93 of file ByteOrder.h.

References Rose::BitOps::toBigEndian().

Referenced by hostToBe().

◆ hostToBe() [2/2]

template<class T >
void Rose::BinaryAnalysis::ByteOrder::hostToBe ( const RelativeVirtualAddress in,
T *  out 
)

Convert host order to big-endian.

The source value is first converted to the type of the destination argument and an exception is raised if the source value is not representable as the destination type. Then the converted source value is byte swapped if necessary as it is stored in the destination argument.

Definition at line 101 of file ByteOrder.h.

References hostToBe(), and Rose::BinaryAnalysis::RelativeVirtualAddress::rva().

◆ hostToDisk()

template<class Source , class Destination >
void Rose::BinaryAnalysis::ByteOrder::hostToDisk ( Endianness  sex,
const Source &  src,
Destination *  dst,
typename std::enable_if< std::is_integral< Source >::value &&std::is_integral< Destination >::value >::type *  = nullptr 
)

Convert host value to specified endianness.

The source value is first converted to the type of the destination argument and an exception is raised if the source value is not representable as the destination type. Then the converted source value is byte swapped if necessary as it is stored in the destination argument.

Definition at line 113 of file ByteOrder.h.

References ORDER_LSB, Rose::BitOps::toBigEndian(), and Rose::BitOps::toLittleEndian().