ROSE  0.11.145.0
BinaryLoaderPe.h
1 #ifndef ROSE_BinaryAnalysis_BinaryLoaderPe_H
2 #define ROSE_BinaryAnalysis_BinaryLoaderPe_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 #include <Rose/BinaryAnalysis/BinaryLoader.h>
6 
7 namespace Rose {
8 namespace BinaryAnalysis {
9 
12 public:
15 
16 protected:
17  BinaryLoaderPe() {
20  performingRemap(true);
21  }
22 
23  BinaryLoaderPe(const BinaryLoaderPe &other)
24  : BinaryLoader(other){
27  performingRemap(true);
28  }
29 
30 public:
32  static Ptr instance() {
33  return Ptr(new BinaryLoaderPe);
34  }
35 
36  virtual BinaryLoaderPtr clone() const override {
37  return BinaryLoaderPtr(new BinaryLoaderPe(*this));
38  }
39 
40  virtual ~BinaryLoaderPe() {}
41 
42  /* Override virtual methods from BinaryLoader */
43 public:
44 
45  virtual bool canLoad(SgAsmGenericHeader*) const override;
46 
47  // documented in superclass
48  virtual void link(SgAsmInterpretation *interp) override;
49 
51  virtual rose_addr_t rebase(const MemoryMap::Ptr&, SgAsmGenericHeader*, const SgAsmGenericSectionPtrList&) override;
52 
53  // Resolve import section to DLL files.
54  virtual void fixup(SgAsmInterpretation *interp, FixupErrors *errors=NULL) override;
55 
56  // Returns sections in order of their definition in the PE Section Table.
57  virtual SgAsmGenericSectionPtrList getRemapSections(SgAsmGenericHeader*) override;
58 
61  rose_addr_t *malign_lo, rose_addr_t *malign_hi,
62  rose_addr_t *va, rose_addr_t *mem_size,
63  rose_addr_t *offset, rose_addr_t *file_size, bool *map_private,
64  rose_addr_t *va_offset, bool *anon_lo, bool *anon_hi,
65  ConflictResolution *resolve) override;
66 
70  virtual bool isLinked(SgBinaryComposite *composite, const std::string &filename) override;
71  virtual bool isLinked(SgAsmInterpretation *interp, const std::string &filename) override;
76  void addLibDefaults(SgAsmGenericHeader *header=NULL);
77 
82  virtual std::string findSoFile(const std::string &libname) const override;
83 
84 };
85 
86 } // namespace
87 } // namespace
88 
89 #endif
90 #endif
bool performingRelocations() const
Property: Whether this loader will perform the relocation step.
Definition: BinaryLoader.h:216
bool performingRemap() const
Property: Whether this loader will perform the mapping step.
Definition: BinaryLoader.h:204
Contiguous region of a file.
virtual SgAsmGenericSectionPtrList getRemapSections(SgAsmGenericHeader *) override
Selects those sections of a header that should be mapped.
Loader for Windows PE files.
Sawyer::SharedPointer< BinaryLoader > BinaryLoaderPtr
Reference counting pointer.
virtual void fixup(SgAsmInterpretation *interp, FixupErrors *errors=NULL) override
Performs relocation fixups on the specified interpretation.
Main namespace for the ROSE library.
virtual void link(SgAsmInterpretation *interp) override
Finds and parses all shared objects needed by an interpretation.
void addLibDefaults(SgAsmGenericHeader *header=NULL)
Sets up library search paths and preloads from the environment.
MemoryMapPtr Ptr
Reference counting pointer.
Definition: MemoryMap.h:115
Base class for container file headers.
virtual std::string findSoFile(const std::string &libname) const override
Convert name to fully qualified name.
static Ptr instance()
Allocating constructor.
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.
virtual BinaryLoaderPtr clone() const override
Creates a new copy of a loader.
MappingContribution
Describes how a section contributes to the overall memory map.
Definition: BinaryLoader.h:63
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 canLoad(SgAsmGenericHeader *) const override
Predicate determining the suitability of a loader for a specific file header.
ConflictResolution
Describes how conflicts are resolved when mapping a section.
Definition: BinaryLoader.h:71
Base class for loading a static or dynamic object.
Definition: BinaryLoader.h:54
bool performingDynamicLinking() const
Property: Whether this loader will perform the linking step.
Definition: BinaryLoader.h:193
Represents an interpretation of a binary container.
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...
BinaryLoaderPePtr Ptr
Reference counting pointer to BinaryLoaderPe.
Sawyer::SharedPointer< BinaryLoaderPe > BinaryLoaderPePtr
Refernce counting pointer.