Zebediah Figura : ntoskrnl.exe: Protect the two relocated pages independently.
Module: wine Branch: stable Commit: 02d156580efef9035baac2b702ce999759329248 URL: https://source.winehq.org/git/wine.git/?a=commit;h=02d156580efef9035baac2b70... Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Fri May 22 09:52:56 2020 -0500 ntoskrnl.exe: Protect the two relocated pages independently. They may have different protection flags. This fixes a regression introduced by 22dfb0df10b44d1c21b3d04b59312670c2318431. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49198 Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> (cherry picked from commit c750ae6b9dc85fd2173e40a07204388988b64532) Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/ntoskrnl.exe/ntoskrnl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index f6b27d8c2f..25ace4f1a3 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -3412,8 +3412,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len, ULONG page_size ) while (rel < end - 1 && rel->SizeOfBlock) { - void *page = get_rva( module, rel->VirtualAddress ); - DWORD old_prot; + char *page = get_rva( module, rel->VirtualAddress ); + DWORD old_prot1, old_prot2; if (rel->VirtualAddress >= len) { @@ -3423,10 +3423,12 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len, ULONG page_size ) /* Relocation entries may hang over the end of the page, so we need to * protect two pages. */ - VirtualProtect( page, page_size * 2, PAGE_READWRITE, &old_prot ); + VirtualProtect( page, page_size, PAGE_READWRITE, &old_prot1 ); + VirtualProtect( page + page_size, page_size, PAGE_READWRITE, &old_prot2 ); rel = LdrProcessRelocationBlock( page, (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT), (USHORT *)(rel + 1), delta ); - VirtualProtect( page, page_size * 2, old_prot, &old_prot ); + VirtualProtect( page, page_size, old_prot1, &old_prot1 ); + VirtualProtect( page + page_size, page_size, old_prot2, &old_prot2 ); if (!rel) return STATUS_INVALID_IMAGE_FORMAT; }
participants (1)
-
Alexandre Julliard