summaryrefslogtreecommitdiff
path: root/examples/print_syscalls
diff options
context:
space:
mode:
authorBrick <6098371+0x1F9F1@users.noreply.github.com>2019-02-15 17:23:04 +0000
committerJordan <jordan@psifertex.com>2019-02-27 15:16:38 -0500
commit156ad4bb6d7c789c4f4a1c7daf635eb7d3a92400 (patch)
treee3f53c7d401e215a06c52582aad6ddfe5f3067d5 /examples/print_syscalls
parent49f6de04c7106e6ab8ce31fac6299f372a665698 (diff)
Greatly improved CMake builds + Fixed tests compilation
Diffstat (limited to 'examples/print_syscalls')
-rw-r--r--examples/print_syscalls/CMakeLists.txt18
-rw-r--r--examples/print_syscalls/src/arm-syscall.cpp30
2 files changed, 34 insertions, 14 deletions
diff --git a/examples/print_syscalls/CMakeLists.txt b/examples/print_syscalls/CMakeLists.txt
new file mode 100644
index 00000000..d8495b3c
--- /dev/null
+++ b/examples/print_syscalls/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
+
+project(print_syscalls CXX)
+
+add_executable(${PROJECT_NAME}
+ src/arm-syscall.cpp)
+
+target_link_libraries(${PROJECT_NAME}
+ binaryninjaapi)
+
+if (NOT WIN32)
+ target_link_libraries(${PROJECT_NAME}
+ dl)
+endif()
+
+set_target_properties(${PROJECT_NAME} PROPERTIES
+ CXX_STANDARD 11
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../bin)
diff --git a/examples/print_syscalls/src/arm-syscall.cpp b/examples/print_syscalls/src/arm-syscall.cpp
index 3424619b..2eb5e402 100644
--- a/examples/print_syscalls/src/arm-syscall.cpp
+++ b/examples/print_syscalls/src/arm-syscall.cpp
@@ -9,11 +9,12 @@
#include "binaryninjacore.h"
#include "binaryninjaapi.h"
+#include "lowlevelilinstruction.h"
using namespace BinaryNinja;
using namespace std;
-#ifndef __WIN32__
+#ifndef _WIN32
#include <libgen.h>
#include <dlfcn.h>
string get_plugins_directory()
@@ -29,7 +30,7 @@ string get_plugins_directory()
#else
string get_plugins_directory()
{
- return "C:\\Program Files\\Vector35\\Binary Ninja\\plugins\\";
+ return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\";
}
#endif
@@ -63,23 +64,24 @@ int main(int argc, char *argv[])
InitCorePlugins();
InitUserPlugins();
- auto bd = BinaryData(new FileMetadata(), fname);
- BinaryView *bv = 0;
-
- for (auto type : BinaryViewType::GetViewTypesForData(&bd)) {
- if (type->GetName() != "Raw") {
- bv = type->Create(&bd);
+ Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]);
+ Ref<BinaryView> bv;
+ for (auto type : BinaryViewType::GetViewTypes())
+ {
+ if (type->IsTypeValidForData(bd) && type->GetName() != "Raw")
+ {
+ bv = type->Create(bd);
break;
}
}
- if (!bv || bv->GetTypeName() == "Raw"){
- cerr << "Error: Unable to get any other view type besides Raw";
- exit(-1);
+ if (!bv || bv->GetTypeName() == "Raw")
+ {
+ fprintf(stderr, "Input file does not appear to be an exectuable\n");
+ return -1;
}
- bv->UpdateAnalysis();
- while (bv->GetAnalysisProgress().state != IdleState);
+ bv->UpdateAnalysisAndWait();
auto arch = bv->GetDefaultArchitecture();
auto platform = bv->GetDefaultPlatform();
@@ -100,7 +102,7 @@ int main(int argc, char *argv[])
auto instr = (*il_func)[il_func->GetIndexForInstruction(i)];
if (instr.operation == LLIL_SYSCALL) {
- auto reg_value = func->GetRegisterValueAtLowLevelILInstruction(i, reg);
+ auto reg_value = il_func->GetRegisterValueAtInstruction(reg, i);
cout << "System call address: 0x"
<< hex << instr.address