mirror of
https://github.com/reactos/reactos.git
synced 2024-08-19 18:02:55 +00:00
- Readded the code for unportecting second page while relocating. Some applications like OpenOffice actually depend on it.
svn path=/trunk/; revision=9885
This commit is contained in:
parent
399da20296
commit
9cea7cc06c
|
@ -1,4 +1,4 @@
|
|||
/* $Id: utils.c,v 1.94 2004/06/26 14:37:05 navaraf Exp $
|
||||
/* $Id: utils.c,v 1.95 2004/06/26 15:11:14 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -1226,8 +1226,8 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
|||
{
|
||||
PIMAGE_DATA_DIRECTORY RelocationDDir;
|
||||
PIMAGE_BASE_RELOCATION RelocationDir, RelocationEnd;
|
||||
ULONG Count, ProtectSize, OldProtect, i;
|
||||
PVOID Page, ProtectPage;
|
||||
ULONG Count, ProtectSize, OldProtect, OldProtect2, i;
|
||||
PVOID Page, ProtectPage, ProtectPage2;
|
||||
PWORD TypeOffset;
|
||||
ULONG Delta = (ULONG_PTR)ImageBase - NTHeaders->OptionalHeader.ImageBase;
|
||||
NTSTATUS Status;
|
||||
|
@ -1258,7 +1258,7 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
|||
Page = ImageBase + RelocationDir->VirtualAddress;
|
||||
TypeOffset = (PWORD)(RelocationDir + 1);
|
||||
|
||||
/* Unprotect the page we're about to relocate. */
|
||||
/* Unprotect the page(s) we're about to relocate. */
|
||||
ProtectPage = Page;
|
||||
Status = NtProtectVirtualMemory(NtCurrentProcess(),
|
||||
&ProtectPage,
|
||||
|
@ -1271,6 +1271,27 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
if (RelocationDir->VirtualAddress + PAGE_SIZE <
|
||||
NTHeaders->OptionalHeader.SizeOfImage)
|
||||
{
|
||||
ProtectPage2 = ProtectPage + PAGE_SIZE;
|
||||
Status = NtProtectVirtualMemory(NtCurrentProcess(),
|
||||
&ProtectPage2,
|
||||
&ProtectSize,
|
||||
PAGE_READWRITE,
|
||||
&OldProtect2);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Failed to unprotect relocation target (2).\n");
|
||||
NtProtectVirtualMemory(NtCurrentProcess(),
|
||||
&ProtectPage,
|
||||
&ProtectSize,
|
||||
OldProtect,
|
||||
&OldProtect);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
|
||||
/* Patch the page. */
|
||||
for (i = 0; i < Count; i++)
|
||||
{
|
||||
|
@ -1304,6 +1325,16 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
|||
OldProtect,
|
||||
&OldProtect);
|
||||
|
||||
if (RelocationDir->VirtualAddress + PAGE_SIZE <
|
||||
NTHeaders->OptionalHeader.SizeOfImage)
|
||||
{
|
||||
NtProtectVirtualMemory(NtCurrentProcess(),
|
||||
&ProtectPage2,
|
||||
&ProtectSize,
|
||||
OldProtect2,
|
||||
&OldProtect2);
|
||||
}
|
||||
|
||||
RelocationDir = (IMAGE_BASE_RELOCATION*)((ULONG_PTR)RelocationDir +
|
||||
RelocationDir->SizeOfBlock);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue