From d19f5e85ee26c3d6604798d30ab821d15731cada Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Wed, 19 May 2021 20:40:24 -0400 Subject: DebugInfo - plugable debug information importers - C++, Rust, and Python APIs --- binaryninjaapi.h | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 5c3e0cde..6d4119ca 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1301,6 +1301,17 @@ __attribute__ ((format (printf, 1, 2))) bool autoDiscovered; }; + struct DataVariableAndName + { + DataVariableAndName() { } + DataVariableAndName(uint64_t a, Type* t, bool d, const std::string& n) : address(a), type(t), autoDiscovered(d), name(n) { } + + uint64_t address; + Confidence> type; + bool autoDiscovered; + std::string name; + }; + class TagType: public CoreRefCountObject { public: @@ -5623,8 +5634,85 @@ __attribute__ ((format (printf, 1, 2))) uint64_t findConstant; DataBuffer findBuffer; - + std::vector ranges; uint64_t totalLength; }; + + struct DebugFunctionInfo + { + std::string shortName; + std::string fullName; + std::string rawName; + uint64_t address; + Ref returnType; + std::vector>> parameters; + bool variableParameters; + Ref callingConvention; + Ref platform; + + DebugFunctionInfo(std::string shortName, + std::string fullName, + std::string rawName, + uint64_t address, + Ref returnType, + std::vector>> parameters, + bool variableParameters, + Ref callingConvention, + Ref platform) : + shortName(shortName), + fullName(fullName), + rawName(rawName), + address(address), + returnType(returnType), + parameters(parameters), + variableParameters(variableParameters), + callingConvention(callingConvention), + platform(platform) + {} + }; + + class DebugInfo : public CoreRefCountObject + { + public: + DebugInfo(BNDebugInfo* debugInfo); + + std::vector GetTypes(const std::string& parserName = ""); + std::vector GetFunctions(const std::string& parserName = ""); + std::vector GetDataVariables(const std::string& parserName = ""); + + bool AddType(const std::string& name, Ref type); + bool AddFunction(const DebugFunctionInfo& function); + bool AddDataVariable(uint64_t address, Ref type, const std::string& name = ""); + }; + + class DebugInfoParser : public CoreRefCountObject + { + public: + DebugInfoParser(BNDebugInfoParser* parser); + + static Ref GetByName(const std::string& name); + static std::vector> GetList(); + static std::vector> GetListForView(const Ref data); + + std::string GetName() const; + Ref Parse(Ref view, Ref existingDebugInfo = nullptr) const; + + bool IsValidForView(const Ref view) const; + }; + + class CustomDebugInfoParser : public DebugInfoParser + { + static bool IsValidCallback(void* ctxt, BNBinaryView* view); + static void ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view); + BNDebugInfoParser* Register(const std::string& name); + + public: + CustomDebugInfoParser(const std::string& name); + virtual ~CustomDebugInfoParser() {} + + virtual bool IsValid(Ref) = 0; + virtual void ParseInfo(Ref, Ref) = 0; + }; } + -- cgit v1.3.1