summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h3
-rw-r--r--binaryninjacore.h4
-rw-r--r--debuginfo.cpp14
-rw-r--r--rust/src/debuginfo.rs17
4 files changed, 36 insertions, 2 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 22b72ee4..fa076984 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -6953,11 +6953,13 @@ namespace BinaryNinja {
std::string GetName() const;
Ref<DebugInfo> Parse(Ref<BinaryView> view, Ref<DebugInfo> existingDebugInfo = nullptr) const;
+ bool IsExternal() const;
bool IsValidForView(const Ref<BinaryView> view) const;
};
class CustomDebugInfoParser : public DebugInfoParser
{
+ static bool IsExternalCallback(void* ctxt);
static bool IsValidCallback(void* ctxt, BNBinaryView* view);
static void ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view);
BNDebugInfoParser* Register(const std::string& name);
@@ -6966,6 +6968,7 @@ namespace BinaryNinja {
CustomDebugInfoParser(const std::string& name);
virtual ~CustomDebugInfoParser() {}
+ virtual bool IsExternal() = 0;
virtual bool IsValid(Ref<BinaryView>) = 0;
virtual void ParseInfo(Ref<DebugInfo>, Ref<BinaryView>) = 0;
};
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 9961f45b..64b41bde 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -6109,13 +6109,15 @@ extern "C"
BINARYNINJACOREAPI char* BNRustSimplifyStrToStr(const char* const);
BINARYNINJACOREAPI BNDebugInfoParser* BNRegisterDebugInfoParser(const char* name,
- bool (*isValid)(void*, BNBinaryView*), void (*parseInfo)(void*, BNDebugInfo*, BNBinaryView*), void* context);
+ bool(*IsExternal)(void*), bool (*isValid)(void*, BNBinaryView*),
+ void (*parseInfo)(void*, BNDebugInfo*, BNBinaryView*), void* context);
BINARYNINJACOREAPI void BNUnregisterDebugInfoParser(const char* rawName);
BINARYNINJACOREAPI BNDebugInfoParser* BNGetDebugInfoParserByName(const char* name);
BINARYNINJACOREAPI BNDebugInfoParser** BNGetDebugInfoParsers(size_t* count);
BINARYNINJACOREAPI BNDebugInfoParser** BNGetDebugInfoParsersForView(BNBinaryView* view, size_t* count);
BINARYNINJACOREAPI char* BNGetDebugInfoParserName(BNDebugInfoParser* parser);
BINARYNINJACOREAPI bool BNIsDebugInfoParserValidForView(BNDebugInfoParser* parser, BNBinaryView* view);
+ BINARYNINJACOREAPI bool BNIsDebugInfoParserExternal(BNDebugInfoParser* parser);
BINARYNINJACOREAPI BNDebugInfo* BNParseDebugInfo(
BNDebugInfoParser* parser, BNBinaryView* view, BNDebugInfo* existingDebugInfo);
BINARYNINJACOREAPI BNDebugInfoParser* BNNewDebugInfoParserReference(BNDebugInfoParser* parser);
diff --git a/debuginfo.cpp b/debuginfo.cpp
index e8450399..59636d4a 100644
--- a/debuginfo.cpp
+++ b/debuginfo.cpp
@@ -222,6 +222,12 @@ Ref<DebugInfo> DebugInfoParser::Parse(Ref<BinaryView> view, Ref<DebugInfo> exist
}
+bool DebugInfoParser::IsExternal() const
+{
+ return BNIsDebugInfoParserExternal(m_object);
+}
+
+
bool DebugInfoParser::IsValidForView(const Ref<BinaryView> view) const
{
return BNIsDebugInfoParserValidForView(m_object, view->GetObject());
@@ -232,6 +238,12 @@ bool DebugInfoParser::IsValidForView(const Ref<BinaryView> view) const
// Plugin registration APIs //
//////////////////////////////
+bool CustomDebugInfoParser::IsExternalCallback(void* ctxt)
+{
+ CustomDebugInfoParser* parser = (CustomDebugInfoParser*)ctxt;
+ return parser->IsExternal();
+}
+
bool CustomDebugInfoParser::IsValidCallback(void* ctxt, BNBinaryView* view)
{
@@ -249,5 +261,5 @@ void CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BN
CustomDebugInfoParser::CustomDebugInfoParser(const string& name) :
DebugInfoParser(
- BNNewDebugInfoParserReference(BNRegisterDebugInfoParser(name.c_str(), IsValidCallback, ParseCallback, this)))
+ BNNewDebugInfoParserReference(BNRegisterDebugInfoParser(name.c_str(), IsExternalCallback, IsValidCallback, ParseCallback, this)))
{}
diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs
index 56786d19..3ed4e3c6 100644
--- a/rust/src/debuginfo.rs
+++ b/rust/src/debuginfo.rs
@@ -131,6 +131,10 @@ impl DebugInfoParser {
unsafe { BNIsDebugInfoParserValidForView(self.handle, view.handle) }
}
+ pub fn is_external(&self) -> bool {
+ unsafe { BNIsDebugInfoParserExternal(self.handle) }
+ }
+
/// Returns a `DebugInfo` object populated with debug info by this debug-info parser. Only provide a `DebugInfo` object if you wish to append to the existing debug info
pub fn parse_debug_info(
&self,
@@ -157,6 +161,17 @@ impl DebugInfoParser {
S: BnStrCompatible,
C: CustomDebugInfoParser,
{
+ extern "C" fn cb_is_external<C>(ctxt: *mut c_void) -> bool
+ where
+ C: CustomDebugInfoParser,
+ {
+ ffi_wrap!("CustomDebugInfoParser::is_external", unsafe {
+ let cmd = &*(ctxt as *const C);
+
+ cmd.is_external()
+ })
+ }
+
extern "C" fn cb_is_valid<C>(ctxt: *mut c_void, view: *mut BNBinaryView) -> bool
where
C: CustomDebugInfoParser,
@@ -192,6 +207,7 @@ impl DebugInfoParser {
unsafe {
DebugInfoParser::from_raw(BNRegisterDebugInfoParser(
name_ptr,
+ Some(cb_is_external::<C>),
Some(cb_is_valid::<C>),
Some(cb_parse_info::<C>),
ctxt as *mut _,
@@ -643,6 +659,7 @@ impl ToOwned for DebugInfo {
/// Implement this trait to implement a debug info parser. See `DebugInfoParser` for more details.
pub trait CustomDebugInfoParser: 'static + Sync {
+ fn is_external(&self) -> bool;
fn is_valid(&self, view: &BinaryView) -> bool;
fn parse_info(&self, debug_info: &mut DebugInfo, view: &BinaryView);
}