ReactOS  0.4.15-dev-3165-gdf6fff7
partlist.c File Reference
#include "usetup.h"
#include <debug.h>
Include dependency graph for partlist.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID GetPartitionTypeString (IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
 
VOID PrettifySize1 (IN OUT PULONGLONG Size, OUT PCSTR *Unit)
 
VOID PrettifySize2 (IN OUT PULONGLONG Size, OUT PCSTR *Unit)
 
VOID PartitionDescription (IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
 
VOID DiskDescription (IN PDISKENTRY DiskEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
 
VOID InitPartitionListUi (IN OUT PPARTLIST_UI ListUi, IN PPARTLIST List, IN PPARTENTRY CurrentEntry OPTIONAL, IN SHORT Left, IN SHORT Top, IN SHORT Right, IN SHORT Bottom)
 
static VOID PrintEmptyLine (IN PPARTLIST_UI ListUi)
 
static VOID PrintPartitionData (IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
 
static VOID PrintDiskData (IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry)
 
VOID DrawPartitionList (IN PPARTLIST_UI ListUi)
 
VOID ScrollDownPartitionList (IN PPARTLIST_UI ListUi)
 
VOID ScrollUpPartitionList (IN PPARTLIST_UI ListUi)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 29 of file partlist.c.

Function Documentation

◆ DiskDescription()

VOID DiskDescription ( IN PDISKENTRY  DiskEntry,
OUT PSTR  strBuffer,
IN SIZE_T  cchBuffer 
)

Definition at line 301 of file partlist.c.

305 {
306  ULONGLONG DiskSize;
307  PCSTR Unit;
308 
309  /* Get the disk size */
310  DiskSize = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
311  PrettifySize1(&DiskSize, &Unit);
312 
313  //
314  // FIXME: We *MUST* use TXTSETUP.SIF strings from section "DiskDriverMap" !!
315  //
316  if (DiskEntry->DriverName.Length > 0)
317  {
318  RtlStringCchPrintfA(strBuffer, cchBuffer,
320  DiskSize,
321  Unit,
322  DiskEntry->DiskNumber,
323  DiskEntry->Port,
324  DiskEntry->Bus,
325  DiskEntry->Id,
326  &DiskEntry->DriverName,
327  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
328  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
329  "RAW");
330  }
331  else
332  {
333  RtlStringCchPrintfA(strBuffer, cchBuffer,
335  DiskSize,
336  Unit,
337  DiskEntry->DiskNumber,
338  DiskEntry->Port,
339  DiskEntry->Bus,
340  DiskEntry->Id,
341  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
342  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
343  "RAW");
344  }
345 }
Unit
Definition: gdiplusenums.h:25
static DWORD cchBuffer
Definition: fusion.c:85
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
VOID PrettifySize1(IN OUT PULONGLONG Size, OUT PCSTR *Unit)
Definition: partlist.c:96
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:230
#define STRING_HDDINFO_1
Definition: mui.h:154
uint64_t ULONGLONG
Definition: typedefs.h:67
#define STRING_HDDINFO_2
Definition: mui.h:155
const char * PCSTR
Definition: typedefs.h:52

Referenced by CreateExtendedPartitionPage(), CreateLogicalPartitionPage(), CreatePrimaryPartitionPage(), DeletePartitionPage(), PrintDiskData(), and SelectFileSystemPage().

◆ DrawPartitionList()

VOID DrawPartitionList ( IN PPARTLIST_UI  ListUi)

Definition at line 582 of file partlist.c.

584 {
585  PPARTLIST List = ListUi->List;
586  PLIST_ENTRY Entry, Entry2;
587  PDISKENTRY DiskEntry;
588  PPARTENTRY PartEntry = NULL;
589  COORD coPos;
590  ULONG Written;
591  USHORT Width;
592  USHORT Height;
593  SHORT i;
594  SHORT CurrentDiskLine;
595  SHORT CurrentPartLine;
596  SHORT LastLine;
597  BOOLEAN CurrentPartLineFound = FALSE;
598  BOOLEAN CurrentDiskLineFound = FALSE;
599 
600  Width = ListUi->Right - ListUi->Left - 1;
601  Height = ListUi->Bottom - ListUi->Top - 2;
602 
603  /* Calculate the line of the current disk and partition */
604  CurrentDiskLine = 0;
605  CurrentPartLine = 0;
606  LastLine = 0;
607 
608  for (Entry = List->DiskListHead.Flink;
609  Entry != &List->DiskListHead;
610  Entry = Entry->Flink)
611  {
612  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
613 
614  LastLine += 2;
615  if (CurrentPartLineFound == FALSE)
616  {
617  CurrentPartLine += 2;
618  }
619 
620  for (Entry2 = DiskEntry->PrimaryPartListHead.Flink;
621  Entry2 != &DiskEntry->PrimaryPartListHead;
622  Entry2 = Entry2->Flink)
623  {
624  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
625  if (PartEntry == ListUi->CurrentPartition)
626  {
627  CurrentPartLineFound = TRUE;
628  }
629 
630  if (CurrentPartLineFound == FALSE)
631  {
632  CurrentPartLine++;
633  }
634 
635  LastLine++;
636  }
637 
638  if (CurrentPartLineFound == FALSE)
639  {
640  for (Entry2 = DiskEntry->LogicalPartListHead.Flink;
641  Entry2 != &DiskEntry->LogicalPartListHead;
642  Entry2 = Entry2->Flink)
643  {
644  PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
645  if (PartEntry == ListUi->CurrentPartition)
646  {
647  CurrentPartLineFound = TRUE;
648  }
649 
650  if (CurrentPartLineFound == FALSE)
651  {
652  CurrentPartLine++;
653  }
654 
655  LastLine++;
656  }
657  }
658 
659  if (DiskEntry == ListUi->CurrentDisk)
660  {
661  CurrentDiskLineFound = TRUE;
662  }
663 
664  if (Entry->Flink != &List->DiskListHead)
665  {
666  if (CurrentDiskLineFound == FALSE)
667  {
668  CurrentPartLine++;
669  CurrentDiskLine = CurrentPartLine;
670  }
671 
672  LastLine++;
673  }
674  else
675  {
676  LastLine--;
677  }
678  }
679 
680  /* If it possible, make the disk name visible */
681  if (CurrentPartLine < ListUi->Offset)
682  {
683  ListUi->Offset = CurrentPartLine;
684  }
685  else if (CurrentPartLine - ListUi->Offset > Height)
686  {
687  ListUi->Offset = CurrentPartLine - Height;
688  }
689 
690  if (CurrentDiskLine < ListUi->Offset && CurrentPartLine - CurrentDiskLine < Height)
691  {
692  ListUi->Offset = CurrentDiskLine;
693  }
694 
695  /* Draw upper left corner */
696  coPos.X = ListUi->Left;
697  coPos.Y = ListUi->Top;
699  0xDA, // '+',
700  1,
701  coPos,
702  &Written);
703 
704  /* Draw upper edge */
705  coPos.X = ListUi->Left + 1;
706  coPos.Y = ListUi->Top;
707  if (ListUi->Offset == 0)
708  {
710  0xC4, // '-',
711  Width,
712  coPos,
713  &Written);
714  }
715  else
716  {
718  0xC4, // '-',
719  Width - 4,
720  coPos,
721  &Written);
722  coPos.X = ListUi->Right - 5;
724  "(\x18)", // "(up)"
725  3,
726  coPos,
727  &Written);
728  coPos.X = ListUi->Right - 2;
730  0xC4, // '-',
731  2,
732  coPos,
733  &Written);
734  }
735 
736  /* Draw upper right corner */
737  coPos.X = ListUi->Right;
738  coPos.Y = ListUi->Top;
740  0xBF, // '+',
741  1,
742  coPos,
743  &Written);
744 
745  /* Draw left and right edge */
746  for (i = ListUi->Top + 1; i < ListUi->Bottom; i++)
747  {
748  coPos.X = ListUi->Left;
749  coPos.Y = i;
751  0xB3, // '|',
752  1,
753  coPos,
754  &Written);
755 
756  coPos.X = ListUi->Right;
758  0xB3, //'|',
759  1,
760  coPos,
761  &Written);
762  }
763 
764  /* Draw lower left corner */
765  coPos.X = ListUi->Left;
766  coPos.Y = ListUi->Bottom;
768  0xC0, // '+',
769  1,
770  coPos,
771  &Written);
772 
773  /* Draw lower edge */
774  coPos.X = ListUi->Left + 1;
775  coPos.Y = ListUi->Bottom;
776  if (LastLine - ListUi->Offset <= Height)
777  {
779  0xC4, // '-',
780  Width,
781  coPos,
782  &Written);
783  }
784  else
785  {
787  0xC4, // '-',
788  Width - 4,
789  coPos,
790  &Written);
791  coPos.X = ListUi->Right - 5;
793  "(\x19)", // "(down)"
794  3,
795  coPos,
796  &Written);
797  coPos.X = ListUi->Right - 2;
799  0xC4, // '-',
800  2,
801  coPos,
802  &Written);
803  }
804 
805  /* Draw lower right corner */
806  coPos.X = ListUi->Right;
807  coPos.Y = ListUi->Bottom;
809  0xD9, // '+',
810  1,
811  coPos,
812  &Written);
813 
814  /* Print list entries */
815  ListUi->Line = -ListUi->Offset;
816 
817  for (Entry = List->DiskListHead.Flink;
818  Entry != &List->DiskListHead;
819  Entry = Entry->Flink)
820  {
821  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
822 
823  /* Print disk entry */
824  PrintDiskData(ListUi, DiskEntry);
825  }
826 }
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:131
struct _Entry Entry
Definition: kefuncs.h:627
#define TRUE
Definition: types.h:120
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:557
#define FALSE
Definition: types.h:117
short SHORT
Definition: pedump.c:59
HANDLE StdOutput
Definition: consup.c:37
unsigned char BOOLEAN
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:404
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULONG X
Definition: bl.h:1340
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
Definition: typedefs.h:119
static VOID PrintDiskData(IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry)
Definition: partlist.c:501
Definition: bl.h:1338
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static LPHIST_ENTRY Bottom
Definition: history.c:54
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:132
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341
base of all file and directory entries
Definition: entries.h:82

Referenced by ScrollDownPartitionList(), and ScrollUpPartitionList().

◆ GetPartitionTypeString()

VOID GetPartitionTypeString ( IN PPARTENTRY  PartEntry,
OUT PSTR  strBuffer,
IN ULONG  cchBuffer 
)

Definition at line 35 of file partlist.c.

39 {
40  if (PartEntry->PartitionType == PARTITION_ENTRY_UNUSED)
41  {
42  RtlStringCchCopyA(strBuffer, cchBuffer,
44  }
45  else if (IsContainerPartition(PartEntry->PartitionType))
46  {
47  RtlStringCchCopyA(strBuffer, cchBuffer,
49  }
50  else
51  {
52  UINT i;
53 
54  /* Do the table lookup */
55  if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR)
56  {
57  for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i)
58  {
59  if (PartEntry->PartitionType == MbrPartitionTypes[i].Type)
60  {
61  RtlStringCchCopyA(strBuffer, cchBuffer,
63  return;
64  }
65  }
66  }
67 #if 0 // TODO: GPT support!
68  else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
69  {
70  for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i)
71  {
72  if (IsEqualPartitionType(PartEntry->PartitionType,
74  {
75  RtlStringCchCopyA(strBuffer, cchBuffer,
77  return;
78  }
79  }
80  }
81 #endif
82 
83  /* We are here because the partition type is unknown */
84  if (cchBuffer > 0) *strBuffer = '\0';
85  }
86 
87  if ((cchBuffer > 0) && (*strBuffer == '\0'))
88  {
89  RtlStringCchPrintfA(strBuffer, cchBuffer,
91  PartEntry->PartitionType);
92  }
93 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
static const WCHAR Description[]
Definition: oid.c:1266
#define STRING_EXTENDED_PARTITION
Definition: mui.h:160
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
static DWORD cchBuffer
Definition: fusion.c:85
const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES]
Definition: partinfo.c:271
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:230
#define STRING_FORMATUNUSED
Definition: mui.h:161
const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES]
Definition: partinfo.c:46
#define STRING_PARTTYPE
Definition: mui.h:153
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
NTSTRSAFEAPI RtlStringCchCopyA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:110

Referenced by PartitionDescription().

◆ InitPartitionListUi()

VOID InitPartitionListUi ( IN OUT PPARTLIST_UI  ListUi,
IN PPARTLIST  List,
IN PPARTENTRY CurrentEntry  OPTIONAL,
IN SHORT  Left,
IN SHORT  Top,
IN SHORT  Right,
IN SHORT  Bottom 
)

Definition at line 351 of file partlist.c.

359 {
360  ListUi->List = List;
361  // ListUi->FirstShown = NULL;
362  // ListUi->LastShown = NULL;
363 
364  ListUi->Left = Left;
365  ListUi->Top = Top;
366  ListUi->Right = Right;
367  ListUi->Bottom = Bottom;
368 
369  ListUi->Line = 0;
370  ListUi->Offset = 0;
371 
372  // ListUi->Redraw = TRUE;
373 
374  /* Search for first usable disk and partition */
375  if (!CurrentEntry)
376  {
377  ListUi->CurrentDisk = NULL;
378  ListUi->CurrentPartition = NULL;
379 
380  if (!IsListEmpty(&List->DiskListHead))
381  {
382  ListUi->CurrentDisk = CONTAINING_RECORD(List->DiskListHead.Flink,
383  DISKENTRY, ListEntry);
384 
385  if (!IsListEmpty(&ListUi->CurrentDisk->PrimaryPartListHead))
386  {
387  ListUi->CurrentPartition = CONTAINING_RECORD(ListUi->CurrentDisk->PrimaryPartListHead.Flink,
388  PARTENTRY, ListEntry);
389  }
390  }
391  }
392  else
393  {
394  /*
395  * The CurrentEntry must belong to the associated partition list,
396  * and the latter must therefore not be empty.
397  */
398  ASSERT(!IsListEmpty(&List->DiskListHead));
399  ASSERT(CurrentEntry->DiskEntry->PartList == List);
400 
401  ListUi->CurrentPartition = CurrentEntry;
402  ListUi->CurrentDisk = CurrentEntry->DiskEntry;
403  }
404 }
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
static LPHIST_ENTRY Bottom
Definition: history.c:54
#define NULL
Definition: types.h:112
static LPHIST_ENTRY Top
Definition: history.c:53

Referenced by SelectPartitionPage().

◆ PartitionDescription()

VOID PartitionDescription ( IN PPARTENTRY  PartEntry,
OUT PSTR  strBuffer,
IN SIZE_T  cchBuffer 
)

Definition at line 148 of file partlist.c.

152 {
153  PSTR pBuffer = strBuffer;
154  size_t cchBufferSize = cchBuffer;
155  ULONGLONG PartSize;
156  PCSTR Unit;
157 
158  /* Get the partition size */
159  PartSize = PartEntry->SectorCount.QuadPart * PartEntry->DiskEntry->BytesPerSector;
160  PrettifySize2(&PartSize, &Unit);
161 
162  if (PartEntry->IsPartitioned == FALSE)
163  {
164  /* Unpartitioned space: Just display the description and size */
166  &pBuffer, &cchBufferSize, 0,
167  " %s%-.30s",
168  PartEntry->LogicalPartition ? " " : "", // Optional indentation
170 
172  "%*s%6I64u %s",
173  38 - min(strlen(strBuffer), 38), "", // Indentation
174  PartSize,
175  Unit);
176  return;
177  }
178 
179 //
180 // NOTE: This could be done with the next case.
181 //
182  if ((PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR) &&
183  IsContainerPartition(PartEntry->PartitionType))
184  {
185  /* Extended partition container: Just display the partition's type and size */
187  &pBuffer, &cchBufferSize, 0,
188  " %-.30s",
190 
192  "%*s%6I64u %s",
193  38 - min(strlen(strBuffer), 38), "", // Indentation
194  PartSize,
195  Unit);
196  return;
197  }
198 
199  /*
200  * Not an extended partition container.
201  */
202 
203  /* Drive letter and partition number */
205  &pBuffer, &cchBufferSize, 0,
206  "%c%c %c %s(%lu) ",
207  (PartEntry->DriveLetter == 0) ? '-' : (CHAR)PartEntry->DriveLetter,
208  (PartEntry->DriveLetter == 0) ? '-' : ':',
209  PartEntry->BootIndicator ? '*' : ' ',
210  PartEntry->LogicalPartition ? " " : "", // Optional indentation
211  PartEntry->PartitionNumber);
212 
213  /*
214  * If the volume's file system is recognized, display the volume label
215  * (if any) and the file system name. Otherwise, display the partition
216  * type if it's not a new partition.
217  */
218  if (!PartEntry->New && *PartEntry->FileSystem &&
219  _wcsicmp(PartEntry->FileSystem, L"RAW") != 0)
220  {
221  size_t cchLabelSize = 0;
222  if (*PartEntry->VolumeLabel)
223  {
225  &pBuffer, &cchLabelSize, 0,
226  "\"%-.11S\" ",
227  PartEntry->VolumeLabel);
228  cchLabelSize = cchBufferSize - cchLabelSize; // Actual length of the label part.
229  cchBufferSize -= cchLabelSize; // And reset cchBufferSize to what it should be.
230  }
231 
232  // TODO: Group this part together with the similar one
233  // from below once the strings are in the same encoding...
235  &pBuffer, &cchBufferSize, 0,
236  "[%-.*S]",
237  /* The minimum length can be at most 11 since
238  * cchLabelSize can be at most == 11 + 3 == 14 */
239  25 - min(cchLabelSize, 25),
240  PartEntry->FileSystem);
241  }
242  else
243  {
244  CHAR PartTypeString[32];
245  PCSTR PartType = PartTypeString;
246 
247  if (PartEntry->New)
248  {
249  /* Use this description if the partition is new (and thus, not formatted) */
251  }
252  else
253  {
254  /* If the partition is not new but its file system is not recognized
255  * (or is not formatted), use the partition type description. */
256  GetPartitionTypeString(PartEntry,
257  PartTypeString,
258  ARRAYSIZE(PartTypeString));
259  PartType = PartTypeString;
260  }
261  if (!PartType || !*PartType)
262  {
264  }
265 
266  // TODO: Group this part together with the similar one
267  // from above once the strings are in the same encoding...
269  &pBuffer, &cchBufferSize, 0,
270  "[%-.*s]",
271  25,
272  PartType);
273  }
274 
275  /* Show the remaining free space only if a FS is mounted */
276  // FIXME: We don't support that yet!
277 #if 0
278  if (*PartEntry->FileSystem)
279  {
281  "%*s%6I64u %s (%6I64u %s %s)",
282  38 - min(strlen(strBuffer), 38), "", // Indentation
283  PartSize,
284  Unit,
285  PartFreeSize,
286  Unit,
287  "free");
288  }
289  else
290 #endif
291  {
293  "%*s%6I64u %s",
294  38 - min(strlen(strBuffer), 38), "", // Indentation
295  PartSize,
296  Unit);
297  }
298 }
#define STRING_UNFORMATTED
Definition: mui.h:159
IN BOOLEAN OUT PSTR IN SIZE_T cchBufferSize
Definition: progress.h:34
#define STRING_FORMATUNKNOWN
Definition: mui.h:162
Unit
Definition: gdiplusenums.h:25
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define STRING_UNPSPACE
Definition: mui.h:157
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define STRING_EXTENDED_PARTITION
Definition: mui.h:160
#define FALSE
Definition: types.h:117
static DWORD cchBuffer
Definition: fusion.c:85
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
PVOID pBuffer
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:230
VOID GetPartitionTypeString(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
Definition: partlist.c:35
VOID PrettifySize2(IN OUT PULONGLONG Size, OUT PCSTR *Unit)
Definition: partlist.c:119
uint64_t ULONGLONG
Definition: typedefs.h:67
static const WCHAR L[]
Definition: oid.c:1250
PartType
signed char * PSTR
Definition: retypes.h:7
#define min(a, b)
Definition: monoChain.cc:55
const char * PCSTR
Definition: typedefs.h:52
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NTSTRSAFEVAPI RtlStringCchPrintfExA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _Outptr_opt_result_buffer_(*pcchRemaining) NTSTRSAFE_PSTR *ppszDestEnd, _Out_opt_ size_t *pcchRemaining, _In_ STRSAFE_DWORD dwFlags, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1218

Referenced by DeletePartitionPage(), PrintPartitionData(), and SelectFileSystemPage().

◆ PrettifySize1()

VOID PrettifySize1 ( IN OUT PULONGLONG  Size,
OUT PCSTR Unit 
)

Definition at line 96 of file partlist.c.

99 {
100  ULONGLONG DiskSize = *Size;
101 
102  if (DiskSize >= 10 * GB) /* 10 GB */
103  {
104  DiskSize = RoundingDivide(DiskSize, GB);
106  }
107  else
108  {
109  DiskSize = RoundingDivide(DiskSize, MB);
110  if (DiskSize == 0)
111  DiskSize = 1;
113  }
114 
115  *Size = DiskSize;
116 }
Unit
Definition: gdiplusenums.h:25
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define STRING_GB
Definition: mui.h:165
#define MB
Definition: setuplib.h:56
#define STRING_MB
Definition: mui.h:164
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:230
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define GB
Definition: setuplib.h:57

Referenced by DiskDescription().

◆ PrettifySize2()

VOID PrettifySize2 ( IN OUT PULONGLONG  Size,
OUT PCSTR Unit 
)

Definition at line 119 of file partlist.c.

122 {
123  ULONGLONG PartSize = *Size;
124 
125 #if 0
126  if (PartSize >= 10 * GB) /* 10 GB */
127  {
128  PartSize = RoundingDivide(PartSize, GB);
130  }
131  else
132 #endif
133  if (PartSize >= 10 * MB) /* 10 MB */
134  {
135  PartSize = RoundingDivide(PartSize, MB);
137  }
138  else
139  {
140  PartSize = RoundingDivide(PartSize, KB);
142  }
143 
144  *Size = PartSize;
145 }
Unit
Definition: gdiplusenums.h:25
#define STRING_KB
Definition: mui.h:163
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define STRING_GB
Definition: mui.h:165
#define MB
Definition: setuplib.h:56
#define STRING_MB
Definition: mui.h:164
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:230
uint64_t ULONGLONG
Definition: typedefs.h:67
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define GB
Definition: setuplib.h:57
#define KB
Definition: setuplib.h:55

Referenced by PartitionDescription().

◆ PrintDiskData()

static VOID PrintDiskData ( IN PPARTLIST_UI  ListUi,
IN PDISKENTRY  DiskEntry 
)
static

Definition at line 501 of file partlist.c.

504 {
505  PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
506  PLIST_ENTRY PrimaryEntry, LogicalEntry;
507  COORD coPos;
508  ULONG Written;
509  USHORT Width;
510  USHORT Height;
511  CHAR LineBuffer[100];
512 
513  DiskDescription(DiskEntry, LineBuffer, ARRAYSIZE(LineBuffer));
514 
515  Width = ListUi->Right - ListUi->Left - 1;
516  Height = ListUi->Bottom - ListUi->Top - 2;
517 
518  coPos.X = ListUi->Left + 1;
519  coPos.Y = ListUi->Top + 1 + ListUi->Line;
520 
521  if (ListUi->Line >= 0 && ListUi->Line <= Height)
522  {
525  Width,
526  coPos,
527  &Written);
528 
530  ' ',
531  Width,
532  coPos,
533  &Written);
534  }
535 
536  coPos.X++;
537  if (ListUi->Line >= 0 && ListUi->Line <= Height)
538  {
540  LineBuffer,
541  min((USHORT)strlen(LineBuffer), Width - 2),
542  coPos,
543  &Written);
544  }
545 
546  ListUi->Line++;
547 
548  /* Print separator line */
549  PrintEmptyLine(ListUi);
550 
551  /* Print partition lines */
552  for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
553  PrimaryEntry != &DiskEntry->PrimaryPartListHead;
554  PrimaryEntry = PrimaryEntry->Flink)
555  {
556  PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
557 
558  PrintPartitionData(ListUi,
559  DiskEntry,
560  PrimaryPartEntry);
561 
562  if (IsContainerPartition(PrimaryPartEntry->PartitionType))
563  {
564  for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
565  LogicalEntry != &DiskEntry->LogicalPartListHead;
566  LogicalEntry = LogicalEntry->Flink)
567  {
568  LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
569 
570  PrintPartitionData(ListUi,
571  DiskEntry,
572  LogicalPartEntry);
573  }
574  }
575  }
576 
577  /* Print separator line */
578  PrintEmptyLine(ListUi);
579 }
static VOID PrintEmptyLine(IN PPARTLIST_UI ListUi)
Definition: partlist.c:408
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:522
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
VOID DiskDescription(IN PDISKENTRY DiskEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
Definition: partlist.c:301
#define FOREGROUND_WHITE
Definition: consup.h:29
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:557
static VOID PrintPartitionData(IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
Definition: partlist.c:442
HANDLE StdOutput
Definition: consup.c:37
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:404
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ULONG X
Definition: bl.h:1340
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR PartitionType
Definition: partlist.h:53
Definition: typedefs.h:119
Definition: bl.h:1338
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
#define BACKGROUND_BLUE
Definition: blue.h:65
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341

Referenced by DrawPartitionList().

◆ PrintEmptyLine()

static VOID PrintEmptyLine ( IN PPARTLIST_UI  ListUi)
static

Definition at line 408 of file partlist.c.

410 {
411  COORD coPos;
412  ULONG Written;
413  USHORT Width;
414  USHORT Height;
415 
416  Width = ListUi->Right - ListUi->Left - 1;
417  Height = ListUi->Bottom - ListUi->Top - 2;
418 
419  coPos.X = ListUi->Left + 1;
420  coPos.Y = ListUi->Top + 1 + ListUi->Line;
421 
422  if (ListUi->Line >= 0 && ListUi->Line <= Height)
423  {
426  Width,
427  coPos,
428  &Written);
429 
431  ' ',
432  Width,
433  coPos,
434  &Written);
435  }
436 
437  ListUi->Line++;
438 }
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:522
#define FOREGROUND_WHITE
Definition: consup.h:29
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:557
HANDLE StdOutput
Definition: consup.c:37
ULONG X
Definition: bl.h:1340
Definition: bl.h:1338
unsigned short USHORT
Definition: pedump.c:61
#define BACKGROUND_BLUE
Definition: blue.h:65
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341

Referenced by PrintDiskData().

◆ PrintPartitionData()

static VOID PrintPartitionData ( IN PPARTLIST_UI  ListUi,
IN PDISKENTRY  DiskEntry,
IN PPARTENTRY  PartEntry 
)
static

Definition at line 442 of file partlist.c.

446 {
447  COORD coPos;
448  ULONG Written;
449  USHORT Width;
450  USHORT Height;
451  UCHAR Attribute;
452  CHAR LineBuffer[100];
453 
454  PartitionDescription(PartEntry, LineBuffer, ARRAYSIZE(LineBuffer));
455 
456  Width = ListUi->Right - ListUi->Left - 1;
457  Height = ListUi->Bottom - ListUi->Top - 2;
458 
459  coPos.X = ListUi->Left + 1;
460  coPos.Y = ListUi->Top + 1 + ListUi->Line;
461 
462  Attribute = (ListUi->CurrentDisk == DiskEntry &&
463  ListUi->CurrentPartition == PartEntry) ?
466 
467  if (ListUi->Line >= 0 && ListUi->Line <= Height)
468  {
470  ' ',
471  Width,
472  coPos,
473  &Written);
474  }
475  coPos.X += 4;
476  Width -= 8;
477  if (ListUi->Line >= 0 && ListUi->Line <= Height)
478  {
480  Attribute,
481  Width,
482  coPos,
483  &Written);
484  }
485  coPos.X++;
486  Width -= 2;
487  if (ListUi->Line >= 0 && ListUi->Line <= Height)
488  {
490  LineBuffer,
491  min(strlen(LineBuffer), Width),
492  coPos,
493  &Written);
494  }
495 
496  ListUi->Line++;
497 }
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:522
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define FOREGROUND_WHITE
Definition: consup.h:29
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:557
HANDLE StdOutput
Definition: consup.c:37
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:404
ULONG X
Definition: bl.h:1340
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: bl.h:1338
VOID PartitionDescription(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
Definition: partlist.c:148
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
#define BACKGROUND_WHITE
Definition: consup.h:31
#define BACKGROUND_BLUE
Definition: blue.h:65
unsigned int ULONG
Definition: retypes.h:1
ULONG Y
Definition: bl.h:1341
#define FOREGROUND_BLUE
Definition: blue.h:61

Referenced by PrintDiskData().

◆ ScrollDownPartitionList()

VOID ScrollDownPartitionList ( IN PPARTLIST_UI  ListUi)

Definition at line 829 of file partlist.c.

831 {
832  PPARTENTRY NextPart = GetNextPartition(ListUi->List, ListUi->CurrentPartition);
833  if (NextPart)
834  {
835  ListUi->CurrentPartition = NextPart;
836  ListUi->CurrentDisk = NextPart->DiskEntry;
837  DrawPartitionList(ListUi);
838  }
839 }
PPARTENTRY GetNextPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
Definition: partlist.c:2207
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
VOID DrawPartitionList(IN PPARTLIST_UI ListUi)
Definition: partlist.c:582

Referenced by SelectPartitionPage().

◆ ScrollUpPartitionList()

VOID ScrollUpPartitionList ( IN PPARTLIST_UI  ListUi)

Definition at line 842 of file partlist.c.

844 {
845  PPARTENTRY PrevPart = GetPrevPartition(ListUi->List, ListUi->CurrentPartition);
846  if (PrevPart)
847  {
848  ListUi->CurrentPartition = PrevPart;
849  ListUi->CurrentDisk = PrevPart->DiskEntry;
850  DrawPartitionList(ListUi);
851  }
852 }
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
PPARTENTRY GetPrevPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
Definition: partlist.c:2299
VOID DrawPartitionList(IN PPARTLIST_UI ListUi)
Definition: partlist.c:582

Referenced by SelectPartitionPage().