MCPcopy Create free account
hub / github.com/acl-dev/acl / DetourVirtualProtectSameExecuteEx

Function DetourVirtualProtectSameExecuteEx

lib_fiber/cpp/src/detours/detours.cpp:2542–2564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2540
2541_Success_(return != FALSE)
2542BOOL WINAPI DetourVirtualProtectSameExecuteEx(_In_ HANDLE hProcess,
2543 _In_ PVOID pAddress,
2544 _In_ SIZE_T nSize,
2545 _In_ DWORD dwNewProtect,
2546 _Out_ PDWORD pdwOldProtect)
2547// Some systems do not allow executability of a page to change. This function applies
2548// dwNewProtect to [pAddress, nSize), but preserving the previous executability.
2549// This function is meant to be a drop-in replacement for some uses of VirtualProtectEx.
2550// When "restoring" page protection, there is no need to use this function.
2551{
2552 MEMORY_BASIC_INFORMATION mbi;
2553
2554 // Query to get existing execute access.
2555
2556 ZeroMemory(&mbi, sizeof(mbi));
2557
2558 if (VirtualQueryEx(hProcess, pAddress, &mbi, sizeof(mbi)) == 0) {
2559 return FALSE;
2560 }
2561 return VirtualProtectEx(hProcess, pAddress, nSize,
2562 DetourPageProtectAdjustExecute(mbi.Protect, dwNewProtect),
2563 pdwOldProtect);
2564}
2565
2566_Success_(return != FALSE)
2567BOOL WINAPI DetourVirtualProtectSameExecute(_In_ PVOID pAddress,

Callers 4

UpdateFrom32To64Function · 0.85
UPDATE_IMPORTS_XXFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…