Implement the magic flag in RtlImageDirectoryEntryToData and make the
Size parameter non-optional.
Modified: trunk/reactos/lib/ntdll/ldr/utils.c
Modified: trunk/reactos/lib/rtl/image.c
Modified: trunk/reactos/ntoskrnl/ldr/loader.c
_____
Modified: trunk/reactos/lib/ntdll/ldr/utils.c
--- trunk/reactos/lib/ntdll/ldr/utils.c 2005-07-31 09:48:12 UTC (rev
16917)
+++ trunk/reactos/lib/ntdll/ldr/utils.c 2005-07-31 10:22:29 UTC (rev
16918)
@@ -237,6 +237,7 @@
PLDR_DATA_TABLE_ENTRY Module;
PIMAGE_TLS_DIRECTORY TlsDirectory;
PTLS_DATA TlsData;
+ ULONG Size;
DPRINT("LdrpInitializeTlsForProccess() called for %wZ\n",
&ExeModule->BaseDllName);
@@ -263,7 +264,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_TLS,
- NULL);
+ &Size);
ASSERT(Module->TlsIndex < LdrpTlsCount);
TlsData = &LdrpTlsArray[Module->TlsIndex];
TlsData->StartAddressOfRawData =
(PVOID)TlsDirectory->StartAddressOfRawData;
@@ -1476,6 +1477,7 @@
NTSTATUS Status;
PIMAGE_IMPORT_DESCRIPTOR ImportModuleDirectory;
PCHAR Name;
+ ULONG Size;
DPRINT("LdrpProcessImportDirectory(%x '%wZ', '%s')\n",
Module, &Module->BaseDllName, ImportedName);
@@ -1485,7 +1487,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
- NULL);
+ &Size);
if (ImportModuleDirectory == NULL)
{
return STATUS_UNSUCCESSFUL;
@@ -1529,6 +1531,7 @@
ULONG IATSize;
PIMAGE_NT_HEADERS NTHeaders;
PCHAR Name;
+ ULONG Size;
DPRINT("LdrpAdjustImportDirectory(Module %x '%wZ', %x '%wZ', %x
'%s')\n",
Module, &Module->BaseDllName, ImportedModule,
&ImportedModule->BaseDllName, ImportedName);
@@ -1537,7 +1540,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
- NULL);
+ &Size);
if (ImportModuleDirectory == NULL)
{
return STATUS_UNSUCCESSFUL;
@@ -1647,6 +1650,7 @@
NTSTATUS Status;
PLDR_DATA_TABLE_ENTRY ImportedModule;
PCHAR ImportedName;
+ ULONG Size;
DPRINT("LdrFixupImports(SearchPath %x, Module %x)\n", SearchPath,
Module);
@@ -1655,7 +1659,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_TLS,
- NULL);
+ &Size);
if (TlsDirectory)
{
TlsSize = TlsDirectory->EndAddressOfRawData
@@ -1676,13 +1680,13 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
- NULL);
+ &Size);
BoundImportDescriptor = (PIMAGE_BOUND_IMPORT_DESCRIPTOR)
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT,
- NULL);
+ &Size);
if (BoundImportDescriptor != NULL && ImportModuleDirectory == NULL)
{
@@ -2142,8 +2146,8 @@
PLDR_DATA_TABLE_ENTRY ImportedModule;
NTSTATUS Status;
LONG LoadCount;
+ ULONG Size;
-
if (Unload)
{
RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock);
@@ -2163,7 +2167,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT,
- NULL);
+ &Size);
if (BoundImportDescriptor)
{
/* dereferencing all imported modules, use the bound import
descriptor */
@@ -2197,7 +2201,7 @@
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
-
NULL);
+
&Size);
if (ImportModuleDirectory)
{
/* dereferencing all imported modules, use the import
descriptor */
_____
Modified: trunk/reactos/lib/rtl/image.c
--- trunk/reactos/lib/rtl/image.c 2005-07-31 09:48:12 UTC (rev
16917)
+++ trunk/reactos/lib/rtl/image.c 2005-07-31 10:22:29 UTC (rev
16918)
@@ -49,7 +49,7 @@
STDCALL
RtlImageDirectoryEntryToData (
PVOID BaseAddress,
- BOOLEAN bFlag,
+ BOOLEAN bMappedAsImage,
ULONG Directory,
PULONG Size
)
@@ -59,8 +59,12 @@
/* Magic flag for non-mapped images. */
if ((ULONG_PTR)BaseAddress & 1)
- BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1);
+ {
+ BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1);
+ bMappedAsImage = FALSE;
+ }
+
NtHeader = RtlImageNtHeader (BaseAddress);
if (NtHeader == NULL)
return NULL;
@@ -72,10 +76,9 @@
if (Va == 0)
return NULL;
- if (Size)
- *Size =
NtHeader->OptionalHeader.DataDirectory[Directory].Size;
+ *Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size;
- if (bFlag)
+ if (bMappedAsImage || Va <
NtHeader->OptionalHeader.SizeOfHeaders)
return (PVOID)((ULONG_PTR)BaseAddress + Va);
/* image mapped as ordinary file, we must find raw pointer */
_____
Modified: trunk/reactos/ntoskrnl/ldr/loader.c
--- trunk/reactos/ntoskrnl/ldr/loader.c 2005-07-31 09:48:12 UTC (rev
16917)
+++ trunk/reactos/ntoskrnl/ldr/loader.c 2005-07-31 10:22:29 UTC (rev
16918)
@@ -161,8 +161,8 @@
if (ModuleBase)
*ModuleBase = ModuleObject->DllBase;
- //if (SectionPointer)
- // *SectionPointer = ModuleObject->
+ if (SectionPointer)
+ *SectionPointer = ModuleObject;
if (EntryPoint)
*EntryPoint = ModuleObject->EntryPoint;
@@ -204,7 +204,7 @@
DriverEntry = (PDRIVER_INITIALIZE)ModuleObject->EntryPoint;
RtlZeroMemory(&DriverObject, sizeof(DriverObject));
- DriverObject.DriverStart = ModuleObject->DllBase;
+// DriverObject.DriverStart = ModuleObject->DllBase;
Status = DriverEntry(&DriverObject, NULL);
if (!NT_SUCCESS(Status))
@@ -768,6 +768,7 @@
}
RtlCopyUnicodeString(&CreatedModuleObject->FullDllName, FileName);
+ CreatedModuleObject->FullDllName.Buffer[FileName->Length /
sizeof(WCHAR)] = 0;
LdrpBuildModuleBaseName(&CreatedModuleObject->BaseDllName,
&CreatedModuleObject->FullDllName);
@@ -1482,13 +1483,14 @@
PCHAR ImportedName;
PLDR_DATA_TABLE_ENTRY ImportedModule;
NTSTATUS Status;
+ ULONG Size;
/* Process each import module */
ImportModuleDirectory = (PIMAGE_IMPORT_DESCRIPTOR)
RtlImageDirectoryEntryToData(Module->DllBase,
TRUE,
IMAGE_DIRECTORY_ENTRY_IMPORT,
- NULL);
+ &Size);
DPRINT("Processeing import directory at %p\n",
ImportModuleDirectory);
while (ImportModuleDirectory->Name)
{