Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2017-13861/liboffsetfinder64/insn.hpp
Views: 11784
//1// insn.hpp2// liboffsetfinder643//4// Created by tihmstar on 09.03.18.5// Copyright © 2018 tihmstar. All rights reserved.6//78#ifndef insn_hpp9#define insn_hpp1011#include "common.h"12#include <vector>1314namespace tihmstar{15namespace patchfinder64{16class insn{17public:18enum segtype{19kText_only,20kData_only,21kText_and_Data22};23private:24std::pair <loc_t,int> _p;25std::vector<text_t> _segments;26segtype _segtype;27public:28insn(segment_t segments, loc_t p = 0, segtype segType = kText_only);29insn(const insn &cpy, loc_t p=0);30insn &operator++();31insn &operator--();32insn operator+(int i);33insn operator-(int i);34insn &operator+=(int i);35insn &operator-=(int i);36insn &operator=(loc_t p);3738public: //helpers39uint64_t pc();40uint32_t value();41uint64_t doublevalue();4243public: //static type determinition44static uint64_t deref(segment_t segments, loc_t p);45static bool is_adrp(uint32_t i);46static bool is_adr(uint32_t i);47static bool is_add(uint32_t i);48static bool is_bl(uint32_t i);49static bool is_cbz(uint32_t i);50static bool is_ret(uint32_t i);51static bool is_tbnz(uint32_t i);52static bool is_br(uint32_t i);53static bool is_ldr(uint32_t i);54static bool is_cbnz(uint32_t i);55static bool is_movk(uint32_t i);56static bool is_orr(uint32_t i);57static bool is_and(uint32_t i);58static bool is_tbz(uint32_t i);59static bool is_ldxr(uint32_t i);60static bool is_ldrb(uint32_t i);61static bool is_str(uint32_t i);62static bool is_stp(uint32_t i);63static bool is_movz(uint32_t i);64static bool is_bcond(uint32_t i);65static bool is_b(uint32_t i);66static bool is_nop(uint32_t i);6768public: //type69enum type{70unknown,71adrp,72adr,73bl,74cbz,75ret,76tbnz,77add,78br,79ldr,80cbnz,81movk,82orr,83tbz,84ldxr,85ldrb,86str,87stp,88movz,89bcond,90b,91nop,92and_93};94enum subtype{95st_general,96st_register,97st_immediate,98st_literal99};100enum supertype{101sut_general,102sut_branch_imm103};104enum cond{105NE = 000,106EG = 000,107CS = 001,108CC = 001,109MI = 010,110PL = 010,111VS = 011,112VC = 011,113HI = 100,114LS = 100,115GE = 101,116LT = 101,117GT = 110,118LE = 110,119AL = 111120};121type type();122subtype subtype();123supertype supertype();124int64_t imm();125uint8_t rd();126uint8_t rn();127uint8_t rt();128uint8_t other();129public: //cast operators130operator void*();131operator loc_t();132operator enum type();133};134135loc_t find_literal_ref(segment_t segemts, loc_t pos, int ignoreTimes = 0);136loc_t find_rel_branch_source(insn bdst, bool searchUp, int ignoreTimes=0, int limit = 0);137138};139};140141142#endif /* insn_hpp */143144145