From 06a10105c9dd2512859597b848251f9c32037125 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Fri, 10 Aug 2018 10:23:11 -0400 Subject: Fix ScriptingProvider reference counting and instance cleanup. --- scriptingprovider.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scriptingprovider.cpp') diff --git a/scriptingprovider.cpp b/scriptingprovider.cpp index 6a52e095..475d69ce 100644 --- a/scriptingprovider.cpp +++ b/scriptingprovider.cpp @@ -60,6 +60,7 @@ ScriptingInstance::ScriptingInstance(ScriptingProvider* provider) cb.setCurrentBasicBlock = SetCurrentBasicBlockCallback; cb.setCurrentAddress = SetCurrentAddressCallback; cb.setCurrentSelection = SetCurrentSelectionCallback; + AddRefForRegistration(); m_object = BNInitScriptingInstance(provider->GetObject(), &cb); } @@ -70,6 +71,12 @@ ScriptingInstance::ScriptingInstance(BNScriptingInstance* instance) } +ScriptingInstance::~ScriptingInstance() +{ + BNFreeScriptingInstance(m_object); +} + + void ScriptingInstance::DestroyInstanceCallback(void* ctxt) { ScriptingInstance* instance = (ScriptingInstance*)ctxt; -- cgit v1.3.1 From e8e844ef24483102103e6d20e8debbc78a687d17 Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Wed, 15 Aug 2018 09:43:26 -0400 Subject: Expose ScriptingProvider name in C++ bindings --- binaryninjaapi.h | 2 ++ docs/getting-started.md | 19 ++++++++++--------- scriptingprovider.cpp | 9 +++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'scriptingprovider.cpp') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 6cfa49bf..620c0472 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -3802,6 +3802,8 @@ namespace BinaryNinja public: virtual Ref CreateNewInstance() = 0; + std::string GetName(); + static std::vector> GetList(); static Ref GetByName(const std::string& name); static void Register(ScriptingProvider* provider); diff --git a/docs/getting-started.md b/docs/getting-started.md index 7e7e4acb..0e0bd596 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -265,9 +265,10 @@ Settings are stored in the _user_ directory in the file `settings.json`. Each to | ui | activeContent | boolean | True | Allow Binary Ninja to connect to the web to check for updates | | ui | colorblind | boolean | True | Choose colors that are visible to those with red/green colorblind | | ui | debug | boolean | False | Enable developer debugging features (Additional views: Lifted IL, and SSA forms) | -| ui | recent-file-limit | integer | 10 | Specify limit for number of recent files | +| ui | recent-file-limit | integer | 10 | Specify limit for number of recent files | +| ui | scriptingprovider | string | "Python" | Specify the registered ScriptingProvider that controls the 'Console' in the UI | | pdb | local-store-absolute | string | "" | Absolute path specifying where the pdb symbol store exists on this machine, overrides relative path | -| pdb | local-store-relative | string | "symbols" | Path *relative* to the binaryninja _user_ directory, sepcifying the pdb symbol store | +| pdb | local-store-relative | string | "symbols" | Path *relative* to the binaryninja _user_ directory, sepcifying the pdb symbol store | | pdb | auto-download-pdb | boolean | True | Automatically download pdb files from specified symbol servers | | pdb | symbol-server-list | list(string) | ["http://msdl.microsoft.com/download/symbols"] | List of servers to query for pdb symbols. | | python | interpreter | string | "python27.{dylib,dll,so.1}" | Python interpreter to load if one is not already present when plugins are loaded | @@ -275,13 +276,13 @@ Settings are stored in the _user_ directory in the file `settings.json`. Each to Below is an example `settings.json` setting various options: ``` { - "ui" : - { - "activeContent" : false, - "colorblind" : false, - "debug" : true - "recent-file-limit" : 10 - } + "ui" : + { + "activeContent" : false, + "colorblind" : false, + "debug" : true + "recent-file-limit" : 10 + } "pdb" : { "local-store-absolute" : "C:\Symbols", diff --git a/scriptingprovider.cpp b/scriptingprovider.cpp index 475d69ce..2a233cfe 100644 --- a/scriptingprovider.cpp +++ b/scriptingprovider.cpp @@ -252,6 +252,15 @@ BNScriptingInstance* ScriptingProvider::CreateInstanceCallback(void* ctxt) } +string ScriptingProvider::GetName() +{ + char* providerNameRaw = BNGetScriptingProviderName(m_object); + string providerName(providerNameRaw); + BNFreeString(providerNameRaw); + return providerName; +} + + vector> ScriptingProvider::GetList() { size_t count; -- cgit v1.3.1