MCPcopy Create free account
hub / github.com/ajkhoury/ReClassEx / UpdateMemoryMap

Function UpdateMemoryMap

ReClass/stdafx.cpp:459–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459BOOLEAN UpdateMemoryMap( void )
460{
461 g_MemMap.clear( );
462 g_MemMapCode.clear( );
463 g_MemMapData.clear( );
464 g_MemMapModules.clear( );
465 g_Exports.clear( );
466 g_CustomNames.clear( );
467
468 if (g_hProcess == NULL)
469 return FALSE;
470
471 if (!IsProcessHandleValid( g_hProcess ))
472 {
473 g_hProcess = NULL;
474 return FALSE;
475 }
476
477 SYSTEM_INFO SysInfo;
478 GetSystemInfo( &SysInfo );
479
480 MEMORY_BASIC_INFORMATION MemInfo;
481 ULONG_PTR pMemory = (ULONG_PTR)SysInfo.lpMinimumApplicationAddress;
482 while (pMemory < (ULONG_PTR)SysInfo.lpMaximumApplicationAddress)
483 {
484 if (VirtualQueryEx( g_hProcess, (LPCVOID)pMemory, &MemInfo, sizeof( MEMORY_BASIC_INFORMATION ) ) != FALSE)
485 {
486 if (MemInfo.State == MEM_COMMIT /*&& MemInfo.Type == MEM_PRIVATE*/)
487 {
488 MemMapInfo Mem;
489 Mem.Start = (ULONG_PTR)pMemory;
490 Mem.End = (ULONG_PTR)pMemory + MemInfo.RegionSize - 1;
491 g_MemMap.push_back( Mem );
492 }
493 pMemory = (ULONG_PTR)MemInfo.BaseAddress + MemInfo.RegionSize;
494 }
495 else
496 {
497 pMemory += 1024;
498 }
499 }
500
501 PPROCESS_BASIC_INFORMATION ProcessInfo = NULL;
502 PEB Peb;
503 PEB_LDR_DATA LdrData;
504
505 // Try to allocate buffer
506 DWORD dwSize = sizeof( PROCESS_BASIC_INFORMATION );
507 ProcessInfo = (PPROCESS_BASIC_INFORMATION)malloc( dwSize );
508 if (!ProcessInfo)
509 {
510 #ifdef _DEBUG
511 PrintOut( _T( "[UpdateMemoryMap]: Couldn't allocate process info buffer!" ) );
512 #endif
513 return FALSE;
514 }
515
516 ULONG dwSizeNeeded = 0;

Callers 2

OnTimerMethod · 0.85
OnAttachButtonMethod · 0.85

Calls 7

IsProcessHandleValidFunction · 0.85
ReClassReadMemoryFunction · 0.85
GetLastErrorStringFunction · 0.85
IsModuleFunction · 0.85
GetModuleNameFunction · 0.85
clearMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected