diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2025-09-08 20:04:36 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2025-10-21 13:52:39 -0400 |
| commit | cae26921cf2b2e564f66e58b77a3963fe36f6d2d (patch) | |
| tree | bfa7ec8de23c1de758463a894583086c8d0b050e /binaryninjaapi.h | |
| parent | 11ad1fc28470b863326f7136cf9b5723a06e89d3 (diff) | |
Add constant renderer API
Diffstat (limited to 'binaryninjaapi.h')
| -rw-r--r-- | binaryninjaapi.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index fd1363b2..96105e66 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -4811,6 +4811,7 @@ namespace BinaryNinja { public: StringRef(); explicit StringRef(BNStringRef* ref); + StringRef(const std::string& str); StringRef(const StringRef& other); StringRef(StringRef&& other); ~StringRef(); @@ -21277,6 +21278,54 @@ namespace BinaryNinja { std::vector<LinearDisassemblyLine>& lines ) override; }; + + class ConstantRenderer : public StaticCoreRefCountObject<BNConstantRenderer> + { + std::string m_nameForRegister; + + public: + ConstantRenderer(const std::string& name); + ConstantRenderer(BNConstantRenderer* renderer); + + std::string GetName() const; + + virtual bool IsValidForType(HighLevelILFunction* func, Type* type); + virtual bool RenderConstant(const HighLevelILInstruction& instr, Type* type, int64_t val, + HighLevelILTokenEmitter& tokens, DisassemblySettings* settings, BNOperatorPrecedence precedence); + virtual bool RenderConstantPointer(const HighLevelILInstruction& instr, Type* type, int64_t val, + HighLevelILTokenEmitter& tokens, DisassemblySettings* settings, BNSymbolDisplayType symbolDisplay, + BNOperatorPrecedence precedence); + + /*! Registers the constant renderer. + + \param renderer The constant renderer to register. + */ + static void Register(ConstantRenderer* renderer); + + static Ref<ConstantRenderer> GetByName(const std::string& name); + static std::vector<Ref<ConstantRenderer>> GetRenderers(); + + private: + static bool IsValidForTypeCallback(void* ctxt, BNHighLevelILFunction* hlil, BNType* type); + static bool RenderConstantCallback(void* ctxt, BNHighLevelILFunction* hlil, size_t expr, BNType* type, + int64_t val, BNHighLevelILTokenEmitter* tokens, BNDisassemblySettings* settings, + BNOperatorPrecedence precedence); + static bool RenderConstantPointerCallback(void* ctxt, BNHighLevelILFunction* hlil, size_t expr, BNType* type, + int64_t val, BNHighLevelILTokenEmitter* tokens, BNDisassemblySettings* settings, + BNSymbolDisplayType symbolDisplay, BNOperatorPrecedence precedence); + }; + + class CoreConstantRenderer : public ConstantRenderer + { + public: + CoreConstantRenderer(BNConstantRenderer* renderer); + bool IsValidForType(HighLevelILFunction* func, Type* type) override; + bool RenderConstant(const HighLevelILInstruction& instr, Type* type, int64_t val, + HighLevelILTokenEmitter& tokens, DisassemblySettings* settings, BNOperatorPrecedence precedence) override; + bool RenderConstantPointer(const HighLevelILInstruction& instr, Type* type, int64_t val, + HighLevelILTokenEmitter& tokens, DisassemblySettings* settings, BNSymbolDisplayType symbolDisplay, + BNOperatorPrecedence precedence) override; + }; } // namespace BinaryNinja |
