Index: ntoskrnl/fstub/disksup.c =================================================================== --- ntoskrnl/fstub/disksup.c (revision 63912) +++ ntoskrnl/fstub/disksup.c (working copy) @@ -1042,8 +1042,16 @@ ULONGLONG EndingSector; PAGED_CODE(); + DPRINT1("FSTUB: entry \n"); + DPRINT1("type %#x\n", Entry->PartitionType); + DPRINT1("offset %#08lx\n", GET_STARTING_SECTOR(Entry)); + DPRINT1("length %#08lx\n", GET_PARTITION_LENGTH(Entry)); + /* Unused partitions are considered valid */ - if (Entry->PartitionType == PARTITION_ENTRY_UNUSED) return TRUE; + if (Entry->PartitionType == PARTITION_ENTRY_UNUSED) { + DPRINT1("FSTUB: unused entry \n"); + return TRUE; + } /* Get the last sector of the partition */ EndingSector = GET_STARTING_SECTOR(Entry) + GET_PARTITION_LENGTH(Entry); @@ -1052,9 +1060,11 @@ if (EndingSector > MaxSector) { /* Invalid partition */ - DPRINT1("FSTUB: entry is invalid\n"); + DPRINT1("FSTUB: entry is invalid [1]\n"); + /* DPRINT1("FSTUB: offset %#08lx\n", GET_STARTING_SECTOR(Entry)); DPRINT1("FSTUB: length %#08lx\n", GET_PARTITION_LENGTH(Entry)); + */ DPRINT1("FSTUB: end %#I64x\n", EndingSector); DPRINT1("FSTUB: max %#I64x\n", MaxSector); return FALSE; @@ -1062,9 +1072,11 @@ else if(GET_STARTING_SECTOR(Entry) > MaxOffset) { /* Invalid partition */ - DPRINT1("FSTUB: entry is invalid\n"); + DPRINT1("FSTUB: entry is invalid [2]\n"); + /* DPRINT1("FSTUB: offset %#08lx\n", GET_STARTING_SECTOR(Entry)); DPRINT1("FSTUB: length %#08lx\n", GET_PARTITION_LENGTH(Entry)); + */ DPRINT1("FSTUB: end %#I64x\n", EndingSector); DPRINT1("FSTUB: maxOffset %#I64x\n", MaxOffset); return FALSE; @@ -1377,7 +1389,7 @@ PUCHAR Buffer = NULL; ULONG BufferSize = 2048, InputSize; PDRIVE_LAYOUT_INFORMATION DriveLayoutInfo = NULL; - LONG j = -1, i = -1, k; + LONG j = -1, i = -1; DISK_GEOMETRY DiskGeometry; LONGLONG EndSector, MaxSector, StartOffset; ULONGLONG MaxOffset; @@ -1476,7 +1488,10 @@ /* Normalize status code and check for failure */ if (Status == STATUS_NO_DATA_DETECTED) Status = STATUS_SUCCESS; - if (!NT_SUCCESS(Status)) break; + if (!NT_SUCCESS(Status)) { + DPRINT1("Can't read Part desc, status %#x\n", Status); + break; + } /* If we biased for EZ-Drive, unbias now */ if (IsEzDrive && (Offset.QuadPart == 512)) Offset.QuadPart = 0; @@ -1507,19 +1522,19 @@ /* Start looping partitions */ j++; - DPRINT("FSTUB: Partition Table %d:\n", j); - for (Entry = 1, k = 0; Entry <= 4; Entry++, PartitionDescriptor++) + DPRINT1("FSTUB: Partition Table %d:\n", j); + for (Entry = 1; Entry <= 4; Entry++, PartitionDescriptor++) { /* Get the partition type */ PartitionType = PartitionDescriptor->PartitionType; /* Print debug messages */ - DPRINT("Partition Entry %d,%d: type %#x %s\n", + DPRINT1("Partition Entry %d,%d: type %#x %s\n", j, Entry, PartitionType, (PartitionDescriptor->ActiveFlag) ? "Active" : ""); - DPRINT("\tOffset %#08lx for %#08lx Sectors\n", + DPRINT1("\tOffset %#08lx for %#08lx Sectors\n", GET_STARTING_SECTOR(PartitionDescriptor), GET_PARTITION_LENGTH(PartitionDescriptor)); @@ -1526,6 +1541,7 @@ /* Check whether we're facing a protective MBR */ if (PartitionType == EFI_PMBR_OSTYPE_EFI) { + DPRINT1("FSTUB: EFI_PMBR_OSTYPE_EFI\n"); /* Partition length might be bigger than disk size */ FstubFixupEfiPartition(PartitionDescriptor, MaxOffset); @@ -1536,21 +1552,19 @@ MaxOffset, MaxSector)) && !(j)) { - /* It's invalid, so fail */ - IsValid = FALSE; - break; - } - - /* Check if it's a container */ - if (IsContainerPartition(PartitionType)) - { - /* Increase the count of containers */ - if (++k != 1) - { - /* More then one table is invalid */ - DPRINT1("FSTUB: Multiple container partitions found in " - "partition table %d\n - table is invalid\n", - j); + /* It's invalid */ + if (PartitionType == PARTITION_ENTRY_UNUSED) { + DPRINT1("Skip invalid Part Entry %d,%d\n", j, Entry); + continue; + } + if (IsContainerPartition(PartitionType)) { + /* Some disk utilities generate wrong partition size for + Extended Partition, while set correct values inside. + Keep it. + */ + DPRINT1("Keep invalid ExtPart Entry %d,%d\n", j, Entry); + } else { + DPRINT1("Invalid Part Entry %d,%d\n", j, Entry); IsValid = FALSE; break; } @@ -1591,6 +1605,7 @@ TAG_FILE_SYSTEM); if (!DriveLayoutInfo) { + DPRINT1("FSTUB: Out of memory, buff size %#x\n", BufferSize); /* Out of memory, unto this extra structure */ --i; Status = STATUS_INSUFFICIENT_RESOURCES; Index: ntoskrnl/io/iomgr/arcname.c =================================================================== --- ntoskrnl/io/iomgr/arcname.c (revision 63912) +++ ntoskrnl/io/iomgr/arcname.c (working copy) @@ -43,6 +43,7 @@ { SIZE_T Length; NTSTATUS Status; + NTSTATUS StatusCD; CHAR Buffer[128]; BOOLEAN SingleDisk; BOOLEAN FoundBoot = FALSE; @@ -138,9 +139,12 @@ /* Loop every disk and try to find boot disk */ Status = IopCreateArcNamesDisk(LoaderBlock, SingleDisk, &FoundBoot); /* If it succeed but we didn't find boot device, try to browse Cds */ - if (NT_SUCCESS(Status) && !FoundBoot) + if(!FoundBoot) { - Status = IopCreateArcNamesCd(LoaderBlock); + StatusCD = IopCreateArcNamesCd(LoaderBlock); + if(NT_SUCCESS(StatusCD)) { + Status = StatusCD; + } } /* Return success */ @@ -191,6 +195,7 @@ &EnabledDisks); if (!NT_SUCCESS(Status)) { + DPRINT1("GUID_DEVINTERFACE_CDROM failed, status %#x\n", Status); NotEnabledPresent = TRUE; } /* Save symbolic link list address in order to free it after */ @@ -199,6 +204,8 @@ Status = STATUS_SUCCESS; /* Browse all the ARC devices trying to find the one matching boot device */ + + DPRINT1("ArcBootDeviceName: %s \n", LoaderBlock->ArcBootDeviceName); for (NextEntry = ArcDiskInformation->DiskSignatureListHead.Flink; NextEntry != &ArcDiskInformation->DiskSignatureListHead; NextEntry = NextEntry->Flink) @@ -206,7 +213,9 @@ ArcDiskSignature = CONTAINING_RECORD(NextEntry, ARC_DISK_SIGNATURE, ListEntry); - + DPRINT1("ArcDiskSignature->ArcName: %s", ArcDiskSignature->ArcName); + DPRINT1("CD check sig %s vs %s\n", LoaderBlock->ArcBootDeviceName, ArcDiskSignature->ArcName); + DPRINT1("ArcDiskSignature->ArcName: %s ArcDiskSignature->Checksum:%#x \n", ArcDiskSignature->ArcName, ArcDiskSignature->Checksum); if (strcmp(LoaderBlock->ArcBootDeviceName, ArcDiskSignature->ArcName) == 0) { break; @@ -218,7 +227,7 @@ /* Not found... Not booting from a Cd */ if (!ArcDiskSignature) { - DPRINT("Failed finding a cd that could match current boot device\n"); + DPRINT1("Failed finding a CD that could match current boot device\n"); goto Cleanup; } @@ -226,7 +235,7 @@ PartitionBuffer = ExAllocatePoolWithTag(NonPagedPoolCacheAligned, 2048, TAG_IO); if (!PartitionBuffer) { - DPRINT("Failed allocating resources!\n"); + DPRINT1("Failed allocating resources 2k!\n"); /* Here, we fail, BUT we return success, some Microsoft joke */ goto Cleanup; } @@ -237,7 +246,7 @@ CdRomCount = EnabledDisks; } - /* If we'll have to browse for none enabled Cds, fix higher count */ + /* If we'll have to browse for not enabled Cds, fix higher count */ if (NotEnabledPresent && !EnabledDisks) { CdRomCount += 5; @@ -246,6 +255,7 @@ /* Finally, if in spite of all that work, we still don't have Cds, leave */ if (!CdRomCount) { + DPRINT1("!CdRomCount\n"); goto Cleanup; } @@ -252,6 +262,7 @@ /* Start browsing Cds */ for (DiskNumber = 0, EnabledDisks = 0; DiskNumber < CdRomCount; DiskNumber++) { + DPRINT1("Try CD %d\n", DiskNumber); /* Check if we have an enabled disk */ if (SymbolicLinkList && *SymbolicLinkList != UNICODE_NULL) { @@ -268,7 +279,8 @@ /* Failure? Good bye! */ if (!NT_SUCCESS(Status)) { - goto Cleanup; + DPRINT1("CD symlink access failed: status %#x\n", Status); + continue; } /* Now, we'll ask the device its device number */ @@ -332,8 +344,9 @@ &DeviceObject); if (!NT_SUCCESS(Status)) { + DPRINT1("CD access failed: status %#x\n", Status); RtlFreeUnicodeString(&DeviceStringW); - goto Cleanup; + continue; } } @@ -359,13 +372,25 @@ } /* Reading succeed, compute checksum by adding data, 2048 bytes checksum */ + DPRINT1("Read CD status: %#x\n", Status); if (NT_SUCCESS(Status)) { for (i = 0; i < 2048 / sizeof(ULONG); i++) { + DPRINT1("%2.2x", PartitionBuffer[i]); + if(i % 256 == 255) { + DPRINT1("\n\n"); + } else + if(i % 32 == 31) { + DPRINT1("\n"); + } else + if(i % 8 == 7) { + DPRINT1(" "); + } CheckSum += PartitionBuffer[i]; } } + DPRINT1("CheckSum: %#x\n", CheckSum); } /* Dereference file object */ @@ -372,6 +397,9 @@ ObDereferenceObject(FileObject); /* If checksums are matching, we have the proper cd */ + DPRINT1("CheckSum + ArcDiskSignature->CheckSum: %#x + %#x = %#x\n", + CheckSum, ArcDiskSignature->CheckSum, + CheckSum + ArcDiskSignature->CheckSum); if (CheckSum + ArcDiskSignature->CheckSum == 0) { /* Create ARC name */ @@ -383,7 +411,7 @@ /* Create symbolic link */ IoAssignArcName(&ArcNameStringW, &DeviceStringW); RtlFreeUnicodeString(&ArcNameStringW); - DPRINT1("Boot device found\n"); + DPRINT1("Boot CD device found\n"); } /* And quit, whatever happens */ @@ -396,6 +424,7 @@ } Cleanup: + DPRINT1("IopCreateArcNamesCd: status %#x\n", Status); if (PartitionBuffer) { ExFreePoolWithTag(PartitionBuffer, TAG_IO); @@ -482,6 +511,7 @@ for (DiskNumber = 0; DiskNumber < DiskCount; DiskNumber++) { /* Check if we have an enabled disk */ + DPRINT1("Try DISK %d\n", DiskNumber); if (lSymbolicLinkList && *lSymbolicLinkList != UNICODE_NULL) { /* Create its device name using first symbolic link */ @@ -526,9 +556,12 @@ /* If we didn't get the appriopriate data, just skip that disk */ if (!NT_SUCCESS(Status)) { - ObDereferenceObject(FileObject); - continue; + DPRINT1("Can't get device number, status %#x\n", Status); + ObDereferenceObject(FileObject); + continue; } + } else { + DPRINT1("Can't get DO, status %#x\n", Status); } /* End of enabled disks enumeration */ @@ -558,6 +591,7 @@ Status = RtlAnsiStringToUnicodeString(&DeviceStringW, &DeviceStringA, TRUE); if (!NT_SUCCESS(Status)) { + DPRINT1("Can't create disk path, status %#x\n", Status); goto Cleanup; } @@ -575,6 +609,7 @@ /* Something failed somewhere earlier, just skip the disk */ if (!NT_SUCCESS(Status)) { + DPRINT1("DIsk access error, status %#x\n", Status); continue; } @@ -734,11 +769,14 @@ for (i = 1; i <= DriveLayout->PartitionCount; i++) { /* Create device name */ + DPRINT1("Try create \\Device\\Harddisk%lu\\Partition%lu\n", + (DeviceNumber.DeviceNumber != ULONG_MAX) ? DeviceNumber.DeviceNumber : DiskNumber, i); sprintf(Buffer, "\\Device\\Harddisk%lu\\Partition%lu", (DeviceNumber.DeviceNumber != ULONG_MAX) ? DeviceNumber.DeviceNumber : DiskNumber, i); RtlInitAnsiString(&DeviceStringA, Buffer); Status = RtlAnsiStringToUnicodeString(&DeviceStringW, &DeviceStringA, TRUE); if (!NT_SUCCESS(Status)) { + DPRINT1("Can't create, status %#x\n", Status); goto Cleanup; } @@ -749,7 +787,7 @@ /* Is that boot device? */ if (RtlEqualString(&ArcNameStringA, &ArcBootString, TRUE)) { - DPRINT("Found boot device\n"); + DPRINT1("Found HDD boot device\n"); *FoundBoot = TRUE; } @@ -761,6 +799,7 @@ Status = RtlAnsiStringToUnicodeString(&HalPathStringW, &HalPathStringA, TRUE); if (!NT_SUCCESS(Status)) { + DPRINT1("Can't create HAT path, status %#x\n", Status); RtlFreeUnicodeString(&DeviceStringW); goto Cleanup; } @@ -776,6 +815,7 @@ Status = RtlAnsiStringToUnicodeString(&ArcNameStringW, &ArcNameStringA, TRUE); if (!NT_SUCCESS(Status)) { + DPRINT1("Can't create Arc path, status %#x\n", Status); RtlFreeUnicodeString(&DeviceStringW); goto Cleanup; } @@ -813,6 +853,7 @@ Status = STATUS_SUCCESS; Cleanup: + DPRINT1("IopCreateArcNamesDisk: status %#x\n", Status); if (SymbolicLinkList) { ExFreePool(SymbolicLinkList);