diff options
| author | Brian Potchik <brian@vector35.com> | 2019-05-27 00:51:39 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2019-05-27 00:51:39 -0400 |
| commit | 312950417858a9d89446889fdee2e5988a699861 (patch) | |
| tree | 6cda347356c12d81327ae7b7adcf3b0ddc178645 | |
| parent | a3b1547175eb776498f15ff662ecf309a7af8009 (diff) | |
Add API to query settings properties.
| -rw-r--r-- | binaryninjaapi.h | 3 | ||||
| -rw-r--r-- | binaryninjacore.h | 1 | ||||
| -rw-r--r-- | python/settings.py | 9 | ||||
| -rw-r--r-- | settings.cpp | 15 |
4 files changed, 28 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 064dd213..e9277d65 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -4314,6 +4314,8 @@ namespace BinaryNinja bool RegisterGroup(const std::string& group, const std::string& title); bool RegisterSetting(const std::string& id, const std::string& properties); + template<typename T> T QueryProperty(const std::string& id, const std::string& property); + bool UpdateProperty(const std::string& id, const std::string& property); bool UpdateProperty(const std::string& id, const std::string& property, bool value); bool UpdateProperty(const std::string& id, const std::string& property, double value); @@ -4345,6 +4347,7 @@ namespace BinaryNinja }; // explicit specializations + template<> std::vector<std::string> Settings::QueryProperty<std::vector<std::string>>(const std::string& id, const std::string& property); template<> bool Settings::Get<bool>(const std::string& id, Ref<BinaryView> view, BNSettingsScope* scope); template<> double Settings::Get<double>(const std::string& id, Ref<BinaryView> view, BNSettingsScope* scope); template<> int64_t Settings::Get<int64_t>(const std::string& id, Ref<BinaryView> view, BNSettingsScope* scope); diff --git a/binaryninjacore.h b/binaryninjacore.h index e29b813c..cc707770 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3784,6 +3784,7 @@ extern "C" // Settings APIs BINARYNINJACOREAPI bool BNSettingsRegisterGroup(const char* registry, const char* group, const char* title); BINARYNINJACOREAPI bool BNSettingsRegisterSetting(const char* registry, const char* id, const char* properties); + BINARYNINJACOREAPI const char** BNSettingsQueryPropertyStringList(const char* registry, const char* id, const char* property, size_t* inoutSize); BINARYNINJACOREAPI bool BNSettingsUpdateProperty(const char* registry, const char* id, const char* property); BINARYNINJACOREAPI bool BNSettingsUpdateBoolProperty(const char* registry, const char* id, const char* property, bool value); BINARYNINJACOREAPI bool BNSettingsUpdateDoubleProperty(const char* registry, const char* id, const char* property, double value); diff --git a/python/settings.py b/python/settings.py index 61c1c771..92136460 100644 --- a/python/settings.py +++ b/python/settings.py @@ -66,6 +66,15 @@ class Settings(object): """ return core.BNSettingsRegisterSetting(self.registry_id, id, properties) + def query_property_string_list(self, id, property_name): + length = ctypes.c_ulonglong() + result = core.BNSettingsQueryPropertyStringList(self.registry_id, id, property_name, ctypes.byref(length)) + out_list = [] + for i in range(length.value): + out_list.append(pyNativeStr(result[i])) + core.BNFreeStringList(result, length) + return out_list + def update_property(self, id, setting_property): return core.BNSettingsUpdateProperty(self.registry_id, tr(), id, setting_property) diff --git a/settings.cpp b/settings.cpp index 6f1640a6..1c7bc819 100644 --- a/settings.cpp +++ b/settings.cpp @@ -18,6 +18,21 @@ bool Settings::RegisterSetting(const string& id, const string& properties) } +template<> vector<string> Settings::QueryProperty<vector<string>>(const string& id, const string& property) +{ + size_t size = 0; + char** outBuffer = (char**)BNSettingsQueryPropertyStringList(m_registry.c_str(), id.c_str(), property.c_str(), &size); + + vector<string> result; + result.reserve(size); + for (size_t i = 0; i < size; i++) + result.emplace_back(outBuffer[i]); + + BNFreeStringList(outBuffer, size); + return result; +} + + bool Settings::UpdateProperty(const std::string& id, const std::string& property) { return BNSettingsUpdateProperty(m_registry.c_str(), id.c_str(), property.c_str()); |
