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