libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
cpuInterface.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_CPUINTERFACE_HPP
9#define TRITON_CPUINTERFACE_HPP
10
11#include <set>
12#include <string>
13#include <unordered_map>
14#include <vector>
15
16#include <triton/archEnums.hpp>
17#include <triton/dllexport.hpp>
20#include <triton/register.hpp>
22
23
24
26namespace triton {
33 namespace arch {
43 public:
45 TRITON_EXPORT virtual ~CpuInterface(){};
46
48 TRITON_EXPORT virtual void clear(void) = 0;
49
51 TRITON_EXPORT virtual triton::arch::endianness_e getEndianness(void) const = 0;
52
54 TRITON_EXPORT virtual bool isFlag(triton::arch::register_e regId) const = 0;
55
57 TRITON_EXPORT virtual bool isRegister(triton::arch::register_e regId) const = 0;
58
60 TRITON_EXPORT virtual bool isRegisterValid(triton::arch::register_e regId) const = 0;
61
63 TRITON_EXPORT virtual bool isThumb(void) const = 0;
64
66 TRITON_EXPORT virtual void setThumb(bool state) = 0;
67
69 TRITON_EXPORT virtual bool isMemoryExclusive(const triton::arch::MemoryAccess& mem) const = 0;
70
72 TRITON_EXPORT virtual void setMemoryExclusiveTag(const triton::arch::MemoryAccess& mem, bool tag) = 0;
73
75 TRITON_EXPORT virtual triton::uint32 gprSize(void) const = 0;
76
78 TRITON_EXPORT virtual triton::uint32 gprBitSize(void) const = 0;
79
81 TRITON_EXPORT virtual triton::uint32 numberOfRegisters(void) const = 0;
82
84 TRITON_EXPORT virtual std::set<const triton::arch::Register*> getParentRegisters(void) const = 0;
85
87 TRITON_EXPORT virtual const std::unordered_map<triton::arch::register_e, const triton::arch::Register>& getAllRegisters(void) const = 0;
88
90 TRITON_EXPORT virtual const std::unordered_map<triton::uint64, triton::uint8, IdentityHash<triton::uint64>>& getConcreteMemory(void) const = 0;
91
93 TRITON_EXPORT virtual const triton::arch::Register& getParentRegister(const triton::arch::Register& reg) const = 0;
94
96 TRITON_EXPORT virtual const triton::arch::Register& getParentRegister(triton::arch::register_e id) const = 0;
97
99 TRITON_EXPORT virtual const triton::arch::Register& getRegister(triton::arch::register_e id) const = 0;
100
102 TRITON_EXPORT virtual const triton::arch::Register& getRegister(const std::string& name) const = 0;
103
105 TRITON_EXPORT virtual const triton::arch::Register& getProgramCounter(void) const = 0;
106
108 TRITON_EXPORT virtual const triton::arch::Register& getStackPointer(void) const = 0;
109
111 TRITON_EXPORT virtual void disassembly(triton::arch::Instruction& inst) = 0;
112
114 TRITON_EXPORT virtual triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const = 0;
115
117 TRITON_EXPORT virtual triton::uint512 getConcreteMemoryValue(const triton::arch::MemoryAccess& mem, bool execCallbacks=true) const = 0;
118
120 TRITON_EXPORT virtual std::vector<triton::uint8> getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const = 0;
121
123 TRITON_EXPORT virtual triton::uint512 getConcreteRegisterValue(const triton::arch::Register& reg, bool execCallbacks=true) const = 0;
124
131 TRITON_EXPORT virtual void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true) = 0;
132
139 TRITON_EXPORT virtual void setConcreteMemoryValue(const triton::arch::MemoryAccess& mem, const triton::uint512& value, bool execCallbacks=true) = 0;
140
147 TRITON_EXPORT virtual void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector<triton::uint8>& values, bool execCallbacks=true) = 0;
148
155 TRITON_EXPORT virtual void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const void* area, triton::usize size, bool execCallbacks=true) = 0;
156
163 TRITON_EXPORT virtual void setConcreteRegisterValue(const triton::arch::Register& reg, const triton::uint512& value, bool execCallbacks=true) = 0;
164
166 TRITON_EXPORT virtual bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess& mem) const = 0;
167
169 TRITON_EXPORT virtual bool isConcreteMemoryValueDefined(triton::uint64 baseAddr, triton::usize size=1) const = 0;
170
172 TRITON_EXPORT virtual void clearConcreteMemoryValue(const triton::arch::MemoryAccess& mem) = 0;
173
175 TRITON_EXPORT virtual void clearConcreteMemoryValue(triton::uint64 baseAddr, triton::usize size=1) = 0;
176 };
177
179 };
181};
182
183#endif /* TRITON_CPUINTERFACE_HPP */
This interface is used as abstract CPU interface. All CPU must use this interface.
virtual TRITON_EXPORT triton::uint32 gprBitSize(void) const =0
Returns the bit in bit of the General Purpose Registers.
virtual TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const void *area, triton::usize size, bool execCallbacks=true)=0
[architecture api] - Sets the concrete value of a memory area.
virtual TRITON_EXPORT void clearConcreteMemoryValue(const triton::arch::MemoryAccess &mem)=0
Clears concrete values assigned to the memory cells.
virtual TRITON_EXPORT void setConcreteMemoryAreaValue(triton::uint64 baseAddr, const std::vector< triton::uint8 > &values, bool execCallbacks=true)=0
[architecture api] - Sets the concrete value of a memory area.
virtual TRITON_EXPORT void setConcreteMemoryValue(triton::uint64 addr, triton::uint8 value, bool execCallbacks=true)=0
[architecture api] - Sets the concrete value of a memory cell.
virtual TRITON_EXPORT void setThumb(bool state)=0
Sets CPU state to Thumb mode.
virtual TRITON_EXPORT triton::uint512 getConcreteMemoryValue(const triton::arch::MemoryAccess &mem, bool execCallbacks=true) const =0
Returns the concrete value of memory cells.
virtual TRITON_EXPORT const triton::arch::Register & getParentRegister(const triton::arch::Register &reg) const =0
Returns parent register from a given one.
virtual TRITON_EXPORT bool isRegisterValid(triton::arch::register_e regId) const =0
Returns true if the register ID is valid.
virtual TRITON_EXPORT const triton::arch::Register & getProgramCounter(void) const =0
Returns the program counter register.
virtual TRITON_EXPORT void setConcreteMemoryValue(const triton::arch::MemoryAccess &mem, const triton::uint512 &value, bool execCallbacks=true)=0
[architecture api] - Sets the concrete value of memory cells.
virtual TRITON_EXPORT void setConcreteRegisterValue(const triton::arch::Register &reg, const triton::uint512 &value, bool execCallbacks=true)=0
[architecture api] - Sets the concrete value of a register.
virtual TRITON_EXPORT const triton::arch::Register & getRegister(triton::arch::register_e id) const =0
Returns register from id.
virtual TRITON_EXPORT bool isConcreteMemoryValueDefined(triton::uint64 baseAddr, triton::usize size=1) const =0
Returns true if memory cells have a defined concrete value.
virtual TRITON_EXPORT std::set< const triton::arch::Register * > getParentRegisters(void) const =0
Returns all parent registers.
virtual TRITON_EXPORT bool isFlag(triton::arch::register_e regId) const =0
Returns true if the register ID is a flag.
virtual TRITON_EXPORT void clear(void)=0
Clears the architecture states (registers and memory).
virtual TRITON_EXPORT bool isConcreteMemoryValueDefined(const triton::arch::MemoryAccess &mem) const =0
Returns true if memory cells have a defined concrete value.
virtual TRITON_EXPORT triton::uint32 gprSize(void) const =0
Returns the bit in byte of the General Purpose Registers.
virtual TRITON_EXPORT triton::arch::endianness_e getEndianness(void) const =0
Returns the kind of endianness as triton::arch::endianness_e.
virtual TRITON_EXPORT bool isMemoryExclusive(const triton::arch::MemoryAccess &mem) const =0
Returns true if the given memory access is tagged as exclusive. Only valid for Arm32 and AArch64.
virtual TRITON_EXPORT void clearConcreteMemoryValue(triton::uint64 baseAddr, triton::usize size=1)=0
Clears concrete values assigned to the memory cells.
virtual TRITON_EXPORT const std::unordered_map< triton::uint64, triton::uint8, IdentityHash< triton::uint64 > > & getConcreteMemory(void) const =0
Return all memory.
virtual TRITON_EXPORT ~CpuInterface()
Destructor.
virtual TRITON_EXPORT void setMemoryExclusiveTag(const triton::arch::MemoryAccess &mem, bool tag)=0
Sets exclusive memory access tag. Only valid for Arm32 and AArch64.
virtual TRITON_EXPORT void disassembly(triton::arch::Instruction &inst)=0
Disassembles the instruction according to the architecture.
virtual TRITON_EXPORT bool isThumb(void) const =0
Returns true if the execution mode is Thumb. Only useful for Arm32.
virtual TRITON_EXPORT bool isRegister(triton::arch::register_e regId) const =0
Returns true if the register ID is a register.
virtual TRITON_EXPORT const triton::arch::Register & getParentRegister(triton::arch::register_e id) const =0
Returns parent register from a given one.
virtual TRITON_EXPORT std::vector< triton::uint8 > getConcreteMemoryAreaValue(triton::uint64 baseAddr, triton::usize size, bool execCallbacks=true) const =0
Returns the concrete value of a memory area.
virtual TRITON_EXPORT const triton::arch::Register & getStackPointer(void) const =0
Returns the stack pointer register.
virtual TRITON_EXPORT triton::uint8 getConcreteMemoryValue(triton::uint64 addr, bool execCallbacks=true) const =0
Returns the concrete value of a memory cell.
virtual TRITON_EXPORT triton::uint32 numberOfRegisters(void) const =0
Returns the number of registers according to the CPU architecture.
virtual TRITON_EXPORT const triton::arch::Register & getRegister(const std::string &name) const =0
Returns register from name.
virtual TRITON_EXPORT triton::uint512 getConcreteRegisterValue(const triton::arch::Register &reg, bool execCallbacks=true) const =0
Returns the concrete value of a register.
virtual TRITON_EXPORT const std::unordered_map< triton::arch::register_e, const triton::arch::Register > & getAllRegisters(void) const =0
Returns all registers.
This class is used to represent an instruction.
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition register.hpp:44
register_e
Types of register.
Definition archEnums.hpp:68
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
std::uint8_t uint8
unisgned 8-bits
The Triton namespace.