[FORMATTING]

No code changes!

svn path=/trunk/; revision=63168
This commit is contained in:
Eric Kohl 2014-05-04 22:03:00 +00:00
parent 2ed05c2f8f
commit 921ed79298
2 changed files with 2677 additions and 2578 deletions

View file

@ -33,8 +33,10 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
static VOID static
GetDriverName (PDISKENTRY DiskEntry) VOID
GetDriverName(
PDISKENTRY DiskEntry)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[2]; RTL_QUERY_REGISTRY_TABLE QueryTable[2];
WCHAR KeyName[32]; WCHAR KeyName[32];
@ -66,8 +68,10 @@ GetDriverName (PDISKENTRY DiskEntry)
} }
static VOID static
AssignDriverLetters (PPARTLIST List) VOID
AssignDriverLetters(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -161,8 +165,10 @@ AssignDriverLetters (PPARTLIST List)
} }
static VOID static
UpdatePartitionNumbers (PDISKENTRY DiskEntry) VOID
UpdatePartitionNumbers(
PDISKENTRY DiskEntry)
{ {
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
PLIST_ENTRY Entry; PLIST_ENTRY Entry;
@ -210,8 +216,10 @@ UpdatePartitionNumbers (PDISKENTRY DiskEntry)
} }
static VOID static
AddPartitionToList (ULONG DiskNumber, VOID
AddPartitionToList(
ULONG DiskNumber,
PDISKENTRY DiskEntry, PDISKENTRY DiskEntry,
DRIVE_LAYOUT_INFORMATION *LayoutBuffer) DRIVE_LAYOUT_INFORMATION *LayoutBuffer)
{ {
@ -229,6 +237,7 @@ AddPartitionToList (ULONG DiskNumber,
break; break;
} }
} }
if (j >= 4) if (j >= 4)
{ {
continue; continue;
@ -320,8 +329,10 @@ AddPartitionToList (ULONG DiskNumber,
} }
static VOID static
ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry) VOID
ScanForUnpartitionedDiskSpace(
PDISKENTRY DiskEntry)
{ {
ULONGLONG LastStartingOffset; ULONGLONG LastStartingOffset;
ULONGLONG LastPartitionLength; ULONGLONG LastPartitionLength;
@ -445,9 +456,11 @@ ScanForUnpartitionedDiskSpace (PDISKENTRY DiskEntry)
} }
} }
NTSTATUS NTSTATUS
NTAPI NTAPI
DiskIdentifierQueryRoutine(PWSTR ValueName, DiskIdentifierQueryRoutine(
PWSTR ValueName,
ULONG ValueType, ULONG ValueType,
PVOID ValueData, PVOID ValueData,
ULONG ValueLength, ULONG ValueLength,
@ -469,12 +482,15 @@ DiskIdentifierQueryRoutine(PWSTR ValueName,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
NTSTATUS NTSTATUS
NTAPI NTAPI
DiskConfigurationDataQueryRoutine(PWSTR ValueName, DiskConfigurationDataQueryRoutine(
PWSTR ValueName,
ULONG ValueType, ULONG ValueType,
PVOID ValueData, PVOID ValueData,
ULONG ValueLength, ULONG ValueLength,
@ -491,10 +507,13 @@ DiskConfigurationDataQueryRoutine(PWSTR ValueName,
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData; FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData;
/* Hm. Version and Revision are not set on Microsoft Windows XP... */ /* Hm. Version and Revision are not set on Microsoft Windows XP... */
/*if (FullResourceDescriptor->PartialResourceList.Version != 1 || #if 0
if (FullResourceDescriptor->PartialResourceList.Version != 1 ||
FullResourceDescriptor->PartialResourceList.Revision != 1) FullResourceDescriptor->PartialResourceList.Revision != 1)
return STATUS_UNSUCCESSFUL;*/ return STATUS_UNSUCCESSFUL;
#endif
for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++) for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++)
{ {
@ -507,12 +526,15 @@ DiskConfigurationDataQueryRoutine(PWSTR ValueName,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
NTSTATUS NTSTATUS
NTAPI NTAPI
SystemConfigurationDataQueryRoutine(PWSTR ValueName, SystemConfigurationDataQueryRoutine(
PWSTR ValueName,
ULONG ValueType, ULONG ValueType,
PVOID ValueData, PVOID ValueData,
ULONG ValueLength, ULONG ValueLength,
@ -528,10 +550,13 @@ SystemConfigurationDataQueryRoutine(PWSTR ValueName,
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData; FullResourceDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)ValueData;
/* Hm. Version and Revision are not set on Microsoft Windows XP... */ /* Hm. Version and Revision are not set on Microsoft Windows XP... */
/*if (FullResourceDescriptor->PartialResourceList.Version != 1 || #if 0
if (FullResourceDescriptor->PartialResourceList.Version != 1 ||
FullResourceDescriptor->PartialResourceList.Revision != 1) FullResourceDescriptor->PartialResourceList.Revision != 1)
return STATUS_UNSUCCESSFUL;*/ return STATUS_UNSUCCESSFUL;
#endif
for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++) for (i = 0; i < FullResourceDescriptor->PartialResourceList.Count; i++)
{ {
@ -542,17 +567,22 @@ SystemConfigurationDataQueryRoutine(PWSTR ValueName,
*Int13Drives = (CM_INT13_DRIVE_PARAMETER*) RtlAllocateHeap(ProcessHeap, 0, FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize); *Int13Drives = (CM_INT13_DRIVE_PARAMETER*) RtlAllocateHeap(ProcessHeap, 0, FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize);
if (*Int13Drives == NULL) if (*Int13Drives == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
memcpy(*Int13Drives, memcpy(*Int13Drives,
&FullResourceDescriptor->PartialResourceList.PartialDescriptors[i + 1], &FullResourceDescriptor->PartialResourceList.PartialDescriptors[i + 1],
FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize); FullResourceDescriptor->PartialResourceList.PartialDescriptors[i].u.DeviceSpecificData.DataSize);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
#define ROOT_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter" #define ROOT_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter"
static VOID static VOID
EnumerateBiosDiskEntries(PPARTLIST PartList) EnumerateBiosDiskEntries(
PPARTLIST PartList)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[3]; RTL_QUERY_REGISTRY_TABLE QueryTable[3];
WCHAR Name[120]; WCHAR Name[120];
@ -626,6 +656,7 @@ EnumerateBiosDiskEntries(PPARTLIST PartList)
QueryTable[0].QueryRoutine = DiskIdentifierQueryRoutine; QueryTable[0].QueryRoutine = DiskIdentifierQueryRoutine;
QueryTable[1].Name = L"Configuration Data"; QueryTable[1].Name = L"Configuration Data";
QueryTable[1].QueryRoutine = DiskConfigurationDataQueryRoutine; QueryTable[1].QueryRoutine = DiskConfigurationDataQueryRoutine;
DiskCount = 0; DiskCount = 0;
while (1) while (1)
{ {
@ -634,6 +665,7 @@ EnumerateBiosDiskEntries(PPARTLIST PartList)
{ {
break; break;
} }
swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu", ROOT_NAME, AdapterCount, DiskCount); swprintf(Name, L"%s\\%lu\\DiskController\\0\\DiskPeripheral\\%lu", ROOT_NAME, AdapterCount, DiskCount);
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
Name, Name,
@ -645,6 +677,7 @@ EnumerateBiosDiskEntries(PPARTLIST PartList)
RtlFreeHeap(ProcessHeap, 0, BiosDiskEntry); RtlFreeHeap(ProcessHeap, 0, BiosDiskEntry);
break; break;
} }
BiosDiskEntry->DiskNumber = DiskCount; BiosDiskEntry->DiskNumber = DiskCount;
BiosDiskEntry->Recognized = FALSE; BiosDiskEntry->Recognized = FALSE;
@ -657,7 +690,6 @@ EnumerateBiosDiskEntries(PPARTLIST PartList)
DPRINT1("Didn't find int13 drive datas for disk %u\n", DiskCount); DPRINT1("Didn't find int13 drive datas for disk %u\n", DiskCount);
} }
InsertTailList(&PartList->BiosDiskListHead, &BiosDiskEntry->ListEntry); InsertTailList(&PartList->BiosDiskListHead, &BiosDiskEntry->ListEntry);
DPRINT("DiskNumber: %lu\n", BiosDiskEntry->DiskNumber); DPRINT("DiskNumber: %lu\n", BiosDiskEntry->DiskNumber);
@ -675,17 +707,23 @@ EnumerateBiosDiskEntries(PPARTLIST PartList)
DiskCount++; DiskCount++;
} }
} }
RtlFreeHeap(ProcessHeap, 0, Int13Drives); RtlFreeHeap(ProcessHeap, 0, Int13Drives);
return; return;
} }
} }
AdapterCount++; AdapterCount++;
} }
RtlFreeHeap(ProcessHeap, 0, Int13Drives); RtlFreeHeap(ProcessHeap, 0, Int13Drives);
} }
static VOID
AddDiskToList (HANDLE FileHandle, static
VOID
AddDiskToList(
HANDLE FileHandle,
ULONG DiskNumber, ULONG DiskNumber,
PPARTLIST List) PPARTLIST List)
{ {
@ -745,7 +783,6 @@ AddDiskToList (HANDLE FileHandle,
Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap, Mbr = (PARTITION_SECTOR*)RtlAllocateHeap(ProcessHeap,
0, 0,
DiskGeometry.BytesPerSector); DiskGeometry.BytesPerSector);
if (Mbr == NULL) if (Mbr == NULL)
{ {
return; return;
@ -924,7 +961,8 @@ AddDiskToList (HANDLE FileHandle,
PPARTLIST PPARTLIST
CreatePartitionList (SHORT Left, CreatePartitionList(
SHORT Left,
SHORT Top, SHORT Top,
SHORT Right, SHORT Right,
SHORT Bottom) SHORT Bottom)
@ -1020,8 +1058,7 @@ CreatePartitionList (SHORT Left,
} }
else else
{ {
List->CurrentDisk = List->CurrentDisk = CONTAINING_RECORD(List->DiskListHead.Flink,
CONTAINING_RECORD (List->DiskListHead.Flink,
DISKENTRY, DISKENTRY,
ListEntry); ListEntry);
@ -1032,8 +1069,7 @@ CreatePartitionList (SHORT Left,
} }
else else
{ {
List->CurrentPartition = List->CurrentPartition = CONTAINING_RECORD(List->CurrentDisk->PartListHead.Flink,
CONTAINING_RECORD (List->CurrentDisk->PartListHead.Flink,
PARTENTRY, PARTENTRY,
ListEntry); ListEntry);
List->CurrentPartitionNumber = 0; List->CurrentPartitionNumber = 0;
@ -1045,7 +1081,8 @@ CreatePartitionList (SHORT Left,
VOID VOID
DestroyPartitionList (PPARTLIST List) DestroyPartitionList(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PBIOSDISKENTRY BiosDiskEntry; PBIOSDISKENTRY BiosDiskEntry;
@ -1090,8 +1127,10 @@ DestroyPartitionList (PPARTLIST List)
} }
static VOID static
PrintEmptyLine (PPARTLIST List) VOID
PrintEmptyLine(
PPARTLIST List)
{ {
COORD coPos; COORD coPos;
DWORD Written; DWORD Written;
@ -1101,7 +1140,6 @@ PrintEmptyLine (PPARTLIST List)
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 2; Height = List->Bottom - List->Top - 2;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
@ -1119,12 +1157,15 @@ PrintEmptyLine (PPARTLIST List)
coPos, coPos,
&Written); &Written);
} }
List->Line++; List->Line++;
} }
static VOID static
PrintPartitionData (PPARTLIST List, VOID
PrintPartitionData(
PPARTLIST List,
PDISKENTRY DiskEntry, PDISKENTRY DiskEntry,
PPARTENTRY PartEntry, PPARTENTRY PartEntry,
ULONG PartNumber) ULONG PartNumber)
@ -1134,7 +1175,6 @@ PrintPartitionData (PPARTLIST List,
DWORD Written; DWORD Written;
USHORT Width; USHORT Width;
USHORT Height; USHORT Height;
LARGE_INTEGER PartSize; LARGE_INTEGER PartSize;
PCHAR Unit; PCHAR Unit;
UCHAR Attribute; UCHAR Attribute;
@ -1143,7 +1183,6 @@ PrintPartitionData (PPARTLIST List,
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 2; Height = List->Bottom - List->Top - 2;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
@ -1280,12 +1319,15 @@ PrintPartitionData (PPARTLIST List,
coPos, coPos,
&Written); &Written);
} }
List->Line++; List->Line++;
} }
static VOID static
PrintDiskData (PPARTLIST List, VOID
PrintDiskData(
PPARTLIST List,
PDISKENTRY DiskEntry) PDISKENTRY DiskEntry)
{ {
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -1302,7 +1344,6 @@ PrintDiskData (PPARTLIST List,
Width = List->Right - List->Left - 1; Width = List->Right - List->Left - 1;
Height = List->Bottom - List->Top - 2; Height = List->Bottom - List->Top - 2;
coPos.X = List->Left + 1; coPos.X = List->Left + 1;
coPos.Y = List->Top + 1 + List->Line; coPos.Y = List->Top + 1 + List->Line;
@ -1344,6 +1385,7 @@ PrintDiskData (PPARTLIST List,
DiskEntry->Bus, DiskEntry->Bus,
DiskEntry->Id); DiskEntry->Id);
} }
if (List->Line >= 0 && List->Line <= Height) if (List->Line >= 0 && List->Line <= Height)
{ {
FillConsoleOutputAttribute(StdOutput, FillConsoleOutputAttribute(StdOutput,
@ -1368,6 +1410,7 @@ PrintDiskData (PPARTLIST List,
coPos, coPos,
&Written); &Written);
} }
List->Line++; List->Line++;
/* Print separator line */ /* Print separator line */
@ -1410,7 +1453,8 @@ PrintDiskData (PPARTLIST List,
VOID VOID
DrawPartitionList (PPARTLIST List) DrawPartitionList(
PPARTLIST List)
{ {
PLIST_ENTRY Entry, Entry2; PLIST_ENTRY Entry, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
@ -1428,15 +1472,18 @@ DrawPartitionList (PPARTLIST List)
CurrentDiskLine = 0; CurrentDiskLine = 0;
CurrentPartLine = 0; CurrentPartLine = 0;
LastLine = 0; LastLine = 0;
Entry = List->DiskListHead.Flink; Entry = List->DiskListHead.Flink;
while (Entry != &List->DiskListHead) while (Entry != &List->DiskListHead)
{ {
DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
LastLine += 2; LastLine += 2;
if (CurrentPartLineFound == FALSE) if (CurrentPartLineFound == FALSE)
{ {
CurrentPartLine += 2; CurrentPartLine += 2;
} }
Entry2 = DiskEntry->PartListHead.Flink; Entry2 = DiskEntry->PartListHead.Flink;
while (Entry2 != &DiskEntry->PartListHead) while (Entry2 != &DiskEntry->PartListHead)
{ {
@ -1445,17 +1492,21 @@ DrawPartitionList (PPARTLIST List)
{ {
CurrentPartLineFound = TRUE; CurrentPartLineFound = TRUE;
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
if (CurrentPartLineFound == FALSE) if (CurrentPartLineFound == FALSE)
{ {
CurrentPartLine++; CurrentPartLine++;
} }
LastLine++; LastLine++;
} }
if (DiskEntry == List->CurrentDisk) if (DiskEntry == List->CurrentDisk)
{ {
CurrentDiskLineFound = TRUE; CurrentDiskLineFound = TRUE;
} }
Entry = Entry->Flink; Entry = Entry->Flink;
if (Entry != &List->DiskListHead) if (Entry != &List->DiskListHead)
{ {
@ -1464,6 +1515,7 @@ DrawPartitionList (PPARTLIST List)
CurrentPartLine ++; CurrentPartLine ++;
CurrentDiskLine = CurrentPartLine; CurrentDiskLine = CurrentPartLine;
} }
LastLine++; LastLine++;
} }
else else
@ -1481,12 +1533,12 @@ DrawPartitionList (PPARTLIST List)
{ {
List->Offset = CurrentPartLine - (List->Bottom - List->Top - 2); List->Offset = CurrentPartLine - (List->Bottom - List->Top - 2);
} }
if (CurrentDiskLine < List->Offset && CurrentPartLine - CurrentDiskLine < List->Bottom - List->Top - 2) if (CurrentDiskLine < List->Offset && CurrentPartLine - CurrentDiskLine < List->Bottom - List->Top - 2)
{ {
List->Offset = CurrentDiskLine; List->Offset = CurrentDiskLine;
} }
/* draw upper left corner */ /* draw upper left corner */
coPos.X = List->Left; coPos.X = List->Left;
coPos.Y = List->Top; coPos.Y = List->Top;
@ -1624,7 +1676,10 @@ DrawPartitionList (PPARTLIST List)
DWORD DWORD
SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber) SelectPartition(
PPARTLIST List,
ULONG DiskNumber,
ULONG PartitionNumber)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -1660,18 +1715,23 @@ SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber)
return TRUE; return TRUE;
} }
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
return FALSE; return FALSE;
} }
Entry1 = Entry1->Flink; Entry1 = Entry1->Flink;
} }
return FALSE; return FALSE;
} }
VOID VOID
ScrollDownPartitionList (PPARTLIST List) ScrollDownPartitionList(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -1721,6 +1781,7 @@ ScrollDownPartitionList (PPARTLIST List)
DrawPartitionList(List); DrawPartitionList(List);
return; return;
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
} }
@ -1757,7 +1818,8 @@ ScrollDownPartitionList (PPARTLIST List)
VOID VOID
ScrollUpPartitionList (PPARTLIST List) ScrollUpPartitionList(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -1816,6 +1878,7 @@ ScrollUpPartitionList (PPARTLIST List)
DrawPartitionList(List); DrawPartitionList(List);
return; return;
} }
Entry2 = Entry2->Blink; Entry2 = Entry2->Blink;
} }
} }
@ -1863,8 +1926,10 @@ ScrollUpPartitionList (PPARTLIST List)
} }
static PPARTENTRY static
GetPrevPartitionedEntry (PDISKENTRY DiskEntry, PPARTENTRY
GetPrevPartitionedEntry(
PDISKENTRY DiskEntry,
PPARTENTRY CurrentEntry) PPARTENTRY CurrentEntry)
{ {
PPARTENTRY PrevEntry; PPARTENTRY PrevEntry;
@ -1889,8 +1954,10 @@ GetPrevPartitionedEntry (PDISKENTRY DiskEntry,
} }
static PPARTENTRY static
GetNextPartitionedEntry (PDISKENTRY DiskEntry, PPARTENTRY
GetNextPartitionedEntry(
PDISKENTRY DiskEntry,
PPARTENTRY CurrentEntry) PPARTENTRY CurrentEntry)
{ {
PPARTENTRY NextEntry; PPARTENTRY NextEntry;
@ -1915,8 +1982,10 @@ GetNextPartitionedEntry (PDISKENTRY DiskEntry,
} }
static PPARTENTRY static
GetPrevUnpartitionedEntry (PDISKENTRY DiskEntry, PPARTENTRY
GetPrevUnpartitionedEntry(
PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) PPARTENTRY PartEntry)
{ {
PPARTENTRY PrevPartEntry; PPARTENTRY PrevPartEntry;
@ -1934,8 +2003,10 @@ GetPrevUnpartitionedEntry (PDISKENTRY DiskEntry,
} }
static PPARTENTRY static
GetNextUnpartitionedEntry (PDISKENTRY DiskEntry, PPARTENTRY
GetNextUnpartitionedEntry(
PDISKENTRY DiskEntry,
PPARTENTRY PartEntry) PPARTENTRY PartEntry)
{ {
PPARTENTRY NextPartEntry; PPARTENTRY NextPartEntry;
@ -1954,7 +2025,8 @@ GetNextUnpartitionedEntry (PDISKENTRY DiskEntry,
VOID VOID
CreateNewPartition (PPARTLIST List, CreateNewPartition(
PPARTLIST List,
ULONGLONG PartitionSize, ULONGLONG PartitionSize,
BOOLEAN AutoCreate) BOOLEAN AutoCreate)
{ {
@ -2126,7 +2198,6 @@ CreateNewPartition (PPARTLIST List,
NewPartEntry->PartInfo[1].RewritePartition = TRUE; NewPartEntry->PartInfo[1].RewritePartition = TRUE;
/* Update previous container partition data */ /* Update previous container partition data */
PrevPartEntry->PartInfo[1].StartingOffset.QuadPart = PrevPartEntry->PartInfo[1].StartingOffset.QuadPart =
NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize; NewPartEntry->PartInfo[0].StartingOffset.QuadPart - DiskEntry->TrackSize;
PrevPartEntry->PartInfo[1].HiddenSectors = PrevPartEntry->PartInfo[1].HiddenSectors =
@ -2201,7 +2272,8 @@ CreateNewPartition (PPARTLIST List,
VOID VOID
DeleteCurrentPartition (PPARTLIST List) DeleteCurrentPartition(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2354,7 +2426,8 @@ DeleteCurrentPartition (PPARTLIST List)
VOID VOID
CheckActiveBootPartition (PPARTLIST List) CheckActiveBootPartition(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2447,6 +2520,7 @@ CheckActiveBootPartition (PPARTLIST List)
} }
} }
} }
/* Go to the next one */ /* Go to the next one */
ListEntry = ListEntry->Flink; ListEntry = ListEntry->Flink;
} }
@ -2454,7 +2528,8 @@ CheckActiveBootPartition (PPARTLIST List)
BOOLEAN BOOLEAN
CheckForLinuxFdiskPartitions (PPARTLIST List) CheckForLinuxFdiskPartitions(
PPARTLIST List)
{ {
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
PPARTENTRY PartEntry; PPARTENTRY PartEntry;
@ -2507,7 +2582,8 @@ CheckForLinuxFdiskPartitions (PPARTLIST List)
BOOLEAN BOOLEAN
WritePartitionsToDisk (PPARTLIST List) WritePartitionsToDisk(
PPARTLIST List)
{ {
PDRIVE_LAYOUT_INFORMATION DriveLayout; PDRIVE_LAYOUT_INFORMATION DriveLayout;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -2541,6 +2617,7 @@ WritePartitionsToDisk (PPARTLIST List)
{ {
/* Count partitioned entries */ /* Count partitioned entries */
PartitionCount = 0; PartitionCount = 0;
Entry2 = DiskEntry1->PartListHead.Flink; Entry2 = DiskEntry1->PartListHead.Flink;
while (Entry2 != &DiskEntry1->PartListHead) while (Entry2 != &DiskEntry1->PartListHead)
{ {
@ -2554,6 +2631,7 @@ WritePartitionsToDisk (PPARTLIST List)
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
if (PartitionCount == 0) if (PartitionCount == 0)
{ {
DriveLayoutSize = sizeof (DRIVE_LAYOUT_INFORMATION) + DriveLayoutSize = sizeof (DRIVE_LAYOUT_INFORMATION) +
@ -2564,6 +2642,7 @@ WritePartitionsToDisk (PPARTLIST List)
DriveLayoutSize = sizeof (DRIVE_LAYOUT_INFORMATION) + DriveLayoutSize = sizeof (DRIVE_LAYOUT_INFORMATION) +
((PartitionCount - 1) * sizeof (PARTITION_INFORMATION)); ((PartitionCount - 1) * sizeof (PARTITION_INFORMATION));
} }
DriveLayout = (PDRIVE_LAYOUT_INFORMATION)RtlAllocateHeap(ProcessHeap, DriveLayout = (PDRIVE_LAYOUT_INFORMATION)RtlAllocateHeap(ProcessHeap,
0, 0,
DriveLayoutSize); DriveLayoutSize);
@ -2588,8 +2667,8 @@ WritePartitionsToDisk (PPARTLIST List)
else else
{ {
DriveLayout->PartitionCount = PartitionCount; DriveLayout->PartitionCount = PartitionCount;
Index = 0; Index = 0;
Entry2 = DiskEntry1->PartListHead.Flink; Entry2 = DiskEntry1->PartListHead.Flink;
while (Entry2 != &DiskEntry1->PartListHead) while (Entry2 != &DiskEntry1->PartListHead)
{ {
@ -2607,6 +2686,7 @@ WritePartitionsToDisk (PPARTLIST List)
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
} }
if (DiskEntry1->Signature == 0) if (DiskEntry1->Signature == 0)
{ {
LARGE_INTEGER SystemTime; LARGE_INTEGER SystemTime;
@ -2643,8 +2723,10 @@ WritePartitionsToDisk (PPARTLIST List)
{ {
break; break;
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
if (Entry2 == &List->DiskListHead) if (Entry2 == &List->DiskListHead)
{ {
break; break;
@ -2653,12 +2735,10 @@ WritePartitionsToDisk (PPARTLIST List)
/* set one partition entry to dirty, this will update the signature */ /* set one partition entry to dirty, this will update the signature */
DriveLayout->PartitionEntry[0].RewritePartition = TRUE; DriveLayout->PartitionEntry[0].RewritePartition = TRUE;
} }
DriveLayout->Signature = DiskEntry1->Signature; DriveLayout->Signature = DiskEntry1->Signature;
swprintf(DstPath, swprintf(DstPath,
L"\\Device\\Harddisk%d\\Partition0", L"\\Device\\Harddisk%d\\Partition0",
DiskEntry1->DiskNumber); DiskEntry1->DiskNumber);
@ -2676,7 +2756,6 @@ WritePartitionsToDisk (PPARTLIST List)
&Iosb, &Iosb,
0, 0,
FILE_SYNCHRONOUS_IO_NONALERT); FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); DPRINT1("NtOpenFile() failed (Status %lx)\n", Status);
@ -2713,7 +2792,10 @@ WritePartitionsToDisk (PPARTLIST List)
return TRUE; return TRUE;
} }
BOOL SetMountedDeviceValues(PPARTLIST List)
BOOL
SetMountedDeviceValues(
PPARTLIST List)
{ {
PLIST_ENTRY Entry1, Entry2; PLIST_ENTRY Entry1, Entry2;
PDISKENTRY DiskEntry; PDISKENTRY DiskEntry;
@ -2742,20 +2824,23 @@ BOOL SetMountedDeviceValues(PPARTLIST List)
{ {
if (PartEntry->DriveLetter[i]) if (PartEntry->DriveLetter[i])
{ {
if (!SetMountedDeviceValue(PartEntry->DriveLetter[i], DiskEntry->Signature, PartEntry->PartInfo[i].StartingOffset)) if (!SetMountedDeviceValue(PartEntry->DriveLetter[i],
DiskEntry->Signature,
PartEntry->PartInfo[i].StartingOffset))
{ {
return FALSE; return FALSE;
} }
} }
} }
} }
Entry2 = Entry2->Flink; Entry2 = Entry2->Flink;
} }
Entry1 = Entry1->Flink; Entry1 = Entry1->Flink;
} }
return TRUE; return TRUE;
} }
/* EOF */ /* EOF */

View file

@ -181,44 +181,58 @@ typedef struct
} BIOS_DISK, *PBIOS_DISK; } BIOS_DISK, *PBIOS_DISK;
PPARTLIST PPARTLIST
CreatePartitionList (SHORT Left, CreatePartitionList(
SHORT Left,
SHORT Top, SHORT Top,
SHORT Right, SHORT Right,
SHORT Bottom); SHORT Bottom);
VOID VOID
DestroyPartitionList (PPARTLIST List); DestroyPartitionList(
PPARTLIST List);
VOID VOID
DrawPartitionList (PPARTLIST List); DrawPartitionList(
PPARTLIST List);
DWORD DWORD
SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber); SelectPartition(
PPARTLIST List,
ULONG DiskNumber,
ULONG PartitionNumber);
BOOL BOOL
SetMountedDeviceValues(PPARTLIST List); SetMountedDeviceValues(
PPARTLIST List);
VOID VOID
ScrollDownPartitionList (PPARTLIST List); ScrollDownPartitionList(
PPARTLIST List);
VOID VOID
ScrollUpPartitionList (PPARTLIST List); ScrollUpPartitionList(
PPARTLIST List);
VOID VOID
CreateNewPartition (PPARTLIST List, CreateNewPartition(
PPARTLIST List,
ULONGLONG PartitionSize, ULONGLONG PartitionSize,
BOOLEAN AutoCreate); BOOLEAN AutoCreate);
VOID VOID
DeleteCurrentPartition (PPARTLIST List); DeleteCurrentPartition(
PPARTLIST List);
VOID VOID
CheckActiveBootPartition (PPARTLIST List); CheckActiveBootPartition(
PPARTLIST List);
BOOLEAN BOOLEAN
CheckForLinuxFdiskPartitions (PPARTLIST List); CheckForLinuxFdiskPartitions(
PPARTLIST List);
BOOLEAN BOOLEAN
WritePartitionsToDisk (PPARTLIST List); WritePartitionsToDisk(
PPARTLIST List);
/* EOF */ /* EOF */