From 05b2a463483804c59b0921ffde839ec302e0125e Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Sun, 3 Feb 2019 12:07:28 -0500 Subject: [PATCH] adding irdb-deep to irdb-sdk --- include/inc-deep/deep.hpp | 39 ++++++++++++++++++++++++++++++ include/inc-util/register.hpp | 45 +++++++++++++++++++++++++++++++++++ include/irdb-deep | 9 +++++++ include/irdb-util | 3 +++ 4 files changed, 96 insertions(+) create mode 100644 include/inc-deep/deep.hpp create mode 100644 include/inc-util/register.hpp create mode 100644 include/irdb-deep diff --git a/include/inc-deep/deep.hpp b/include/inc-deep/deep.hpp new file mode 100644 index 0000000..1ab8fdf --- /dev/null +++ b/include/inc-deep/deep.hpp @@ -0,0 +1,39 @@ + +#include <irdb-core> +#include <irdb-util> +#include <map> +#include <set> +#include <memory> + + +namespace IRDB_SDK +{ + using namespace std; + + using AnalysisEngine_t = enum AnalysisEngine + { + aeSTARS, + aeMoon, + aeRida + }; + + using RegisterIDSet_t = set<RegisterID_t>; + using DeadRegisterMap_t = map<Instruction_t*,RegisterIDSet_t*>; + using StaticGlobalSet_t = InstructionSet_t; + using RangeSentinalSet_t = InstructionSet_t; + + class DeepAnalysis_t + { + protected: + DeepAnalysis_t() {} + DeepAnalysis_t(const DeepAnalysis_t& copy) = delete; + + public: + unique_ptr<DeadRegisterMap_t> getDeadRegisters() const = 0; + unique_ptr<StaticGlobalSet_t> getStaticGlobalRanges() const = 0; + unique_ptr<SentinalSet_t > getRangeSentials() const = 0; + + // factories + unique_ptr<DeepAnalysis_t> factory(FileIR_t* firp, const AnalysisEngine_t& ae=aeSTARS, vector<string> options={}); + }; +} diff --git a/include/inc-util/register.hpp b/include/inc-util/register.hpp new file mode 100644 index 0000000..e25f96d --- /dev/null +++ b/include/inc-util/register.hpp @@ -0,0 +1,45 @@ + +#include <string> + + +namespace IRDB_SDK +{ + using namespace std; + + using RegisterID_t = enum RegisterID + { + /* an register that's not valid on any machine, equiv. to a nullptr of registers */ + rn_UNKNOWN, + + /* x86 32 and 64 */ + rn_EFLAGS, + + /* x86 IP register names */ + rn_IP, rn_EIP=rn_IP, rn_RIP=rn_IP, + + /* x86 general purpose registers */ + rn_EAX, rn_EBX, rn_ECX, rn_EDX, rn_ESI, rn_EDI, rn_EBP, rn_ESP, rn_R8D, rn_R9D, rn_R10D, rn_R11D, rn_R12D, rn_R13D, rn_R14D, rn_R15D, + rn_RAX, rn_RBX, rn_RCX, rn_RDX, rn_RBP, rn_RSP, rn_RSI, rn_RDI, rn_R8, rn_R9 , rn_R10, rn_R11, rn_R12, rn_R13, rn_R14, rn_R15, + rn_AX, rn_BX, rn_CX, rn_DX, rn_BP, rn_SP, rn_SI, rn_DI, rn_R8W, rn_R9W, rn_R10W, rn_R11W, rn_R12W, rn_R13W, rn_R14W, rn_R15W, + rn_AH, rn_BH, rn_CH, rn_DH, rn_SIH, rn_DIH, rn_BPH, rn_SPH, + rn_AL, rn_BL, rn_CL, rn_DL, rn_SIL, rn_DIL, rn_BPL, rn_SPL, rn_R8B, rn_R9B, rn_R10B, rn_R11B, rn_R12B, rn_R13B, rn_R14B, rn_R15B, + + /* other x86 registers here (e.g., fp, xmm, etc.), eventually */ + + /* other archs support added here, eventually */ + }; + + RegisterID_t strToRegister (const string& p_regStr); + RegisterID_t strToRegister (const char * p_regStr); + bool isValidRegister (const RegisterID_t p_reg); + bool is64bitRegister (const RegisterID_t p_reg); + bool is32bitRegister (const RegisterID_t p_reg); + bool is16bitRegister (const RegisterID_t p_reg); + bool is8bitRegister (const RegisterID_t p_reg); + int getRegisterBitWidth (const RegisterID_t p_reg); + string registerToString (const RegisterID_t p_reg); + RegisterID_t convertRegisterTo64bit (const RegisterID_t p_reg); + RegisterID_t convertRegisterTo32bit (const RegisterID_t p_reg); + RegisterID_t convertRegisterTo16bit (const RegisterID_t p_reg); + +} diff --git a/include/irdb-deep b/include/irdb-deep new file mode 100644 index 0000000..bc7e909 --- /dev/null +++ b/include/irdb-deep @@ -0,0 +1,9 @@ + + +#ifndef IRDB_SDK_deep +#define IRDB_SDK_deep + + +#include <inc-deep/deep.hpp> + +#endif diff --git a/include/irdb-util b/include/irdb-util index a658784..2468876 100644 --- a/include/irdb-util +++ b/include/irdb-util @@ -19,6 +19,8 @@ */ #ifndef IRDB_SDK_util + +#include <irdb-core> #define IRDB_SDK_util /* Building a CFG depends on core functionality */ @@ -30,5 +32,6 @@ #include <inc-util/IBT_Provenance.hpp> #include <inc-util/params.hpp> #include <inc-util/utils.hpp> +#include <inc-util/register.hpp> #endif -- GitLab