ROSE  0.9.9.109
BasicTypes.h
1 #ifndef ROSE_Partitioner2_BasicTypes_H
2 #define ROSE_Partitioner2_BasicTypes_H
3 
4 #include <boost/serialization/access.hpp>
5 #include <boost/serialization/nvp.hpp>
6 #include <string>
7 #include <vector>
8 
9 // Define this as one if you want extra invariant checks that are quite expensive, or define as zero. This only makes a
10 // difference if NDEBUG and SAWYER_NDEBUG are both undefined--if either one of them are defined then no expensive (or
11 // inexpensive) checks are performed.
12 #define ROSE_PARTITIONER_EXPENSIVE_CHECKS 0
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace Partitioner2 {
17 
19 enum VertexType {
27 };
28 
30 enum EdgeType {
51 };
52 
54 enum Confidence {
57 };
58 
63 };
64 
75 
82 
90 
103 
104 private:
105  friend class boost::serialization::access;
106 
107  template<class S>
108  void serialize(S &s, unsigned version) {
109  s & allowEmptyGlobalBlock & allowFunctionWithNoBasicBlocks & allowEmptyBasicBlocks & copyAllInstructions;
110  }
111 
112 public:
115  : allowEmptyGlobalBlock(false), allowFunctionWithNoBasicBlocks(false), allowEmptyBasicBlocks(false),
116  copyAllInstructions(true) {}
117 
124  s.allowEmptyGlobalBlock = false;
126  s.allowEmptyBasicBlocks = false;
127  s.copyAllInstructions = true;
128  return s;
129  }
130 
138  s.allowEmptyGlobalBlock = true;
140  s.allowEmptyBasicBlocks = true;
141  s.copyAllInstructions = true; // true keeps the AST a tree instead of a lattice
142  return s;
143  }
144 };
145 
147 // Settings. All settings must act like properties, which means the following:
148 // 1. Each setting must have a name that does not begin with a verb.
149 // 2. Each setting must have a command-line switch to manipulate it.
150 // 3. Each setting must have a method that queries the property (same name as the property and taking no arguments).
151 // 4. Each setting must have a modifier method (same name as property but takes a value and returns void)
153 
165 };
166 
194  : deExecuteZerosThreshold(0), deExecuteZerosLeaveAtFront(16), deExecuteZerosLeaveAtBack(1),
195  memoryDataAdjustment(DATA_IS_INITIALIZED), memoryIsExecutable(false) {}
196 
197 private:
198  friend class boost::serialization::access;
199 
200  template<class S>
201  void serialize(S &s, unsigned version) {
202  s & deExecuteZerosThreshold & deExecuteZerosLeaveAtFront & deExecuteZerosLeaveAtBack;
203  s & memoryDataAdjustment & memoryIsExecutable;
204  }
205 };
206 
211  std::string isaName;
215 private:
216  friend class boost::serialization::access;
217 
218  template<class S>
219  void serialize(S &s, unsigned version) {
220  s & isaName;
221  }
222 };
223 
234 };
235 
247 private:
248  friend class boost::serialization::access;
249 
250  template<class S>
251  void serialize(S &s, const unsigned version) {
252  s & BOOST_SERIALIZATION_NVP(usingSemantics);
253  s & BOOST_SERIALIZATION_NVP(checkingCallBranch);
254  s & BOOST_SERIALIZATION_NVP(basicBlockSemanticsAutoDrop);
255  }
256 
257 public:
259  : usingSemantics(false), checkingCallBranch(false), basicBlockSemanticsAutoDrop(true) {}
260 };
261 
271  std::vector<rose_addr_t> startingVas;
307 private:
308  friend class boost::serialization::access;
309 
310  template<class S>
311  void serialize(S &s, unsigned version) {
312  s & base;
313  s & startingVas;
317  s & findingDeadCode;
322  s & interruptVector;
323  s & doingPostAnalysis;
331  s & findingThunks;
332  s & splittingThunks;
334  s & namingConstants;
335  s & namingStrings;
336  }
337 
338 public:
340  : followingGhostEdges(false), discontiguousBlocks(true), findingFunctionPadding(true),
341  findingDeadCode(true), peScramblerDispatcherVa(0), findingIntraFunctionCode(true), findingIntraFunctionData(true),
342  findingInterFunctionCalls(true), doingPostAnalysis(true), doingPostFunctionMayReturn(true),
343  doingPostFunctionStackDelta(true), doingPostCallingConvention(false), doingPostFunctionNoop(false),
344  functionReturnAnalysis(MAYRETURN_DEFAULT_YES), findingDataFunctionPointers(false), findingCodeFunctionPointers(false),
345  findingThunks(true), splittingThunks(false), semanticMemoryParadigm(LIST_BASED_MEMORY), namingConstants(true),
346  namingStrings(true), demangleNames(true) {}
347 };
348 
354  std::vector<std::string> configurationNames;
355  bool exitOnError;
358  : exitOnError(true) {}
359 
360 private:
361  friend class boost::serialization::access;
362 
363  template<class S>
364  void serialize(S &s, unsigned version) {
365  s & configurationNames;
366  s & exitOnError;
367  }
368 };
369 
370 // Additional declarations w/out definitions yet.
371 class Partitioner;
372 class Function;
374 class BasicBlock;
376 class DataBlock;
378 
379 } // namespace
380 } // namespace
381 } // namespace
382 
383 #endif
bool findingInterFunctionCalls
Look for function calls between functions.
Definition: BasicTypes.h:290
Edge is a function call transfer.
Definition: BasicTypes.h:42
bool splittingThunks
Split thunks into their own separate functions.
Definition: BasicTypes.h:301
bool memoryIsExecutable
Determines whether all of memory should be made executable.
Definition: BasicTypes.h:186
Settings for controling the engine behavior.
Definition: BasicTypes.h:353
std::vector< rose_addr_t > startingVas
Addresses at which to start recursive disassembly.
Definition: BasicTypes.h:271
MemoryDataAdjustment
How the partitioner should globally treat memory.
Definition: BasicTypes.h:155
bool findingDataFunctionPointers
Look for function pointers in static data.
Definition: BasicTypes.h:298
Assume a function returns if the may-return analysis cannot decide whether it may return...
Definition: BasicTypes.h:226
std::string isaName
Name of the instruction set architecture.
Definition: BasicTypes.h:211
bool doingPostFunctionStackDelta
Run function-stack-delta analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:294
EdgeType
Partitioner control flow edge types.
Definition: BasicTypes.h:30
rose_addr_t peScramblerDispatcherVa
Run the PeDescrambler module if non-zero.
Definition: BasicTypes.h:287
Settings that control the disassembler.
Definition: BasicTypes.h:210
Treat all memory as if it were initialized.
Definition: BasicTypes.h:158
size_t deExecuteZerosLeaveAtBack
Number of bytes at the end of each zero area to leave unaffected.
Definition: BasicTypes.h:180
bool copyAllInstructions
Whether to allow shared instructions in the AST.
Definition: BasicTypes.h:102
Special vertex destination for indeterminate edges.
Definition: BasicTypes.h:22
static AstConstructionSettings permissive()
Default permissive settings.
Definition: BasicTypes.h:136
Settings that directly control a partitioner.
Definition: BasicTypes.h:239
bool doingPostFunctionNoop
Find and name functions that are effectively no-ops.
Definition: BasicTypes.h:296
Assume that all functions return without ever running the may-return analysis.
Definition: BasicTypes.h:230
bool findingIntraFunctionCode
Suck up unused addresses as intra-function code.
Definition: BasicTypes.h:288
bool followingGhostEdges
Should ghost edges be followed during disassembly? A ghost edge is a CFG edge that is apparent from t...
Definition: BasicTypes.h:274
Main namespace for the ROSE library.
bool doingPostCallingConvention
Run calling-convention analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:295
Settings for loading specimens.
Definition: BasicTypes.h:170
VertexType
Partitioner control flow vertex types.
Definition: BasicTypes.h:19
Settings that control building the AST.
Definition: BasicTypes.h:69
static AstConstructionSettings strict()
Default strict settings.
Definition: BasicTypes.h:122
bool discontiguousBlocks
Should basic blocks be allowed to be discontiguous.
Definition: BasicTypes.h:281
bool allowEmptyGlobalBlock
Whether to allow an empty global block.
Definition: BasicTypes.h:74
bool namingStrings
Give labels to constants that are string literal addresses.
Definition: BasicTypes.h:304
Sawyer::SharedPointer< Function > FunctionPtr
Shared-ownership pointer for function.
Definition: BasicTypes.h:372
FunctionReturnAnalysis functionReturnAnalysis
How to run the function may-return analysis.
Definition: BasicTypes.h:297
bool demangleNames
Run all names through a demangling step.
Definition: BasicTypes.h:305
std::vector< std::string > configurationNames
List of configuration files and/or directories.
Definition: BasicTypes.h:354
bool doingPostFunctionMayReturn
Run function-may-return analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:293
The special "undiscovered" vertex.
Definition: BasicTypes.h:21
The value is an assumption without any proof.
Definition: BasicTypes.h:55
Settings that control the engine partitioning.
Definition: BasicTypes.h:269
Confidence
How sure are we of something.
Definition: BasicTypes.h:54
bool doingPostAnalysis
Perform enabled post-partitioning analyses?
Definition: BasicTypes.h:292
Do not make any global changes to the memory map.
Definition: BasicTypes.h:164
bool findingThunks
Look for common thunk patterns in undiscovered areas.
Definition: BasicTypes.h:300
A basic block or placeholder for a basic block.
Definition: BasicTypes.h:20
SemanticMemoryParadigm
Organization of semantic memory.
Definition: BasicTypes.h:60
Edge is a function return from the call site.
Definition: BasicTypes.h:36
Normal control flow edge, nothing special.
Definition: BasicTypes.h:31
MemoryDataAdjustment memoryDataAdjustment
How to globally adjust memory segment access bits for data areas.
Definition: BasicTypes.h:182
FunctionReturnAnalysis
Controls whether the function may-return analysis runs.
Definition: BasicTypes.h:225
size_t deExecuteZerosLeaveAtFront
Number of bytes at the beginning of each zero area to leave unaffected.
Definition: BasicTypes.h:178
The value was somehow proved.
Definition: BasicTypes.h:56
bool findingDeadCode
Look for unreachable basic blocks?
Definition: BasicTypes.h:286
SemanticMemoryParadigm semanticMemoryParadigm
Container used for semantic memory states.
Definition: BasicTypes.h:302
bool checkingCallBranch
Check for situations where CALL is used as a branch.
Definition: BasicTypes.h:244
bool allowEmptyBasicBlocks
Whether to allow a basic block to be empty.
Definition: BasicTypes.h:89
bool usingSemantics
Whether instruction semantics are used.
Definition: BasicTypes.h:240
Treat all memory as if it were constant.
Definition: BasicTypes.h:156
bool exitOnError
If true, emit error message and exit non-zero, else throw.
Definition: BasicTypes.h:355
bool basicBlockSemanticsAutoDrop
Conserve memory by dropping semantics for attached basic blocks.
Definition: BasicTypes.h:245
Assume a function cannot return if the may-return analysis cannot decide whether it may return...
Definition: BasicTypes.h:228
bool namingConstants
Give names to constants by calling Modules::nameConstants.
Definition: BasicTypes.h:303
size_t deExecuteZerosThreshold
Size threshold for removing execute permission from zero data.
Definition: BasicTypes.h:171
bool findingCodeFunctionPointers
Look for function pointers in instructions.
Definition: BasicTypes.h:299
Special vertex destination for non-existing basic blocks.
Definition: BasicTypes.h:23
bool findingIntraFunctionData
Suck up unused addresses as intra-function data.
Definition: BasicTypes.h:289
Assume that a function cannot return without ever running the may-return analysis.
Definition: BasicTypes.h:232
bool allowFunctionWithNoBasicBlocks
Whether to allow functions with no basic blocks.
Definition: BasicTypes.h:81
AddressInterval interruptVector
Table of interrupt handling functions.
Definition: BasicTypes.h:291
bool findingFunctionPadding
Look for padding before each function entry point?
Definition: BasicTypes.h:285