Skip to content
Permalink
Browse files
Rename getter from get_XXX to XXX
related to #66
  • Loading branch information
romainthomas committed Sep 7, 2017
1 parent d18074c commit a4c69f7
Show file tree
Hide file tree
Showing 21 changed files with 144 additions and 144 deletions.
@@ -19,7 +19,7 @@ namespace LIEF {
namespace PE {
void init_c_sections(Pe_Binary_t* c_binary, Binary* binary) {

it_sections sections = binary->get_sections();
it_sections sections = binary->sections();

c_binary->sections = static_cast<Pe_Section_t**>(
malloc((sections.size() + 1) * sizeof(Pe_Section_t**)));
@@ -54,15 +54,15 @@ void init_LIEF_Binary_class(py::module& m) {
"Binary's name")

.def_property_readonly("header",
&Binary::get_header,
&Binary::header,
"Binary's header")

.def_property_readonly("entrypoint",
&Binary::entrypoint,
"Binary's entrypoint")

.def_property_readonly("sections",
static_cast<it_t<it_sections>>(&Binary::get_sections),
static_cast<it_t<it_sections>>(&Binary::sections),
"Return a list in **read only** of binary's abstract " RST_CLASS_REF(lief.Section) "",
py::return_value_policy::reference_internal)

@@ -73,7 +73,7 @@ void init_LIEF_Binary_class(py::module& m) {

.def_property_readonly("exported_functions",
[] (const Binary& binary) {
const std::vector<std::string>& exported_functions = binary.get_exported_functions();
const std::vector<std::string>& exported_functions = binary.exported_functions();
std::vector<py::object> exported_functions_encoded;
exported_functions_encoded.reserve(exported_functions.size());

@@ -89,7 +89,7 @@ void init_LIEF_Binary_class(py::module& m) {

.def_property_readonly("imported_functions",
[] (const Binary& binary) {
const std::vector<std::string>& imported_functions = binary.get_imported_functions();
const std::vector<std::string>& imported_functions = binary.imported_functions();
std::vector<py::object> imported_functions_encoded;
imported_functions_encoded.reserve(imported_functions.size());

@@ -104,7 +104,7 @@ void init_LIEF_Binary_class(py::module& m) {

.def_property_readonly("libraries",
[] (const Binary& binary) {
const std::vector<std::string>& imported_libraries = binary.get_imported_libraries();
const std::vector<std::string>& imported_libraries = binary.imported_libraries();
std::vector<py::object> imported_libraries_encoded;
imported_libraries_encoded.reserve(imported_libraries.size());

@@ -118,7 +118,7 @@ void init_LIEF_Binary_class(py::module& m) {
"Return binary's imported libraries (name)")

.def_property_readonly("symbols",
static_cast<it_t<it_symbols>>(&Binary::get_symbols),
static_cast<it_t<it_symbols>>(&Binary::symbols),
"Return a list in **read only** of binary's abstract " RST_CLASS_REF(lief.Symbol) "",
py::return_value_policy::reference_internal)

@@ -72,12 +72,12 @@ void init_MachO_Binary_class(py::module& m) {
py::return_value_policy::reference)

.def_property_readonly("imported_symbols",
static_cast<no_const_getter<it_imported_symbols>>(&Binary::get_imported_symbols),
static_cast<no_const_getter<it_imported_symbols>>(&Binary::imported_symbols),
"Return binary's " RST_CLASS_REF(lief.MachO.Symbol) " which are imported",
py::return_value_policy::reference_internal)

.def_property_readonly("exported_symbols",
static_cast<no_const_getter<it_exported_symbols>>(&Binary::get_exported_symbols),
static_cast<no_const_getter<it_exported_symbols>>(&Binary::exported_symbols),
"Return binary's " RST_CLASS_REF(lief.MachO.Symbol) " which are exported",
py::return_value_policy::reference_internal)

@@ -38,7 +38,7 @@ void init_PE_Binary_class(py::module& m) {
.def(py::init<const std::string &, PE_TYPE>())

.def_property_readonly("sections",
static_cast<no_const_getter<it_sections>>(&Binary::get_sections),
static_cast<no_const_getter<it_sections>>(&Binary::sections),
"Return binary's " RST_CLASS_REF(lief.PE.Section) " sections",
py::return_value_policy::reference)

@@ -58,12 +58,12 @@ void init_PE_Binary_class(py::module& m) {
py::return_value_policy::reference)

.def_property_readonly("virtual_size",
&Binary::get_virtual_size,
&Binary::virtual_size,
"Binary size when mapped in memory.\n\n"
"This value should matches :attr:`~lief.PE.OptionalHeader.sizeof_image`")

.def_property_readonly("sizeof_headers",
&Binary::get_sizeof_headers,
&Binary::sizeof_headers,
"Size of all PE headers")

.def("rva_to_offset",
@@ -141,7 +141,7 @@ void init_PE_Binary_class(py::module& m) {


.def_property_readonly("debug",
static_cast<Debug& (Binary::*)(void)>(&Binary::get_debug),
static_cast<Debug& (Binary::*)(void)>(&Binary::debug),
"Return the " RST_CLASS_REF(lief.PE.Debug) " object",
py::return_value_policy::reference)

@@ -212,11 +212,11 @@ void init_PE_Binary_class(py::module& m) {
py::return_value_policy::reference)

.def_property_readonly("resources_manager",
static_cast<no_const_getter<ResourcesManager>>(&Binary::get_resources_manager),
static_cast<no_const_getter<ResourcesManager>>(&Binary::resources_manager),
"Return the " RST_CLASS_REF(lief.PE.ResourcesManager) " to manage resources")

.def_property_readonly("resources",
static_cast<no_const_getter<ResourceNode&>>(&Binary::get_resources),
static_cast<no_const_getter<ResourceNode&>>(&Binary::resources),
"Return the " RST_CLASS_REF(lief.PE.ResourceNode) " tree",
py::return_value_policy::reference)

@@ -29,30 +29,30 @@ int main(int argc, char **argv) {
std::unique_ptr<const LIEF::Binary> binary{LIEF::Parser::parse(argv[1])};

std::cout << "== Header ==" << std::endl;
std::cout << binary->get_header() << std::endl;
std::cout << binary->header() << std::endl;

std::cout << "== Sections ==" << std::endl;
for (const LIEF::Section& s : binary->get_sections()) {
for (const LIEF::Section& s : binary->sections()) {
std::cout << s << std::endl;
}

std::cout << "== Symbols ==" << std::endl;
for (const LIEF::Symbol& s : binary->get_symbols()) {
for (const LIEF::Symbol& s : binary->symbols()) {
std::cout << s << std::endl;
}

std::cout << "== Exported functions ==" << std::endl;
for(const std::string& name : binary->get_exported_functions()) {
for(const std::string& name : binary->exported_functions()) {
std::cout << name << std::endl;
}

std::cout << "== Imported functions ==" << std::endl;
for(const std::string& name : binary->get_imported_functions()) {
for(const std::string& name : binary->imported_functions()) {
std::cout << name << std::endl;
}

std::cout << "== Imported Libraries ==" << std::endl;
for(const std::string& name : binary->get_imported_libraries()) {
for(const std::string& name : binary->imported_libraries()) {
std::cout << name << std::endl;
}

@@ -74,12 +74,12 @@ void print_binary(const Binary* binary) {


std::cout << "== Exported symbols ==" << std::endl;
for (const Symbol& symbol : binary->get_exported_symbols()) {
for (const Symbol& symbol : binary->exported_symbols()) {
std::cout << symbol << std::endl;
}

std::cout << "== Imported symbols ==" << std::endl;
for (const Symbol& symbol : binary->get_imported_symbols()) {
for (const Symbol& symbol : binary->imported_symbols()) {
std::cout << symbol << std::endl;
}

@@ -49,7 +49,7 @@ int main(int argc, char **argv) {
}

std::cout << "== Sections ==" << std::endl;
for (const Section& section : binary->get_sections()) {
for (const Section& section : binary->sections()) {
std::cout << section << std::endl;
}

@@ -87,13 +87,13 @@ int main(int argc, char **argv) {

if (binary->has_debug()) {
std::cout << "== Debug ==" << std::endl;
std::cout << binary->get_debug() << std::endl;
std::cout << binary->debug() << std::endl;
}


if (binary->has_resources()) {
std::cout << "== Resources ==" << std::endl;
std::cout << binary->get_resources_manager() << std::endl;
std::cout << binary->resources_manager() << std::endl;
}


@@ -46,13 +46,13 @@ class DLL_PUBLIC Binary : public Visitable {
EXE_FORMATS format(void) const;

//! @brief Return the abstract header of the binary
Header get_header(void) const;
Header header(void) const;

//! @brief Return list of symbols whose elements **can** be modified
it_symbols get_symbols(void);
it_symbols symbols(void);

//! @brief Return list of symbols whose elements **can't** be modified
it_const_symbols get_symbols(void) const;
it_const_symbols symbols(void) const;

//! @brief Check if a Symbol with the given name exists
bool has_symbol(const std::string& name) const;
@@ -63,8 +63,8 @@ class DLL_PUBLIC Binary : public Visitable {
Symbol& get_symbol(const std::string& name);

//! @brief Returns binary's sections
it_sections get_sections(void);
it_const_sections get_sections(void) const;
it_sections sections(void);
it_const_sections sections(void) const;

//! @brief Returns binary's relocations
it_relocations relocations(void);
@@ -80,13 +80,13 @@ class DLL_PUBLIC Binary : public Visitable {
uint64_t original_size(void) const;

//! @brief Return functions's name exported by the binary
std::vector<std::string> get_exported_functions(void) const;
std::vector<std::string> exported_functions(void) const;

//! @brief Return libraries which are imported by the binary
std::vector<std::string> get_imported_libraries(void) const;
std::vector<std::string> imported_libraries(void) const;

//! @brief Return functions's name imported by the binary
std::vector<std::string> get_imported_functions(void) const;
std::vector<std::string> imported_functions(void) const;

//! @brief Return the address of the given function name
virtual uint64_t get_function_address(const std::string& func_name) const;
@@ -78,15 +78,15 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
static bool is_exported(const Symbol& symbol);

//! @brief Return binary's exported symbols
it_exported_symbols get_exported_symbols(void);
it_const_exported_symbols get_exported_symbols(void) const;
it_exported_symbols exported_symbols(void);
it_const_exported_symbols exported_symbols(void) const;

//! @brief Check if the given symbol is an imported one
static bool is_imported(const Symbol& symbol);

//! @brief Return binary's imported symbols
it_imported_symbols get_imported_symbols(void);
it_const_imported_symbols get_imported_symbols(void) const;
it_imported_symbols imported_symbols(void);
it_const_imported_symbols imported_symbols(void) const;

//! @brief Return binary imported libraries (MachO::DylibCommand)
it_libraries libraries(void);
@@ -121,7 +121,7 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
uint64_t imagebase(void) const;

//! @brief Return binary's loader (e.g. ``/usr/lib/dyld``)
const std::string& get_loader(void) const;
const std::string& loader(void) const;

//! @brief Check if a section with the given name exists
bool has_section(const std::string& name) const;
@@ -251,10 +251,10 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
bool has_command(void) const;

template<class T>
T& get_command(void);
T& command(void);

template<class T>
const T& get_command(void) const;
const T& command(void) const;

template<class T>
size_t count_commands(void) const;
@@ -77,8 +77,8 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
const Section& section_from_rva(uint64_t virtual_address) const;

//! @brief Return binary's sections
it_sections get_sections(void);
it_const_sections get_sections(void) const;
it_sections sections(void);
it_const_sections sections(void) const;

// =======
// Headers
@@ -98,10 +98,10 @@ class DLL_PUBLIC Binary : public LIEF::Binary {

//! @brief Compute the binary's virtual size.
//! It should match with OptionalHeader::sizeof_image
uint64_t get_virtual_size(void) const;
uint64_t virtual_size(void) const;

//! @brief Compute the size of all headers
uint32_t get_sizeof_headers(void) const;
uint32_t sizeof_headers(void) const;

//! @brief Return a reference to the TLS object
TLS& tls(void);
@@ -169,8 +169,8 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
const std::vector<Symbol>& symbols(void) const;

//! @brief Return resources as a tree
ResourceNode& get_resources(void);
const ResourceNode& get_resources(void) const;
ResourceNode& resources(void);
const ResourceNode& resources(void) const;

//! @brief Set a new resource tree
void set_resources(const ResourceDirectory& resource);
@@ -179,8 +179,8 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
void set_resources(const ResourceData& resource);

//! @brief Return the ResourcesManager (class to manage resources more easily than the tree one)
ResourcesManager get_resources_manager(void);
const ResourcesManager get_resources_manager(void) const;
ResourcesManager resources_manager(void);
const ResourcesManager resources_manager(void) const;

// ==========================
// Methods to manage sections
@@ -193,8 +193,8 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
const Section& get_section(const std::string& name) const;

//! @brief Return the section associated with import table
const Section& get_import_section(void) const;
Section& get_import_section(void);
const Section& import_section(void) const;
Section& import_section(void);

//! @brief Delete the section with the given name
//!
@@ -232,8 +232,8 @@ class DLL_PUBLIC Binary : public LIEF::Binary {
const DataDirectory& data_directory(DATA_DIRECTORY index) const;

//! @brief Return the Debug object
Debug& get_debug(void);
const Debug& get_debug(void) const;
Debug& debug(void);
const Debug& debug(void) const;

// =======
// Overlay

0 comments on commit a4c69f7

Please sign in to comment.