Skip to content

Maybe a potential issue in detour_alloc_region_from_hi function #330

Open
@MouriNaruto

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions