@@ -86,33 +86,24 @@ void EnumerateRemoteSectionsAndModules(const std::function<void(const void*, con
8686	};
8787	std::vector<SectionInfo> sections;
8888
89- 	SYSTEM_INFO sysInfo;
90- 	GetSystemInfo (&sysInfo);
91- 
9289	//  First enumerate all memory sections.
93- 	MEMORY_BASIC_INFORMATION memInfo;
94- 	size_t  address = (size_t )sysInfo.lpMinimumApplicationAddress ;
95- 	while  (address < (size_t )sysInfo.lpMaximumApplicationAddress )
90+ 	MEMORY_BASIC_INFORMATION memInfo = { 0  };
91+ 	memInfo.RegionSize  = 0x1000 ;
92+ 	size_t  address = 0 ;
93+ 	while  (VirtualQuery ((LPCVOID)address, &memInfo, sizeof (MEMORY_BASIC_INFORMATION)) != 0  && address + memInfo.RegionSize  > address)
9694	{
97- 		if  (VirtualQuery ((LPCVOID)address, &memInfo, sizeof (MEMORY_BASIC_INFORMATION)) != 0 )
98- 		{
99- 			if  (memInfo.State  == MEM_COMMIT /* && memInfo.Type == MEM_PRIVATE*/  )
100- 			{
101- 				SectionInfo section = {};
102- 				section.BaseAddress  = memInfo.BaseAddress ;
103- 				section.RegionSize  = memInfo.RegionSize ;
104- 				section.State  = memInfo.State ;
105- 				section.Protection  = memInfo.Protect ;
106- 				section.Type  = memInfo.Type ;
107- 
108- 				sections.push_back (std::move (section));
109- 			}
110- 			address = (ULONG_PTR)memInfo.BaseAddress  + memInfo.RegionSize ;
111- 		}
112- 		else 
95+ 		if  (memInfo.State  == MEM_COMMIT)
11396		{
114- 			address += 1024 ;
97+ 			SectionInfo section = {};
98+ 			section.BaseAddress  = memInfo.BaseAddress ;
99+ 			section.RegionSize  = memInfo.RegionSize ;
100+ 			section.State  = memInfo.State ;
101+ 			section.Protection  = memInfo.Protect ;
102+ 			section.Type  = memInfo.Type ;
103+ 
104+ 			sections.push_back (std::move (section));
115105		}
106+ 		address = (size_t )memInfo.BaseAddress  + memInfo.RegionSize ;
116107	}
117108
118109	struct  UNICODE_STRING 
0 commit comments