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