File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ Modules HostWindows::modules() const {
32
32
33
33
const auto snapshotHandle = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, m_pid);
34
34
if (snapshotHandle == INVALID_HANDLE_VALUE) {
35
+ CloseHandle (processHandle);
35
36
return {};
36
37
}
37
38
@@ -49,7 +50,11 @@ Modules HostWindows::modules() const {
49
50
MEMORY_BASIC_INFORMATION64 mbi;
50
51
auto address = reinterpret_cast < procptr_t >(me.modBaseAddr );
51
52
while (VirtualQueryEx (processHandle, reinterpret_cast < LPCVOID >(address),
52
- reinterpret_cast < PMEMORY_BASIC_INFORMATION >(&mbi), sizeof (mbi))) {
53
+ reinterpret_cast < PMEMORY_BASIC_INFORMATION >(&mbi), sizeof (mbi))
54
+ /* Only enumerate pages that belong to the allocation for this module.
55
+ * This stops if it sees a page for a different allocation, belonging
56
+ * to another module or dynamic memory, or gap between pages. */
57
+ && (mbi.AllocationBase == reinterpret_cast < procptr_t >(me.modBaseAddr ))) {
53
58
MemoryRegion region{};
54
59
region.address = address;
55
60
region.size = mbi.RegionSize ;
You can’t perform that action at this time.
0 commit comments