summaryrefslogtreecommitdiff
path: root/plugins/msvc_rtti/plugin.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-03-01 00:34:12 -0500
committerMason Reed <mason@vector35.com>2025-03-19 21:17:34 -0400
commitf719d1d5565f7b7b1237b8e183c2985f006fa3e4 (patch)
tree0fbb2c1af1254add49049abdec3f935669d658de /plugins/msvc_rtti/plugin.cpp
parent93e92844d77b72f07bd7563211d60dc3595cc2e0 (diff)
Refactor and fixup MSVC and Itanium RTTI
Bunch of misc fixes and performance improvements
Diffstat (limited to 'plugins/msvc_rtti/plugin.cpp')
-rw-r--r--plugins/msvc_rtti/plugin.cpp88
1 files changed, 0 insertions, 88 deletions
diff --git a/plugins/msvc_rtti/plugin.cpp b/plugins/msvc_rtti/plugin.cpp
deleted file mode 100644
index ee3ebb32..00000000
--- a/plugins/msvc_rtti/plugin.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "rtti.h"
-
-#include <thread>
-
-using namespace BinaryNinja;
-
-static Ref<BackgroundTask> rttiBackgroundTask = nullptr;
-static Ref<BackgroundTask> vftBackgroundTask = nullptr;
-
-
-bool MetadataExists(Ref<BinaryView> view)
-{
- return view->QueryMetadata(VIEW_METADATA_MSVC) != nullptr;
-}
-
-
-void RTTIAnalysis(Ref<AnalysisContext> analysisContext)
-{
- auto view = analysisContext->GetBinaryView();
- auto platform = view->GetDefaultPlatform();
- if (!platform)
- return;
- auto platformName = platform->GetName();
- // We currently only want to check for MSVC rtti on windows platforms
- if (platformName.find("window") == std::string::npos)
- return;
- auto processor = MicrosoftRTTIProcessor(view);
- processor.ProcessRTTI();
- view->StoreMetadata(VIEW_METADATA_MSVC, processor.SerializedMetadata(), true);
-}
-
-
-void VFTAnalysis(Ref<AnalysisContext> analysisContext)
-{
- auto view = analysisContext->GetBinaryView();
- if (!MetadataExists(view))
- return;
- auto processor = MicrosoftRTTIProcessor(view);
- processor.ProcessVFT();
- view->StoreMetadata(VIEW_METADATA_MSVC, processor.SerializedMetadata(), true);
-}
-
-
-extern "C" {
- BN_DECLARE_CORE_ABI_VERSION
-
- BINARYNINJAPLUGIN bool CorePluginInit()
- {
- // TODO: In the future we will have a function level workflow which:
- // TODO: 1. Uses MSVC metadata to identify if a function is apart of a VFT
- // TODO: a. Or possibly we can tag some info to the function as apart of the VFT analysis, this would save a lookup.
- // TODO: 2. Identify if the function is unique to a class, renaming and retyping if true
- // TODO: 3. Identify functions which address a VFT and are probably a constructor (alloc use), retyping if true
- // TODO: 4. Identify functions which address a VFT and are probably a deconstructor (free use), retyping if true
- Ref<Workflow> msvcMetaWorkflow = Workflow::Instance("core.module.metaAnalysis")->Clone();
-
- // Add RTTI analysis.
- msvcMetaWorkflow->RegisterActivity(R"~({
- "title": "MSVC RTTI Analysis",
- "name": "plugin.msvc.rttiAnalysis",
- "role": "action",
- "description": "This analysis step attempts to parse and symbolize msvc rtti information.",
- "eligibility": {
- "runOnce": true,
- "auto": {}
- }
- })~", &RTTIAnalysis);
- // Add Virtual Function Table analysis.
- msvcMetaWorkflow->RegisterActivity(R"~({
- "title": "MSVC VFT Analysis",
- "name": "plugin.msvc.vftAnalysis",
- "role": "action",
- "description": "This analysis step attempts to parse and symbolize msvc virtual function table information.",
- "eligibility": {
- "runOnce": true,
- "auto": {}
- }
- })~", &VFTAnalysis);
-
- // Run rtti before debug info is applied.
- msvcMetaWorkflow->Insert("core.module.loadDebugInfo", "plugin.msvc.rttiAnalysis");
- // Run vft after functions have analyzed (so that the virtual functions have analyzed)
- msvcMetaWorkflow->Insert("core.module.deleteUnusedAutoFunctions", "plugin.msvc.vftAnalysis");
- Workflow::RegisterWorkflow(msvcMetaWorkflow);
-
- return true;
- }
-} \ No newline at end of file