[USETUP] Code improvements for PartList.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 13 May 2017 16:32:53 +0000 (16:32 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 26 May 2018 17:09:39 +0000 (19:09 +0200)
- Use explicit ansi string safe functions (where they are used ansi, but not explicitely);
- Add (old-school) function parameters annotations;
- Use PARTITION_ENTRY_UNUSED where needed (instead of hardcoding its value);
- Turn some functions static to this module;
- Turn the 2nd parameter of both GetNextUnformattedPartition() and GetNextUncheckedPartition() optional (for next commit);
- Improve some comments;
- Use NT types.

svn path=/branches/setup_improvements/; revision=74531

base/setup/usetup/partlist.c
base/setup/usetup/partlist.h

index b047a22..22867b7 100644 (file)
@@ -174,19 +174,19 @@ static PARTITION_TYPE PartitionTypes[] =
 
 VOID
 GetPartTypeStringFromPartitionType(
 
 VOID
 GetPartTypeStringFromPartitionType(
-    UCHAR partitionType,
-    PCHAR strPartType,
-    DWORD cchPartType)
+    IN UCHAR partitionType,
+    OUT PCHAR strPartType,
+    IN ULONG cchPartType)
 {
     /* Determine partition type */
 
     if (IsContainerPartition(partitionType))
     {
 {
     /* Determine partition type */
 
     if (IsContainerPartition(partitionType))
     {
-        StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_EXTENDED_PARTITION));
+        RtlStringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_EXTENDED_PARTITION));
     }
     else if (partitionType == PARTITION_ENTRY_UNUSED)
     {
     }
     else if (partitionType == PARTITION_ENTRY_UNUSED)
     {
-        StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_FORMATUNUSED));
+        RtlStringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_FORMATUNUSED));
     }
     else
     {
     }
     else
     {
@@ -197,13 +197,13 @@ GetPartTypeStringFromPartitionType(
         {
             if (partitionType == PartitionTypes[i].Type)
             {
         {
             if (partitionType == PartitionTypes[i].Type)
             {
-                StringCchCopy(strPartType, cchPartType, PartitionTypes[i].Description);
+                RtlStringCchCopyA(strPartType, cchPartType, PartitionTypes[i].Description);
                 return;
             }
         }
 
         /* We are here because the partition type is unknown */
                 return;
             }
         }
 
         /* We are here because the partition type is unknown */
-        StringCchCopy(strPartType, cchPartType, MUIGetString(STRING_FORMATUNKNOWN));
+        RtlStringCchCopyA(strPartType, cchPartType, MUIGetString(STRING_FORMATUNKNOWN));
     }
 }
 
     }
 }
 
@@ -253,7 +253,6 @@ AlignDown(
     return Temp * Alignment;
 }
 
     return Temp * Alignment;
 }
 
-
 ULONGLONG
 AlignUp(
     IN ULONGLONG Value,
 ULONGLONG
 AlignUp(
     IN ULONGLONG Value,
@@ -282,7 +281,7 @@ RoundingDivide(
 static
 VOID
 GetDriverName(
 static
 VOID
 GetDriverName(
-    PDISKENTRY DiskEntry)
+    IN PDISKENTRY DiskEntry)
 {
     RTL_QUERY_REGISTRY_TABLE QueryTable[2];
     WCHAR KeyName[32];
 {
     RTL_QUERY_REGISTRY_TABLE QueryTable[2];
     WCHAR KeyName[32];
@@ -317,7 +316,7 @@ GetDriverName(
 static
 VOID
 AssignDriveLetters(
 static
 VOID
 AssignDriveLetters(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -396,7 +395,7 @@ AssignDriveLetters(
 }
 
 
 }
 
 
-NTSTATUS
+static NTSTATUS
 NTAPI
 DiskIdentifierQueryRoutine(
     PWSTR ValueName,
 NTAPI
 DiskIdentifierQueryRoutine(
     PWSTR ValueName,
@@ -426,7 +425,7 @@ DiskIdentifierQueryRoutine(
 }
 
 
 }
 
 
-NTSTATUS
+static NTSTATUS
 NTAPI
 DiskConfigurationDataQueryRoutine(
     PWSTR ValueName,
 NTAPI
 DiskConfigurationDataQueryRoutine(
     PWSTR ValueName,
@@ -470,7 +469,7 @@ DiskConfigurationDataQueryRoutine(
 }
 
 
 }
 
 
-NTSTATUS
+static NTSTATUS
 NTAPI
 SystemConfigurationDataQueryRoutine(
     PWSTR ValueName,
 NTAPI
 SystemConfigurationDataQueryRoutine(
     PWSTR ValueName,
@@ -522,7 +521,7 @@ SystemConfigurationDataQueryRoutine(
 
 static VOID
 EnumerateBiosDiskEntries(
 
 static VOID
 EnumerateBiosDiskEntries(
-    PPARTLIST PartList)
+    IN PPARTLIST PartList)
 {
     RTL_QUERY_REGISTRY_TABLE QueryTable[3];
     WCHAR Name[120];
 {
     RTL_QUERY_REGISTRY_TABLE QueryTable[3];
     WCHAR Name[120];
@@ -663,16 +662,16 @@ EnumerateBiosDiskEntries(
 static
 VOID
 AddPartitionToDisk(
 static
 VOID
 AddPartitionToDisk(
-    ULONG DiskNumber,
-    PDISKENTRY DiskEntry,
-    ULONG PartitionIndex,
-    BOOLEAN LogicalPartition)
+    IN ULONG DiskNumber,
+    IN PDISKENTRY DiskEntry,
+    IN ULONG PartitionIndex,
+    IN BOOLEAN LogicalPartition)
 {
     PPARTITION_INFORMATION PartitionInfo;
     PPARTENTRY PartEntry;
 
     PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
 {
     PPARTITION_INFORMATION PartitionInfo;
     PPARTENTRY PartEntry;
 
     PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
-    if (PartitionInfo->PartitionType == 0 ||
+    if (PartitionInfo->PartitionType == PARTITION_ENTRY_UNUSED ||
         ((LogicalPartition != FALSE) && IsContainerPartition(PartitionInfo->PartitionType)))
         return;
 
         ((LogicalPartition != FALSE) && IsContainerPartition(PartitionInfo->PartitionType)))
         return;
 
@@ -773,7 +772,7 @@ AddPartitionToDisk(
 static
 VOID
 ScanForUnpartitionedDiskSpace(
 static
 VOID
 ScanForUnpartitionedDiskSpace(
-    PDISKENTRY DiskEntry)
+    IN PDISKENTRY DiskEntry)
 {
     ULONGLONG LastStartSector;
     ULONGLONG LastSectorCount;
 {
     ULONGLONG LastStartSector;
     ULONGLONG LastSectorCount;
@@ -788,7 +787,7 @@ ScanForUnpartitionedDiskSpace(
     {
         DPRINT1("No primary partition!\n");
 
     {
         DPRINT1("No primary partition!\n");
 
-        /* Create a partition table that represents the empty disk */
+        /* Create a partition entry that represents the empty disk */
         NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                        HEAP_ZERO_MEMORY,
                                        sizeof(PARTENTRY));
         NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                        HEAP_ZERO_MEMORY,
                                        sizeof(PARTENTRY));
@@ -906,7 +905,7 @@ ScanForUnpartitionedDiskSpace(
         {
             DPRINT1("No logical partition!\n");
 
         {
             DPRINT1("No logical partition!\n");
 
-            /* Create a partition table entry that represents the empty extended partition */
+            /* Create a partition entry that represents the empty extended partition */
             NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                            HEAP_ZERO_MEMORY,
                                            sizeof(PARTENTRY));
             NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                            HEAP_ZERO_MEMORY,
                                            sizeof(PARTENTRY));
@@ -1080,12 +1079,12 @@ SetDiskSignature(
 static
 VOID
 UpdateDiskSignatures(
 static
 VOID
 UpdateDiskSignatures(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY Entry;
     PDISKENTRY DiskEntry;
 
 {
     PLIST_ENTRY Entry;
     PDISKENTRY DiskEntry;
 
-    /* Print partition lines*/
+    /* Print partition lines */
     Entry = List->DiskListHead.Flink;
     while (Entry != &List->DiskListHead)
     {
     Entry = List->DiskListHead.Flink;
     while (Entry != &List->DiskListHead)
     {
@@ -1106,9 +1105,9 @@ UpdateDiskSignatures(
 static
 VOID
 AddDiskToList(
 static
 VOID
 AddDiskToList(
-    HANDLE FileHandle,
-    ULONG DiskNumber,
-    PPARTLIST List)
+    IN HANDLE FileHandle,
+    IN ULONG DiskNumber,
+    IN PPARTLIST List)
 {
     DISK_GEOMETRY DiskGeometry;
     SCSI_ADDRESS ScsiAddress;
 {
     DISK_GEOMETRY DiskGeometry;
     SCSI_ADDRESS ScsiAddress;
@@ -1138,9 +1137,7 @@ AddDiskToList(
                                    &DiskGeometry,
                                    sizeof(DISK_GEOMETRY));
     if (!NT_SUCCESS(Status))
                                    &DiskGeometry,
                                    sizeof(DISK_GEOMETRY));
     if (!NT_SUCCESS(Status))
-    {
         return;
         return;
-    }
 
     if (DiskGeometry.MediaType != FixedMedia &&
         DiskGeometry.MediaType != RemovableMedia)
 
     if (DiskGeometry.MediaType != FixedMedia &&
         DiskGeometry.MediaType != RemovableMedia)
@@ -1159,17 +1156,13 @@ AddDiskToList(
                                    &ScsiAddress,
                                    sizeof(SCSI_ADDRESS));
     if (!NT_SUCCESS(Status))
                                    &ScsiAddress,
                                    sizeof(SCSI_ADDRESS));
     if (!NT_SUCCESS(Status))
-    {
         return;
         return;
-    }
 
     Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap,
                                              0,
                                              DiskGeometry.BytesPerSector);
     if (Mbr == NULL)
 
     Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap,
                                              0,
                                              DiskGeometry.BytesPerSector);
     if (Mbr == NULL)
-    {
         return;
         return;
-    }
 
     FileOffset.QuadPart = 0;
     Status = NtReadFile(FileHandle,
 
     FileOffset.QuadPart = 0;
     Status = NtReadFile(FileHandle,
@@ -1219,7 +1212,7 @@ AddDiskToList(
     else
         DiskEntry->NoMbr = FALSE;
 
     else
         DiskEntry->NoMbr = FALSE;
 
-    /* Free Mbr sector buffer */
+    /* Free the MBR sector buffer */
     RtlFreeHeap(ProcessHeap, 0, Mbr);
 
     ListEntry = List->BiosDiskListHead.Flink;
     RtlFreeHeap(ProcessHeap, 0, Mbr);
 
     ListEntry = List->BiosDiskListHead.Flink;
@@ -1228,7 +1221,7 @@ AddDiskToList(
         BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry);
         /* FIXME:
          *   Compare the size from bios and the reported size from driver.
         BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry);
         /* FIXME:
          *   Compare the size from bios and the reported size from driver.
-         *   If we have more than one disk with a zero or with the same signatur
+         *   If we have more than one disk with a zero or with the same signature
          *   we must create new signatures and reboot. After the reboot,
          *   it is possible to identify the disks.
          */
          *   we must create new signatures and reboot. After the reboot,
          *   it is possible to identify the disks.
          */
@@ -1348,7 +1341,7 @@ AddDiskToList(
 
     if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
         DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.QuadPart != 0 &&
 
     if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
         DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.QuadPart != 0 &&
-        DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionType != 0)
+        DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionType != PARTITION_ENTRY_UNUSED)
     {
         if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
         {
     {
         if ((DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart / DiskEntry->BytesPerSector) % DiskEntry->SectorsPerTrack == 0)
         {
@@ -1499,7 +1492,7 @@ CreatePartitionList(
 
         if (IsListEmpty(&List->CurrentDisk->PrimaryPartListHead))
         {
 
         if (IsListEmpty(&List->CurrentDisk->PrimaryPartListHead))
         {
-            List->CurrentPartition = 0;
+            List->CurrentPartition = NULL;
         }
         else
         {
         }
         else
         {
@@ -1515,7 +1508,7 @@ CreatePartitionList(
 
 VOID
 DestroyPartitionList(
 
 VOID
 DestroyPartitionList(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PDISKENTRY DiskEntry;
     PBIOSDISKENTRY BiosDiskEntry;
 {
     PDISKENTRY DiskEntry;
     PBIOSDISKENTRY BiosDiskEntry;
@@ -1575,10 +1568,10 @@ DestroyPartitionList(
 static
 VOID
 PrintEmptyLine(
 static
 VOID
 PrintEmptyLine(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     COORD coPos;
 {
     COORD coPos;
-    DWORD Written;
+    ULONG Written;
     USHORT Width;
     USHORT Height;
 
     USHORT Width;
     USHORT Height;
 
@@ -1610,13 +1603,13 @@ PrintEmptyLine(
 static
 VOID
 PrintPartitionData(
 static
 VOID
 PrintPartitionData(
-    PPARTLIST List,
-    PDISKENTRY DiskEntry,
-    PPARTENTRY PartEntry)
+    IN PPARTLIST List,
+    IN PDISKENTRY DiskEntry,
+    IN PPARTENTRY PartEntry)
 {
     CHAR LineBuffer[128];
     COORD coPos;
 {
     CHAR LineBuffer[128];
     COORD coPos;
-    DWORD Written;
+    ULONG Written;
     USHORT Width;
     USHORT Height;
     LARGE_INTEGER PartSize;
     USHORT Width;
     USHORT Height;
     LARGE_INTEGER PartSize;
@@ -1766,14 +1759,14 @@ PrintPartitionData(
 static
 VOID
 PrintDiskData(
 static
 VOID
 PrintDiskData(
-    PPARTLIST List,
-    PDISKENTRY DiskEntry)
+    IN PPARTLIST List,
+    IN PDISKENTRY DiskEntry)
 {
     PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
     PLIST_ENTRY PrimaryEntry, LogicalEntry;
     CHAR LineBuffer[128];
     COORD coPos;
 {
     PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
     PLIST_ENTRY PrimaryEntry, LogicalEntry;
     CHAR LineBuffer[128];
     COORD coPos;
-    DWORD Written;
+    ULONG Written;
     USHORT Width;
     USHORT Height;
     ULARGE_INTEGER DiskSize;
     USHORT Width;
     USHORT Height;
     ULARGE_INTEGER DiskSize;
@@ -1888,19 +1881,19 @@ PrintDiskData(
 
 VOID
 DrawPartitionList(
 
 VOID
 DrawPartitionList(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY Entry, Entry2;
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry = NULL;
     COORD coPos;
 {
     PLIST_ENTRY Entry, Entry2;
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry = NULL;
     COORD coPos;
-    DWORD Written;
+    ULONG Written;
     SHORT i;
     SHORT CurrentDiskLine;
     SHORT CurrentPartLine;
     SHORT LastLine;
     SHORT i;
     SHORT CurrentDiskLine;
     SHORT CurrentPartLine;
     SHORT LastLine;
-    BOOL CurrentPartLineFound = FALSE;
-    BOOL CurrentDiskLineFound = FALSE;
+    BOOLEAN CurrentPartLineFound = FALSE;
+    BOOLEAN CurrentDiskLineFound = FALSE;
 
     /* Calculate the line of the current disk and partition */
     CurrentDiskLine = 0;
 
     /* Calculate the line of the current disk and partition */
     CurrentDiskLine = 0;
@@ -2130,11 +2123,11 @@ DrawPartitionList(
 }
 
 
 }
 
 
-DWORD
+ULONG
 SelectPartition(
 SelectPartition(
-    PPARTLIST List,
-    ULONG DiskNumber,
-    ULONG PartitionNumber)
+    IN PPARTLIST List,
+    IN ULONG DiskNumber,
+    IN ULONG PartitionNumber)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -2181,7 +2174,7 @@ SelectPartition(
 
 BOOL
 ScrollDownPartitionList(
 
 BOOL
 ScrollDownPartitionList(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY DiskListEntry;
     PLIST_ENTRY PartListEntry;
 {
     PLIST_ENTRY DiskListEntry;
     PLIST_ENTRY PartListEntry;
@@ -2277,7 +2270,7 @@ ScrollDownPartitionList(
 
 BOOL
 ScrollUpPartitionList(
 
 BOOL
 ScrollUpPartitionList(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY DiskListEntry;
     PLIST_ENTRY PartListEntry;
 {
     PLIST_ENTRY DiskListEntry;
     PLIST_ENTRY PartListEntry;
@@ -2374,7 +2367,7 @@ ScrollUpPartitionList(
 static
 BOOLEAN
 IsEmptyLayoutEntry(
 static
 BOOLEAN
 IsEmptyLayoutEntry(
-    PPARTITION_INFORMATION PartitionInfo)
+    IN PPARTITION_INFORMATION PartitionInfo)
 {
     if (PartitionInfo->StartingOffset.QuadPart == 0 &&
         PartitionInfo->PartitionLength.QuadPart == 0)
 {
     if (PartitionInfo->StartingOffset.QuadPart == 0 &&
         PartitionInfo->PartitionLength.QuadPart == 0)
@@ -2427,7 +2420,7 @@ GetPrimaryPartitionCount(
 static
 ULONG
 GetLogicalPartitionCount(
 static
 ULONG
 GetLogicalPartitionCount(
-    PDISKENTRY DiskEntry)
+    IN PDISKENTRY DiskEntry)
 {
     PLIST_ENTRY ListEntry;
     PPARTENTRY PartEntry;
 {
     PLIST_ENTRY ListEntry;
     PPARTENTRY PartEntry;
@@ -2448,9 +2441,9 @@ GetLogicalPartitionCount(
 
 
 static
 
 
 static
-BOOL
+BOOLEAN
 ReAllocateLayoutBuffer(
 ReAllocateLayoutBuffer(
-    PDISKENTRY DiskEntry)
+    IN PDISKENTRY DiskEntry)
 {
     PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer;
     ULONG NewPartitionCount;
 {
     PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer;
     ULONG NewPartitionCount;
@@ -2486,8 +2479,8 @@ ReAllocateLayoutBuffer(
     /* If the layout buffer grows, make sure the new (empty) entries are written to the disk */
     if (NewPartitionCount > CurrentPartitionCount)
     {
     /* If the layout buffer grows, make sure the new (empty) entries are written to the disk */
     if (NewPartitionCount > CurrentPartitionCount)
     {
-         for (i = CurrentPartitionCount; i < NewPartitionCount; i++)
-             NewLayoutBuffer->PartitionEntry[i].RewritePartition = TRUE;
+        for (i = CurrentPartitionCount; i < NewPartitionCount; i++)
+            NewLayoutBuffer->PartitionEntry[i].RewritePartition = TRUE;
     }
 
     DiskEntry->LayoutBuffer = NewLayoutBuffer;
     }
 
     DiskEntry->LayoutBuffer = NewLayoutBuffer;
@@ -2556,7 +2549,7 @@ UpdateDiskLayout(
         ListEntry = ListEntry->Flink;
     }
 
         ListEntry = ListEntry->Flink;
     }
 
-    /* Update the logical partition tables */
+    /* Update the logical partition table */
     Index = 4;
     ListEntry = DiskEntry->LogicalPartListHead.Flink;
     while (ListEntry != &DiskEntry->LogicalPartListHead)
     Index = 4;
     ListEntry = DiskEntry->LogicalPartListHead.Flink;
     while (ListEntry != &DiskEntry->LogicalPartListHead)
@@ -2581,7 +2574,7 @@ UpdateDiskLayout(
             PartEntry->PartitionNumber = PartitionNumber;
             PartEntry->PartitionIndex = Index;
 
             PartEntry->PartitionNumber = PartitionNumber;
             PartEntry->PartitionIndex = Index;
 
-            /* Fill the link entry of the previous partition table */
+            /* Fill the link entry of the previous partition entry */
             if (LinkInfo != NULL)
             {
                 LinkInfo->StartingOffset.QuadPart = (PartEntry->StartSector.QuadPart - DiskEntry->SectorAlignment) * DiskEntry->BytesPerSector;
             if (LinkInfo != NULL)
             {
                 LinkInfo->StartingOffset.QuadPart = (PartEntry->StartSector.QuadPart - DiskEntry->SectorAlignment) * DiskEntry->BytesPerSector;
@@ -2595,7 +2588,7 @@ UpdateDiskLayout(
                 LinkInfo->RewritePartition = TRUE;
             }
 
                 LinkInfo->RewritePartition = TRUE;
             }
 
-            /* Save a pointer to the link entry of the current partition table */
+            /* Save a pointer to the link entry of the current partition entry */
             LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[Index + 1];
 
             PartitionNumber++;
             LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[Index + 1];
 
             PartitionNumber++;
@@ -2605,7 +2598,7 @@ UpdateDiskLayout(
         ListEntry = ListEntry->Flink;
     }
 
         ListEntry = ListEntry->Flink;
     }
 
-    /* Wipe unused primary partition table entries */
+    /* Wipe unused primary partition entries */
     for (Index = GetPrimaryPartitionCount(DiskEntry); Index < 4; Index++)
     {
         DPRINT1("Primary partition entry %lu\n", Index);
     for (Index = GetPrimaryPartitionCount(DiskEntry); Index < 4; Index++)
     {
         DPRINT1("Primary partition entry %lu\n", Index);
@@ -2627,7 +2620,7 @@ UpdateDiskLayout(
         }
     }
 
         }
     }
 
-    /* Wipe unused logical partition table entries */
+    /* Wipe unused logical partition entries */
     for (Index = 4; Index < DiskEntry->LayoutBuffer->PartitionCount; Index++)
     {
         if (Index % 4 >= 2)
     for (Index = 4; Index < DiskEntry->LayoutBuffer->PartitionCount; Index++)
     {
         if (Index % 4 >= 2)
@@ -2661,8 +2654,8 @@ UpdateDiskLayout(
 static
 PPARTENTRY
 GetPrevUnpartitionedEntry(
 static
 PPARTENTRY
 GetPrevUnpartitionedEntry(
-    PDISKENTRY DiskEntry,
-    PPARTENTRY PartEntry)
+    IN PDISKENTRY DiskEntry,
+    IN PPARTENTRY PartEntry)
 {
     PPARTENTRY PrevPartEntry;
     PLIST_ENTRY ListHead;
 {
     PPARTENTRY PrevPartEntry;
     PLIST_ENTRY ListHead;
@@ -2688,8 +2681,8 @@ GetPrevUnpartitionedEntry(
 static
 PPARTENTRY
 GetNextUnpartitionedEntry(
 static
 PPARTENTRY
 GetNextUnpartitionedEntry(
-    PDISKENTRY DiskEntry,
-    PPARTENTRY PartEntry)
+    IN PDISKENTRY DiskEntry,
+    IN PPARTENTRY PartEntry)
 {
     PPARTENTRY NextPartEntry;
     PLIST_ENTRY ListHead;
 {
     PPARTENTRY NextPartEntry;
     PLIST_ENTRY ListHead;
@@ -2714,9 +2707,9 @@ GetNextUnpartitionedEntry(
 
 VOID
 CreatePrimaryPartition(
 
 VOID
 CreatePrimaryPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount,
-    BOOLEAN AutoCreate)
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount,
+    IN BOOLEAN AutoCreate)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -2800,13 +2793,13 @@ CreatePrimaryPartition(
 static
 VOID
 AddLogicalDiskSpace(
 static
 VOID
 AddLogicalDiskSpace(
-    PDISKENTRY DiskEntry)
+    IN PDISKENTRY DiskEntry)
 {
     PPARTENTRY NewPartEntry;
 
     DPRINT1("AddLogicalDiskSpace()\n");
 
 {
     PPARTENTRY NewPartEntry;
 
     DPRINT1("AddLogicalDiskSpace()\n");
 
-    /* Create a partition table entry that represents the empty space in the container partition */
+    /* Create a partition entry that represents the empty space in the container partition */
     NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                    HEAP_ZERO_MEMORY,
                                    sizeof(PARTENTRY));
     NewPartEntry = RtlAllocateHeap(ProcessHeap,
                                    HEAP_ZERO_MEMORY,
                                    sizeof(PARTENTRY));
@@ -2833,8 +2826,8 @@ AddLogicalDiskSpace(
 
 VOID
 CreateExtendedPartition(
 
 VOID
 CreateExtendedPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount)
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -2845,7 +2838,7 @@ CreateExtendedPartition(
     if (List == NULL ||
         List->CurrentDisk == NULL ||
         List->CurrentPartition == NULL ||
     if (List == NULL ||
         List->CurrentDisk == NULL ||
         List->CurrentPartition == NULL ||
-        (List->CurrentPartition->IsPartitioned != FALSE))
+        List->CurrentPartition->IsPartitioned != FALSE)
     {
         return;
     }
     {
         return;
     }
@@ -2942,9 +2935,9 @@ CreateExtendedPartition(
 
 VOID
 CreateLogicalPartition(
 
 VOID
 CreateLogicalPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount,
-    BOOLEAN AutoCreate)
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount,
+    IN BOOLEAN AutoCreate)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -3029,7 +3022,7 @@ CreateLogicalPartition(
 
 VOID
 DeleteCurrentPartition(
 
 VOID
 DeleteCurrentPartition(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
 {
     PDISKENTRY DiskEntry;
     PPARTENTRY PartEntry;
@@ -3046,7 +3039,7 @@ DeleteCurrentPartition(
         return;
     }
 
         return;
     }
 
-    /* Clear the system disk and partition pointers if the system partition will be deleted */
+    /* Clear the system disk and partition pointers if the system partition is being deleted */
     if (List->SystemPartition == List->CurrentPartition)
     {
         List->SystemDisk = NULL;
     if (List->SystemPartition == List->CurrentPartition)
     {
         List->SystemDisk = NULL;
@@ -3462,7 +3455,7 @@ WritePartitions(
 
 BOOLEAN
 WritePartitionsToDisk(
 
 BOOLEAN
 WritePartitionsToDisk(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY Entry;
     PDISKENTRY DiskEntry;
 {
     PLIST_ENTRY Entry;
     PDISKENTRY DiskEntry;
@@ -3488,9 +3481,9 @@ WritePartitionsToDisk(
 }
 
 
 }
 
 
-BOOL
+BOOLEAN
 SetMountedDeviceValues(
 SetMountedDeviceValues(
-    PPARTLIST List)
+    IN PPARTLIST List)
 {
     PLIST_ENTRY Entry1, Entry2;
     PDISKENTRY DiskEntry;
 {
     PLIST_ENTRY Entry1, Entry2;
     PDISKENTRY DiskEntry;
@@ -3498,9 +3491,7 @@ SetMountedDeviceValues(
     LARGE_INTEGER StartingOffset;
 
     if (List == NULL)
     LARGE_INTEGER StartingOffset;
 
     if (List == NULL)
-    {
         return FALSE;
         return FALSE;
-    }
 
     Entry1 = List->DiskListHead.Flink;
     while (Entry1 != &List->DiskListHead)
 
     Entry1 = List->DiskListHead.Flink;
     while (Entry1 != &List->DiskListHead)
@@ -3515,6 +3506,7 @@ SetMountedDeviceValues(
             PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
             if (PartEntry->IsPartitioned)
             {
             PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
             if (PartEntry->IsPartitioned)
             {
+                /* Assign a "\DosDevices\#:" mount point to this partition */
                 if (PartEntry->DriveLetter)
                 {
                     StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
                 if (PartEntry->DriveLetter)
                 {
                     StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
@@ -3603,10 +3595,10 @@ LogicalPartitionCreationChecks(
 }
 
 
 }
 
 
-BOOL
+BOOLEAN
 GetNextUnformattedPartition(
     IN PPARTLIST List,
 GetNextUnformattedPartition(
     IN PPARTLIST List,
-    OUT PDISKENTRY *pDiskEntry,
+    OUT PDISKENTRY *pDiskEntry OPTIONAL,
     OUT PPARTENTRY *pPartEntry)
 {
     PLIST_ENTRY Entry1, Entry2;
     OUT PPARTENTRY *pPartEntry)
 {
     PLIST_ENTRY Entry1, Entry2;
@@ -3657,11 +3649,10 @@ GetNextUnformattedPartition(
     return FALSE;
 }
 
     return FALSE;
 }
 
-
-BOOL
+BOOLEAN
 GetNextUncheckedPartition(
     IN PPARTLIST List,
 GetNextUncheckedPartition(
     IN PPARTLIST List,
-    OUT PDISKENTRY *pDiskEntry,
+    OUT PDISKENTRY *pDiskEntry OPTIONAL,
     OUT PPARTENTRY *pPartEntry)
 {
     PLIST_ENTRY Entry1, Entry2;
     OUT PPARTENTRY *pPartEntry)
 {
     PLIST_ENTRY Entry1, Entry2;
index c42335a..9787f94 100644 (file)
@@ -209,6 +209,12 @@ typedef struct
     ULONG Signature;
 } BIOS_DISK, *PBIOS_DISK;
 
     ULONG Signature;
 } BIOS_DISK, *PBIOS_DISK;
 
+VOID
+GetPartTypeStringFromPartitionType(
+    IN UCHAR partitionType,
+    OUT PCHAR strPartType,
+    IN ULONG cchPartType);
+
 PPARTLIST
 CreatePartitionList(
     SHORT Left,
 PPARTLIST
 CreatePartitionList(
     SHORT Left,
@@ -218,50 +224,46 @@ CreatePartitionList(
 
 VOID
 DestroyPartitionList(
 
 VOID
 DestroyPartitionList(
-    PPARTLIST List);
+    IN PPARTLIST List);
 
 VOID
 DrawPartitionList(
 
 VOID
 DrawPartitionList(
-    PPARTLIST List);
+    IN PPARTLIST List);
 
 
-DWORD
+ULONG
 SelectPartition(
 SelectPartition(
-    PPARTLIST List,
-    ULONG DiskNumber,
-    ULONG PartitionNumber);
-
-BOOL
-SetMountedDeviceValues(
-    PPARTLIST List);
+    IN PPARTLIST List,
+    IN ULONG DiskNumber,
+    IN ULONG PartitionNumber);
 
 BOOL
 ScrollDownPartitionList(
 
 BOOL
 ScrollDownPartitionList(
-    PPARTLIST List);
+    IN PPARTLIST List);
 
 BOOL
 ScrollUpPartitionList(
 
 BOOL
 ScrollUpPartitionList(
-    PPARTLIST List);
+    IN PPARTLIST List);
 
 VOID
 CreatePrimaryPartition(
 
 VOID
 CreatePrimaryPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount,
-    BOOLEAN AutoCreate);
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount,
+    IN BOOLEAN AutoCreate);
 
 VOID
 CreateExtendedPartition(
 
 VOID
 CreateExtendedPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount);
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount);
 
 VOID
 CreateLogicalPartition(
 
 VOID
 CreateLogicalPartition(
-    PPARTLIST List,
-    ULONGLONG SectorCount,
-    BOOLEAN AutoCreate);
+    IN PPARTLIST List,
+    IN ULONGLONG SectorCount,
+    IN BOOLEAN AutoCreate);
 
 VOID
 DeleteCurrentPartition(
 
 VOID
 DeleteCurrentPartition(
-    PPARTLIST List);
+    IN PPARTLIST List);
 
 VOID
 CheckActiveSystemPartition(
 
 VOID
 CheckActiveSystemPartition(
@@ -270,7 +272,11 @@ CheckActiveSystemPartition(
 
 BOOLEAN
 WritePartitionsToDisk(
 
 BOOLEAN
 WritePartitionsToDisk(
-    PPARTLIST List);
+    IN PPARTLIST List);
+
+BOOLEAN
+SetMountedDeviceValues(
+    IN PPARTLIST List);
 
 ULONG
 PrimaryPartitionCreationChecks(
 
 ULONG
 PrimaryPartitionCreationChecks(
@@ -284,22 +290,16 @@ ULONG
 LogicalPartitionCreationChecks(
     IN PPARTLIST List);
 
 LogicalPartitionCreationChecks(
     IN PPARTLIST List);
 
-BOOL
+BOOLEAN
 GetNextUnformattedPartition(
     IN PPARTLIST List,
 GetNextUnformattedPartition(
     IN PPARTLIST List,
-    OUT PDISKENTRY *pDiskEntry,
+    OUT PDISKENTRY *pDiskEntry OPTIONAL,
     OUT PPARTENTRY *pPartEntry);
 
     OUT PPARTENTRY *pPartEntry);
 
-BOOL
+BOOLEAN
 GetNextUncheckedPartition(
     IN PPARTLIST List,
 GetNextUncheckedPartition(
     IN PPARTLIST List,
-    OUT PDISKENTRY *pDiskEntry,
+    OUT PDISKENTRY *pDiskEntry OPTIONAL,
     OUT PPARTENTRY *pPartEntry);
 
     OUT PPARTENTRY *pPartEntry);
 
-VOID
-GetPartTypeStringFromPartitionType(
-    UCHAR partitionType,
-    PCHAR strPartType,
-    DWORD cchPartType);
-
 /* EOF */
 /* EOF */