Skip to content

Commit 5e9a330

Browse files
committed
DBG: (hopefully) fixed issue x64dbg#249 (force refresh memory map every second)
1 parent bac2859 commit 5e9a330

File tree

5 files changed

+3
-33
lines changed

5 files changed

+3
-33
lines changed

src/dbg/_dbgfunctions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ bool _getprocesslist(DBGPROCESSINFO** entries, int* count)
166166

167167
static void _memupdatemap()
168168
{
169-
dbggetprivateusage(fdProcessInfo->hProcess, true);
170169
MemUpdateMap();
171170
GuiUpdateMemoryView();
172171
}

src/dbg/debugger.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ static bool bSkipExceptions = false;
3535
static bool bBreakOnNextDll = false;
3636
static int ecount = 0;
3737
static std::vector<ExceptionRange> ignoredExceptionRange;
38-
static SIZE_T cachePrivateUsage = 0;
3938
static HANDLE hEvent = 0;
4039
static HANDLE hProcess = 0;
4140
static HANDLE hMemMapThread = 0;
@@ -64,13 +63,8 @@ static DWORD WINAPI memMapThread(void* ptr)
6463
}
6564
if(bStopMemMapThread)
6665
break;
67-
const SIZE_T PrivateUsage = dbggetprivateusage(fdProcessInfo->hProcess);
68-
if(cachePrivateUsage != PrivateUsage && !dbgisrunning()) //update the memory map when the memory usage changed
69-
{
70-
cachePrivateUsage = PrivateUsage;
71-
MemUpdateMap();
72-
GuiUpdateMemoryView();
73-
}
66+
MemUpdateMap();
67+
GuiUpdateMemoryView();
7468
Sleep(1000);
7569
}
7670
return 0;
@@ -115,17 +109,6 @@ void dbgstop()
115109
WaitForThreadTermination(hTimeWastedCounterThread);
116110
}
117111

118-
SIZE_T dbggetprivateusage(HANDLE hProcess, bool update)
119-
{
120-
PROCESS_MEMORY_COUNTERS_EX memoryCounters;
121-
memoryCounters.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX);
122-
if(!GetProcessMemoryInfo(fdProcessInfo->hProcess, (PPROCESS_MEMORY_COUNTERS)&memoryCounters, sizeof(PROCESS_MEMORY_COUNTERS_EX)))
123-
return 0;
124-
if(update)
125-
cachePrivateUsage = memoryCounters.PrivateUsage;
126-
return memoryCounters.PrivateUsage;
127-
}
128-
129112
duint dbgdebuggedbase()
130113
{
131114
return pDebuggedBase;
@@ -642,7 +625,6 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
642625
dprintf("Process Started: " fhex " %s\n", base, DebugFileName);
643626

644627
//update memory map
645-
dbggetprivateusage(fdProcessInfo->hProcess, true);
646628
MemUpdateMap();
647629
GuiUpdateMemoryView();
648630

@@ -764,7 +746,6 @@ static void cbCreateThread(CREATE_THREAD_DEBUG_INFO* CreateThread)
764746
if(settingboolget("Events", "ThreadStart"))
765747
{
766748
//update memory map
767-
dbggetprivateusage(fdProcessInfo->hProcess, true);
768749
MemUpdateMap();
769750
//update GUI
770751
GuiSetDebugState(paused);
@@ -856,7 +837,6 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
856837
ModLoad((duint)base, modInfo.ImageSize, modInfo.ImageName);
857838

858839
//update memory map
859-
dbggetprivateusage(fdProcessInfo->hProcess, true);
860840
MemUpdateMap();
861841
GuiUpdateMemoryView();
862842

@@ -984,7 +964,6 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll)
984964
ModUnload((duint)base);
985965

986966
//update memory map
987-
dbggetprivateusage(fdProcessInfo->hProcess, true);
988967
MemUpdateMap();
989968
GuiUpdateMemoryView();
990969
}
@@ -1057,7 +1036,7 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
10571036
dputs("paused!");
10581037
SetNextDbgContinueStatus(DBG_CONTINUE);
10591038
GuiSetDebugState(paused);
1060-
dbggetprivateusage(fdProcessInfo->hProcess, true);
1039+
//update memory map
10611040
MemUpdateMap();
10621041
DebugUpdateGui(GetContextDataEx(hActiveThread, UE_CIP), true);
10631042
//lock
@@ -1174,7 +1153,6 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
11741153
varset("$hp", (duint)fdProcessInfo->hProcess, true);
11751154
varset("$pid", fdProcessInfo->dwProcessId, true);
11761155
ecount = 0;
1177-
cachePrivateUsage = 0;
11781156
//NOTE: set custom handlers
11791157
SetCustomHandler(UE_CH_CREATEPROCESS, (void*)cbCreateProcess);
11801158
SetCustomHandler(UE_CH_EXITPROCESS, (void*)cbExitProcess);
@@ -1438,7 +1416,6 @@ DWORD WINAPI threadAttachLoop(void* lpParameter)
14381416
bFileIsDll = IsFileDLL(szFileName, 0);
14391417
GuiAddRecentFile(szFileName);
14401418
ecount = 0;
1441-
cachePrivateUsage = 0;
14421419
//NOTE: set custom handlers
14431420
SetCustomHandler(UE_CH_CREATEPROCESS, (void*)cbCreateProcess);
14441421
SetCustomHandler(UE_CH_EXITPROCESS, (void*)cbExitProcess);

src/dbg/debugger.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ typedef struct _THREADNAME_INFO
6161
#pragma pack(pop)
6262

6363
//functions
64-
SIZE_T dbggetprivateusage(HANDLE hProcess, bool update = false);
6564
void dbginit();
6665
void dbgstop();
6766
duint dbgdebuggedbase();

src/dbg/debugger_commands.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,6 @@ CMDRESULT cbDebugAlloc(int argc, char* argv[])
799799
if(mem)
800800
varset("$lastalloc", mem, true);
801801
//update memory map
802-
dbggetprivateusage(fdProcessInfo->hProcess, true);
803802
MemUpdateMap();
804803
GuiUpdateMemoryView();
805804

@@ -828,7 +827,6 @@ CMDRESULT cbDebugFree(int argc, char* argv[])
828827
if(!ok)
829828
dputs("VirtualFreeEx failed");
830829
//update memory map
831-
dbggetprivateusage(fdProcessInfo->hProcess, true);
832830
MemUpdateMap();
833831
GuiUpdateMemoryView();
834832

@@ -1869,7 +1867,6 @@ CMDRESULT cbDebugSetPageRights(int argc, char* argv[])
18691867
}
18701868

18711869
//update the memory map
1872-
dbggetprivateusage(fdProcessInfo->hProcess, true);
18731870
MemUpdateMap();
18741871
GuiUpdateMemoryView();
18751872

@@ -2074,7 +2071,6 @@ CMDRESULT cbDebugSetCmdline(int argc, char* argv[])
20742071
}
20752072

20762073
//update the memory map
2077-
dbggetprivateusage(fdProcessInfo->hProcess, true);
20782074
MemUpdateMap();
20792075
GuiUpdateMemoryView();
20802076

src/dbg/instruction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,6 @@ CMDRESULT cbInstrMeminfo(int argc, char* argv[])
22252225
}
22262226
else if (argv[1][0] == 'r')
22272227
{
2228-
dbggetprivateusage(fdProcessInfo->hProcess, true);
22292228
MemUpdateMap();
22302229
GuiUpdateMemoryView();
22312230
dputs("memory map updated!");

0 commit comments

Comments
 (0)