libTriton  version 1.0 build 1558
memoryAccess.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_MEMORYACCESS_HPP
9#define TRITON_MEMORYACCESS_HPP
10
11#include <triton/archEnums.hpp>
12#include <triton/ast.hpp>
13#include <triton/bitsVector.hpp>
14#include <triton/cpuSize.hpp>
15#include <triton/dllexport.hpp>
16#include <triton/immediate.hpp>
17#include <triton/register.hpp>
19
20
21
23namespace triton {
30 namespace arch {
40 class MemoryAccess : public BitsVector {
41 protected:
44
47
50
53
56
59
62
65
66 private:
68 void copy(const MemoryAccess& other);
69
70 public:
72 TRITON_EXPORT MemoryAccess();
73
75 TRITON_EXPORT MemoryAccess(triton::uint64 address, triton::uint32 size /* bytes */);
76
78 TRITON_EXPORT MemoryAccess(const MemoryAccess& other);
79
81 TRITON_EXPORT triton::ast::SharedAbstractNode getLeaAst(void) const;
82
84 TRITON_EXPORT triton::uint64 getAddress(void) const;
85
87 TRITON_EXPORT triton::uint64 getPcRelative(void) const;
88
90 TRITON_EXPORT triton::uint32 getBitSize(void) const;
91
93 TRITON_EXPORT triton::uint32 getSize(void) const;
94
96 TRITON_EXPORT triton::arch::operand_e getType(void) const;
97
99 TRITON_EXPORT triton::arch::Register& getSegmentRegister(void);
100
102 TRITON_EXPORT triton::arch::Register& getBaseRegister(void);
103
105 TRITON_EXPORT triton::arch::Register& getIndexRegister(void);
106
108 TRITON_EXPORT triton::arch::Immediate& getDisplacement(void);
109
111 TRITON_EXPORT triton::arch::Immediate& getScale(void);
112
114 TRITON_EXPORT const triton::arch::Register& getConstSegmentRegister(void) const;
115
117 TRITON_EXPORT const triton::arch::Register& getConstBaseRegister(void) const;
118
120 TRITON_EXPORT const triton::arch::Register& getConstIndexRegister(void) const;
121
123 TRITON_EXPORT const triton::arch::Immediate& getConstDisplacement(void) const;
124
126 TRITON_EXPORT const triton::arch::Immediate& getConstScale(void) const;
127
129 TRITON_EXPORT bool isOverlapWith(const MemoryAccess& other) const;
130
132 TRITON_EXPORT void setAddress(triton::uint64 addr);
133
135 TRITON_EXPORT void setPcRelative(triton::uint64 addr);
136
138 TRITON_EXPORT void setSegmentRegister(const triton::arch::Register& segment);
139
141 TRITON_EXPORT void setBaseRegister(const triton::arch::Register& base);
142
144 TRITON_EXPORT void setIndexRegister(const triton::arch::Register& index);
145
147 TRITON_EXPORT void setDisplacement(const triton::arch::Immediate& displacement);
148
150 TRITON_EXPORT void setScale(const triton::arch::Immediate& scale);
151
153 TRITON_EXPORT void setLeaAst(const triton::ast::SharedAbstractNode& ast);
154
156 TRITON_EXPORT MemoryAccess& operator=(const MemoryAccess& other);
157 };
158
160 TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const MemoryAccess& mem);
161
163 TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const MemoryAccess* mem);
164
166 TRITON_EXPORT bool operator==(const MemoryAccess& mem1, const MemoryAccess& mem2);
167
169 TRITON_EXPORT bool operator!=(const MemoryAccess& mem1, const MemoryAccess& mem2);
170
172 TRITON_EXPORT bool operator<(const MemoryAccess& mem1, const MemoryAccess& mem2);
173
176
178 };
180};
181
182#endif /* TRITON_MEMORYACCESS_HPP */
This class is used to deal with registers and memory as bits vector.
Definition: bitsVector.hpp:36
This class is used to represent an immediate.
Definition: immediate.hpp:37
This class is used to represent a memory access.
triton::arch::Register baseReg
LEA - If the operand has a base register, this attribute is filled.
TRITON_EXPORT bool isOverlapWith(const MemoryAccess &other) const
Returns true if other and self overlap.
triton::uint64 address
The memory' address.
TRITON_EXPORT triton::uint64 getPcRelative(void) const
LEA - Gets pc relative.
TRITON_EXPORT triton::ast::SharedAbstractNode getLeaAst(void) const
Returns the AST of the memory access (LEA).
TRITON_EXPORT void setDisplacement(const triton::arch::Immediate &displacement)
LEA - Sets the displacement operand.
triton::arch::Immediate displacement
LEA - If the operand has a displacement, this attribute is filled.
triton::uint64 pcRelative
Contains the pc relative if it exists.
TRITON_EXPORT triton::arch::Register & getSegmentRegister(void)
LEA - Returns the segment register operand.
TRITON_EXPORT const triton::arch::Register & getConstBaseRegister(void) const
LEA - Returns the base register operand.
TRITON_EXPORT void setLeaAst(const triton::ast::SharedAbstractNode &ast)
Sets the AST of the memory access (LEA).
TRITON_EXPORT const triton::arch::Register & getConstSegmentRegister(void) const
LEA - Returns the segment register operand.
TRITON_EXPORT triton::uint32 getBitSize(void) const
Returns the size (in bits) of the memory vector.
TRITON_EXPORT triton::arch::operand_e getType(void) const
Returns the type of the operand (triton::arch::OPERAND_MEMORY).
TRITON_EXPORT triton::arch::Register & getIndexRegister(void)
LEA - Returns the index register operand.
TRITON_EXPORT triton::arch::Immediate & getScale(void)
LEA - Returns the scale operand.
TRITON_EXPORT const triton::arch::Immediate & getConstDisplacement(void) const
LEA - Returns the displacement operand.
TRITON_EXPORT MemoryAccess & operator=(const MemoryAccess &other)
Copies a MemoryAccess.
TRITON_EXPORT void setScale(const triton::arch::Immediate &scale)
LEA - Sets the scale operand.
TRITON_EXPORT triton::uint64 getAddress(void) const
Returns the address of the memory.
TRITON_EXPORT void setPcRelative(triton::uint64 addr)
LEA - Sets pc relative.
TRITON_EXPORT triton::uint32 getSize(void) const
Returns the size (in bytes) of the memory vector.
TRITON_EXPORT triton::arch::Immediate & getDisplacement(void)
LEA - Returns the displacement operand.
triton::arch::Immediate scale
LEA - If the operand has a scale, this attribute is filled.
triton::arch::Register segmentReg
LEA - If the operand has a segment register, this attribute is filled.
triton::arch::Register indexReg
LEA - If the operand has an index register, this attribute is filled.
TRITON_EXPORT void setAddress(triton::uint64 addr)
Sets the address of the memory access.
TRITON_EXPORT void setIndexRegister(const triton::arch::Register &index)
LEA - Sets the index register operand.
TRITON_EXPORT triton::arch::Register & getBaseRegister(void)
LEA - Returns the base register operand.
triton::ast::SharedAbstractNode leaAst
The AST of the memory access (LEA).
TRITON_EXPORT const triton::arch::Register & getConstIndexRegister(void) const
LEA - Returns the index register operand.
TRITON_EXPORT const triton::arch::Immediate & getConstScale(void) const
LEA - Returns the scale operand.
TRITON_EXPORT void setSegmentRegister(const triton::arch::Register &segment)
LEA - Sets the segment register operand.
TRITON_EXPORT void setBaseRegister(const triton::arch::Register &base)
LEA - Sets the base register operand.
TRITON_EXPORT MemoryAccess()
Constructor.
This class is used when an instruction has a register operand.
Definition: register.hpp:44
bool operator==(const Immediate &imm1, const Immediate &imm2)
Compares two Immediate.
Definition: immediate.cpp:128
const bool FORCE_MEMORY_INITIALIZATION
Defines the force memory initialization constant.
std::ostream & operator<<(std::ostream &stream, BasicBlock &block)
Displays an BasicBlock.
Definition: basicBlock.cpp:82
bool operator!=(const Immediate &imm1, const Immediate &imm2)
Compares two Immediate.
Definition: immediate.cpp:137
bool operator<(const Immediate &imm1, const Immediate &imm2)
Compares two Immediate (needed for std::map)
Definition: immediate.cpp:142
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:59
std::uint64_t uint64
unisgned 64-bits
Definition: tritonTypes.hpp:42
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:39
The Triton namespace.