ReactOS 0.4.16-dev-1041-g8b6907f
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 ScrollUpDownPartitionList (_In_ PPARTLIST_UI ListUi, _In_ BOOLEAN Direction)
 

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 279 of file partlist.c.

283{
284 ULONGLONG DiskSize;
285 PCSTR Unit;
286
287 /* Get the disk size */
288 DiskSize = GetDiskSizeInBytes(DiskEntry);
289 PrettifySize1(&DiskSize, &Unit);
290
291 //
292 // FIXME: We *MUST* use TXTSETUP.SIF strings from section "DiskDriverMap" !!
293 //
294 if (DiskEntry->DriverName.Length > 0)
295 {
298 DiskSize,
299 Unit,
300 DiskEntry->DiskNumber,
301 DiskEntry->Port,
302 DiskEntry->Bus,
303 DiskEntry->Id,
304 &DiskEntry->DriverName,
305 DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
306 DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
307 "RAW");
308 }
309 else
310 {
313 DiskSize,
314 Unit,
315 DiskEntry->DiskNumber,
316 DiskEntry->Port,
317 DiskEntry->Bus,
318 DiskEntry->Id,
319 DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? "MBR" :
320 DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? "GPT" :
321 "RAW");
322 }
323}
static DWORD cchBuffer
Definition: fusion.c:85
Unit
Definition: gdiplusenums.h:26
#define GetDiskSizeInBytes(DiskEntry)
Definition: partlist.h:257
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
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:74
const char * PCSTR
Definition: typedefs.h:52
uint64_t ULONGLONG
Definition: typedefs.h:67
PCSTR MUIGetString(ULONG Number)
Definition: mui.c:251
#define STRING_HDDINFO2
Definition: mui.h:177
#define STRING_HDDINFO1
Definition: mui.h:176

Referenced by ChangeSystemPartitionPage(), CheckFileSystemPage(), CreatePartitionPage(), DeletePartitionPage(), FormatPartitionPage(), PrintDiskData(), and SelectFileSystemPage().

◆ DrawPartitionList()

VOID DrawPartitionList ( IN PPARTLIST_UI  ListUi)

Definition at line 560 of file partlist.c.

562{
563 PPARTLIST List = ListUi->List;
564 PLIST_ENTRY Entry, Entry2;
565 PDISKENTRY DiskEntry;
566 PPARTENTRY PartEntry = NULL;
567 COORD coPos;
568 ULONG Written;
571 SHORT i;
572 SHORT CurrentDiskLine;
573 SHORT CurrentPartLine;
574 SHORT LastLine;
575 BOOLEAN CurrentPartLineFound = FALSE;
576 BOOLEAN CurrentDiskLineFound = FALSE;
577
578 Width = ListUi->Right - ListUi->Left - 1;
579 Height = ListUi->Bottom - ListUi->Top - 2;
580
581 /* Calculate the line of the current disk and partition */
582 CurrentDiskLine = 0;
583 CurrentPartLine = 0;
584 LastLine = 0;
585
586 for (Entry = List->DiskListHead.Flink;
587 Entry != &List->DiskListHead;
588 Entry = Entry->Flink)
589 {
590 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
591
592 LastLine += 2;
593 if (CurrentPartLineFound == FALSE)
594 {
595 CurrentPartLine += 2;
596 }
597
598 for (Entry2 = DiskEntry->PrimaryPartListHead.Flink;
599 Entry2 != &DiskEntry->PrimaryPartListHead;
600 Entry2 = Entry2->Flink)
601 {
602 PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
603 if (PartEntry == ListUi->CurrentPartition)
604 {
605 CurrentPartLineFound = TRUE;
606 }
607
608 if (CurrentPartLineFound == FALSE)
609 {
610 CurrentPartLine++;
611 }
612
613 LastLine++;
614 }
615
616 if (CurrentPartLineFound == FALSE)
617 {
618 for (Entry2 = DiskEntry->LogicalPartListHead.Flink;
619 Entry2 != &DiskEntry->LogicalPartListHead;
620 Entry2 = Entry2->Flink)
621 {
622 PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
623 if (PartEntry == ListUi->CurrentPartition)
624 {
625 CurrentPartLineFound = TRUE;
626 }
627
628 if (CurrentPartLineFound == FALSE)
629 {
630 CurrentPartLine++;
631 }
632
633 LastLine++;
634 }
635 }
636
637 if (DiskEntry == ListUi->CurrentDisk)
638 {
639 CurrentDiskLineFound = TRUE;
640 }
641
642 if (Entry->Flink != &List->DiskListHead)
643 {
644 if (CurrentDiskLineFound == FALSE)
645 {
646 CurrentPartLine++;
647 CurrentDiskLine = CurrentPartLine;
648 }
649
650 LastLine++;
651 }
652 else
653 {
654 LastLine--;
655 }
656 }
657
658 /* If it possible, make the disk name visible */
659 if (CurrentPartLine < ListUi->Offset)
660 {
661 ListUi->Offset = CurrentPartLine;
662 }
663 else if (CurrentPartLine - ListUi->Offset > Height)
664 {
665 ListUi->Offset = CurrentPartLine - Height;
666 }
667
668 if (CurrentDiskLine < ListUi->Offset && CurrentPartLine - CurrentDiskLine < Height)
669 {
670 ListUi->Offset = CurrentDiskLine;
671 }
672
673 /* Draw upper left corner */
674 coPos.X = ListUi->Left;
675 coPos.Y = ListUi->Top;
677 CharUpperLeftCorner, // '+',
678 1,
679 coPos,
680 &Written);
681
682 /* Draw upper edge */
683 coPos.X = ListUi->Left + 1;
684 coPos.Y = ListUi->Top;
685 if (ListUi->Offset == 0)
686 {
688 CharHorizontalLine, // '-',
689 Width,
690 coPos,
691 &Written);
692 }
693 else
694 {
696 CharHorizontalLine, // '-',
697 Width - 4,
698 coPos,
699 &Written);
700 {
701 CHAR szBuff[] = "(.)"; // "(up)"
702 szBuff[1] = CharUpArrow;
703 coPos.X = ListUi->Right - 5;
705 szBuff,
706 3,
707 coPos,
708 &Written);
709 }
710 coPos.X = ListUi->Right - 2;
712 CharHorizontalLine, // '-',
713 2,
714 coPos,
715 &Written);
716 }
717
718 /* Draw upper right corner */
719 coPos.X = ListUi->Right;
720 coPos.Y = ListUi->Top;
722 CharUpperRightCorner, // '+',
723 1,
724 coPos,
725 &Written);
726
727 /* Draw left and right edge */
728 for (i = ListUi->Top + 1; i < ListUi->Bottom; i++)
729 {
730 coPos.X = ListUi->Left;
731 coPos.Y = i;
733 CharVerticalLine, // '|',
734 1,
735 coPos,
736 &Written);
737
738 coPos.X = ListUi->Right;
740 CharVerticalLine, //'|',
741 1,
742 coPos,
743 &Written);
744 }
745
746 /* Draw lower left corner */
747 coPos.X = ListUi->Left;
748 coPos.Y = ListUi->Bottom;
750 CharLowerLeftCorner, // '+',
751 1,
752 coPos,
753 &Written);
754
755 /* Draw lower edge */
756 coPos.X = ListUi->Left + 1;
757 coPos.Y = ListUi->Bottom;
758 if (LastLine - ListUi->Offset <= Height)
759 {
761 CharHorizontalLine, // '-',
762 Width,
763 coPos,
764 &Written);
765 }
766 else
767 {
769 CharHorizontalLine, // '-',
770 Width - 4,
771 coPos,
772 &Written);
773 {
774 CHAR szBuff[] = "(.)"; // "(down)"
775 szBuff[1] = CharDownArrow;
776 coPos.X = ListUi->Right - 5;
778 szBuff,
779 3,
780 coPos,
781 &Written);
782 }
783 coPos.X = ListUi->Right - 2;
785 CharHorizontalLine, // '-',
786 2,
787 coPos,
788 &Written);
789 }
790
791 /* Draw lower right corner */
792 coPos.X = ListUi->Right;
793 coPos.Y = ListUi->Bottom;
795 CharLowerRightCorner, // '+',
796 1,
797 coPos,
798 &Written);
799
800 /* Print list entries */
801 ListUi->Line = -ListUi->Offset;
802
803 for (Entry = List->DiskListHead.Flink;
804 Entry != &List->DiskListHead;
805 Entry = Entry->Flink)
806 {
807 DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
808
809 /* Print disk entry */
810 PrintDiskData(ListUi, DiskEntry);
811 }
812}
unsigned char BOOLEAN
BOOL WINAPI WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:407
BOOL WINAPI FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:560
static LPHIST_ENTRY Bottom
Definition: history.c:54
HANDLE StdOutput
Definition: consup.c:37
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
short SHORT
Definition: pedump.c:59
unsigned short USHORT
Definition: pedump.c:61
static VOID PrintDiskData(IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry)
Definition: partlist.c:479
base of all file and directory entries
Definition: entries.h:83
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
LIST_ENTRY LogicalPartListHead
Definition: partlist.h:150
LIST_ENTRY PrimaryPartListHead
Definition: partlist.h:149
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
CHAR CharHorizontalLine
Definition: mui.c:39
CHAR CharUpperRightCorner
Definition: mui.c:42
CHAR CharDownArrow
Definition: mui.c:38
CHAR CharLowerRightCorner
Definition: mui.c:44
CHAR CharUpperLeftCorner
Definition: mui.c:41
CHAR CharVerticalLine
Definition: mui.c:40
CHAR CharLowerLeftCorner
Definition: mui.c:43
CHAR CharUpArrow
Definition: mui.c:37
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
char CHAR
Definition: xmlstorage.h:175

Referenced by ScrollUpDownPartitionList().

◆ 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 {
44 }
45 else if (IsContainerPartition(PartEntry->PartitionType))
46 {
49 }
50 else
51 {
52 /* Do the table lookup */
53 PCSTR Description = LookupPartitionTypeString(PartEntry->DiskEntry->DiskStyle,
54 &PartEntry->PartitionType);
55 if (Description)
56 {
58 return;
59 }
60
61 /* We are here because the partition type is unknown */
62 if (cchBuffer > 0) *strBuffer = '\0';
63 }
64
65 if ((cchBuffer > 0) && (*strBuffer == '\0'))
66 {
69 PartEntry->PartitionType);
70 }
71}
PCSTR NTAPI LookupPartitionTypeString(_In_ PARTITION_STYLE PartitionStyle, _In_ PVOID PartitionType)
Definition: partinfo.c:804
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:87
static const WCHAR Description[]
Definition: oid.c:1266
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:321
NTSTRSAFEAPI RtlStringCchCopyA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:110
#define STRING_FORMATUNUSED
Definition: mui.h:182
#define STRING_EXTENDED_PARTITION
Definition: mui.h:181
#define STRING_PARTTYPE
Definition: mui.h:175

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 329 of file partlist.c.

337{
338 ListUi->List = List;
339 // ListUi->FirstShown = NULL;
340 // ListUi->LastShown = NULL;
341
342 ListUi->Left = Left;
343 ListUi->Top = Top;
344 ListUi->Right = Right;
345 ListUi->Bottom = Bottom;
346
347 ListUi->Line = 0;
348 ListUi->Offset = 0;
349
350 // ListUi->Redraw = TRUE;
351
352 /* Search for first usable disk and partition */
353 if (!CurrentEntry)
354 {
355 ListUi->CurrentDisk = NULL;
356 ListUi->CurrentPartition = NULL;
357
358 if (!IsListEmpty(&List->DiskListHead))
359 {
360 ListUi->CurrentDisk = CONTAINING_RECORD(List->DiskListHead.Flink,
361 DISKENTRY, ListEntry);
362
363 if (!IsListEmpty(&ListUi->CurrentDisk->PrimaryPartListHead))
364 {
365 ListUi->CurrentPartition = CONTAINING_RECORD(ListUi->CurrentDisk->PrimaryPartListHead.Flink,
366 PARTENTRY, ListEntry);
367 }
368 }
369 }
370 else
371 {
372 /*
373 * The CurrentEntry must belong to the associated partition list,
374 * and the latter must therefore not be empty.
375 */
376 ASSERT(!IsListEmpty(&List->DiskListHead));
377 ASSERT(CurrentEntry->DiskEntry->PartList == List);
378
379 ListUi->CurrentPartition = CurrentEntry;
380 ListUi->CurrentDisk = CurrentEntry->DiskEntry;
381 }
382}
static LPHIST_ENTRY Top
Definition: history.c:53
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ASSERT(a)
Definition: mode.c:44

Referenced by SelectPartitionPage().

◆ PartitionDescription()

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

Definition at line 126 of file partlist.c.

130{
131 PSTR pBuffer = strBuffer;
132 size_t cchBufferSize = cchBuffer;
133 ULONGLONG PartSize;
134 PCSTR Unit;
135 PVOLINFO VolInfo = (PartEntry->Volume ? &PartEntry->Volume->Info : NULL);
136
137 /* Get the partition size */
138 PartSize = GetPartEntrySizeInBytes(PartEntry);
139 PrettifySize2(&PartSize, &Unit);
140
141 if (PartEntry->IsPartitioned == FALSE)
142 {
143 /* Unpartitioned space: Just display the description and size */
144 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
145 &pBuffer, &cchBufferSize, 0,
146 " %s%-.30s",
147 PartEntry->LogicalPartition ? " " : "", // Optional indentation
149
150 RtlStringCchPrintfA(pBuffer, cchBufferSize,
151 "%*s%6I64u %s",
152 38 - min(strlen(strBuffer), 38), "", // Indentation
153 PartSize,
154 Unit);
155 return;
156 }
157
158//
159// NOTE: This could be done with the next case.
160//
161 if ((PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR) &&
162 IsContainerPartition(PartEntry->PartitionType))
163 {
164 /* Extended partition container: Just display the partition's type and size */
165 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
166 &pBuffer, &cchBufferSize, 0,
167 " %-.30s",
169
170 RtlStringCchPrintfA(pBuffer, cchBufferSize,
171 "%*s%6I64u %s",
172 38 - min(strlen(strBuffer), 38), "", // Indentation
173 PartSize,
174 Unit);
175 return;
176 }
177
178 /*
179 * Not an extended partition container.
180 */
181
182 /* Drive letter and partition number */
183 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
184 &pBuffer, &cchBufferSize, 0,
185 "%c%c %c %s(%lu) ",
186 !(VolInfo && VolInfo->DriveLetter) ? '-' : (CHAR)VolInfo->DriveLetter,
187 !(VolInfo && VolInfo->DriveLetter) ? '-' : ':',
188 PartEntry->BootIndicator ? '*' : ' ',
189 PartEntry->LogicalPartition ? " " : "", // Optional indentation
190 PartEntry->PartitionNumber);
191
192 /*
193 * If the volume's file system is recognized, display the volume label
194 * (if any) and the file system name. Otherwise, display the partition
195 * type if it's not a new partition.
196 */
197 if (VolInfo && IsFormatted(VolInfo))
198 {
199 size_t cchLabelSize = 0;
200 if (*VolInfo->VolumeLabel)
201 {
202 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
203 &pBuffer, &cchLabelSize, 0,
204 "\"%-.11S\" ",
205 VolInfo->VolumeLabel);
206 cchLabelSize = cchBufferSize - cchLabelSize; // Actual length of the label part.
207 cchBufferSize -= cchLabelSize; // And reset cchBufferSize to what it should be.
208 }
209
210 // TODO: Group this part together with the similar one
211 // from below once the strings are in the same encoding...
212 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
213 &pBuffer, &cchBufferSize, 0,
214 "[%-.*S]",
215 /* The minimum length can be at most 11 since
216 * cchLabelSize can be at most == 11 + 3 == 14 */
217 25 - min(cchLabelSize, 25),
218 VolInfo->FileSystem);
219 }
220 else
221 {
222 CHAR PartTypeString[32];
223 PCSTR PartType = PartTypeString;
224
225 if (PartEntry->New)
226 {
227 /* Use this description if the partition is new (and thus, not formatted) */
229 }
230 else
231 {
232 /* If the partition is not new but its file system is not recognized
233 * (or is not formatted), use the partition type description. */
234 GetPartitionTypeString(PartEntry,
235 PartTypeString,
236 ARRAYSIZE(PartTypeString));
237 PartType = PartTypeString;
238 }
239 if (!PartType || !*PartType)
240 {
242 }
243
244 // TODO: Group this part together with the similar one
245 // from above once the strings are in the same encoding...
246 RtlStringCchPrintfExA(pBuffer, cchBufferSize,
247 &pBuffer, &cchBufferSize, 0,
248 "[%-.*s]",
249 25,
250 PartType);
251 }
252
253 /* Show the remaining free space only if a FS is mounted */
254 // FIXME: We don't support that yet!
255#if 0
256 if (VolInfo && *VolInfo->FileSystem)
257 {
258 RtlStringCchPrintfA(pBuffer, cchBufferSize,
259 "%*s%6I64u %s (%6I64u %s %s)",
260 38 - min(strlen(strBuffer), 38), "", // Indentation
261 PartSize,
262 Unit,
263 PartFreeSize,
264 Unit,
265 "free");
266 }
267 else
268#endif
269 {
270 RtlStringCchPrintfA(pBuffer, cchBufferSize,
271 "%*s%6I64u %s",
272 38 - min(strlen(strBuffer), 38), "", // Indentation
273 PartSize,
274 Unit);
275 }
276}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PartType
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetPartEntrySizeInBytes(PartEntry)
Definition: partlist.h:254
#define min(a, b)
Definition: monoChain.cc:55
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
PVOID pBuffer
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:97
WCHAR VolumeLabel[20]
Definition: volutil.h:16
WCHAR FileSystem[MAX_PATH+1]
Definition: volutil.h:17
WCHAR DriveLetter
Definition: volutil.h:15
char * PSTR
Definition: typedefs.h:51
#define STRING_UNPSPACE
Definition: mui.h:178
#define STRING_FORMATUNKNOWN
Definition: mui.h:183
#define STRING_UNFORMATTED
Definition: mui.h:180
#define IsFormatted(VolInfo)
Definition: volutil.h:34

Referenced by ChangeSystemPartitionPage(), CheckFileSystemPage(), DeletePartitionPage(), FormatPartitionPage(), PrintPartitionData(), and SelectFileSystemPage().

◆ PrettifySize1()

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

Definition at line 74 of file partlist.c.

77{
78 ULONGLONG DiskSize = *Size;
79
80 if (DiskSize >= 10 * GB) /* 10 GB */
81 {
82 DiskSize = RoundingDivide(DiskSize, GB);
84 }
85 else
86 {
87 DiskSize = RoundingDivide(DiskSize, MB);
88 if (DiskSize == 0)
89 DiskSize = 1;
91 }
92
93 *Size = DiskSize;
94}
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
#define GB
Definition: setuplib.h:76
#define MB
Definition: setuplib.h:75
#define STRING_GB
Definition: mui.h:186
#define STRING_MB
Definition: mui.h:185
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by DiskDescription().

◆ PrettifySize2()

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

Definition at line 97 of file partlist.c.

100{
101 ULONGLONG PartSize = *Size;
102
103#if 0
104 if (PartSize >= 10 * GB) /* 10 GB */
105 {
106 PartSize = RoundingDivide(PartSize, GB);
108 }
109 else
110#endif
111 if (PartSize >= 10 * MB) /* 10 MB */
112 {
113 PartSize = RoundingDivide(PartSize, MB);
115 }
116 else
117 {
118 PartSize = RoundingDivide(PartSize, KB);
120 }
121
122 *Size = PartSize;
123}
#define KB
Definition: setuplib.h:74
#define STRING_KB
Definition: mui.h:184

Referenced by PartitionDescription().

◆ PrintDiskData()

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

Definition at line 479 of file partlist.c.

482{
483 PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
484 PLIST_ENTRY PrimaryEntry, LogicalEntry;
485 COORD coPos;
486 ULONG Written;
489 CHAR LineBuffer[100];
490
491 DiskDescription(DiskEntry, LineBuffer, ARRAYSIZE(LineBuffer));
492
493 Width = ListUi->Right - ListUi->Left - 1;
494 Height = ListUi->Bottom - ListUi->Top - 2;
495
496 coPos.X = ListUi->Left + 1;
497 coPos.Y = ListUi->Top + 1 + ListUi->Line;
498
499 if (ListUi->Line >= 0 && ListUi->Line <= Height)
500 {
503 Width,
504 coPos,
505 &Written);
506
508 ' ',
509 Width,
510 coPos,
511 &Written);
512 }
513
514 coPos.X++;
515 if (ListUi->Line >= 0 && ListUi->Line <= Height)
516 {
518 LineBuffer,
519 min((USHORT)strlen(LineBuffer), Width - 2),
520 coPos,
521 &Written);
522 }
523
524 ListUi->Line++;
525
526 /* Print separator line */
527 PrintEmptyLine(ListUi);
528
529 /* Print partition lines */
530 for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
531 PrimaryEntry != &DiskEntry->PrimaryPartListHead;
532 PrimaryEntry = PrimaryEntry->Flink)
533 {
534 PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
535
536 PrintPartitionData(ListUi,
537 DiskEntry,
538 PrimaryPartEntry);
539
540 if (IsContainerPartition(PrimaryPartEntry->PartitionType))
541 {
542 for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
543 LogicalEntry != &DiskEntry->LogicalPartListHead;
544 LogicalEntry = LogicalEntry->Flink)
545 {
546 LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
547
548 PrintPartitionData(ListUi,
549 DiskEntry,
550 LogicalPartEntry);
551 }
552 }
553 }
554
555 /* Print separator line */
556 PrintEmptyLine(ListUi);
557}
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
#define BACKGROUND_BLUE
Definition: blue.h:65
#define FOREGROUND_WHITE
Definition: consup.h:29
VOID DiskDescription(IN PDISKENTRY DiskEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
Definition: partlist.c:279
static VOID PrintEmptyLine(IN PPARTLIST_UI ListUi)
Definition: partlist.c:386
static VOID PrintPartitionData(IN PPARTLIST_UI ListUi, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
Definition: partlist.c:420
UCHAR PartitionType
Definition: partlist.h:73

Referenced by DrawPartitionList().

◆ PrintEmptyLine()

static VOID PrintEmptyLine ( IN PPARTLIST_UI  ListUi)
static

Definition at line 386 of file partlist.c.

388{
389 COORD coPos;
390 ULONG Written;
393
394 Width = ListUi->Right - ListUi->Left - 1;
395 Height = ListUi->Bottom - ListUi->Top - 2;
396
397 coPos.X = ListUi->Left + 1;
398 coPos.Y = ListUi->Top + 1 + ListUi->Line;
399
400 if (ListUi->Line >= 0 && ListUi->Line <= Height)
401 {
404 Width,
405 coPos,
406 &Written);
407
409 ' ',
410 Width,
411 coPos,
412 &Written);
413 }
414
415 ListUi->Line++;
416}

Referenced by PrintDiskData().

◆ PrintPartitionData()

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

Definition at line 420 of file partlist.c.

424{
425 COORD coPos;
426 ULONG Written;
429 UCHAR Attribute;
430 CHAR LineBuffer[100];
431
432 PartitionDescription(PartEntry, LineBuffer, ARRAYSIZE(LineBuffer));
433
434 Width = ListUi->Right - ListUi->Left - 1;
435 Height = ListUi->Bottom - ListUi->Top - 2;
436
437 coPos.X = ListUi->Left + 1;
438 coPos.Y = ListUi->Top + 1 + ListUi->Line;
439
440 Attribute = (ListUi->CurrentDisk == DiskEntry &&
441 ListUi->CurrentPartition == PartEntry) ?
444
445 if (ListUi->Line >= 0 && ListUi->Line <= Height)
446 {
448 ' ',
449 Width,
450 coPos,
451 &Written);
452 }
453 coPos.X += 4;
454 Width -= 8;
455 if (ListUi->Line >= 0 && ListUi->Line <= Height)
456 {
458 Attribute,
459 Width,
460 coPos,
461 &Written);
462 }
463 coPos.X++;
464 Width -= 2;
465 if (ListUi->Line >= 0 && ListUi->Line <= Height)
466 {
468 LineBuffer,
469 min(strlen(LineBuffer), Width),
470 coPos,
471 &Written);
472 }
473
474 ListUi->Line++;
475}
#define FOREGROUND_BLUE
Definition: blue.h:61
#define BACKGROUND_WHITE
Definition: consup.h:31
VOID PartitionDescription(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN SIZE_T cchBuffer)
Definition: partlist.c:126
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by PrintDiskData().

◆ ScrollUpDownPartitionList()

VOID ScrollUpDownPartitionList ( _In_ PPARTLIST_UI  ListUi,
_In_ BOOLEAN  Direction 
)
Parameters
[in]DirectionTRUE or FALSE to scroll to the next (down) or previous (up) entry, respectively.

Definition at line 819 of file partlist.c.

822{
823 PPARTENTRY PartEntry =
825 : GetPrevPartition)(ListUi->List, ListUi->CurrentPartition);
826 if (PartEntry)
827 {
828 ListUi->CurrentPartition = PartEntry;
829 ListUi->CurrentDisk = PartEntry->DiskEntry;
830 DrawPartitionList(ListUi);
831 }
832}
PPARTENTRY NTAPI GetPrevPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
Definition: partlist.c:2387
PPARTENTRY NTAPI GetNextPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
Definition: partlist.c:2294
VOID DrawPartitionList(IN PPARTLIST_UI ListUi)
Definition: partlist.c:560
struct _DISKENTRY * DiskEntry
Definition: partlist.h:66
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction

Referenced by SelectPartitionPage().