diff options
| author | Xusheng <xusheng@vector35.com> | 2022-08-08 13:12:11 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2022-08-08 13:14:52 +0800 |
| commit | eb5d564e7919b217b7a932fc7f9e576221e89574 (patch) | |
| tree | cfb9cb95b52d43c8225be4227e903bb849e3b5d4 /examples | |
| parent | b7521c12b31aa938e497bb25f893131405170cc6 (diff) | |
Use BinaryNinja::GetBundledPluginPath() to get the bundled plugin path. Close https://github.com/Vector35/binaryninja-api/issues/2982.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/bin-info/src/bin-info.cpp | 28 | ||||
| -rw-r--r-- | examples/llil_parser/src/llil_parser.cpp | 27 | ||||
| -rw-r--r-- | examples/mlil_parser/src/mlil_parser.cpp | 27 | ||||
| -rw-r--r-- | examples/print_syscalls/src/arm-syscall.cpp | 25 |
4 files changed, 9 insertions, 98 deletions
diff --git a/examples/bin-info/src/bin-info.cpp b/examples/bin-info/src/bin-info.cpp index 9503c734..3d2b2451 100644 --- a/examples/bin-info/src/bin-info.cpp +++ b/examples/bin-info/src/bin-info.cpp @@ -1,6 +1,6 @@ /* * Command line executable file that outputs - * some information about the exectuable passed to. + * some information about the executable passed to. */ #include <sys/stat.h> @@ -15,26 +15,6 @@ using namespace BinaryNinja; using namespace std; -#ifndef _WIN32 - #include <libgen.h> - #include <dlfcn.h> -string get_plugins_directory() -{ - Dl_info info; - if (!dladdr((void*)BNGetBundledPluginDirectory, &info)) - return NULL; - - stringstream ss; - ss << dirname((char*)info.dli_fname) << "/plugins/"; - return ss.str(); -} -#else -string get_plugins_directory() -{ - return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\"; -} -#endif - bool is_file(char* fname) { struct stat buf; @@ -60,10 +40,8 @@ int main(int argc, char* argv[]) } /* In order to initiate the bundled plugins properly, the location - * of where bundled plugins directory is must be set. Since - * libbinaryninjacore is in the path get the path to it and use it to - * determine the plugins directory */ - SetBundledPluginDirectory(get_plugins_directory()); + * of where bundled plugins directory is must be set. */ + SetBundledPluginDirectory(GetBundledPluginDirectory()); InitPlugins(); Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]); diff --git a/examples/llil_parser/src/llil_parser.cpp b/examples/llil_parser/src/llil_parser.cpp index d700e7ce..fcff0612 100644 --- a/examples/llil_parser/src/llil_parser.cpp +++ b/examples/llil_parser/src/llil_parser.cpp @@ -8,27 +8,6 @@ using namespace BinaryNinja; using namespace std; -#ifndef _WIN32 - #include <libgen.h> - #include <dlfcn.h> -static string GetPluginsDirectory() -{ - Dl_info info; - if (!dladdr((void*)BNGetBundledPluginDirectory, &info)) - return NULL; - - stringstream ss; - ss << dirname((char*)info.dli_fname) << "/plugins/"; - return ss.str(); -} -#else -static string GetPluginsDirectory() -{ - return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\"; -} -#endif - - static void PrintIndent(size_t indent) { for (size_t i = 0; i < indent; i++) @@ -309,10 +288,8 @@ int main(int argc, char* argv[]) } // In order to initiate the bundled plugins properly, the location - // of where bundled plugins directory is must be set. Since - // libbinaryninjacore is in the path get the path to it and use it to - // determine the plugins directory - SetBundledPluginDirectory(GetPluginsDirectory()); + // of where bundled plugins directory is must be set. + SetBundledPluginDirectory(GetBundledPluginDirectory()); InitPlugins(); Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]); diff --git a/examples/mlil_parser/src/mlil_parser.cpp b/examples/mlil_parser/src/mlil_parser.cpp index c31ec035..6122dbc7 100644 --- a/examples/mlil_parser/src/mlil_parser.cpp +++ b/examples/mlil_parser/src/mlil_parser.cpp @@ -8,27 +8,6 @@ using namespace BinaryNinja; using namespace std; -#ifndef _WIN32 - #include <libgen.h> - #include <dlfcn.h> -static string GetPluginsDirectory() -{ - Dl_info info; - if (!dladdr((void*)BNGetBundledPluginDirectory, &info)) - return NULL; - - stringstream ss; - ss << dirname((char*)info.dli_fname) << "/plugins/"; - return ss.str(); -} -#else -static string GetPluginsDirectory() -{ - return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\"; -} -#endif - - static void PrintIndent(size_t indent) { for (size_t i = 0; i < indent; i++) @@ -257,10 +236,8 @@ int main(int argc, char* argv[]) } // In order to initiate the bundled plugins properly, the location - // of where bundled plugins directory is must be set. Since - // libbinaryninjacore is in the path get the path to it and use it to - // determine the plugins directory - SetBundledPluginDirectory(GetPluginsDirectory()); + // of where bundled plugins directory must be set + SetBundledPluginDirectory(GetBundledPluginDirectory()); InitPlugins(); Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]); diff --git a/examples/print_syscalls/src/arm-syscall.cpp b/examples/print_syscalls/src/arm-syscall.cpp index e74f8324..b21a2a27 100644 --- a/examples/print_syscalls/src/arm-syscall.cpp +++ b/examples/print_syscalls/src/arm-syscall.cpp @@ -14,25 +14,6 @@ using namespace BinaryNinja; using namespace std; -#ifndef _WIN32 - #include <libgen.h> - #include <dlfcn.h> -string get_plugins_directory() -{ - Dl_info info; - if (!dladdr((void*)BNGetBundledPluginDirectory, &info)) - return NULL; - - stringstream ss; - ss << dirname((char*)info.dli_fname) << "/plugins/"; - return ss.str(); -} -#else -string get_plugins_directory() -{ - return "C:\\Program Files\\Vector35\\BinaryNinja\\plugins\\"; -} -#endif bool is_file(char* fname) { @@ -59,10 +40,8 @@ int main(int argc, char* argv[]) } /* In order to initiate the bundled plugins properly, the location - * of where bundled plugins directory is must be set. Since - * libbinaryninjacore is in the path get the path to it and use it to - * determine the plugins directory */ - SetBundledPluginDirectory(get_plugins_directory()); + * of where bundled plugins directory is must be set.*/ + SetBundledPluginDirectory(GetBundledPluginDirectory()); InitPlugins(); Ref<BinaryData> bd = new BinaryData(new FileMetadata(), argv[1]); |
