| 22 | } |
| 23 | |
| 24 | void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const QString& type) |
| 25 | { |
| 26 | if (!frame) |
| 27 | return; |
| 28 | |
| 29 | auto view = frame->getCurrentBinaryView(); |
| 30 | if (!view || view->GetTypeName() != VIEW_NAME) |
| 31 | return; |
| 32 | |
| 33 | auto viewInt = frame->getCurrentViewInterface(); |
| 34 | if (!viewInt) |
| 35 | return; |
| 36 | |
| 37 | auto ah = viewInt->actionHandler(); |
| 38 | // Check to see if we have already bound these actions. |
| 39 | if (ah->isBoundAction("Load Image by Name")) |
| 40 | return; |
| 41 | |
| 42 | static auto loadRegionAtAddr = [](BinaryView& view, uint64_t addr) { |
| 43 | auto controller = SharedCacheController::GetController(view); |
| 44 | if (!controller) |
| 45 | return; |
| 46 | if (auto foundRegion = controller->GetRegionContaining(addr)) |
| 47 | { |
| 48 | // If we did not load the region, then we don't need to run analysis. |
| 49 | if (!controller->ApplyRegion(view, *foundRegion)) |
| 50 | return; |
| 51 | view.AddAnalysisOption("linearsweep"); |
| 52 | view.UpdateAnalysis(); |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | static auto loadImageAtAddr = [](BinaryView& view, uint64_t addr) { |
| 57 | auto controller = SharedCacheController::GetController(view); |
| 58 | if (!controller) |
| 59 | return; |
| 60 | if (auto foundImage = controller->GetImageContaining(addr)) |
| 61 | { |
| 62 | // If we did not load the image, then we don't need to run analysis. |
| 63 | if (!controller->ApplyImage(view, *foundImage)) |
| 64 | return; |
| 65 | view.AddAnalysisOption("linearsweep"); |
| 66 | view.UpdateAnalysis(); |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | auto loadImageNameAction = [](const UIActionContext& ctx) { |
| 71 | DisplayDSCPicker(ctx.context, ctx.binaryView); |
| 72 | }; |
| 73 | |
| 74 | auto loadImageAddrAction = [](const UIActionContext& ctx) { |
| 75 | uint64_t addr = 0; |
| 76 | if (GetAddressInput(addr, "Address", "Address")) |
| 77 | { |
| 78 | BackgroundThread::create(ctx.context->mainWindow()) |
| 79 | ->thenBackground([ctx, addr]() { |
| 80 | loadImageAtAddr(*ctx.binaryView, addr); |
| 81 | })->start(); |
nothing calls this directly
no test coverage detected