Skip to content

Commit

Permalink
Only remove the segment at 0x0 if it is added by the debugger. Fix Ve…
Browse files Browse the repository at this point in the history
  • Loading branch information
xusheng6 committed Jul 10, 2024
1 parent 935bfae commit f6fd36a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/debuggercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ DebugStopReason DebuggerController::RunToAndWait(const std::vector<uint64_t>& re
bool DebuggerController::CreateDebuggerBinaryView()
{
BinaryViewRef data = GetData();
auto segment = data->GetSegmentAt(0);
m_zeroSegmentAddedByDebugger = segment == nullptr;
m_accessor = new DebuggerFileAccessor(data);
data->GetMemoryMap()->AddRemoteMemoryRegion("debugger", 0, m_accessor);
return true;
Expand Down Expand Up @@ -2524,9 +2526,12 @@ bool DebuggerController::RemoveDebuggerMemoryRegion()
if (!ret)
return false;

auto segment = m_data->GetSegmentAt(0);
if (segment)
m_data->RemoveAutoSegment(segment->GetStart(), segment->GetLength());
if (m_zeroSegmentAddedByDebugger)
{
auto segment = m_data->GetSegmentAt(0);
if (segment)
m_data->RemoveAutoSegment(segment->GetStart(), segment->GetLength());
}

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions core/debuggercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ namespace BinaryNinjaDebugger {
std::string m_lastAdapterName;
std::string m_lastCommand;

bool m_zeroSegmentAddedByDebugger = false;

void DetectLoadedModule();

public:
Expand Down

0 comments on commit f6fd36a

Please sign in to comment.