From 56115aecf186bc720dae9a20cc4c6aef248ba07f Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Fri, 24 May 2024 14:47:15 -0400 Subject: platform: initial BNCustomPlatform support --- binaryninjaapi.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 477d1b60..8eb3cdaf 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -14495,6 +14495,12 @@ namespace BinaryNinja { Platform(Architecture* arch, const std::string& name, const std::string& typeFile, const std::vector& includeDirs = std::vector()); + static void InitCallback(void *ctxt, BNPlatform*); + static void InitViewCallback(void* ctxt, BNBinaryView* view); + 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); + public: Platform(BNPlatform* platform); @@ -14630,6 +14636,30 @@ namespace BinaryNinja { */ void SetSystemCallConvention(CallingConvention* cc); + /*! Callback that will be called when the platform of a binaryview + * is set. Allows for the Platform to to do platform-specific + * processing of views just after finalization. + * + * \param view BinaryView that was just set to this Platform + */ + virtual void BinaryViewInit(BinaryView* view); + + /*! Get the global register list for this Platform + * + * Allows the Platform to override the global register list + * used by analysis. + */ + virtual std::vector GetGlobalRegisters(); + + /*! Get the type of a global register + * + * Called by analysis when the incoming register value of a + * global register is observed. + * + * \param reg The register being queried for type information. + */ + virtual Ref GetGlobalRegisterType(uint32_t reg); + Ref GetRelatedPlatform(Architecture* arch); void AddRelatedPlatform(Architecture* arch, Platform* platform); Ref GetAssociatedPlatformByAddress(uint64_t& addr); @@ -14720,6 +14750,16 @@ namespace BinaryNinja { const std::string& autoTypeSource = ""); }; + + class CorePlatform : public Platform + { + public: + CorePlatform(BNPlatform* plat); + + virtual std::vector GetGlobalRegisters() override; + virtual Ref GetGlobalRegisterType(uint32_t reg) override; + }; + /*! \ingroup typeparser */ -- cgit v1.3.1