| 133 | |
| 134 | |
| 135 | BINARYNINJAPLUGIN bool CorePluginInit() |
| 136 | { |
| 137 | auto inlinerIsValid = [](BinaryView* view, Function* func) { |
| 138 | if (auto workflow = func->GetWorkflow(); workflow) |
| 139 | return workflow->Contains("extension.functionInliner"); |
| 140 | return false; |
| 141 | }; |
| 142 | |
| 143 | // PluginCommand::RegisterForFunction( |
| 144 | // "Optimizer\\Inline All Calls to Current Function", |
| 145 | // "Inline all calls to the current function.", |
| 146 | // [](BinaryView* view, Function* func) { |
| 147 | // LogError("TODO Inline Current Function: %" PRIx64, func->GetStart()); |
| 148 | // }, inlinerIsValid); |
| 149 | |
| 150 | PluginCommand::RegisterForFunction( |
| 151 | "Optimizer\\Inline Function at Current Call Site", "Inline function call at current call site.", |
| 152 | [](BinaryView* view, Function* func) { |
| 153 | // TODO func->Inform("inlinedCallSites") |
| 154 | // TODO resolve multiple embedded inlines |
| 155 | std::lock_guard<std::mutex> lock(g_mutex); |
| 156 | g_callSiteInlines[view->GetObject()][func->GetStart()].insert(view->GetCurrentOffset()); |
| 157 | func->Reanalyze(); |
| 158 | }, |
| 159 | inlinerIsValid); |
| 160 | |
| 161 | Ref<Workflow> inlinerWorkflow = Workflow::Instance("core.function.baseAnalysis")->Clone("InlinerWorkflow"); |
| 162 | inlinerWorkflow->RegisterActivity(new Activity("extension.functionInliner", &FunctionInliner)); |
| 163 | inlinerWorkflow->Insert("core.function.translateTailCalls", "extension.functionInliner"); |
| 164 | Workflow::RegisterWorkflow(inlinerWorkflow, |
| 165 | R"#({ |
| 166 | "title" : "Function Inliner (Example)", |
| 167 | "description" : "This analysis stands in as an example to demonstrate Binary Ninja's extensible analysis APIs.", |
| 168 | "targetType" : "function" |
| 169 | })#"); |
| 170 | |
| 171 | return true; |
| 172 | } |
| 173 | } |
nothing calls this directly
no test coverage detected