Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(plugins): Load correct pages for modules #6598

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plugins/HostWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Modules HostWindows::modules() const {

const auto snapshotHandle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, m_pid);
if (snapshotHandle == INVALID_HANDLE_VALUE) {
CloseHandle(processHandle);
return {};
}

Expand All @@ -49,7 +50,11 @@ Modules HostWindows::modules() const {
MEMORY_BASIC_INFORMATION64 mbi;
auto address = reinterpret_cast< procptr_t >(me.modBaseAddr);
while (VirtualQueryEx(processHandle, reinterpret_cast< LPCVOID >(address),
reinterpret_cast< PMEMORY_BASIC_INFORMATION >(&mbi), sizeof(mbi))) {
reinterpret_cast< PMEMORY_BASIC_INFORMATION >(&mbi), sizeof(mbi))
/* Only enumerate pages that belong to the allocation for this module.
* This stops if it sees a page for a different allocation, belonging
* to another module or dynamic memory, or gap between pages. */
&& (mbi.AllocationBase == reinterpret_cast< procptr_t >(me.modBaseAddr))) {
sqwishy marked this conversation as resolved.
Show resolved Hide resolved
MemoryRegion region{};
region.address = address;
region.size = mbi.RegionSize;
Expand Down