DBG: MemUpdateMapAsync()
This commit is contained in:
parent
4a192a1c9f
commit
dec53c13c4
|
@ -63,12 +63,19 @@ static DWORD WINAPI memMapThread(void* ptr)
|
||||||
break;
|
break;
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
}
|
}
|
||||||
if(bStopMemMapThread)
|
|
||||||
break;
|
// Execute the update only if the delta if >= 1 second
|
||||||
MemUpdateMap();
|
if((GetTickCount() - memMapThreadCounter) >= 1000)
|
||||||
GuiUpdateMemoryView();
|
{
|
||||||
Sleep(1000);
|
MemUpdateMap();
|
||||||
|
GuiUpdateMemoryView();
|
||||||
|
|
||||||
|
memMapThreadCounter = GetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +113,7 @@ void dbginit()
|
||||||
void dbgstop()
|
void dbgstop()
|
||||||
{
|
{
|
||||||
bStopMemMapThread = true;
|
bStopMemMapThread = true;
|
||||||
|
memMapThreadCounter = 0;
|
||||||
bStopTimeWastedCounterThread = true;
|
bStopTimeWastedCounterThread = true;
|
||||||
WaitForThreadTermination(hMemMapThread);
|
WaitForThreadTermination(hMemMapThread);
|
||||||
WaitForThreadTermination(hTimeWastedCounterThread);
|
WaitForThreadTermination(hTimeWastedCounterThread);
|
||||||
|
@ -867,9 +875,8 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
|
||||||
if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo))
|
if(SafeSymGetModuleInfo64(fdProcessInfo->hProcess, (DWORD64)base, &modInfo))
|
||||||
ModLoad((duint)base, modInfo.ImageSize, modInfo.ImageName);
|
ModLoad((duint)base, modInfo.ImageSize, modInfo.ImageName);
|
||||||
|
|
||||||
//update memory map
|
// Update memory map
|
||||||
MemUpdateMap();
|
MemUpdateMapAsync();
|
||||||
GuiUpdateMemoryView();
|
|
||||||
|
|
||||||
char modname[256] = "";
|
char modname[256] = "";
|
||||||
if(ModNameFromAddr((duint)base, modname, true))
|
if(ModNameFromAddr((duint)base, modname, true))
|
||||||
|
@ -995,8 +1002,7 @@ static void cbUnloadDll(UNLOAD_DLL_DEBUG_INFO* UnloadDll)
|
||||||
ModUnload((duint)base);
|
ModUnload((duint)base);
|
||||||
|
|
||||||
//update memory map
|
//update memory map
|
||||||
MemUpdateMap();
|
MemUpdateMapAsync();
|
||||||
GuiUpdateMemoryView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString)
|
static void cbOutputDebugString(OUTPUT_DEBUG_STRING_INFO* DebugString)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
std::map<Range, MEMPAGE, RangeCompare> memoryPages;
|
std::map<Range, MEMPAGE, RangeCompare> memoryPages;
|
||||||
bool bListAllPages = false;
|
bool bListAllPages = false;
|
||||||
|
DWORD memMapThreadCounter = 0;
|
||||||
|
|
||||||
void MemUpdateMap()
|
void MemUpdateMap()
|
||||||
{
|
{
|
||||||
|
@ -214,6 +215,13 @@ void MemUpdateMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemUpdateMapAsync()
|
||||||
|
{
|
||||||
|
// Setting the last tick to 0 will force the thread to execute MemUpdateMap()
|
||||||
|
// as soon as possible
|
||||||
|
InterlockedExchange((volatile LONG*)&memMapThreadCounter, 0);
|
||||||
|
}
|
||||||
|
|
||||||
duint MemFindBaseAddr(duint Address, duint* Size, bool Refresh)
|
duint MemFindBaseAddr(duint Address, duint* Size, bool Refresh)
|
||||||
{
|
{
|
||||||
// Update the memory map if needed
|
// Update the memory map if needed
|
||||||
|
@ -414,11 +422,6 @@ bool MemFreeRemote(duint Address)
|
||||||
return VirtualFreeEx(fdProcessInfo->hProcess, (LPVOID)Address, 0, MEM_RELEASE) == TRUE;
|
return VirtualFreeEx(fdProcessInfo->hProcess, (LPVOID)Address, 0, MEM_RELEASE) == TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
duint MemGetPageAligned(duint Address)
|
|
||||||
{
|
|
||||||
return PAGE_ALIGN(Address);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh)
|
bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh)
|
||||||
{
|
{
|
||||||
// Update the memory map if needed
|
// Update the memory map if needed
|
||||||
|
@ -443,7 +446,7 @@ bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh)
|
||||||
bool MemSetPageRights(duint Address, const char* Rights)
|
bool MemSetPageRights(duint Address, const char* Rights)
|
||||||
{
|
{
|
||||||
// Align address to page base
|
// Align address to page base
|
||||||
Address = MemGetPageAligned(Address);
|
Address = PAGE_ALIGN(Address);
|
||||||
|
|
||||||
// String -> bit mask
|
// String -> bit mask
|
||||||
DWORD protect;
|
DWORD protect;
|
||||||
|
@ -457,7 +460,7 @@ bool MemSetPageRights(duint Address, const char* Rights)
|
||||||
bool MemGetPageRights(duint Address, char* Rights)
|
bool MemGetPageRights(duint Address, char* Rights)
|
||||||
{
|
{
|
||||||
// Align address to page base
|
// Align address to page base
|
||||||
Address = MemGetPageAligned(Address);
|
Address = PAGE_ALIGN(Address);
|
||||||
|
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
|
memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION));
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
extern std::map<Range, MEMPAGE, RangeCompare> memoryPages;
|
extern std::map<Range, MEMPAGE, RangeCompare> memoryPages;
|
||||||
extern bool bListAllPages;
|
extern bool bListAllPages;
|
||||||
|
extern DWORD memMapThreadCounter;
|
||||||
|
|
||||||
struct SimplePage
|
struct SimplePage
|
||||||
{
|
{
|
||||||
|
@ -20,6 +21,7 @@ struct SimplePage
|
||||||
};
|
};
|
||||||
|
|
||||||
void MemUpdateMap();
|
void MemUpdateMap();
|
||||||
|
void MemUpdateMapAsync();
|
||||||
duint MemFindBaseAddr(duint Address, duint* Size, bool Refresh = false);
|
duint MemFindBaseAddr(duint Address, duint* Size, bool Refresh = false);
|
||||||
bool MemRead(duint BaseAddress, void* Buffer, duint Size, duint* NumberOfBytesRead = nullptr);
|
bool MemRead(duint BaseAddress, void* Buffer, duint Size, duint* NumberOfBytesRead = nullptr);
|
||||||
bool MemWrite(duint BaseAddress, const void* Buffer, duint Size, duint* NumberOfBytesWritten = nullptr);
|
bool MemWrite(duint BaseAddress, const void* Buffer, duint Size, duint* NumberOfBytesWritten = nullptr);
|
||||||
|
@ -29,7 +31,6 @@ bool MemIsCanonicalAddress(duint Address);
|
||||||
bool MemIsCodePage(duint Address, bool Refresh);
|
bool MemIsCodePage(duint Address, bool Refresh);
|
||||||
duint MemAllocRemote(duint Address, duint Size, DWORD Type = MEM_RESERVE | MEM_COMMIT, DWORD Protect = PAGE_EXECUTE_READWRITE);
|
duint MemAllocRemote(duint Address, duint Size, DWORD Type = MEM_RESERVE | MEM_COMMIT, DWORD Protect = PAGE_EXECUTE_READWRITE);
|
||||||
bool MemFreeRemote(duint Address);
|
bool MemFreeRemote(duint Address);
|
||||||
duint MemGetPageAligned(duint Address);
|
|
||||||
bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh = false);
|
bool MemGetPageInfo(duint Address, MEMPAGE* PageInfo, bool Refresh = false);
|
||||||
bool MemSetPageRights(duint Address, const char* Rights);
|
bool MemSetPageRights(duint Address, const char* Rights);
|
||||||
bool MemGetPageRights(duint Address, char* Rights);
|
bool MemGetPageRights(duint Address, char* Rights);
|
||||||
|
|
Loading…
Reference in New Issue