Skip to content

Commit 4785bbc

Browse files
committed
Add explicit API for cancelling plugin uninstalls.
1 parent a02818c commit 4785bbc

5 files changed

Lines changed: 20 additions & 1 deletion

File tree

binaryninjaapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20094,6 +20094,7 @@ namespace BinaryNinja {
2009420094
bool AreDependenciesBeingInstalled() const;
2009520095

2009620096
bool Uninstall();
20097+
bool CancelUninstall();
2009720098
bool Install(std::string versionID);
2009820099
bool InstallDependencies();
2009920100
// `force` ignores optional checks for platform/api compliance

binaryninjacore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 179
40+
#define BN_CURRENT_CORE_ABI_VERSION 180
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
@@ -8371,6 +8371,7 @@ extern "C"
83718371
BINARYNINJACOREAPI bool BNPluginInstall(BNPlugin* p, const char* versionID);
83728372
BINARYNINJACOREAPI bool BNPluginInstallDependencies(BNPlugin* p);
83738373
BINARYNINJACOREAPI bool BNPluginUninstall(BNPlugin* p);
8374+
BINARYNINJACOREAPI bool BNPluginCancelUninstall(BNPlugin* p);
83748375
BINARYNINJACOREAPI bool BNPluginUpdate(BNPlugin* p, const char* versionID);
83758376
BINARYNINJACOREAPI char** BNPluginGetPlatforms(BNPlugin* p, size_t* count);
83768377
BINARYNINJACOREAPI void BNFreePluginPlatforms(char** platforms, size_t count);

pluginmanager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ bool Extension::Uninstall()
309309
}
310310

311311

312+
bool Extension::CancelUninstall()
313+
{
314+
return BNPluginCancelUninstall(m_object);
315+
}
316+
317+
312318
bool Extension::Install(std::string versionID)
313319
{
314320
char* versionIDStr = BNAllocString(versionID.c_str());

python/pluginmanager.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,19 @@ def installed(self) -> bool:
9191

9292
def install(self, version_id=None) -> bool:
9393
"""Attempt to install the given plugin. Defaults to the latest available version."""
94+
if self.delete_pending:
95+
return self.cancel_uninstall()
9496
self.install_dependencies()
9597
return core.BNPluginInstall(self.handle, version_id)
9698

9799
def uninstall(self) -> bool:
98100
"""Attempt to uninstall the given plugin"""
99101
return core.BNPluginUninstall(self.handle)
100102

103+
def cancel_uninstall(self) -> bool:
104+
"""Cancel an uninstall that is pending until restart."""
105+
return core.BNPluginCancelUninstall(self.handle)
106+
101107
@installed.setter
102108
def installed(self, state: bool):
103109
if state:

rust/src/repository/plugin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ impl Extension {
253253
unsafe { BNPluginUninstall(self.handle.as_ptr()) }
254254
}
255255

256+
/// Cancel an uninstall that is pending until restart.
257+
pub fn cancel_uninstall(&self) -> bool {
258+
unsafe { BNPluginCancelUninstall(self.handle.as_ptr()) }
259+
}
260+
256261
pub fn updated(&self, version_id: &str) -> bool {
257262
let version_id_raw = version_id.to_cstr();
258263
unsafe { BNPluginUpdate(self.handle.as_ptr(), version_id_raw.as_ptr()) }

0 commit comments

Comments
 (0)