ROSE 0.11.145.192
|
Loader for Windows PE files.
Definition at line 11 of file BinaryLoaderPe.h.
#include <Rose/BinaryAnalysis/BinaryLoaderPe.h>
Public Types | |
using | Ptr = BinaryLoaderPePtr |
Reference counting pointer to BinaryLoaderPe. | |
Public Types inherited from Rose::BinaryAnalysis::BinaryLoader | |
enum | MappingContribution { CONTRIBUTE_NONE , CONTRIBUTE_ADD , CONTRIBUTE_SUB } |
Describes how a section contributes to the overall memory map. More... | |
enum | ConflictResolution { RESOLVE_THROW , RESOLVE_OVERMAP , RESOLVE_REMAP , RESOLVE_REMAP_ABOVE } |
Describes how conflicts are resolved when mapping a section. More... | |
using | Ptr = BinaryLoaderPtr |
Referenc counting pointer to BinaryLoader. | |
typedef std::vector< Exception > | FixupErrors |
Public Member Functions | |
virtual BinaryLoaderPtr | clone () const override |
Creates a new copy of a loader. | |
virtual bool | canLoad (SgAsmGenericHeader *) const override |
Predicate determining the suitability of a loader for a specific file header. | |
virtual void | link (SgAsmInterpretation *interp) override |
Finds and parses all shared objects needed by an interpretation. | |
virtual rose_addr_t | rebase (const MemoryMap::Ptr &, SgAsmGenericHeader *, const SgAsmGenericSectionPtrList &) override |
Returns a new, temporary base address which is greater than everything that's been mapped already. | |
virtual void | fixup (SgAsmInterpretation *interp, FixupErrors *errors=NULL) override |
Performs relocation fixups on the specified interpretation. | |
virtual SgAsmGenericSectionPtrList | getRemapSections (SgAsmGenericHeader *) override |
Selects those sections of a header that should be mapped. | |
virtual MappingContribution | alignValues (SgAsmGenericSection *, const MemoryMap::Ptr &, rose_addr_t *malign_lo, rose_addr_t *malign_hi, rose_addr_t *va, rose_addr_t *mem_size, rose_addr_t *offset, rose_addr_t *file_size, bool *map_private, rose_addr_t *va_offset, bool *anon_lo, bool *anon_hi, ConflictResolution *resolve) override |
Windows-specific PE section alignment. | |
void | addLibDefaults (SgAsmGenericHeader *header=NULL) |
Sets up library search paths and preloads from the environment. | |
virtual std::string | findSoFile (const std::string &libname) const override |
Convert name to fully qualified name. | |
virtual bool | isLinked (SgBinaryComposite *composite, const std::string &filename) override |
Returns true if the specified file name is already linked into the AST. | |
virtual bool | isLinked (SgAsmInterpretation *interp, const std::string &filename) override |
Returns true if the specified file name is already linked into the AST. | |
Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
void | appendDirectories (const std::vector< std::string > &dirnames) |
Appends directories to the list of directories searched for libraries. | |
virtual void | load (SgAsmInterpretation *) |
Top-level method to do everything. | |
virtual void | remap (SgAsmInterpretation *interp) |
Maps sections of the interpretation into the virtual address space. | |
virtual std::vector< std::string > | dependencies (SgAsmGenericHeader *) |
Finds shared object dependencies of a single binary header. | |
virtual void | remap (Rose::BinaryAnalysis::MemoryMap::Ptr &, SgAsmGenericHeader *) |
Remaps the sections for a particular header. | |
rose_addr_t | bialign (rose_addr_t val1, rose_addr_t align1, rose_addr_t val2, rose_addr_t align2) |
Calculate adjustment to cause two values to be aligned to two different alignments. | |
virtual void | addSectionsForRemap (SgAsmGenericHeader *header, SgAsmGenericSectionPtrList &allSections) |
Selects loadable sections. | |
virtual unsigned | mappingPermissions (SgAsmGenericSection *) const |
MemoryMap permissions. | |
bool | performingDynamicLinking () const |
Property: Whether this loader will perform the linking step. | |
void | performingDynamicLinking (bool b) |
Property: Whether this loader will perform the linking step. | |
bool | performingRemap () const |
Property: Whether this loader will perform the mapping step. | |
void | performingRemap (bool b) |
Property: Whether this loader will perform the mapping step. | |
bool | performingRelocations () const |
Property: Whether this loader will perform the relocation step. | |
void | performingRelocations (bool b) |
Property: Whether this loader will perform the relocation step. | |
const std::vector< std::string > & | preloads () const |
Property: List of libraries that will be pre-loaded. | |
std::vector< std::string > & | preloads () |
Property: List of libraries that will be pre-loaded. | |
void | preloads (const std::vector< std::string > &v) |
Property: List of libraries that will be pre-loaded. | |
const std::vector< std::string > & | directories () const |
Property: List of directories searched for libraries. | |
std::vector< std::string > & | directories () |
Property: List of directories searched for libraries. | |
void | directories (const std::vector< std::string > &v) |
Property: List of directories searched for libraries. | |
Public Member Functions inherited from Sawyer::SharedObject | |
SharedObject () | |
Default constructor. | |
SharedObject (const SharedObject &) | |
Copy constructor. | |
virtual | ~SharedObject () |
Virtual destructor. | |
SharedObject & | operator= (const SharedObject &) |
Assignment. | |
Static Public Member Functions | |
static Ptr | instance () |
Allocating constructor. | |
Static Public Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
static Ptr | instance () |
Allocating constructor. | |
static void | initDiagnostics () |
Initialize diagnostic streams for binary loaders. | |
static void | registerSubclass (const Ptr &) |
Register a loader instance. | |
static Ptr | lookup (SgAsmGenericHeader *) |
Finds a suitable loader. | |
static Ptr | lookup (SgAsmInterpretation *) |
Finds a suitable loader. | |
static void | load (SgBinaryComposite *composite, bool read_executable_file_format_only=false) |
Top-level method to do everything. | |
static SgAsmGenericFile * | createAsmAST (SgBinaryComposite *composite, std::string filePath) |
Parses a single binary file. | |
static int64_t | gcd (int64_t a, int64_t b, int64_t *x=NULL, int64_t *y=NULL) |
Extended Euclid Algorithm. | |
static SgAsmGenericHeaderPtrList | findSimilarHeaders (SgAsmGenericHeader *matchHeader, SgAsmGenericHeaderPtrList &candidateHeaders) |
Find headers similar to given header. | |
static bool | isHeaderSimilar (SgAsmGenericHeader *, SgAsmGenericHeader *) |
Determines whether two headers are similar. | |
Protected Member Functions | |
BinaryLoaderPe (const BinaryLoaderPe &other) | |
Protected Member Functions inherited from Rose::BinaryAnalysis::BinaryLoader | |
BinaryLoader (const BinaryLoader &other) | |
Copy constructor. | |
Additional Inherited Members | |
Static Public Attributes inherited from Rose::BinaryAnalysis::BinaryLoader | |
static Sawyer::Message::Facility | mlog |
Logging facility initialized by initDiagnostics(). | |
Reference counting pointer to BinaryLoaderPe.
Definition at line 14 of file BinaryLoaderPe.h.
|
inlineprotected |
Definition at line 17 of file BinaryLoaderPe.h.
|
inlineprotected |
Definition at line 23 of file BinaryLoaderPe.h.
|
inlinevirtual |
Definition at line 40 of file BinaryLoaderPe.h.
|
inlinestatic |
Allocating constructor.
Definition at line 32 of file BinaryLoaderPe.h.
|
inlineoverridevirtual |
Creates a new copy of a loader.
The new copy has all the same settings as the original. Subclasses that define data methods should certainly provide an implementation of this method, although all they'll need to change is the data type for the 'new' operator.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
Definition at line 36 of file BinaryLoaderPe.h.
|
overridevirtual |
Predicate determining the suitability of a loader for a specific file header.
If this loader is capable of loading the specified file header, then this predicate returns true, otherwise it returns false. The implementation in BinaryLoader always returns true because BinaryLoader is able to generically load all types of files, albeit with limited functionality. Subclasses should certainly redefine this method so it returns true only for certain headers.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Finds and parses all shared objects needed by an interpretation.
Links an interpretation by parsing all shared objects required by that interpretation. In other words, all dependencies of the interpretation are parsed and added to the AST. As mentioned in the BinaryLoader documentation, this process is referred to as "linking".
Recursively perform a breadth-first search of all headers, starting with the headers already in the interpretation. For each header, obtain a list of necessary shared objects (pruning away those that have already been processed) and parse the shared object, adding it to the AST and adding its appropriate headers to the interpretation. Parsing of the shared objects is performed by calling createAsmAST().
This process is recursive in nature. A dynamically linked executable has a list of libraries on which it depends, and those libraries also often have dependencies. The recursion is breadth-first because ELF specifies a particular order that symbols should be resolved. Order is not important for a PE binary since its shared object symbols are scoped to a library.
The list of dependencies for a particular header is obtained by the getDLLs() method, which is also responsible for not returning any shared object that we've already parsed.
Throws a BinaryLoader::Exception if any error occurs.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Returns a new, temporary base address which is greater than everything that's been mapped already.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Performs relocation fixups on the specified interpretation.
This should be called after sections are mapped into memory by remap(). If an error occurs, then this function either throws the error (BinaryLoader::Exception) or appends it to the errors
container (if errors
is non-null).
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Selects those sections of a header that should be mapped.
Returns the sections in the order they should be mapped.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Windows-specific PE section alignment.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Returns true if the specified file name is already linked into the AST.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
|
overridevirtual |
Returns true if the specified file name is already linked into the AST.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.
void Rose::BinaryAnalysis::BinaryLoaderPe::addLibDefaults | ( | SgAsmGenericHeader * | header = NULL | ) |
Sets up library search paths and preloads from the environment.
The search paths and preloads are added to the end of the lists. If a PE file header is provided, then only LD_PRELOAD and LD_LIBRARY_PATH are used.
|
overridevirtual |
Convert name to fully qualified name.
Given the name of a shared object, return the fully qualified name where the library is located in the file system. Throws a BinaryLoader::Exception if the library cannot be found.
Reimplemented from Rose::BinaryAnalysis::BinaryLoader.