From 598fc65ea0a0ccf9dad1a880355718529730614a Mon Sep 17 00:00:00 2001 From: mrexodia Date: Tue, 11 Apr 2017 00:19:37 +0200 Subject: [PATCH] DBG+GUI: no longer override the section name in memory map with user comments --- src/dbg/_dbgfunctions.cpp | 2 ++ src/dbg/_dbgfunctions.h | 2 ++ src/dbg/memory.cpp | 4 ---- src/gui/Src/Gui/MemoryMapView.cpp | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dbg/_dbgfunctions.cpp b/src/dbg/_dbgfunctions.cpp index 09bfc53f..49540d8f 100644 --- a/src/dbg/_dbgfunctions.cpp +++ b/src/dbg/_dbgfunctions.cpp @@ -27,6 +27,7 @@ #include "watch.h" #include "animate.h" #include "thread.h" +#include "comment.h" static DBGFUNCTIONS _dbgfunctions; @@ -382,4 +383,5 @@ void dbgfunctionsinit() _dbgfunctions.ThreadGetName = ThreadGetName; _dbgfunctions.IsDepEnabled = dbgisdepenabled; _dbgfunctions.GetCallStackEx = _getcallstackex; + _dbgfunctions.GetUserComment = CommentGet; } diff --git a/src/dbg/_dbgfunctions.h b/src/dbg/_dbgfunctions.h index 53f380f2..c80221a2 100644 --- a/src/dbg/_dbgfunctions.h +++ b/src/dbg/_dbgfunctions.h @@ -175,6 +175,7 @@ typedef bool(*HANDLESENUMHEAPS)(ListOf(HEAPINFO) heaps); typedef bool(*THREADGETNAME)(DWORD tid, char* name); typedef bool(*ISDEPENABLED)(); typedef void(*GETCALLSTACKEX)(DBGCALLSTACK* callstack, bool cache); +typedef bool(*GETUSERCOMMENT)(duint addr, char* comment); //The list of all the DbgFunctions() return value. //WARNING: This list is append only. Do not insert things in the middle or plugins would break. @@ -240,6 +241,7 @@ typedef struct DBGFUNCTIONS_ THREADGETNAME ThreadGetName; ISDEPENABLED IsDepEnabled; GETCALLSTACKEX GetCallStackEx; + GETUSERCOMMENT GetUserComment; } DBGFUNCTIONS; #ifdef BUILD_DBG diff --git a/src/dbg/memory.cpp b/src/dbg/memory.cpp index 3f7d0939..7bfb361f 100644 --- a/src/dbg/memory.cpp +++ b/src/dbg/memory.cpp @@ -12,7 +12,6 @@ #include "module.h" #include "taskthread.h" #include "value.h" -#include "comment.h" #define PAGE_SHIFT (12) //#define PAGE_SIZE (4096) @@ -238,13 +237,10 @@ void MemUpdateMap() EXCLUSIVE_ACQUIRE(LockMemoryPages); memoryPages.clear(); - char comment[MAX_COMMENT_SIZE] = ""; for(auto & page : pageVector) { duint start = (duint)page.mbi.BaseAddress; duint size = (duint)page.mbi.RegionSize; - if(CommentGet(start, comment)) //user comments override info - strncpy_s(page.info, comment, _TRUNCATE); memoryPages.insert(std::make_pair(std::make_pair(start, start + size - 1), page)); } } diff --git a/src/gui/Src/Gui/MemoryMapView.cpp b/src/gui/Src/Gui/MemoryMapView.cpp index 56611735..087f495f 100644 --- a/src/gui/Src/Gui/MemoryMapView.cpp +++ b/src/gui/Src/Gui/MemoryMapView.cpp @@ -351,8 +351,11 @@ void MemoryMapView::refreshMap() wS = QString((wMemMapStruct.page)[wI].info); setCellContent(wI, 2, wS); - // Content TODO: proper section content analysis in dbg/memory.cpp:MemUpdateMap - if(wS.contains(".bss")) + // Content, TODO: proper section content analysis in dbg/memory.cpp:MemUpdateMap + char comment_text[MAX_COMMENT_SIZE]; + if(DbgFunctions()->GetUserComment((duint)wMbi.BaseAddress, comment_text)) // user comment present + wS = comment_text; + else if(wS.contains(".bss")) wS = tr("Uninitialized data"); else if(wS.contains(".data")) wS = tr("Initialized data");