From 6520026964065327558472841838510176646568 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 28 May 2024 18:53:17 -0400 Subject: Add AdjustTypeParserArguments callback to platform Implementing the solution to #4868 --- binaryninjaapi.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 114b6e85..bb243e52 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -14518,6 +14518,28 @@ namespace BinaryNinja { static uint32_t* GetGlobalRegistersCallback(void* ctxt, size_t* count); static void FreeRegisterListCallback(void* ctxt, uint32_t* regs, size_t count); static BNType* GetGlobalRegisterTypeCallback(void* ctxt, uint32_t reg); + static void AdjustTypeParserInputCallback( + void* ctxt, + BNTypeParser* parser, + const char* const* argumentsIn, + size_t argumentsLenIn, + const char* const* sourceFileNamesIn, + const char* const* sourceFileValuesIn, + size_t sourceFilesLenIn, + char*** argumentsOut, + size_t* argumentsLenOut, + char*** sourceFileNamesOut, + char*** sourceFileValuesOut, + size_t* sourceFilesLenOut + ); + static void FreeTypeParserInputCallback( + void* ctxt, + char** arguments, + size_t argumentsLen, + char** sourceFileNames, + char** sourceFileValues, + size_t sourceFilesLen + ); public: Platform(BNPlatform* platform); @@ -14678,6 +14700,18 @@ namespace BinaryNinja { */ virtual Ref GetGlobalRegisterType(uint32_t reg); + /*! Modify the input passed to the Type Parser with Platform-specific features. + + \param[in] parser Type Parser instance + \param[in,out] arguments Arguments to the type parser + \param[in,out] sourceFiles Source file names and contents + */ + virtual void AdjustTypeParserInput( + Ref parser, + std::vector& arguments, + std::vector>& sourceFiles + ); + Ref GetRelatedPlatform(Architecture* arch); void AddRelatedPlatform(Architecture* arch, Platform* platform); Ref GetAssociatedPlatformByAddress(uint64_t& addr); @@ -14776,6 +14810,11 @@ namespace BinaryNinja { virtual std::vector GetGlobalRegisters() override; virtual Ref GetGlobalRegisterType(uint32_t reg) override; + virtual void AdjustTypeParserInput( + Ref parser, + std::vector& arguments, + std::vector>& sourceFiles + ) override; }; /*! @@ -14834,6 +14873,12 @@ namespace BinaryNinja { */ static std::string FormatParseErrors(const std::vector& errors); + /*! + Get the Type Parser's registered name + \return Parser name + */ + std::string GetName() const; + /** Get the string representation of an option for passing to ParseTypes* \param option Option type -- cgit v1.3.1