diff options
| author | Ryan Snyder <ryan@vector35.com> | 2018-07-09 22:58:18 -0400 |
|---|---|---|
| committer | Ryan Snyder <ryan@vector35.com> | 2018-07-09 23:00:18 -0400 |
| commit | 838cb56a8505fc78d09befedd58dd632eeb2ee62 (patch) | |
| tree | 797da072919ae25e8d26a90663c0760e9ef29707 /binaryninjaapi.h | |
| parent | 69743572b93f2e29583751d1ec9656fbb34b9411 (diff) | |
| parent | 4f1a7824357ab58d868dbd675af9b152fc3694e9 (diff) | |
Merge branch 'dev'
Diffstat (limited to 'binaryninjaapi.h')
| -rw-r--r-- | binaryninjaapi.h | 198 |
1 files changed, 183 insertions, 15 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index d0c19e7a..f2c15fde 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -986,6 +986,7 @@ namespace BinaryNinja struct DisassemblyTextLine { uint64_t addr; + size_t instrIndex; std::vector<InstructionTextToken> tokens; }; @@ -1021,6 +1022,25 @@ namespace BinaryNinja void Cancel(); }; + struct ActiveAnalysisInfo + { + Ref<Function> func; + uint64_t analysisTime; + size_t updateCount; + size_t submitCount; + + ActiveAnalysisInfo(Ref<Function> f, uint64_t t, size_t uc, size_t sc) : func(f), analysisTime(t), updateCount(uc), submitCount(sc) + { + } + }; + + struct AnalysisInfo + { + BNAnalysisState state; + uint64_t analysisTime; + std::vector<ActiveAnalysisInfo> activeInfo; + }; + struct DataVariable { DataVariable() { } @@ -1270,6 +1290,7 @@ namespace BinaryNinja Ref<AnalysisCompletionEvent> AddAnalysisCompletionEvent(const std::function<void()>& callback); + AnalysisInfo GetAnalysisInfo(); BNAnalysisProgress GetAnalysisProgress(); Ref<BackgroundTask> GetBackgroundAnalysisTask(); @@ -1349,6 +1370,8 @@ namespace BinaryNinja std::vector<uint8_t> GetRawMetadata(const std::string& key); uint64_t GetUIntMetadata(const std::string& key); + BNAnalysisParameters GetParametersForAnalysis(); + void SetParametersForAnalysis(BNAnalysisParameters params); uint64_t GetMaxFunctionSizeForAnalysis(); void SetMaxFunctionSizeForAnalysis(uint64_t size); }; @@ -1590,6 +1613,7 @@ namespace BinaryNinja }; class LowLevelILFunction; + class MediumLevelILFunction; class FunctionRecognizer; class CallingConvention; @@ -2254,6 +2278,12 @@ namespace BinaryNinja void SetUserBasicBlockHighlight(uint8_t r, uint8_t g, uint8_t b, uint8_t alpha = 255); static bool IsBackEdge(BasicBlock* source, BasicBlock* target); + + bool IsILBlock() const; + bool IsLowLevelILBlock() const; + bool IsMediumLevelILBlock() const; + Ref<LowLevelILFunction> GetLowLevelILFunction() const; + Ref<MediumLevelILFunction> GetMediumLevelILFunction() const; }; struct VariableNameAndType @@ -2485,6 +2515,7 @@ namespace BinaryNinja bool IsFunctionTooLarge(); bool IsAnalysisSkipped(); + BNAnalysisSkipReason GetAnalysisSkipReason(); BNFunctionAnalysisSkipOverride GetAnalysisSkipOverride(); void SetAnalysisSkipOverride(BNFunctionAnalysisSkipOverride skip); }; @@ -2570,6 +2601,12 @@ namespace BinaryNinja bool IsOptionSet(BNDisassemblyOption option) const; void SetOption(BNDisassemblyOption option, bool state = true); + + bool IsILGraph() const; + bool IsLowLevelILGraph() const; + bool IsMediumLevelILGraph() const; + Ref<LowLevelILFunction> GetLowLevelILFunction() const; + Ref<MediumLevelILFunction> GetMediumLevelILFunction() const; }; struct LowLevelILLabel: public BNLowLevelILLabel @@ -2767,12 +2804,16 @@ namespace BinaryNinja ExprId Call(ExprId dest, const ILSourceLocation& loc = ILSourceLocation()); ExprId CallStackAdjust(ExprId dest, size_t adjust, const std::map<uint32_t, int32_t>& regStackAdjust, const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCall(ExprId dest, const ILSourceLocation& loc = ILSourceLocation()); ExprId CallSSA(const std::vector<SSARegister>& output, ExprId dest, const std::vector<ExprId>& params, const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc = ILSourceLocation()); ExprId SystemCallSSA(const std::vector<SSARegister>& output, const std::vector<ExprId>& params, const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCallSSA(const std::vector<SSARegister>& output, ExprId dest, const std::vector<ExprId>& params, + const SSARegister& stack, size_t newMemoryVer, size_t prevMemoryVer, + const ILSourceLocation& loc = ILSourceLocation()); ExprId Return(size_t dest, const ILSourceLocation& loc = ILSourceLocation()); ExprId NoReturn(const ILSourceLocation& loc = ILSourceLocation()); ExprId FlagCondition(BNLowLevelILFlagCondition cond, uint32_t semClass = 0, @@ -3086,6 +3127,10 @@ namespace BinaryNinja const ILSourceLocation& loc = ILSourceLocation()); ExprId SyscallUntyped(const std::vector<Variable>& output, const std::vector<Variable>& params, ExprId stack, const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCall(const std::vector<Variable>& output, ExprId dest, const std::vector<ExprId>& params, + const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCallUntyped(const std::vector<Variable>& output, ExprId dest, const std::vector<Variable>& params, + ExprId stack, const ILSourceLocation& loc = ILSourceLocation()); ExprId CallSSA(const std::vector<SSAVariable>& output, ExprId dest, const std::vector<ExprId>& params, size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation()); ExprId CallUntypedSSA(const std::vector<SSAVariable>& output, ExprId dest, @@ -3096,6 +3141,11 @@ namespace BinaryNinja ExprId SyscallUntypedSSA(const std::vector<SSAVariable>& output, const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, ExprId stack, const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCallSSA(const std::vector<SSAVariable>& output, ExprId dest, const std::vector<ExprId>& params, + size_t newMemVersion, size_t prevMemVersion, const ILSourceLocation& loc = ILSourceLocation()); + ExprId TailCallUntypedSSA(const std::vector<SSAVariable>& output, ExprId dest, + const std::vector<SSAVariable>& params, size_t newMemVersion, size_t prevMemVersion, + ExprId stack, const ILSourceLocation& loc = ILSourceLocation()); ExprId Return(const std::vector<ExprId>& sources, const ILSourceLocation& loc = ILSourceLocation()); ExprId NoReturn(const ILSourceLocation& loc = ILSourceLocation()); ExprId CompareEqual(size_t size, ExprId left, ExprId right, @@ -3216,6 +3266,7 @@ namespace BinaryNinja size_t GetSSAMemoryDefinition(size_t version) const; std::set<size_t> GetSSAVarUses(const SSAVariable& var) const; std::set<size_t> GetSSAMemoryUses(size_t version) const; + bool IsSSAVarLive(const SSAVariable& var) const; std::set<size_t> GetVariableDefinitions(const Variable& var) const; std::set<size_t> GetVariableUses(const Variable& var) const; @@ -3312,7 +3363,10 @@ namespace BinaryNinja { Ref<BinaryView> view; uint64_t address, length; + size_t instrIndex; Ref<Function> function; + Ref<LowLevelILFunction> lowLevelILFunction; + Ref<MediumLevelILFunction> mediumLevelILFunction; PluginCommandContext(); }; @@ -3345,15 +3399,55 @@ namespace BinaryNinja std::function<bool(BinaryView*, Function*)> isValid; }; + struct RegisteredLowLevelILFunctionCommand + { + std::function<void(BinaryView*, LowLevelILFunction*)> action; + std::function<bool(BinaryView*, LowLevelILFunction*)> isValid; + }; + + struct RegisteredLowLevelILInstructionCommand + { + std::function<void(BinaryView*, const LowLevelILInstruction&)> action; + std::function<bool(BinaryView*, const LowLevelILInstruction&)> isValid; + }; + + struct RegisteredMediumLevelILFunctionCommand + { + std::function<void(BinaryView*, MediumLevelILFunction*)> action; + std::function<bool(BinaryView*, MediumLevelILFunction*)> isValid; + }; + + struct RegisteredMediumLevelILInstructionCommand + { + std::function<void(BinaryView*, const MediumLevelILInstruction&)> action; + std::function<bool(BinaryView*, const MediumLevelILInstruction&)> isValid; + }; + static void DefaultPluginCommandActionCallback(void* ctxt, BNBinaryView* view); static void AddressPluginCommandActionCallback(void* ctxt, BNBinaryView* view, uint64_t addr); static void RangePluginCommandActionCallback(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len); static void FunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, BNFunction* func); + static void LowLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, + BNLowLevelILFunction* func); + static void LowLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, + BNLowLevelILFunction* func, size_t instr); + static void MediumLevelILFunctionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, + BNMediumLevelILFunction* func); + static void MediumLevelILInstructionPluginCommandActionCallback(void* ctxt, BNBinaryView* view, + BNMediumLevelILFunction* func, size_t instr); static bool DefaultPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view); static bool AddressPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, uint64_t addr); static bool RangePluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, uint64_t addr, uint64_t len); static bool FunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, BNFunction* func); + static bool LowLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, + BNLowLevelILFunction* func); + static bool LowLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, + BNLowLevelILFunction* func, size_t instr); + static bool MediumLevelILFunctionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, + BNMediumLevelILFunction* func); + static bool MediumLevelILInstructionPluginCommandIsValidCallback(void* ctxt, BNBinaryView* view, + BNMediumLevelILFunction* func, size_t instr); public: PluginCommand(const BNPluginCommand& cmd); @@ -3363,25 +3457,45 @@ namespace BinaryNinja PluginCommand& operator=(const PluginCommand& cmd); static void Register(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view)>& action); + const std::function<void(BinaryView* view)>& action); static void Register(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view)>& action, - const std::function<bool(BinaryView* view)>& isValid); + const std::function<void(BinaryView* view)>& action, + const std::function<bool(BinaryView* view)>& isValid); static void RegisterForAddress(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, uint64_t addr)>& action); + const std::function<void(BinaryView* view, uint64_t addr)>& action); static void RegisterForAddress(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, uint64_t addr)>& action, - const std::function<bool(BinaryView* view, uint64_t addr)>& isValid); + const std::function<void(BinaryView* view, uint64_t addr)>& action, + const std::function<bool(BinaryView* view, uint64_t addr)>& isValid); static void RegisterForRange(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action); + const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action); static void RegisterForRange(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action, - const std::function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid); + const std::function<void(BinaryView* view, uint64_t addr, uint64_t len)>& action, + const std::function<bool(BinaryView* view, uint64_t addr, uint64_t len)>& isValid); static void RegisterForFunction(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, Function* func)>& action); + const std::function<void(BinaryView* view, Function* func)>& action); static void RegisterForFunction(const std::string& name, const std::string& description, - const std::function<void(BinaryView* view, Function* func)>& action, - const std::function<bool(BinaryView* view, Function* func)>& isValid); + const std::function<void(BinaryView* view, Function* func)>& action, + const std::function<bool(BinaryView* view, Function* func)>& isValid); + static void RegisterForLowLevelILFunction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action); + static void RegisterForLowLevelILFunction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, LowLevelILFunction* func)>& action, + const std::function<bool(BinaryView* view, LowLevelILFunction* func)>& isValid); + static void RegisterForLowLevelILInstruction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action); + static void RegisterForLowLevelILInstruction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, const LowLevelILInstruction& instr)>& action, + const std::function<bool(BinaryView* view, const LowLevelILInstruction& instr)>& isValid); + static void RegisterForMediumLevelILFunction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action); + static void RegisterForMediumLevelILFunction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, MediumLevelILFunction* func)>& action, + const std::function<bool(BinaryView* view, MediumLevelILFunction* func)>& isValid); + static void RegisterForMediumLevelILInstruction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action); + static void RegisterForMediumLevelILInstruction(const std::string& name, const std::string& description, + const std::function<void(BinaryView* view, const MediumLevelILInstruction& instr)>& action, + const std::function<bool(BinaryView* view, const MediumLevelILInstruction& instr)>& isValid); static std::vector<PluginCommand> GetList(); static std::vector<PluginCommand> GetValidList(const PluginCommandContext& ctxt); @@ -3545,6 +3659,63 @@ namespace BinaryNinja const std::string& autoTypeSource = ""); }; + // DownloadProvider + class DownloadProvider; + + class DownloadInstance: public CoreRefCountObject<BNDownloadInstance, BNNewDownloadInstanceReference, BNFreeDownloadInstance> + { + protected: + DownloadInstance(DownloadProvider* provider); + DownloadInstance(BNDownloadInstance* instance); + + static void DestroyInstanceCallback(void* ctxt); + static int PerformRequestCallback(void* ctxt, const char* url); + + virtual void DestroyInstance(); + + public: + virtual int PerformRequest(const std::string& url) = 0; + + int PerformRequest(const std::string& url, BNDownloadInstanceOutputCallbacks* callbacks); + + std::string GetError() const; + void SetError(const std::string& error); + }; + + class CoreDownloadInstance: public DownloadInstance + { + public: + CoreDownloadInstance(BNDownloadInstance* instance); + + virtual int PerformRequest(const std::string& url) override; + }; + + class DownloadProvider: public StaticCoreRefCountObject<BNDownloadProvider> + { + std::string m_nameForRegister; + + protected: + DownloadProvider(const std::string& name); + DownloadProvider(BNDownloadProvider* provider); + + static BNDownloadInstance* CreateInstanceCallback(void* ctxt); + + public: + virtual Ref<DownloadInstance> CreateNewInstance() = 0; + + static std::vector<Ref<DownloadProvider>> GetList(); + static Ref<DownloadProvider> GetByName(const std::string& name); + static void Register(DownloadProvider* provider); + }; + + class CoreDownloadProvider: public DownloadProvider + { + public: + CoreDownloadProvider(BNDownloadProvider* provider); + virtual Ref<DownloadInstance> CreateNewInstance() override; + }; + + // Scripting Provider class ScriptingOutputListener { BNScriptingOutputListener m_callbacks; @@ -3903,7 +4074,4 @@ namespace BinaryNinja bool IsArray() const; bool IsKeyValueStore() const; }; - - std::string GetLinuxCADirectory(); - std::string GetLinuxCABundlePath(); } |
