diff options
| author | Zichuan Li <34680029+river-li@users.noreply.github.com> | 2024-06-11 18:20:56 -0400 |
|---|---|---|
| committer | Zichuan Li <34680029+river-li@users.noreply.github.com> | 2024-06-19 13:04:46 -0400 |
| commit | fc5b443d86d10c5ce308630f8b41c8f64f5f40f1 (patch) | |
| tree | d4ba6b13d1ffbc974f6371a7e4037b337afe0bf8 | |
| parent | 7518e76fb706fe036fb4579f21401df6e091f9b0 (diff) | |
Implement callback function for fallback type library
| -rw-r--r-- | binaryninjaapi.h | 8 | ||||
| -rw-r--r-- | binaryninjacore.h | 2 | ||||
| -rw-r--r-- | platform.cpp | 14 |
3 files changed, 24 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 96bb4b8c..c37a1a3d 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -14556,6 +14556,7 @@ namespace BinaryNinja { char** sourceFileValues, size_t sourceFilesLen ); + static bool GetFallbackEnabledCallback(void* ctxt); public: Platform(BNPlatform* platform); @@ -14728,6 +14729,13 @@ namespace BinaryNinja { std::vector<std::pair<std::string, std::string>>& sourceFiles ); + /*! Provide an option for platforms to decide whether to use + * the fallback type library. + * + * Allows the Platform to override it to false. + */ + virtual bool GetFallbackEnabled(); + Ref<Platform> GetRelatedPlatform(Architecture* arch); void AddRelatedPlatform(Architecture* arch, Platform* platform); Ref<Platform> GetAssociatedPlatformByAddress(uint64_t& addr); diff --git a/binaryninjacore.h b/binaryninjacore.h index 96ea6f5e..9d217902 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -1906,6 +1906,8 @@ extern "C" char** sourceFileValues, size_t sourceFilesLen ); + + bool (*getFallbackEnabled)(void* ctxt); } BNCustomPlatform; typedef struct BNBasicBlockEdge diff --git a/platform.cpp b/platform.cpp index ec27b710..55044595 100644 --- a/platform.cpp +++ b/platform.cpp @@ -44,6 +44,7 @@ Platform::Platform(Architecture* arch, const string& name) plat.getGlobalRegisterType = GetGlobalRegisterTypeCallback; plat.adjustTypeParserInput = AdjustTypeParserInputCallback; plat.freeTypeParserInput = FreeTypeParserInputCallback; + plat.getFallbackEnabled = GetFallbackEnabledCallback; m_object = BNCreateCustomPlatform(arch->GetObject(), name.c_str(), &plat); AddRefForRegistration(); } @@ -60,6 +61,7 @@ Platform::Platform(Architecture* arch, const string& name, const string& typeFil plat.getGlobalRegisterType = GetGlobalRegisterTypeCallback; plat.adjustTypeParserInput = AdjustTypeParserInputCallback; plat.freeTypeParserInput = FreeTypeParserInputCallback; + plat.getFallbackEnabled = GetFallbackEnabledCallback; const char** includeDirList = new const char*[includeDirs.size()]; for (size_t i = 0; i < includeDirs.size(); i++) includeDirList[i] = includeDirs[i].c_str(); @@ -191,6 +193,12 @@ BNType* Platform::GetGlobalRegisterTypeCallback(void* ctxt, uint32_t reg) return BNNewTypeReference(result->GetObject()); } +bool Platform::GetFallbackEnabledCallback(void* ctxt) +{ + CallbackRef<Platform> plat(ctxt); + return plat->GetFallbackEnabled(); +} + Ref<Architecture> Platform::GetArchitecture() const { @@ -410,6 +418,12 @@ Ref<Type> Platform::GetGlobalRegisterType(uint32_t reg) } +bool Platform::GetFallbackEnabled() +{ + return true; +} + + std::vector<uint32_t> CorePlatform::GetGlobalRegisters() { size_t count; |
