about summary refs log tree commit diff
path: root/src/include
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-07-20 02:54:22 +0200
committerYour Name <you@example.com>2020-07-20 02:54:22 +0200
commitc69f053c29faa47d0600f5b147835e970d9cf654 (patch)
treed97af2f279114c72c3db81ffb489c316fb3f6dd6 /src/include
downloadAARM64-Disassembler-master.tar.gz
AARM64-Disassembler-master.tar.bz2
AARM64-Disassembler-master.zip
Initial Commit HEAD master
Half-added some basic AARM64 instructions such as ADD, RET, MOV, NOP...
Diffstat (limited to 'src/include')
-rw-r--r--src/include/disassemble.hpp13
-rw-r--r--src/include/instructionhandler.hpp14
-rw-r--r--src/include/instructions.hpp35
-rw-r--r--src/include/utils.hpp13
4 files changed, 75 insertions, 0 deletions
diff --git a/src/include/disassemble.hpp b/src/include/disassemble.hpp
new file mode 100644
index 0000000..fde8fb8
--- /dev/null
+++ b/src/include/disassemble.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "utils.hpp"
+#include "instructions.hpp"
+
+class Disasm
+{
+public:
+    static int disassemble(const uint8_t* buffer, uint32_t pos, uint32_t offset);
+};
diff --git a/src/include/instructionhandler.hpp b/src/include/instructionhandler.hpp
new file mode 100644
index 0000000..c61d3e2
--- /dev/null
+++ b/src/include/instructionhandler.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <tuple>
+#include "instructions.hpp"
+
+class InstructionHanlder
+{
+public:
+    static InstructionType getInstruction(Instruction* instr);
+    static std::string getInstructionString(Instruction* instr);
+private:
+    static std::tuple<std::string, std::string, InstructionType> getTpl(Instruction* instr);
+    static std::tuple<std::string, std::string, InstructionType> array[6];
+};
diff --git a/src/include/instructions.hpp b/src/include/instructions.hpp
new file mode 100644
index 0000000..ed354b4
--- /dev/null
+++ b/src/include/instructions.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <stdint.h>
+#include <string>
+
+#include "utils.hpp"
+#include "disassemble.hpp"
+
+enum class InstructionType
+{
+    NUL,
+    ADD,
+    ADD_SHIFTED_REG,
+    SUB,
+    MOV,
+    MOVZ,
+    RET,
+    NOP
+};
+
+class Instruction
+{
+public:
+    Instruction(uint8_t* hex, uint32_t offset, uint32_t pos);
+    uint8_t bits[33];
+    uint32_t offset;
+    uint32_t pos;
+    uint32_t addr;
+    InstructionType type;
+    std::string string;
+    uint32_t hex;
+};
+
+#include "instructionhandler.hpp"
+
diff --git a/src/include/utils.hpp b/src/include/utils.hpp
new file mode 100644
index 0000000..5c7cc39
--- /dev/null
+++ b/src/include/utils.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <stdint.h>
+#include <string.h>
+#include <elf.h>
+
+class Utils
+{
+public:
+    static void findelf(uint8_t* buffer, uint64_t* textstart, uint64_t* textend);
+    static void getbinaryrepresentation(uint8_t* bytes, size_t numbytes, uint8_t* buf);
+    static uint8_t tobit(uint8_t byte, uint8_t pos);
+};