Commit c750ae6b authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl.exe: Protect the two relocated pages independently.

They may have different protection flags. This fixes a regression introduced by 22dfb0df. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49198Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9ddceebe
...@@ -3413,8 +3413,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len, ULONG page_size ) ...@@ -3413,8 +3413,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len, ULONG page_size )
while (rel < end - 1 && rel->SizeOfBlock) while (rel < end - 1 && rel->SizeOfBlock)
{ {
void *page = get_rva( module, rel->VirtualAddress ); char *page = get_rva( module, rel->VirtualAddress );
DWORD old_prot; DWORD old_prot1, old_prot2;
if (rel->VirtualAddress >= len) if (rel->VirtualAddress >= len)
{ {
...@@ -3424,10 +3424,12 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len, ULONG page_size ) ...@@ -3424,10 +3424,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 /* Relocation entries may hang over the end of the page, so we need to
* protect two pages. */ * 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), rel = LdrProcessRelocationBlock( page, (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT),
(USHORT *)(rel + 1), delta ); (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; if (!rel) return STATUS_INVALID_IMAGE_FORMAT;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment