2003-04-28 Casper S. Hornstrup <chorns@users.sourceforge.net>

* Makefile (DLLS): Add epsapi, psapi and wsock32.
	* lib/ntdll/ldr/utils.c (LdrPerformRelocations): Handle the case where a
	relocation crosses a page boundary.
	(LdrFixupImports): Use image load address in calculatation of import
	address list.

svn path=/trunk/; revision=4614
This commit is contained in:
Casper Hornstrup 2003-04-28 21:32:10 +00:00
parent e97422786f
commit 6247d82cc7
3 changed files with 50 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2003-04-28 Casper S. Hornstrup <chorns@users.sourceforge.net>
* Makefile (DLLS): Add epsapi, psapi and wsock32.
* lib/ntdll/ldr/utils.c (LdrPerformRelocations): Handle the case where a
relocation crosses a page boundary.
(LdrFixupImports): Use image load address in calculatation of import
address list.
2003-04-28 Casper S. Hornstrup <chorns@users.sourceforge.net>
* lib/fslib/vfatlib/vfatlib.h: New file.

View file

@ -32,9 +32,9 @@ LIB_FSLIB = vfatlib
# User mode libraries
# advapi32 crtdll fmifs gdi32 kernel32 libpcap packet msafd msvcrt ntdll ole32
# oleaut32 psapi rpcrt4 secur32 shell32 user32 version ws2help ws2_32 wsock32 wshirda
# oleaut32 epsapi psapi rpcrt4 secur32 shell32 user32 version ws2help ws2_32 wsock32 wshirda
DLLS = advapi32 crtdll fmifs freetype gdi32 kernel32 packet msafd msvcrt ntdll \
secur32 user32 version winedbgc ws2help ws2_32 wshirda zlib epsapi #winmm
epsapi psapi secur32 user32 version winedbgc ws2help ws2_32 wsock32 wshirda zlib #winmm
SUBSYS = smss win32k csrss ntvdm

View file

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.62 2003/04/26 10:05:38 gvg Exp $
/* $Id: utils.c,v 1.63 2003/04/28 21:32:10 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -712,7 +712,7 @@ LdrGetExportByName(PVOID BaseAddress,
ULONG ExportDirSize;
DPRINT("LdrGetExportByName %x %s %hu\n", BaseAddress, SymbolName, Hint);
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
RtlImageDirectoryEntryToData(BaseAddress,
TRUE,
@ -861,6 +861,7 @@ static NTSTATUS LdrPerformRelocations (PIMAGE_NT_HEADERS NTHeaders,
int i;
PIMAGE_DATA_DIRECTORY RelocationDDir;
ULONG OldProtect;
ULONG OldProtect2;
NTSTATUS Status;
PIMAGE_SECTION_HEADER Sections;
ULONG MaxExtend;
@ -918,6 +919,27 @@ static NTSTATUS LdrPerformRelocations (PIMAGE_NT_HEADERS NTHeaders,
DPRINT1("Failed to unprotect relocation target.\n");
return(Status);
}
if (RelocationDir->VirtualAddress + PAGE_SIZE < MaxExtend)
{
Status = NtProtectVirtualMemory(NtCurrentProcess(),
ImageBase +
RelocationDir->VirtualAddress + PAGE_SIZE,
PAGE_SIZE,
PAGE_READWRITE,
&OldProtect2);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to unprotect relocation target (2).\n");
NtProtectVirtualMemory(NtCurrentProcess(),
ImageBase +
RelocationDir->VirtualAddress,
PAGE_SIZE,
OldProtect,
&OldProtect);
return(Status);
}
}
for (i = 0; i < NumberOfEntries; i++)
{
@ -971,6 +993,21 @@ static NTSTATUS LdrPerformRelocations (PIMAGE_NT_HEADERS NTHeaders,
return(Status);
}
if (RelocationDir->VirtualAddress + PAGE_SIZE < MaxExtend)
{
Status = NtProtectVirtualMemory(NtCurrentProcess(),
ImageBase +
RelocationDir->VirtualAddress + PAGE_SIZE,
PAGE_SIZE,
OldProtect2,
&OldProtect2);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to protect relocation target2.\n");
return(Status);
}
}
RelocationRVA += RelocationDir->SizeOfBlock;
RelocationDir =
(PRELOCATION_DIRECTORY) (ImageBase + RelocationRVA);
@ -1055,7 +1092,7 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
/*
* Get the import address list.
*/
ImportAddressList = (PVOID *)(NTHeaders->OptionalHeader.ImageBase
ImportAddressList = (PVOID *)(ImageBase
+ ImportModuleDirectory->dwRVAFunctionAddressList);
/*