| 283 | |
| 284 | |
| 285 | void BaseAddressDetectionWidget::RebaseWithFullAnalysis() |
| 286 | { |
| 287 | auto fileMetadata = m_view->GetFile(); |
| 288 | if (!fileMetadata) |
| 289 | return; |
| 290 | |
| 291 | uint64_t address; |
| 292 | string errorStr; |
| 293 | if (!BinaryNinja::BinaryView::ParseExpression(m_view, m_reloadBase->text().toStdString(), address, 0, errorStr)) |
| 294 | { |
| 295 | m_status->setText(QString("Invalid rebase address (%1)").arg(QString::fromStdString(errorStr))); |
| 296 | return; |
| 297 | } |
| 298 | |
| 299 | auto rebaseViewName = GetRebaseViewName(); |
| 300 | if (!rebaseViewName.empty()) |
| 301 | { |
| 302 | // Found an existing view that isn't raw, rebase it |
| 303 | auto view = m_view->GetFile()->GetViewOfType(rebaseViewName); |
| 304 | if (!view) |
| 305 | return; |
| 306 | |
| 307 | bool result = false; |
| 308 | ProgressTask* task = new ProgressTask(this, "Rebase", "Rebasing...", "Cancel", [&](std::function<bool(size_t, size_t)> progress) { |
| 309 | result = fileMetadata->Rebase(view, address, progress); |
| 310 | }); |
| 311 | task->wait(); |
| 312 | if (!result) |
| 313 | return; |
| 314 | |
| 315 | view->Reanalyze(); |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | // Only a raw view exists - load the binary and run full analysis |
| 320 | BinaryNinja::Settings::Instance()->Set("analysis.mode", "full", m_view); |
| 321 | map<string, BinaryNinja::Ref<BinaryNinja::Metadata>> metadataMap = { |
| 322 | {"analysis.linearSweep.permissive", new BinaryNinja::Metadata(true)}, |
| 323 | {"loader.imageBase", new BinaryNinja::Metadata((uint64_t) address)}, |
| 324 | }; |
| 325 | |
| 326 | if (m_inputs.ArchitectureBox->currentText() != "auto detect") |
| 327 | metadataMap["loader.platform"] = new BinaryNinja::Metadata(m_inputs.ArchitectureBox->currentText().toStdString()); |
| 328 | |
| 329 | auto options = new BinaryNinja::Metadata(metadataMap); |
| 330 | auto newView = Load(m_view->GetFile()->GetViewOfType("Raw"), false, options->GetJsonString()); |
| 331 | if (!newView) |
| 332 | return; |
| 333 | |
| 334 | rebaseViewName = newView->GetTypeName(); |
| 335 | } |
| 336 | |
| 337 | // Refresh the UI and jump to Linear view |
| 338 | auto frame = ViewFrame::viewFrameForWidget(this); |
| 339 | if (!frame) |
| 340 | return; |
| 341 | |
| 342 | auto fileContext = frame->getFileContext(); |
nothing calls this directly
no test coverage detected