Skip to content

Commit

Permalink
Add an option for whether marking the entire binary view as modified …
Browse files Browse the repository at this point in the history
…when the target stops
  • Loading branch information
xusheng6 committed Jan 11, 2023
1 parent 7a157d9 commit 41917bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions core/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ static void RegisterSettings()
"description" : "Add stack variable annotations",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"]
})");

settings->RegisterSetting("debugger.aggressiveAnalysisUpdate",
R"({
"title" : "Update the analysis aggressively",
"type" : "boolean",
"default" : false,
"description" : "Whether to aggressively update the memory cache and analysis. If the target has self-modifying code, turning this on makes sure every function is re-analyzed every time the target stops, which gives the most accurate analysis. However, for large binaries with lots of functions, this may cause performance issues.",
"ignore" : ["SettingsProjectScope", "SettingsResourceScope"]
})");
}

extern "C"
Expand Down
6 changes: 4 additions & 2 deletions core/processview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ DebugProcessView::DebugProcessView(DebugNullView* nullView, BinaryView* parent):
AddAutoSegment(0, 1, 0, 1, SegmentReadable | SegmentWritable | SegmentExecutable);
AddAutoSection("Memory", 0, length);

m_aggressiveAnalysisUpdate = Settings::Instance()->Get<bool>("debugger.aggressiveAnalysisUpdate");

m_controller = DebuggerController::GetController(parent);
m_eventCallback = m_controller->RegisterEventCallback([this](const DebuggerEvent& event){
eventHandler(event);
Expand Down Expand Up @@ -164,8 +166,8 @@ size_t DebugProcessView::PerformWrite(uint64_t offset, const void* data, size_t
void DebugProcessView::MarkDirty()
{
// This hack will let the views (linear/graph) update its display
// We must treat the entire binary view as modified, otherwise, self-modifying code may not be updated properly
BinaryView::NotifyDataWritten(0, GetLength());
uint64_t end = m_aggressiveAnalysisUpdate ? GetLength() : 1;
BinaryView::NotifyDataWritten(0, end);
}


Expand Down
2 changes: 2 additions & 0 deletions core/processview.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace BinaryNinjaDebugger
DbgRef<DebuggerController> m_controller;
size_t m_eventCallback;

bool m_aggressiveAnalysisUpdate;

virtual uint64_t PerformGetEntryPoint() const override;

virtual bool PerformIsExecutable() const override { return true; }
Expand Down

0 comments on commit 41917bb

Please sign in to comment.