From c596e299c6223f53e9f25a4fdead90acb6be4341 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 30 Sep 2011 21:13:49 +0000 Subject: [PATCH] [FREELDR] Remove DTEs for ntbootdd.sys and freeldr.sys after they are not used any longer. freeldr one will even point to invalid stack data. It only works currently, because the LoadOrderListHead is reset later. More fixes are coming. svn path=/trunk/; revision=53908 --- reactos/boot/freeldr/freeldr/disk/scsiport.c | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/disk/scsiport.c b/reactos/boot/freeldr/freeldr/disk/scsiport.c index c86fe7cb2bc..76e03293bc6 100644 --- a/reactos/boot/freeldr/freeldr/disk/scsiport.c +++ b/reactos/boot/freeldr/freeldr/disk/scsiport.c @@ -1659,12 +1659,6 @@ LoadBootDeviceDriver(VOID) FunctionTable[i] = (ULONG)((ULONG_PTR)ExportTable[i].Function - (ULONG_PTR)&ImageDosHeader); } - /* Add freeldr.sys to list of loaded executables */ - Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "scsiport.sys", - "FREELDR.SYS", &ImageDosHeader, &FreeldrDTE); - if (!Status) - return EIO; - /* Create full ntbootdd.sys path */ MachDiskGetBootPath(NtBootDdPath, sizeof(NtBootDdPath)); strcat(NtBootDdPath, "\\NTBOOTDD.SYS"); @@ -1677,12 +1671,28 @@ LoadBootDeviceDriver(VOID) return ESUCCESS; } - /* Fix imports */ + /* Allocate a DTE for ntbootdd */ Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "ntbootdd.sys", "NTBOOTDD.SYS", ImageBase, &BootDdDTE); if (!Status) return EIO; + + /* Add freeldr.sys to list of loaded executables, it repaces scsiport.sys */ + Status = WinLdrAllocateDataTableEntry(&LoaderBlock, "scsiport.sys", + "FREELDR.SYS", &ImageDosHeader, &FreeldrDTE); + if (!Status) + { + RemoveEntryList(&BootDdDTE->InLoadOrderLinks); + return EIO; + } + + /* Fix imports */ Status = WinLdrScanImportDescriptorTable(&LoaderBlock, "", BootDdDTE); + + /* Now unlinkt the DTEs, they won't be valid later */ + RemoveEntryList(&BootDdDTE->InLoadOrderLinks); + RemoveEntryList(&FreeldrDTE->InLoadOrderLinks); + if (!Status) return EIO;