retdec
Public Member Functions | Public Attributes | Private Attributes | List of all members
retdec::fileformat::IntelHexParser Class Reference

The IntelHexParser class - Intel HEX semantical analysis. More...

#include <intel_hex_parser.h>

Collaboration diagram for retdec::fileformat::IntelHexParser:
Collaboration graph
[legend]

Public Member Functions

 IntelHexParser ()
 
Public parsing methods
bool parseFile (const std::string &pathToFile)
 
bool parseStream (std::istream &inputStream)
 
Getters
bool hasEntryPoint () const
 
unsigned long long getEntryPoint () const
 
std::vector< IntelHexSectiongetSectionsByAlignment (unsigned long long alignByValue=0x10000)
 

Static Public Member Functions

Hexadecimal conversions
static unsigned long long strToInt (const std::string &str)
 
static bool isHexadec (char c)
 
static bool isHexadec (const std::string &vec)
 

Public Attributes

std::string errorDesc
 Error description. More...
 
std::vector< IntelHexSectionsections
 Sections (access after methods parseFile() or parseStream() only) More...
 

Private Member Functions

Private parsing methods
bool parse ()
 
void handleData (const IntelHexToken &token)
 
void setOffset (const IntelHexToken &token)
 
void setSegment (const IntelHexToken &token)
 
void setEIP (const IntelHexToken &token)
 
void setCSIP (const IntelHexToken &token)
 

Private Attributes

IntelHexTokenizer tokenizer
 Tokenizer. More...
 
bool mode
 true when 32bit address mode, false when 20bit segment mode More...
 
bool hasEP
 true if entry point record is in file More...
 
std::uint16_t upperAddress
 Upper 16bits of 32bit address. More...
 
std::uint16_t segmenetAddress
 Segment address. More...
 
std::uint32_t EIP
 Entry point (EIP register) More...
 
std::uint16_t CS
 Entry point segment (CS register) More...
 
std::uint16_t IP
 Entry point instruction (IP register) More...
 
IntelHexSection actualSection
 Actual section (one section may be constructed from more than one record) More...
 
retdec::common::Address actualAddress
 Address of last byte saved to actual section. More...
 
unsigned long long index
 Indexing. More...
 

Detailed Description

The IntelHexParser class - Intel HEX semantical analysis.

Constructor & Destructor Documentation

◆ IntelHexParser()

retdec::fileformat::IntelHexParser::IntelHexParser ( )

Constructor

Member Function Documentation

◆ getEntryPoint()

unsigned long long retdec::fileformat::IntelHexParser::getEntryPoint ( ) const

Get entry point

Returns
Entry point

◆ getSectionsByAlignment()

std::vector< IntelHexSection > retdec::fileformat::IntelHexParser::getSectionsByAlignment ( unsigned long long  alignByValue = 0x10000)

Divide sections to more sections by chosen alignment. Function won't affect original vector.

Parameters
alignByValuesize of alignment blocks (default 0x10000)
Returns
Result sections

◆ handleData()

void retdec::fileformat::IntelHexParser::handleData ( const IntelHexToken token)
private

Parse data Intel HEX data record

Parameters
tokenData token received from tokenizer

◆ hasEntryPoint()

bool retdec::fileformat::IntelHexParser::hasEntryPoint ( ) const

Check if entry point record is in input file

Returns
true if entry point record is in input file, false otherwise

◆ isHexadec() [1/2]

bool retdec::fileformat::IntelHexParser::isHexadec ( char  c)
static

Checks whether character is hexadecimal digit

Parameters
cCharacter to check
Returns
true if c is hexadecimal ASCII digit, false otherwise

◆ isHexadec() [2/2]

bool retdec::fileformat::IntelHexParser::isHexadec ( const std::string &  vec)
static

Checks whether characters are hexadecimal digits

Parameters
vecVector of characters to check
Returns
true if vec contains only hexadecimal ASCII digits

◆ parse()

bool retdec::fileformat::IntelHexParser::parse ( )
private

Parsing

Returns
true on success, false otherwise

◆ parseFile()

bool retdec::fileformat::IntelHexParser::parseFile ( const std::string &  pathToFile)

Parse Intel HEX

Parameters
pathToFilePath to input Intel HEX file
Returns
true on success, false otherwise

◆ parseStream()

bool retdec::fileformat::IntelHexParser::parseStream ( std::istream &  inputStream)

Parse Intel HEX

Parameters
inputStreamReference to istream to parse
Returns
true on success, false otherwise

◆ setCSIP()

void retdec::fileformat::IntelHexParser::setCSIP ( const IntelHexToken token)
private

Sets value of entry point

Parameters
tokenCS:IP token

◆ setEIP()

void retdec::fileformat::IntelHexParser::setEIP ( const IntelHexToken token)
private

Sets value of entry point

Parameters
tokenEIP token

◆ setOffset()

void retdec::fileformat::IntelHexParser::setOffset ( const IntelHexToken token)
private

Sets new address offset value

Parameters
tokenExtended address token

◆ setSegment()

void retdec::fileformat::IntelHexParser::setSegment ( const IntelHexToken token)
private

Sets new segment value

Parameters
tokenSegment info token

◆ strToInt()

unsigned long long retdec::fileformat::IntelHexParser::strToInt ( const std::string &  str)
static

Converts hexadecimal characters to integer

Parameters
strString of chars to convert
Returns
Decimal value
Warning
No validity control, use only on valid data

Member Data Documentation

◆ actualAddress

retdec::common::Address retdec::fileformat::IntelHexParser::actualAddress
private

Address of last byte saved to actual section.

◆ actualSection

IntelHexSection retdec::fileformat::IntelHexParser::actualSection
private

Actual section (one section may be constructed from more than one record)

◆ CS

std::uint16_t retdec::fileformat::IntelHexParser::CS
private

Entry point segment (CS register)

◆ EIP

std::uint32_t retdec::fileformat::IntelHexParser::EIP
private

Entry point (EIP register)

◆ errorDesc

std::string retdec::fileformat::IntelHexParser::errorDesc

Error description.

◆ hasEP

bool retdec::fileformat::IntelHexParser::hasEP
private

true if entry point record is in file

◆ index

unsigned long long retdec::fileformat::IntelHexParser::index
private

Indexing.

◆ IP

std::uint16_t retdec::fileformat::IntelHexParser::IP
private

Entry point instruction (IP register)

◆ mode

bool retdec::fileformat::IntelHexParser::mode
private

true when 32bit address mode, false when 20bit segment mode

◆ sections

std::vector<IntelHexSection> retdec::fileformat::IntelHexParser::sections

Sections (access after methods parseFile() or parseStream() only)

◆ segmenetAddress

std::uint16_t retdec::fileformat::IntelHexParser::segmenetAddress
private

Segment address.

◆ tokenizer

IntelHexTokenizer retdec::fileformat::IntelHexParser::tokenizer
private

Tokenizer.

◆ upperAddress

std::uint16_t retdec::fileformat::IntelHexParser::upperAddress
private

Upper 16bits of 32bit address.


The documentation for this class was generated from the following files: