[USETUP] Code improvements for PartList.

- 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
This commit is contained in:
Hermès Bélusca-Maïto 2017-05-13 16:32:53 +00:00
parent 56ea51bbe4
commit eaf7d6ebbe
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 118 additions and 127 deletions

View file

@ -174,19 +174,19 @@ static PARTITION_TYPE PartitionTypes[] =
VOID VOID
GetPartTypeStringFromPartitionType( GetPartTypeStringFromPartitionType(
UCHAR partitionType, IN UCHAR partitionType,
PCHAR strPartType, OUT PCHAR strPartType,
DWORD cchPartType) IN ULONG cchPartType)
{ {
/* Determine partition type */ /* Determine partition type */
if (IsContainerPartition(partitionType)) 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; return;
} }
} }
/* We are here because the partition type is unknown */ /* 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 ULONGLONG
AlignUp( AlignUp(
IN ULONGLONG Value, IN ULONGLONG Value,
@ -282,7 +281,7 @@ RoundingDivide(
static static
VOID VOID
GetDriverName( GetDriverName(
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[2]; RTL_QUERY_REGISTRY_TABLE QueryTable[2];
WCHAR KeyName[32]; WCHAR KeyName[32];
@ -317,7 +316,7 @@ GetDriverName(
static static
VOID VOID
AssignDriveLetters( AssignDriveLetters(
PPARTLIST List) IN PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -396,7 +395,7 @@ AssignDriveLetters(
} }
NTSTATUS static NTSTATUS
NTAPI NTAPI
DiskIdentifierQueryRoutine( DiskIdentifierQueryRoutine(
PWSTR ValueName, PWSTR ValueName,
@ -426,7 +425,7 @@ DiskIdentifierQueryRoutine(
} }
NTSTATUS static NTSTATUS
NTAPI NTAPI
DiskConfigurationDataQueryRoutine( DiskConfigurationDataQueryRoutine(
PWSTR ValueName, PWSTR ValueName,
@ -470,7 +469,7 @@ DiskConfigurationDataQueryRoutine(
} }
NTSTATUS static NTSTATUS
NTAPI NTAPI
SystemConfigurationDataQueryRoutine( SystemConfigurationDataQueryRoutine(
PWSTR ValueName, PWSTR ValueName,
@ -522,7 +521,7 @@ SystemConfigurationDataQueryRoutine(
static VOID static VOID
EnumerateBiosDiskEntries( EnumerateBiosDiskEntries(
PPARTLIST PartList) IN PPARTLIST PartList)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[3]; RTL_QUERY_REGISTRY_TABLE QueryTable[3];
WCHAR Name[120]; WCHAR Name[120];
@ -663,16 +662,16 @@ EnumerateBiosDiskEntries(
static static
VOID VOID
AddPartitionToDisk( AddPartitionToDisk(
ULONG DiskNumber, IN ULONG DiskNumber,
PDISKENTRY DiskEntry, IN PDISKENTRY DiskEntry,
ULONG PartitionIndex, IN ULONG PartitionIndex,
BOOLEAN LogicalPartition) IN BOOLEAN LogicalPartition)
{ {
PPARTITION_INFORMATION PartitionInfo; PPARTITION_INFORMATION PartitionInfo;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex]; PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
if (PartitionInfo->PartitionType == 0 || if (PartitionInfo->PartitionType == PARTITION_ENTRY_UNUSED ||
((LogicalPartition != FALSE) && IsContainerPartition(PartitionInfo->PartitionType))) ((LogicalPartition != FALSE) && IsContainerPartition(PartitionInfo->PartitionType)))
return; return;
@ -773,7 +772,7 @@ AddPartitionToDisk(
static static
VOID VOID
ScanForUnpartitionedDiskSpace( ScanForUnpartitionedDiskSpace(
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
ULONGLONG LastStartSector; ULONGLONG LastStartSector;
ULONGLONG LastSectorCount; 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, NewPartEntry = RtlAllocateHeap(ProcessHeap,
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
sizeof(PARTENTRY)); 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, NewPartEntry = RtlAllocateHeap(ProcessHeap,
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
sizeof(PARTENTRY)); sizeof(PARTENTRY));
@ -1080,12 +1079,12 @@ SetDiskSignature(
static static
VOID VOID
UpdateDiskSignatures( UpdateDiskSignatures(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
/* Print partition lines*/ /* Print partition lines */
Entry = List->DiskListHead.Flink; Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead) while (Entry != &List->DiskListHead)
{ {
@ -1106,9 +1105,9 @@ UpdateDiskSignatures(
static static
VOID VOID
AddDiskToList( AddDiskToList(
HANDLE FileHandle, IN HANDLE FileHandle,
ULONG DiskNumber, IN ULONG DiskNumber,
PPARTLIST List) IN PPARTLIST List)
{ {
DISK_GEOMETRY DiskGeometry; DISK_GEOMETRY DiskGeometry;
SCSI_ADDRESS ScsiAddress; SCSI_ADDRESS ScsiAddress;
@ -1138,9 +1137,7 @@ AddDiskToList(
&DiskGeometry, &DiskGeometry,
sizeof(DISK_GEOMETRY)); sizeof(DISK_GEOMETRY));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{
return; return;
}
if (DiskGeometry.MediaType != FixedMedia && if (DiskGeometry.MediaType != FixedMedia &&
DiskGeometry.MediaType != RemovableMedia) DiskGeometry.MediaType != RemovableMedia)
@ -1159,17 +1156,13 @@ AddDiskToList(
&ScsiAddress, &ScsiAddress,
sizeof(SCSI_ADDRESS)); sizeof(SCSI_ADDRESS));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{
return; return;
}
Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap, Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap,
0, 0,
DiskGeometry.BytesPerSector); DiskGeometry.BytesPerSector);
if (Mbr == NULL) if (Mbr == NULL)
{
return; return;
}
FileOffset.QuadPart = 0; FileOffset.QuadPart = 0;
Status = NtReadFile(FileHandle, Status = NtReadFile(FileHandle,
@ -1219,7 +1212,7 @@ AddDiskToList(
else else
DiskEntry->NoMbr = FALSE; DiskEntry->NoMbr = FALSE;
/* Free Mbr sector buffer */ /* Free the MBR sector buffer */
RtlFreeHeap(ProcessHeap, 0, Mbr); RtlFreeHeap(ProcessHeap, 0, Mbr);
ListEntry = List->BiosDiskListHead.Flink; ListEntry = List->BiosDiskListHead.Flink;
@ -1228,7 +1221,7 @@ AddDiskToList(
BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry); BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry);
/* FIXME: /* FIXME:
* Compare the size from bios and the reported size from driver. * 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, * we must create new signatures and reboot. After the reboot,
* it is possible to identify the disks. * it is possible to identify the disks.
*/ */
@ -1348,7 +1341,7 @@ AddDiskToList(
if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 && if (DiskEntry->LayoutBuffer->PartitionEntry[0].StartingOffset.QuadPart != 0 &&
DiskEntry->LayoutBuffer->PartitionEntry[0].PartitionLength.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 VOID
DestroyPartitionList( DestroyPartitionList(
PPARTLIST List) IN PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PBIOSDISKENTRY BiosDiskEntry; PBIOSDISKENTRY BiosDiskEntry;
@ -1575,10 +1568,10 @@ DestroyPartitionList(
static static
VOID VOID
PrintEmptyLine( PrintEmptyLine(
PPARTLIST List) IN PPARTLIST List)
{ {
COORD coPos; COORD coPos;
DWORD Written; ULONG Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
@ -1610,13 +1603,13 @@ PrintEmptyLine(
static static
VOID VOID
PrintPartitionData( PrintPartitionData(
PPARTLIST List, IN PPARTLIST List,
PDISKENTRY DiskEntry, IN PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) IN PPARTENTRY PartEntry)
{ {
CHAR LineBuffer[128]; CHAR LineBuffer[128];
COORD coPos; COORD coPos;
DWORD Written; ULONG Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
LARGE_INTEGER PartSize; LARGE_INTEGER PartSize;
@ -1766,14 +1759,14 @@ PrintPartitionData(
static static
VOID VOID
PrintDiskData( PrintDiskData(
PPARTLIST List, IN PPARTLIST List,
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
PPARTENTRY PrimaryPartEntry, LogicalPartEntry; PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
PLIST_ENTRY PrimaryEntry, LogicalEntry; PLIST_ENTRY PrimaryEntry, LogicalEntry;
CHAR LineBuffer[128]; CHAR LineBuffer[128];
COORD coPos; COORD coPos;
DWORD Written; ULONG Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
ULARGE_INTEGER DiskSize; ULARGE_INTEGER DiskSize;
@ -1888,19 +1881,19 @@ PrintDiskData(
VOID VOID
DrawPartitionList( DrawPartitionList(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY Entry, Entry2; PLIST_ENTRY Entry, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry = NULL; PPARTENTRY PartEntry = NULL;
COORD coPos; COORD coPos;
DWORD Written; ULONG Written;
SHORT i; SHORT i;
SHORT CurrentDiskLine; SHORT CurrentDiskLine;
SHORT CurrentPartLine; SHORT CurrentPartLine;
SHORT LastLine; SHORT LastLine;
BOOL CurrentPartLineFound = FALSE; BOOLEAN CurrentPartLineFound = FALSE;
BOOL CurrentDiskLineFound = FALSE; BOOLEAN CurrentDiskLineFound = FALSE;
/* Calculate the line of the current disk and partition */ /* Calculate the line of the current disk and partition */
CurrentDiskLine = 0; CurrentDiskLine = 0;
@ -2130,11 +2123,11 @@ DrawPartitionList(
} }
DWORD ULONG
SelectPartition( SelectPartition(
PPARTLIST List, IN PPARTLIST List,
ULONG DiskNumber, IN ULONG DiskNumber,
ULONG PartitionNumber) IN ULONG PartitionNumber)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2181,7 +2174,7 @@ SelectPartition(
BOOL BOOL
ScrollDownPartitionList( ScrollDownPartitionList(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY DiskListEntry; PLIST_ENTRY DiskListEntry;
PLIST_ENTRY PartListEntry; PLIST_ENTRY PartListEntry;
@ -2277,7 +2270,7 @@ ScrollDownPartitionList(
BOOL BOOL
ScrollUpPartitionList( ScrollUpPartitionList(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY DiskListEntry; PLIST_ENTRY DiskListEntry;
PLIST_ENTRY PartListEntry; PLIST_ENTRY PartListEntry;
@ -2374,7 +2367,7 @@ ScrollUpPartitionList(
static static
BOOLEAN BOOLEAN
IsEmptyLayoutEntry( IsEmptyLayoutEntry(
PPARTITION_INFORMATION PartitionInfo) IN PPARTITION_INFORMATION PartitionInfo)
{ {
if (PartitionInfo->StartingOffset.QuadPart == 0 && if (PartitionInfo->StartingOffset.QuadPart == 0 &&
PartitionInfo->PartitionLength.QuadPart == 0) PartitionInfo->PartitionLength.QuadPart == 0)
@ -2427,7 +2420,7 @@ GetPrimaryPartitionCount(
static static
ULONG ULONG
GetLogicalPartitionCount( GetLogicalPartitionCount(
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2448,9 +2441,9 @@ GetLogicalPartitionCount(
static static
BOOL BOOLEAN
ReAllocateLayoutBuffer( ReAllocateLayoutBuffer(
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer; PDRIVE_LAYOUT_INFORMATION NewLayoutBuffer;
ULONG NewPartitionCount; ULONG NewPartitionCount;
@ -2486,8 +2479,8 @@ ReAllocateLayoutBuffer(
/* If the layout buffer grows, make sure the new (empty) entries are written to the disk */ /* If the layout buffer grows, make sure the new (empty) entries are written to the disk */
if (NewPartitionCount > CurrentPartitionCount) if (NewPartitionCount > CurrentPartitionCount)
{ {
for (i = CurrentPartitionCount; i < NewPartitionCount; i++) for (i = CurrentPartitionCount; i < NewPartitionCount; i++)
NewLayoutBuffer->PartitionEntry[i].RewritePartition = TRUE; 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; Index = 4;
ListEntry = DiskEntry->LogicalPartListHead.Flink; ListEntry = DiskEntry->LogicalPartListHead.Flink;
while (ListEntry != &DiskEntry->LogicalPartListHead) while (ListEntry != &DiskEntry->LogicalPartListHead)
@ -2581,7 +2574,7 @@ UpdateDiskLayout(
PartEntry->PartitionNumber = PartitionNumber; PartEntry->PartitionNumber = PartitionNumber;
PartEntry->PartitionIndex = Index; PartEntry->PartitionIndex = Index;
/* Fill the link entry of the previous partition table */ /* Fill the link entry of the previous partition entry */
if (LinkInfo != NULL) if (LinkInfo != NULL)
{ {
LinkInfo->StartingOffset.QuadPart = (PartEntry->StartSector.QuadPart - DiskEntry->SectorAlignment) * DiskEntry->BytesPerSector; 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]; LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[Index + 1];
PartitionNumber++; 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++) for (Index = GetPrimaryPartitionCount(DiskEntry); Index < 4; Index++)
{ {
DPRINT1("Primary partition entry %lu\n", 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++) for (Index = 4; Index < DiskEntry->LayoutBuffer->PartitionCount; Index++)
{ {
if (Index % 4 >= 2) if (Index % 4 >= 2)
@ -2661,8 +2654,8 @@ UpdateDiskLayout(
static static
PPARTENTRY PPARTENTRY
GetPrevUnpartitionedEntry( GetPrevUnpartitionedEntry(
PDISKENTRY DiskEntry, IN PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) IN PPARTENTRY PartEntry)
{ {
PPARTENTRY PrevPartEntry; PPARTENTRY PrevPartEntry;
PLIST_ENTRY ListHead; PLIST_ENTRY ListHead;
@ -2688,8 +2681,8 @@ GetPrevUnpartitionedEntry(
static static
PPARTENTRY PPARTENTRY
GetNextUnpartitionedEntry( GetNextUnpartitionedEntry(
PDISKENTRY DiskEntry, IN PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) IN PPARTENTRY PartEntry)
{ {
PPARTENTRY NextPartEntry; PPARTENTRY NextPartEntry;
PLIST_ENTRY ListHead; PLIST_ENTRY ListHead;
@ -2714,9 +2707,9 @@ GetNextUnpartitionedEntry(
VOID VOID
CreatePrimaryPartition( CreatePrimaryPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount, IN ULONGLONG SectorCount,
BOOLEAN AutoCreate) IN BOOLEAN AutoCreate)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2800,13 +2793,13 @@ CreatePrimaryPartition(
static static
VOID VOID
AddLogicalDiskSpace( AddLogicalDiskSpace(
PDISKENTRY DiskEntry) IN PDISKENTRY DiskEntry)
{ {
PPARTENTRY NewPartEntry; PPARTENTRY NewPartEntry;
DPRINT1("AddLogicalDiskSpace()\n"); 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, NewPartEntry = RtlAllocateHeap(ProcessHeap,
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
sizeof(PARTENTRY)); sizeof(PARTENTRY));
@ -2833,8 +2826,8 @@ AddLogicalDiskSpace(
VOID VOID
CreateExtendedPartition( CreateExtendedPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount) IN ULONGLONG SectorCount)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2845,7 +2838,7 @@ CreateExtendedPartition(
if (List == NULL || if (List == NULL ||
List->CurrentDisk == NULL || List->CurrentDisk == NULL ||
List->CurrentPartition == NULL || List->CurrentPartition == NULL ||
(List->CurrentPartition->IsPartitioned != FALSE)) List->CurrentPartition->IsPartitioned != FALSE)
{ {
return; return;
} }
@ -2942,9 +2935,9 @@ CreateExtendedPartition(
VOID VOID
CreateLogicalPartition( CreateLogicalPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount, IN ULONGLONG SectorCount,
BOOLEAN AutoCreate) IN BOOLEAN AutoCreate)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -3029,7 +3022,7 @@ CreateLogicalPartition(
VOID VOID
DeleteCurrentPartition( DeleteCurrentPartition(
PPARTLIST List) IN PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; 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) if (List->SystemPartition == List->CurrentPartition)
{ {
List->SystemDisk = NULL; List->SystemDisk = NULL;
@ -3462,7 +3455,7 @@ WritePartitions(
BOOLEAN BOOLEAN
WritePartitionsToDisk( WritePartitionsToDisk(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
@ -3488,9 +3481,9 @@ WritePartitionsToDisk(
} }
BOOL BOOLEAN
SetMountedDeviceValues( SetMountedDeviceValues(
PPARTLIST List) IN PPARTLIST List)
{ {
PLIST_ENTRY Entry1, Entry2; PLIST_ENTRY Entry1, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
@ -3498,9 +3491,7 @@ SetMountedDeviceValues(
LARGE_INTEGER StartingOffset; LARGE_INTEGER StartingOffset;
if (List == NULL) if (List == NULL)
{
return FALSE; return FALSE;
}
Entry1 = List->DiskListHead.Flink; Entry1 = List->DiskListHead.Flink;
while (Entry1 != &List->DiskListHead) while (Entry1 != &List->DiskListHead)
@ -3515,6 +3506,7 @@ SetMountedDeviceValues(
PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
if (PartEntry->IsPartitioned) if (PartEntry->IsPartitioned)
{ {
/* Assign a "\DosDevices\#:" mount point to this partition */
if (PartEntry->DriveLetter) if (PartEntry->DriveLetter)
{ {
StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector;
@ -3603,10 +3595,10 @@ LogicalPartitionCreationChecks(
} }
BOOL BOOLEAN
GetNextUnformattedPartition( GetNextUnformattedPartition(
IN PPARTLIST List, IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry, OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry) OUT PPARTENTRY *pPartEntry)
{ {
PLIST_ENTRY Entry1, Entry2; PLIST_ENTRY Entry1, Entry2;
@ -3657,11 +3649,10 @@ GetNextUnformattedPartition(
return FALSE; return FALSE;
} }
BOOLEAN
BOOL
GetNextUncheckedPartition( GetNextUncheckedPartition(
IN PPARTLIST List, IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry, OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry) OUT PPARTENTRY *pPartEntry)
{ {
PLIST_ENTRY Entry1, Entry2; PLIST_ENTRY Entry1, Entry2;

View file

@ -209,6 +209,12 @@ typedef struct
ULONG Signature; ULONG Signature;
} BIOS_DISK, *PBIOS_DISK; } BIOS_DISK, *PBIOS_DISK;
VOID
GetPartTypeStringFromPartitionType(
IN UCHAR partitionType,
OUT PCHAR strPartType,
IN ULONG cchPartType);
PPARTLIST PPARTLIST
CreatePartitionList( CreatePartitionList(
SHORT Left, SHORT Left,
@ -218,50 +224,46 @@ CreatePartitionList(
VOID VOID
DestroyPartitionList( DestroyPartitionList(
PPARTLIST List); IN PPARTLIST List);
VOID VOID
DrawPartitionList( DrawPartitionList(
PPARTLIST List); IN PPARTLIST List);
DWORD ULONG
SelectPartition( SelectPartition(
PPARTLIST List, IN PPARTLIST List,
ULONG DiskNumber, IN ULONG DiskNumber,
ULONG PartitionNumber); IN ULONG PartitionNumber);
BOOL
SetMountedDeviceValues(
PPARTLIST List);
BOOL BOOL
ScrollDownPartitionList( ScrollDownPartitionList(
PPARTLIST List); IN PPARTLIST List);
BOOL BOOL
ScrollUpPartitionList( ScrollUpPartitionList(
PPARTLIST List); IN PPARTLIST List);
VOID VOID
CreatePrimaryPartition( CreatePrimaryPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount, IN ULONGLONG SectorCount,
BOOLEAN AutoCreate); IN BOOLEAN AutoCreate);
VOID VOID
CreateExtendedPartition( CreateExtendedPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount); IN ULONGLONG SectorCount);
VOID VOID
CreateLogicalPartition( CreateLogicalPartition(
PPARTLIST List, IN PPARTLIST List,
ULONGLONG SectorCount, IN ULONGLONG SectorCount,
BOOLEAN AutoCreate); IN BOOLEAN AutoCreate);
VOID VOID
DeleteCurrentPartition( DeleteCurrentPartition(
PPARTLIST List); IN PPARTLIST List);
VOID VOID
CheckActiveSystemPartition( CheckActiveSystemPartition(
@ -270,7 +272,11 @@ CheckActiveSystemPartition(
BOOLEAN BOOLEAN
WritePartitionsToDisk( WritePartitionsToDisk(
PPARTLIST List); IN PPARTLIST List);
BOOLEAN
SetMountedDeviceValues(
IN PPARTLIST List);
ULONG ULONG
PrimaryPartitionCreationChecks( PrimaryPartitionCreationChecks(
@ -284,22 +290,16 @@ ULONG
LogicalPartitionCreationChecks( LogicalPartitionCreationChecks(
IN PPARTLIST List); IN PPARTLIST List);
BOOL BOOLEAN
GetNextUnformattedPartition( GetNextUnformattedPartition(
IN PPARTLIST List, IN PPARTLIST List,
OUT PDISKENTRY *pDiskEntry, OUT PDISKENTRY *pDiskEntry OPTIONAL,
OUT PPARTENTRY *pPartEntry); OUT PPARTENTRY *pPartEntry);
BOOL BOOLEAN
GetNextUncheckedPartition( GetNextUncheckedPartition(
IN PPARTLIST List, 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 */