mirror of
https://github.com/QuasarApp/LIEF.git
synced 2025-04-28 13:24:32 +00:00
Add 'has_section' and 'has_data_directory' methods to PE::TLS object
This commit is contained in:
parent
b4b7b38633
commit
8ecba03288
@ -62,6 +62,12 @@ void init_PE_TLS_class(py::module& m) {
|
||||
static_cast<getter_t<const std::vector<uint8_t>&>>(&TLS::data_template),
|
||||
static_cast<setter_t<const std::vector<uint8_t>&>>(&TLS::data_template))
|
||||
|
||||
.def_property_readonly("has_section",
|
||||
&TLS::has_section)
|
||||
|
||||
.def_property_readonly("has_data_directory",
|
||||
&TLS::has_data_directory)
|
||||
|
||||
.def_property_readonly("directory",
|
||||
static_cast<no_const_getter<DataDirectory&>>(&TLS::directory),
|
||||
py::return_value_policy::reference)
|
||||
|
@ -46,6 +46,7 @@ class DLL_PUBLIC TLS : public Visitable {
|
||||
TLS(const pe64_tls *header);
|
||||
virtual ~TLS(void);
|
||||
|
||||
|
||||
TLS(const TLS& copy);
|
||||
TLS& operator=(TLS copy);
|
||||
void swap(TLS& other);
|
||||
@ -58,9 +59,11 @@ class DLL_PUBLIC TLS : public Visitable {
|
||||
uint32_t characteristics(void) const;
|
||||
const std::vector<uint8_t>& data_template(void) const;
|
||||
|
||||
bool has_data_directory(void) const;
|
||||
DataDirectory& directory(void);
|
||||
const DataDirectory& directory(void) const;
|
||||
|
||||
bool has_section(void) const;
|
||||
Section& section(void);
|
||||
const Section& section(void) const;
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace PE {
|
||||
TLS::~TLS(void) = default;
|
||||
|
||||
TLS::TLS(void) :
|
||||
Visitable{},
|
||||
callbacks_{},
|
||||
VAOfRawData_{std::make_pair<uint64_t>(0, 0)},
|
||||
addressof_index_{0},
|
||||
@ -121,6 +122,10 @@ uint32_t TLS::characteristics(void) const {
|
||||
}
|
||||
|
||||
|
||||
bool TLS::has_data_directory(void) const {
|
||||
return this->directory_ != nullptr;
|
||||
}
|
||||
|
||||
const DataDirectory& TLS::directory(void) const {
|
||||
if (this->directory_ != nullptr) {
|
||||
return *(this->directory_);
|
||||
@ -134,6 +139,11 @@ DataDirectory& TLS::directory(void) {
|
||||
}
|
||||
|
||||
|
||||
bool TLS::has_section(void) const {
|
||||
return this->section_ != nullptr;
|
||||
}
|
||||
|
||||
|
||||
const Section& TLS::section(void) const {
|
||||
if (this->section_ != nullptr) {
|
||||
return *(this->section_);
|
||||
@ -196,14 +206,12 @@ void TLS::accept(LIEF::Visitor& visitor) const {
|
||||
visitor.visit(this->characteristics());
|
||||
visitor.visit(this->data_template());
|
||||
|
||||
try {
|
||||
if (this->has_section()) {
|
||||
visitor(this->section());
|
||||
} catch (const not_found&) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (this->has_data_directory()) {
|
||||
visitor(this->directory());
|
||||
} catch (const not_found&) {
|
||||
}
|
||||
|
||||
for (uint64_t callback : this->callbacks()) {
|
||||
@ -227,16 +235,16 @@ std::ostream& operator<<(std::ostream& os, const TLS& entry) {
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Address Of Index: " << entry.addressof_index() << std::endl;
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Address Of Callbacks: " << entry.addressof_callbacks() << std::endl;
|
||||
|
||||
for (auto& value : entry.callbacks_) {
|
||||
for (uint64_t value : entry.callbacks()) {
|
||||
os << "\t - " << value << std::endl;
|
||||
}
|
||||
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Virtual Address of RawData (start): " << entry.VAOfRawData_.first << std::endl;
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Virtual Address of RawData (end): " << entry.VAOfRawData_.second << std::endl;
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Virtual Address of RawData (start): " << entry.addressof_raw_data().first << std::endl;
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Virtual Address of RawData (end): " << entry.addressof_raw_data().second << std::endl;
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Size Of Zero Fill: " << entry.sizeof_zero_fill() << std::endl;
|
||||
|
||||
if (entry.section_ != nullptr) {
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Associated section: " << entry.section_->name() << std::endl;
|
||||
if (entry.has_section()) {
|
||||
os << std::setw(40) << std::left << std::setfill(' ') << "Associated section: " << entry.section().name() << std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user