Author: tkreuzer
Date: Sun Jul 8 22:06:23 2012
New Revision: 56860
URL:
http://svn.reactos.org/svn/reactos?rev=56860&view=rev
Log:
[FREELDR]
Allocate the ARC_DISK_SIGNATURE structures from the heap instead of putting them into the
initial loader block allocation, since the number of disks changes later. Fixes memory
corrruption and boot breakage when 3 hdds are connected.
[NTOSKRNL]
Remove a hack that disabled unloading drivers, which didn't work because of memory
corruption from freeldr. This works now, too.
See issue #7139 for more details.
Modified:
trunk/reactos/boot/freeldr/freeldr/include/winldr.h
trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
trunk/reactos/ntoskrnl/io/iomgr/driver.c
Modified: trunk/reactos/boot/freeldr/freeldr/include/winldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/winldr.h [iso-8859-1] Sun Jul 8 22:06:23
2012
@@ -71,7 +71,6 @@
CHAR NtBootPathName[MAX_PATH+1];
CHAR NtHalPathName[MAX_PATH+1];
ARC_DISK_INFORMATION ArcDiskInformation;
- ARC_DISK_SIGNATURE_EX ArcDiskSignature[];
} LOADER_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
Modified: trunk/reactos/boot/freeldr/freeldr/windows/winldr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/windo…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/windows/winldr.c [iso-8859-1] Sun Jul 8 22:06:23
2012
@@ -48,12 +48,9 @@
AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
{
PLOADER_PARAMETER_BLOCK LoaderBlock;
- ULONG SystemBlockSize;
/* Allocate and zero-init the LPB */
- SystemBlockSize = sizeof(LOADER_SYSTEM_BLOCK) +
- reactos_disk_count * sizeof(ARC_DISK_SIGNATURE_EX);
- WinLdrSystemBlock = MmAllocateMemoryWithType(SystemBlockSize,
+ WinLdrSystemBlock = MmAllocateMemoryWithType(sizeof(LOADER_SYSTEM_BLOCK),
LoaderSystemBlock);
if (WinLdrSystemBlock == NULL)
{
@@ -135,26 +132,27 @@
/* Convert ARC disk information from freeldr to a correct format */
for (i = 0; i < reactos_disk_count; i++)
{
- PARC_DISK_SIGNATURE ArcDiskSig;
-
- /* Get the ARC structure */
- ArcDiskSig = &WinLdrSystemBlock->ArcDiskSignature[i].DiskSignature;
+ PARC_DISK_SIGNATURE_EX ArcDiskSig;
+
+ /* Allocate the ARC structure */
+ ArcDiskSig = HeapAllocate(FrLdrDefaultHeap,
+ sizeof(ARC_DISK_SIGNATURE_EX),
+ 'giSD');
/* Copy the data over */
- ArcDiskSig->Signature = reactos_arc_disk_info[i].Signature;
- ArcDiskSig->CheckSum = reactos_arc_disk_info[i].CheckSum;
+ ArcDiskSig->DiskSignature.Signature = reactos_arc_disk_info[i].Signature;
+ ArcDiskSig->DiskSignature.CheckSum = reactos_arc_disk_info[i].CheckSum;
/* Copy the ARC Name */
- ArcDiskSig->ArcName = WinLdrSystemBlock->ArcDiskSignature[i].ArcName;
strncpy(ArcDiskSig->ArcName, reactos_arc_disk_info[i].ArcName, MAX_PATH);
- ArcDiskSig->ArcName = PaToVa(ArcDiskSig->ArcName);
+ ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
/* Mark partition table as valid */
- ArcDiskSig->ValidPartitionTable = TRUE;
+ ArcDiskSig->DiskSignature.ValidPartitionTable = TRUE;
/* Insert into the list */
InsertTailList(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead,
- &ArcDiskSig->ListEntry);
+ &ArcDiskSig->DiskSignature.ListEntry);
}
/* Convert all list's to Virtual address */
@@ -639,7 +637,9 @@
WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
WinLdrpDumpBootDriver(LoaderBlockVA);
+#ifndef _M_AMD64
WinLdrpDumpArcDisks(LoaderBlockVA);
+#endif
//FIXME: If I substitute this debugging checkpoint, GCC will "optimize away"
the code below
//while (1) {};
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Sun Jul 8 22:06:23 2012
@@ -76,16 +76,12 @@
DriverExtension = NextDriverExtension;
}
-#if 0
/* Check if the driver image is still loaded */
if (DriverObject->DriverSection)
{
/* Unload it */
MmUnloadSystemImage(DriverObject->DriverSection);
}
-#else
- DPRINT1("HACK: Not unloading the driver image due to critical bugs!\n");
-#endif
/* Check if it has a name */
if (DriverObject->DriverName.Buffer)
@@ -283,7 +279,7 @@
/* Free caller's string */
ExFreePoolWithTag(InputImagePath.Buffer, TAG_RTLREGISTRY);
}
-
+
DPRINT("Normalized image path is '%wZ' for service '%wZ'\n",
ImagePath, ServiceName);
return STATUS_SUCCESS;
@@ -526,7 +522,7 @@
DPRINT("IopCreateDriver() failed (Status 0x%08lx)\n", Status);
return Status;
}
-
+
MmFreeDriverInitialization((PLDR_DATA_TABLE_ENTRY)Driver->DriverSection);
/* Set the driver as initialized */