about summary refs log tree commit diff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..c213f22
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "include/utils.hpp"
+#include "include/disassemble.hpp"
+
+/* AARM64 dissasembler */
+
+int main(int argc, char** argv)
+{
+    (void)argc;
+    int fd;
+    uint64_t textstart;
+    uint64_t textend;
+    struct stat sb;
+    uint8_t* buffer;
+
+    fd = open(argv[1], O_RDONLY);
+    fstat(fd, &sb);
+
+    buffer = (uint8_t*)mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+    textstart = 0;
+    textend = sb.st_size;
+    Utils::findelf(buffer, &textstart, &textend);
+
+    uint32_t pos = 0;
+    while((pos + textstart) < textend)
+        pos += Disasm::disassemble(buffer, pos, textstart);
+
+    munmap(buffer, sb.st_size);
+
+    return 0;
+}