| 2540 | |
| 2541 | _Success_(return != FALSE) |
| 2542 | BOOL 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) |
| 2567 | BOOL WINAPI DetourVirtualProtectSameExecute(_In_ PVOID pAddress, |
no test coverage detected
searching dependent graphs…