1 #ifndef ROSE_Partitioner2_ModulesPe_H
2 #define ROSE_Partitioner2_ModulesPe_H
4 #include <featureTests.h>
5 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
7 #include <Partitioner2/Function.h>
8 #include <Partitioner2/Modules.h>
9 #include <Sawyer/Map.h>
13 namespace Partitioner2 {
93 DispatchEntry(uint32_t returnVa, uint32_t calleeVa): returnVa(returnVa), calleeVa(calleeVa) {}
104 rose_addr_t dispatcherVa_;
105 rose_addr_t dispatchTableVa_;
106 bool reachedEndOfTable_;
107 bool checkedPreconditions_;
108 static const size_t sizeofDispatcherFunction = 65;
109 static const size_t bitsPerWord = 32;
110 DispatchTable dispatchTable_;
115 : dispatcherVa_(dispatcherVa), dispatchTableVa_(dispatchTableVa), reachedEndOfTable_(false),
116 checkedPreconditions_(false) {}
134 return Ptr(
new PeDescrambler(dispatcherVa, dispatcherVa + sizeofDispatcherFunction));
161 virtual bool operator()(
bool chain,
const Args&) ROSE_OVERRIDE;
169 Sawyer::Optional<rose_addr_t> findCalleeAddress(const Partitioner&, rose_addr_t returnVa);
void nameImportThunks(const Partitioner &, SgAsmInterpretation *)
Names functions that look like they're thunks for imports.
rose_addr_t dispatcherVa() const
Virtual address of PEScrambler dispatch function.
rose_addr_t dispatchTableVa() const
Virtual address of PEScrambler dispatch table.
Base class for adjusting basic blocks during discovery.
std::vector< DispatchEntry > DispatchTable
The function dispatch table.
std::string systemFunctionName(const std::string &)
Convert function name to system representation.
static Ptr instance(rose_addr_t dispatcherVa, rose_addr_t dispatchTableVa)
Construct a new PeDescrambler.
Callback to restore PEScrambler function call edges.
Main namespace for the ROSE library.
std::vector< Function::Ptr > findImportFunctions(const Partitioner &, SgAsmPEFileHeader *)
Reads PE import sections to find functions.
Reference-counting intrusive smart pointer.
Name space for the entire library.
virtual bool operator()(bool chain, const Args &) ROSE_OVERRIDE
Callback method.
void nameKeyAddresses(Partitioner &)
Name certain addresses in the specimen.
Sawyer::SharedPointer< PeDescrambler > Ptr
Shared-ownership pointer to a PeDescrambler.
const DispatchTable & dispatchTable() const
Dispatch table.
void buildMayReturnLists(Partitioner &)
Build may-return white and black lists.
DispatchTable & dispatchTable()
Dispatch table.
ImportIndex getImportIndex(const Partitioner &, SgAsmPEFileHeader *)
Scans PE import sections to build an index.
void rebaseImportAddressTables(Partitioner &partitioner, const ImportIndex &index)
Update import address tables to reflect addresses of imported functions.
static Ptr instance(rose_addr_t dispatcherVa)
Construct a new PeDescrambler.
Sawyer::Container::Map< rose_addr_t, SgAsmPEImportItem * > ImportIndex
Index for PE import addresses.
Partitions instructions into basic blocks and functions.
std::vector< Function::Ptr > findExportFunctions(const Partitioner &, SgAsmPEFileHeader *)
Reads PE export sections to find functions.
One dispatch table entry in native format.
Represents an interpretation of a binary container.
Container associating values with keys.