My Project
dynamic.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
19 
20 #ifndef __CPUI_DYNAMIC__
21 #define __CPUI_DYNAMIC__
22 
23 #include "varnode.hh"
24 
30 class ToOpEdge {
31  const PcodeOp *op;
32  int4 slot;
33 public:
34  ToOpEdge(const PcodeOp *o,int4 s) { op = o; slot = s; }
35  const PcodeOp *getOp(void) const { return op; }
36  int4 getSlot(void) const { return slot; }
37  bool operator<(const ToOpEdge &op2) const;
38  uint4 hash(uint4 reg) const;
39 };
40 
60 class DynamicHash {
61  uint4 vnproc;
62  uint4 opproc;
63  uint4 opedgeproc;
64 
65  vector<const PcodeOp *> markop;
66  vector<const Varnode *> markvn;
67  vector<const Varnode *> vnedge;
68  vector<ToOpEdge> opedge;
69 
70  Address addrresult;
71  uint8 hash;
72  void buildVnUp(const Varnode *vn);
73  void buildVnDown(const Varnode *vn);
74  void buildOpUp(const PcodeOp *op);
75  void buildOpDown(const PcodeOp *op);
76  void gatherUnmarkedVn(void);
77  void gatherUnmarkedOp(void);
78 public:
79  void clear(void);
80  void calcHash(const Varnode *root,uint4 method);
81  void uniqueHash(const Varnode *root,Funcdata *fd);
82  Varnode *findVarnode(const Funcdata *fd,const Address &addr,uint8 h);
83  uint8 getHash(void) const { return hash; }
84 
85  const Address &getAddress(void) const { return addrresult; }
86  static void gatherFirstLevelVars(vector<Varnode *> &varlist,const Funcdata *fd,const Address &addr,uint8 h);
87  static int4 getSlotFromHash(uint8 h);
88  static uint4 getMethodFromHash(uint8 h);
89  static OpCode getOpCodeFromHash(uint8 h);
90  static uint4 getPositionFromHash(uint8 h);
91  static uint4 getTotalFromHash(uint8 h);
92  static bool getIsNotAttached(uint8 h);
93  static void clearTotalPosition(uint8 &h);
94  static uint4 transtable[];
95 };
96 
97 #endif
OpCode
The op-code defining a specific p-code operation (PcodeOp)
Definition: opcodes.hh:35
uint8 getHash(void) const
Get the (current) hash.
Definition: dynamic.hh:83
A hash utility to uniquely identify a temporary Varnode in data-flow.
Definition: dynamic.hh:60
Container for data structures associated with a single function.
Definition: funcdata.hh:45
bool operator<(const ToOpEdge &op2) const
Compare two edges based on PcodeOp.
Definition: dynamic.cc:66
Lowest level operation of the p-code language.
Definition: op.hh:58
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
ToOpEdge(const PcodeOp *o, int4 s)
Constructor.
Definition: dynamic.hh:34
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
The Varnode and VarnodeBank classes.
uint4 hash(uint4 reg) const
Hash this edge into an accumulator.
Definition: dynamic.cc:89
An edge between a Varnode and a PcodeOp.
Definition: dynamic.hh:30
const Address & getAddress(void) const
Get the (current) address.
Definition: dynamic.hh:85
int4 getSlot(void) const
Get the slot of the starting Varnode.
Definition: dynamic.hh:36
const PcodeOp * getOp(void) const
Get the PcodeOp defining the edge.
Definition: dynamic.hh:35