ensure memory regions are writeable before patching
This commit is contained in:
@@ -169,13 +169,19 @@ BOOL PatchWUA(HMODULE hModule) {
|
|||||||
lpbIsCPUSupportedResult = (LPBOOL)(*(uintptr_t *)(ptr + offset01));
|
lpbIsCPUSupportedResult = (LPBOOL)(*(uintptr_t *)(ptr + offset01));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DWORD flNewProtect = PAGE_READWRITE;
|
||||||
|
DWORD flOldProtect;
|
||||||
if (*lpbFirstRun) {
|
if (*lpbFirstRun) {
|
||||||
|
VirtualProtect(lpbFirstRun, sizeof(BOOL), flNewProtect, &flOldProtect);
|
||||||
*lpbFirstRun = FALSE;
|
*lpbFirstRun = FALSE;
|
||||||
|
VirtualProtect(lpbFirstRun, sizeof(BOOL), flOldProtect, &flNewProtect);
|
||||||
trace(L"Patched boolean value #1: %p = %08x", lpbFirstRun, *lpbFirstRun);
|
trace(L"Patched boolean value #1: %p = %08x", lpbFirstRun, *lpbFirstRun);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
if (!*lpbIsCPUSupportedResult) {
|
if (!*lpbIsCPUSupportedResult) {
|
||||||
|
VirtualProtect(lpbIsCPUSupportedResult, sizeof(BOOL), flNewProtect, &flOldProtect);
|
||||||
*lpbIsCPUSupportedResult = TRUE;
|
*lpbIsCPUSupportedResult = TRUE;
|
||||||
|
VirtualProtect(lpbIsCPUSupportedResult, sizeof(BOOL), flOldProtect, &flNewProtect);
|
||||||
trace(L"Patched boolean value #2: %p = %08x", lpbIsCPUSupportedResult, *lpbIsCPUSupportedResult);
|
trace(L"Patched boolean value #2: %p = %08x", lpbIsCPUSupportedResult, *lpbIsCPUSupportedResult);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user