1 #ifndef ROSE_BinaryAnalysis_Partitioner2_ModulesPe_H
2 #define ROSE_BinaryAnalysis_Partitioner2_ModulesPe_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 #include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/Partitioner2/Modules.h>
8 #include <Sawyer/Map.h>
11 namespace BinaryAnalysis {
12 namespace Partitioner2 {
92 DispatchEntry(uint32_t returnVa, uint32_t calleeVa): returnVa(returnVa), calleeVa(calleeVa) {}
103 rose_addr_t dispatcherVa_;
104 rose_addr_t dispatchTableVa_;
105 bool reachedEndOfTable_;
106 bool checkedPreconditions_;
107 static const size_t sizeofDispatcherFunction = 65;
108 static const size_t bitsPerWord = 32;
109 DispatchTable dispatchTable_;
114 : dispatcherVa_(dispatcherVa), dispatchTableVa_(dispatchTableVa), reachedEndOfTable_(false),
115 checkedPreconditions_(false) {}
133 return Ptr(
new PeDescrambler(dispatcherVa, dispatcherVa + sizeofDispatcherFunction));
160 virtual bool operator()(
bool chain,
const Args&)
override;
rose_addr_t dispatcherVa() const
Virtual address of PEScrambler dispatch function.
void nameKeyAddresses(const PartitionerPtr &)
Name certain addresses in the specimen.
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.
Sawyer::SharedPointer< PeDescrambler > Ptr
Shared-ownership pointer to a PeDescrambler.
const DispatchTable & dispatchTable() const
Dispatch table.
virtual bool operator()(bool chain, const Args &) override
Callback method.
DispatchTable & dispatchTable()
Dispatch table.
std::vector< FunctionPtr > findExportFunctions(const PartitionerConstPtr &, SgAsmPEFileHeader *)
Reads PE export sections to find functions.
void buildMayReturnLists(const PartitionerPtr &)
Build may-return white and black lists.
static Ptr instance(rose_addr_t dispatcherVa)
Construct a new PeDescrambler.
Sawyer::Container::Map< rose_addr_t, SgAsmPEImportItem * > ImportIndex
Index for PE import addresses.
ImportIndex getImportIndex(const PartitionerConstPtr &, SgAsmPEFileHeader *)
Scans PE import sections to build an index.
std::vector< FunctionPtr > findImportFunctions(const PartitionerConstPtr &, SgAsmPEFileHeader *)
Reads PE import sections to find functions.
void rebaseImportAddressTables(const PartitionerPtr &partitioner, const ImportIndex &index)
Update import address tables to reflect addresses of imported functions.
One dispatch table entry in native format.
Represents an interpretation of a binary container.
void nameImportThunks(const PartitionerConstPtr &, SgAsmInterpretation *)
Names functions that look like they're thunks for imports.
Container associating values with keys.