summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2025-06-20 16:05:02 -0400
committerBrian Potchik <brian@vector35.com>2025-06-20 16:05:02 -0400
commitbd163fb24e4ad95c82d769838c54b46b31262a0f (patch)
tree89b8fbdbdd6f48bae17b23beb6a32bec65f62f92
parent55b3ce7de85ef38158e0a248105d3eb2a8562871 (diff)
Update the Settings IsEmpty API for querying resources.
-rw-r--r--binaryninjaapi.h5
-rw-r--r--binaryninjacore.h6
-rw-r--r--python/settings.py15
-rw-r--r--settings.cpp16
4 files changed, 34 insertions, 8 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 2dc9b899..920d2eb0 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -17125,9 +17125,10 @@ namespace BinaryNinja {
/*! Determine if the active settings schema is empty
+ \param scope the settings scope to check, defaults to SettingsAutoScope
\return True if the active settings schema is empty, False otherwise
*/
- bool IsEmpty();
+ bool IsEmpty(BNSettingsScope scope = SettingsAutoScope);
/*! Retrieve the list of setting identifiers in the active settings schema
@@ -17154,6 +17155,7 @@ namespace BinaryNinja {
const std::string& contents, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
std::string SerializeSettings(Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
+ bool IsEmpty(Ref<BinaryView> view, BNSettingsScope scope = SettingsAutoScope);
bool Reset(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
bool ResetAll(
Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
@@ -17210,6 +17212,7 @@ namespace BinaryNinja {
bool DeserializeSettings(const std::string& contents, Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
std::string SerializeSettings(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
+ bool IsEmpty(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
bool Reset(const std::string& key, Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
bool ResetAll(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index fc98a10d..f94d4de6 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -37,14 +37,14 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 112
+#define BN_CURRENT_CORE_ABI_VERSION 113
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
// will require rebuilding. The minimum version is increased when there are
// incompatible changes that break binary compatibility, such as changes to
// existing types or functions.
-#define BN_MINIMUM_CORE_ABI_VERSION 100
+#define BN_MINIMUM_CORE_ABI_VERSION 113
#ifdef __GNUC__
#ifdef BINARYNINJACORE_LIBRARY
@@ -7429,7 +7429,7 @@ extern "C"
BINARYNINJACOREAPI bool BNSettingsRegisterGroup(BNSettings* settings, const char* group, const char* title);
BINARYNINJACOREAPI bool BNSettingsRegisterSetting(BNSettings* settings, const char* key, const char* properties);
BINARYNINJACOREAPI bool BNSettingsContains(BNSettings* settings, const char* key);
- BINARYNINJACOREAPI bool BNSettingsIsEmpty(BNSettings* settings);
+ BINARYNINJACOREAPI bool BNSettingsIsEmpty(BNSettings* settings, BNBinaryView* view, BNFunction* func, BNSettingsScope scope);
BINARYNINJACOREAPI const char** BNSettingsKeysList(BNSettings* settings, size_t* inoutSize);
BINARYNINJACOREAPI char* BNSettingsQueryPropertyString(BNSettings* settings, const char* key, const char* property);
BINARYNINJACOREAPI const char** BNSettingsQueryPropertyStringList(BNSettings* settings, const char* key, const char* property, size_t* inoutSize);
diff --git a/python/settings.py b/python/settings.py
index 50110df8..59a595e3 100644
--- a/python/settings.py
+++ b/python/settings.py
@@ -244,14 +244,25 @@ class Settings:
"""
return core.BNSettingsContains(self.handle, key)
- def is_empty(self) -> bool:
+ def is_empty(self, resource: Optional[Union['binaryview.BinaryView', 'function.Function']] = None, scope: 'SettingsScope' = SettingsScope.SettingsAutoScope) -> bool:
"""
``is_empty`` determine if the active settings schema is empty
+ :param resource: a BinaryView or Function object to check for emptiness
+ :param scope: the SettingsScope to check for emptiness
:return: True if the active settings schema is empty, False otherwise
:rtype: bool
"""
- return core.BNSettingsIsEmpty(self.handle)
+ view_handle = None
+ func_handle = None
+ if resource is not None:
+ if isinstance(resource, binaryview.BinaryView):
+ view_handle = resource.handle
+ elif isinstance(resource, function.Function):
+ func_handle = resource.handle
+ else:
+ raise TypeError("Expected resource to be either a BinaryView or a Function.")
+ return core.BNSettingsIsEmpty(self.handle, view_handle, func_handle, scope)
def keys(self) -> List[str]:
"""
diff --git a/settings.cpp b/settings.cpp
index ba8d65f6..d06e309b 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -57,9 +57,9 @@ bool Settings::Contains(const string& key)
}
-bool Settings::IsEmpty()
+bool Settings::IsEmpty(BNSettingsScope scope)
{
- return BNSettingsIsEmpty(m_object);
+ return BNSettingsIsEmpty(m_object, nullptr, nullptr, scope);
}
@@ -202,6 +202,12 @@ string Settings::SerializeSettings(Ref<BinaryView> view, BNSettingsScope scope)
}
+bool Settings::IsEmpty(Ref<BinaryView> view, BNSettingsScope scope)
+{
+ return BNSettingsIsEmpty(m_object, view ? view->GetObject() : nullptr, nullptr, scope);
+}
+
+
bool Settings::Reset(const string& key, Ref<BinaryView> view, BNSettingsScope scope)
{
return BNSettingsReset(m_object, key.c_str(), view ? view->GetObject() : nullptr, nullptr, scope);
@@ -360,6 +366,12 @@ string Settings::SerializeSettings(Ref<Function> func, BNSettingsScope scope)
}
+bool Settings::IsEmpty(Ref<Function> func, BNSettingsScope scope)
+{
+ return BNSettingsIsEmpty(m_object, nullptr, func ? func->GetObject() : nullptr, scope);
+}
+
+
bool Settings::Reset(const string& key, Ref<Function> func, BNSettingsScope scope)
{
return BNSettingsReset(m_object, key.c_str(), nullptr, func ? func->GetObject() : nullptr, scope);