LIEF: Library to Instrument Executable Formats Version 0.15.1
|
Class which represents a PE section. More...
#include <Section.hpp>
Public Types | |
enum class | CHARACTERISTICS : uint64_t { TYPE_NO_PAD = 0x00000008 , CNT_CODE = 0x00000020 , CNT_INITIALIZED_DATA = 0x00000040 , CNT_UNINITIALIZED_DATA = 0x00000080 , LNK_OTHER = 0x00000100 , LNK_INFO = 0x00000200 , LNK_REMOVE = 0x00000800 , LNK_COMDAT = 0x00001000 , GPREL = 0x00008000 , MEM_PURGEABLE = 0x00010000 , MEM_16BIT = 0x00020000 , MEM_LOCKED = 0x00040000 , MEM_PRELOAD = 0x00080000 , ALIGN_1BYTES = 0x00100000 , ALIGN_2BYTES = 0x00200000 , ALIGN_4BYTES = 0x00300000 , ALIGN_8BYTES = 0x00400000 , ALIGN_16BYTES = 0x00500000 , ALIGN_32BYTES = 0x00600000 , ALIGN_64BYTES = 0x00700000 , ALIGN_128BYTES = 0x00800000 , ALIGN_256BYTES = 0x00900000 , ALIGN_512BYTES = 0x00A00000 , ALIGN_1024BYTES = 0x00B00000 , ALIGN_2048BYTES = 0x00C00000 , ALIGN_4096BYTES = 0x00D00000 , ALIGN_8192BYTES = 0x00E00000 , LNK_NRELOC_OVFL = 0x01000000 , MEM_DISCARDABLE = 0x02000000 , MEM_NOT_CACHED = 0x04000000 , MEM_NOT_PAGED = 0x08000000 , MEM_SHARED = 0x10000000 , MEM_EXECUTE = 0x20000000 , MEM_READ = 0x40000000 , MEM_WRITE = 0x80000000 } |
Public Types inherited from LIEF::Object | |
template<class T > | |
using | output_t = add_pointer_t<decay_t<T>> |
template<class T > | |
using | output_const_t = add_pointer_t<add_const_t<decay_t<T>>> |
Public Member Functions | |
Section (const details::pe_section &header) | |
Section ()=default | |
Section (const std::vector< uint8_t > &data, const std::string &name="", uint32_t characteristics=0) | |
Section (const std::string &name) | |
Section & | operator= (const Section &)=default |
Section (const Section &)=default | |
~Section () override=default | |
uint32_t | sizeof_raw_data () const |
Return the size of the data in the section. | |
uint32_t | virtual_size () const |
Return the size of the data when mapped in memory. | |
span< const uint8_t > | content () const override |
The actual content of the section. | |
span< const uint8_t > | padding () const |
Content of the section's padding area. | |
uint32_t | pointerto_raw_data () const |
The offset of the section data in the PE file. | |
uint32_t | pointerto_relocation () const |
The file pointer to the beginning of the COFF relocation entries for the section. This is set to zero for executable images or if there are no relocations. | |
uint32_t | pointerto_line_numbers () const |
The file pointer to the beginning of line-number entries for the section. This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF debugging information is deprecated and modern debug information relies on the PDB files. | |
uint16_t | numberof_relocations () const |
No longer used in recent PE binaries produced by Visual Studio. | |
uint16_t | numberof_line_numbers () const |
No longer used in recent PE binaries produced by Visual Studio. | |
uint32_t | characteristics () const |
Characteristics of the section: it provides information about the permissions of the section when mapped. It can also provide information about the purpose of the section (contain code, BSS-like, ...) | |
bool | is_type (PE_SECTION_TYPES type) const |
Deprecated do not use. It will likely change in a future release of LIEF. | |
const std::set< PE_SECTION_TYPES > & | types () const |
Deprecated do not use. It will likely change in a future release of LIEF. | |
bool | has_characteristic (CHARACTERISTICS c) const |
Check if the section has the given CHARACTERISTICS. | |
std::vector< CHARACTERISTICS > | characteristics_list () const |
List of the section characteristics as a std::set. | |
void | clear (uint8_t c) |
Fill the content of the section with the given char | |
void | content (const std::vector< uint8_t > &data) override |
Change section content. | |
void | name (std::string name) override |
Change the section's name. | |
void | virtual_size (uint32_t virtual_sz) |
void | pointerto_raw_data (uint32_t ptr) |
void | pointerto_relocation (uint32_t ptr) |
void | pointerto_line_numbers (uint32_t ptr) |
void | numberof_relocations (uint16_t nb) |
void | numberof_line_numbers (uint16_t nb) |
void | sizeof_raw_data (uint32_t sizeOfRawData) |
void | characteristics (uint32_t characteristics) |
void | type (PE_SECTION_TYPES type) |
void | add_type (PE_SECTION_TYPES type) |
void | remove_type (PE_SECTION_TYPES type) |
Section & | remove_characteristic (CHARACTERISTICS characteristic) |
Section & | add_characteristic (CHARACTERISTICS characteristic) |
void | accept (Visitor &visitor) const override |
Public Member Functions inherited from LIEF::Section | |
Section ()=default | |
Section (std::string name) | |
~Section () override=default | |
Section & | operator= (const Section &)=default |
Section (const Section &)=default | |
virtual std::string | name () const |
section's name | |
virtual const std::string & | fullname () const |
Return the complete section's name which might trailing (0 ) bytes. | |
virtual void | size (uint64_t size) |
Change the section size. | |
virtual uint64_t | size () const |
section's size (size in the binary, not the virtual size) | |
virtual uint64_t | offset () const |
Offset in the binary. | |
virtual uint64_t | virtual_address () const |
Address where the section should be mapped. | |
virtual void | virtual_address (uint64_t virtual_address) |
virtual void | offset (uint64_t offset) |
double | entropy () const |
Section's entropy. | |
size_t | search (uint64_t integer, size_t pos, size_t size) const |
size_t | search (const std::vector< uint8_t > &pattern, size_t pos=0) const |
size_t | search (const std::string &pattern, size_t pos=0) const |
size_t | search (uint64_t integer, size_t pos=0) const |
std::vector< size_t > | search_all (uint64_t v, size_t size) const |
std::vector< size_t > | search_all (uint64_t v) const |
std::vector< size_t > | search_all (const std::string &v) const |
void | accept (Visitor &visitor) const override |
Method so that the visitor can visit us. | |
Public Member Functions inherited from LIEF::Object | |
Object () | |
Object (const Object &other) | |
Object & | operator= (const Object &other) |
template<class T > | |
output_t< T > | as () |
template<class T > | |
output_const_t< T > | as () const |
virtual bool | operator== (const Object &other) const |
virtual bool | operator!= (const Object &other) const |
virtual | ~Object () |
Static Public Attributes | |
static constexpr size_t | MAX_SECTION_NAME = 8 |
Static Public Attributes inherited from LIEF::Section | |
static constexpr size_t | npos = -1 |
Class which represents a PE section.
|
strong |
LIEF::PE::Section::Section | ( | const details::pe_section & | header | ) |
|
default |
LIEF::PE::Section::Section | ( | const std::vector< uint8_t > & | data, |
const std::string & | name = "", | ||
uint32_t | characteristics = 0 ) |
LIEF::PE::Section::Section | ( | const std::string & | name | ) |
|
default |
|
overridedefault |
|
overridevirtual |
Implements LIEF::Object.
|
inline |
void LIEF::PE::Section::add_type | ( | PE_SECTION_TYPES | type | ) |
|
inline |
Characteristics of the section: it provides information about the permissions of the section when mapped. It can also provide information about the purpose of the section (contain code, BSS-like, ...)
|
inline |
std::vector< CHARACTERISTICS > LIEF::PE::Section::characteristics_list | ( | ) | const |
List of the section characteristics as a std::set.
void LIEF::PE::Section::clear | ( | uint8_t | c | ) |
Fill the content of the section with the given char
|
inlineoverridevirtual |
The actual content of the section.
Reimplemented from LIEF::Section.
|
overridevirtual |
Change section content.
Reimplemented from LIEF::Section.
|
inline |
Check if the section has the given CHARACTERISTICS.
bool LIEF::PE::Section::is_type | ( | PE_SECTION_TYPES | type | ) | const |
Deprecated do not use. It will likely change in a future release of LIEF.
|
overridevirtual |
Change the section's name.
Reimplemented from LIEF::Section.
|
inline |
No longer used in recent PE binaries produced by Visual Studio.
|
inline |
|
inline |
No longer used in recent PE binaries produced by Visual Studio.
|
inline |
|
inline |
Content of the section's padding area.
|
inline |
The file pointer to the beginning of line-number entries for the section. This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF debugging information is deprecated and modern debug information relies on the PDB files.
|
inline |
uint32_t LIEF::PE::Section::pointerto_raw_data | ( | ) | const |
The offset of the section data in the PE file.
void LIEF::PE::Section::pointerto_raw_data | ( | uint32_t | ptr | ) |
|
inline |
The file pointer to the beginning of the COFF relocation entries for the section. This is set to zero for executable images or if there are no relocations.
For modern PE binaries, this value is usually set to 0 as the relocations are managed by PE::Relocation.
|
inline |
|
inline |
void LIEF::PE::Section::remove_type | ( | PE_SECTION_TYPES | type | ) |
uint32_t LIEF::PE::Section::sizeof_raw_data | ( | ) | const |
Return the size of the data in the section.
void LIEF::PE::Section::sizeof_raw_data | ( | uint32_t | sizeOfRawData | ) |
void LIEF::PE::Section::type | ( | PE_SECTION_TYPES | type | ) |
const std::set< PE_SECTION_TYPES > & LIEF::PE::Section::types | ( | ) | const |
Deprecated do not use. It will likely change in a future release of LIEF.
|
inline |
Return the size of the data when mapped in memory.
If this value is greater than sizeof_raw_data, the section is zero-padded.
|
inline |
|
staticconstexpr |