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

Maybe a potential issue in detour_alloc_region_from_hi function #330

Open
MouriNaruto opened this issue Dec 23, 2024 · 0 comments
Open

Maybe a potential issue in detour_alloc_region_from_hi function #330

MouriNaruto opened this issue Dec 23, 2024 · 0 comments

Comments

@MouriNaruto
Copy link

MouriNaruto commented Dec 23, 2024

Detours/src/detours.cpp

Lines 1385 to 1408 in b2bf32a

DETOUR_TRACE((" Try %p => %p..%p %6lx\n",
pbTry,
mbi.BaseAddress,
(PBYTE)mbi.BaseAddress + mbi.RegionSize - 1,
mbi.State));
if (mbi.State == MEM_FREE && mbi.RegionSize >= DETOUR_REGION_SIZE) {
PVOID pv = VirtualAlloc(pbTry,
DETOUR_REGION_SIZE,
MEM_COMMIT|MEM_RESERVE,
PAGE_EXECUTE_READWRITE);
if (pv != NULL) {
return pv;
}
else if (GetLastError() == ERROR_DYNAMIC_CODE_BLOCKED) {
return NULL;
}
pbTry -= DETOUR_REGION_SIZE;
}
else {
pbTry = detour_alloc_round_down_to_region((PBYTE)mbi.AllocationBase
- DETOUR_REGION_SIZE);
}

It seems detour_alloc_region_from_hi should try alloc something with the address related to "mbi.BaseAddress", but detour_alloc_round_down_to_region in that snippet uses "mbi.AllocationBase".

I get that information when I chatting with my friends. I try to find why introduce the "mbi.AllocationBase" in that snippet but I'm finally confused. So, I think I should post an issue for ask.

Kenji Mouri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant