From 5399427e628810808d86d812391ca2257ca01e26 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Thu, 18 Jul 2024 22:47:58 -0400 Subject: [PATCH] MemoryMap update with new segment model. --- core/adapters/lldbadapter.cpp | 10 +++++----- core/debugadapter.cpp | 2 +- core/debugadapter.h | 8 ++++---- core/debuggercontroller.cpp | 13 +------------ 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/core/adapters/lldbadapter.cpp b/core/adapters/lldbadapter.cpp index 397e31b..68b6b6f 100644 --- a/core/adapters/lldbadapter.cpp +++ b/core/adapters/lldbadapter.cpp @@ -424,7 +424,7 @@ std::vector LldbAdapter::GetProcessList() // example output lines: // 1268 944 csrss.exe // 37635 9677 xusheng arm64-apple-* Code Helper (Renderer) - // + // // we've 56 bytes until process name which is calculated like this: // (6 + 1) + (6 + 1) + (10 + 1) + (30 + 1) @@ -513,13 +513,13 @@ bool LldbAdapter::SuspendThread(std::uint32_t tid) SBThread thread = m_process.GetThreadByID(tid); if (!thread.IsValid()) return false; - + if (!thread.Suspend(error)) return false; if (!error.Success()) return false; - + return true; } @@ -529,7 +529,7 @@ bool LldbAdapter::ResumeThread(std::uint32_t tid) SBThread thread = m_process.GetThreadByID(tid); if (!thread.IsValid()) return false; - + if (!thread.Resume(error)) return false; @@ -610,7 +610,7 @@ DebugBreakpoint LldbAdapter::AddBreakpoint(const ModuleNameAndOffset& address, u } else { - uint64_t addr = address.offset + m_originalBase; + uint64_t addr = address.offset + m_originalImageBase; std::string entryBreakpointCommand = fmt::format("b -s \"{}\" -a 0x{:x}", address.module, addr); auto ret = InvokeBackendCommand(entryBreakpointCommand); DebuggerEvent evt; diff --git a/core/debugadapter.cpp b/core/debugadapter.cpp index e1827c4..e080505 100644 --- a/core/debugadapter.cpp +++ b/core/debugadapter.cpp @@ -44,7 +44,7 @@ DebugAdapter::DebugAdapter(BinaryView* data) // Here we check if there is actually a function at the entry point, to determine if the entry point is real. m_hasEntryFunction = (data->GetAnalysisEntryPoint() != nullptr); m_start = data->GetStart(); - m_originalBase = data->GetOriginalBase(); + m_originalImageBase = data->GetOriginalImageBase(); if (data->GetDefaultArchitecture()) m_defaultArchitecture = data->GetDefaultArchitecture()->GetName(); diff --git a/core/debugadapter.h b/core/debugadapter.h index 9150b1d..037969f 100644 --- a/core/debugadapter.h +++ b/core/debugadapter.h @@ -200,7 +200,7 @@ namespace BinaryNinjaDebugger { uint64_t m_entryPoint; bool m_hasEntryFunction; uint64_t m_start; - uint64_t m_originalBase; + uint64_t m_originalImageBase; std::string m_defaultArchitecture; std::string m_originalFileName; @@ -283,13 +283,13 @@ namespace BinaryNinjaDebugger { virtual bool Go() = 0; virtual bool GoReverse(); - + virtual bool StepInto() = 0; - + virtual bool StepIntoReverse(); virtual bool StepOver() = 0; - + virtual bool StepOverReverse(); // virtual bool RunTo(std::uintptr_t address) = 0; diff --git a/core/debuggercontroller.cpp b/core/debuggercontroller.cpp index 11a3d11..7af6203 100644 --- a/core/debuggercontroller.cpp +++ b/core/debuggercontroller.cpp @@ -2522,18 +2522,7 @@ bool DebuggerController::IsTTD() bool DebuggerController::RemoveDebuggerMemoryRegion() { - bool ret = GetData()->GetMemoryMap()->RemoveMemoryRegion("debugger"); - if (!ret) - return false; - - if (m_zeroSegmentAddedByDebugger) - { - auto segment = m_data->GetSegmentAt(0); - if (segment) - m_data->RemoveAutoSegment(segment->GetStart(), segment->GetLength()); - } - - return true; + return GetData()->GetMemoryMap()->RemoveMemoryRegion("debugger"); }