From bfd306437f34ebc4d4170c5fb8170261585f6038 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Fri, 17 Apr 2026 12:10:07 -0400 Subject: Add RecognizeConstantData to StringRecognizer API Adds a new recognize_constant_data method to the StringRecognizer API, enabling plugins to decode constant data expressions (HLIL_CONST_DATA) recovered by the outline resolver. The recognizer receives the full instruction, giving access to the data buffer and builtin type via the constant_data accessor. Also fixes a pre-existing ctypes mismatch in get_constant_data_and_builtin where BNBuiltinType (uint8_t) was incorrectly passed as c_int. --- binaryninjaapi.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index fa0a4716..57f896dd 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -22342,6 +22342,19 @@ namespace BinaryNinja { virtual std::optional RecognizeImport( const HighLevelILInstruction& instr, Type* type, int64_t val); + /*! Can be overridden to recognize strings for constant data expressions (HLIL_CONST_DATA). + These expressions are generated by the outline resolver when it recovers constant data + streams from scattered stores. The instruction provides access to the data buffer and + builtin type via its \c constant_data accessor. + + If a string is found, return a \c DerivedString with the string information. + + \param instr High level expression containing the constant data + \return Optional \c DerivedString for any string that is found + */ + virtual std::optional RecognizeConstantData( + const HighLevelILInstruction& instr); + /*! Registers the string recognizer. \param recognizer The string recognizer to register. @@ -22361,6 +22374,8 @@ namespace BinaryNinja { int64_t val, uint64_t offset, BNDerivedString* result); static bool RecognizeImportCallback( void* ctxt, BNHighLevelILFunction* hlil, size_t expr, BNType* type, int64_t val, BNDerivedString* result); + static bool RecognizeConstantDataCallback( + void* ctxt, BNHighLevelILFunction* hlil, size_t expr, BNDerivedString* result); }; class CoreStringRecognizer : public StringRecognizer @@ -22376,6 +22391,8 @@ namespace BinaryNinja { const HighLevelILInstruction& instr, Type* type, int64_t val, uint64_t offset) override; std::optional RecognizeImport( const HighLevelILInstruction& instr, Type* type, int64_t val) override; + std::optional RecognizeConstantData( + const HighLevelILInstruction& instr) override; }; } // namespace BinaryNinja -- cgit v1.3.1