From 93e92844d77b72f07bd7563211d60dc3595cc2e0 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 4 Dec 2024 18:17:10 -0500 Subject: Consolidate metadata for RTTI processors and a bunch of misc fixes Also allows for both processors to be ran for a single binary --- plugins/rtti/plugin.cpp | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'plugins/rtti/plugin.cpp') diff --git a/plugins/rtti/plugin.cpp b/plugins/rtti/plugin.cpp index 52501efe..82b51f78 100644 --- a/plugins/rtti/plugin.cpp +++ b/plugins/rtti/plugin.cpp @@ -2,11 +2,8 @@ #include "microsoft.h" #include "itanium.h" -#include - using namespace BinaryNinja; -// TODO: Split the activities so that there is two for microsoft and itanium. bool MetadataExists(const Ref& view) { @@ -28,14 +25,10 @@ void RTTIAnalysis(const Ref& analysisContext) processor.ProcessRTTI(); view->StoreMetadata(VIEW_METADATA_RTTI, processor.SerializedMetadata(), true); } - else - { - // TODO: We currently only want to check for itanium rtti on non windows platforms - // TODO: This needs to always run. - auto processor = RTTI::Itanium::ItaniumRTTIProcessor(view); - processor.ProcessRTTI(); - view->StoreMetadata(VIEW_METADATA_RTTI, processor.SerializedMetadata(), true); - } + + auto processor = RTTI::Itanium::ItaniumRTTIProcessor(view); + processor.ProcessRTTI(); + view->StoreMetadata(VIEW_METADATA_RTTI, processor.SerializedMetadata(), true); } @@ -44,19 +37,13 @@ void VFTAnalysis(const Ref& analysisContext) auto view = analysisContext->GetBinaryView(); if (!MetadataExists(view)) return; - // TODO: Run for both itanium and ms (depending on platform) - auto processor = RTTI::Microsoft::MicrosoftRTTIProcessor(view); - processor.ProcessVFT(); + auto microsoftProcessor = RTTI::Microsoft::MicrosoftRTTIProcessor(view); + microsoftProcessor.ProcessVFT(); + // TODO: We have to store the data for the second processor to pick up the info. + view->StoreMetadata(VIEW_METADATA_RTTI, microsoftProcessor.SerializedMetadata(), true); auto itaniumProcessor = RTTI::Itanium::ItaniumRTTIProcessor(view); - itaniumProcessor.ProcessVTT(); - view->StoreMetadata(VIEW_METADATA_RTTI, processor.SerializedMetadata(), true); -} - - -void MakeItaniumRTTIHere(Ref view, uint64_t addr) -{ - auto processor = RTTI::Itanium::ItaniumRTTIProcessor(view); - processor.ProcessRTTI(addr); + itaniumProcessor.ProcessVFT(); + view->StoreMetadata(VIEW_METADATA_RTTI, itaniumProcessor.SerializedMetadata(), true); } @@ -73,8 +60,6 @@ extern "C" { // TODO: 4. Identify functions which address a VFT and are probably a deconstructor (free use), retyping if true Ref rttiMetaWorkflow = Workflow::Instance("core.module.metaAnalysis")->Clone("core.module.metaAnalysis"); - PluginCommand::RegisterForAddress("Itanium\\Make RTTI Here", "", MakeItaniumRTTIHere); - // Add RTTI analysis. rttiMetaWorkflow->RegisterActivity(R"~({ "title": "RTTI Analysis", -- cgit v1.3.1