ReactOS  0.4.15-dev-3177-gd6a0299
drivepage.c
Go to the documentation of this file.
1 /*
2  * ReactOS applications
3  * Copyright (C) 2004-2008 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 /*
20  * COPYRIGHT: See COPYING in the top level directory
21  * PROJECT: ReactOS GUI first stage setup application
22  * FILE: base/setup/reactos/drivepage.c
23  * PROGRAMMERS: Matthias Kupfer
24  * Dmitry Chapyshev (dmitry@reactos.org)
25  */
26 
27 #include "reactos.h"
28 #include <shlwapi.h>
29 
30 // #include <ntdddisk.h>
31 #include <ntddstor.h>
32 #include <ntddscsi.h>
33 
34 #include "resource.h"
35 
36 #define NDEBUG
37 #include <debug.h>
38 
39 /* GLOBALS ******************************************************************/
40 
41 #define IDS_LIST_COLUMN_FIRST IDS_PARTITION_NAME
42 #define IDS_LIST_COLUMN_LAST IDS_PARTITION_STATUS
43 
44 #define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
46 static const INT column_widths[MAX_LIST_COLUMNS] = {200, 90, 60, 60};
48 
49 /* FUNCTIONS ****************************************************************/
50 
51 static INT_PTR CALLBACK
53  UINT uMsg,
54  WPARAM wParam,
55  LPARAM lParam)
56 {
57  PSETUPDATA pSetupData;
58 
59  /* Retrieve pointer to the global setup data */
60  pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
61 
62  switch (uMsg)
63  {
64  case WM_INITDIALOG:
65  {
66  /* Save pointer to the global setup data */
67  pSetupData = (PSETUPDATA)lParam;
68  SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
69 
71  SetDlgItemTextW(hwndDlg, IDC_PATH,
72  pSetupData->USetupData.InstallationDirectory);
73  break;
74  }
75 
76  case WM_COMMAND:
77  switch (LOWORD(wParam))
78  {
79  case IDOK:
80  {
81  GetDlgItemTextW(hwndDlg, IDC_PATH,
82  pSetupData->USetupData.InstallationDirectory,
83  ARRAYSIZE(pSetupData->USetupData.InstallationDirectory));
84  EndDialog(hwndDlg, IDOK);
85  return TRUE;
86  }
87 
88  case IDCANCEL:
89  EndDialog(hwndDlg, IDCANCEL);
90  return TRUE;
91  }
92  break;
93  }
94 
95  return FALSE;
96 }
97 
98 static INT_PTR CALLBACK
100  UINT uMsg,
101  WPARAM wParam,
102  LPARAM lParam)
103 {
104  switch (uMsg)
105  {
106  case WM_INITDIALOG:
107  break;
108 
109  case WM_COMMAND:
110  {
111  switch (LOWORD(wParam))
112  {
113  case IDOK:
114  EndDialog(hwndDlg, IDOK);
115  return TRUE;
116  case IDCANCEL:
117  EndDialog(hwndDlg, IDCANCEL);
118  return TRUE;
119  }
120  }
121  }
122  return FALSE;
123 }
124 
125 
126 BOOL
129  IN HWND hWndTreeList,
130  IN const UINT* pIDs,
131  IN const INT* pColsWidth,
132  IN const INT* pColsAlign,
133  IN UINT nNumOfColumns)
134 {
135  UINT i;
136  TLCOLUMN tlC;
137  WCHAR szText[50];
138 
139  /* Create the columns */
140  tlC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
141  tlC.pszText = szText;
142 
143  /* Load the column labels from the resource file */
144  for (i = 0; i < nNumOfColumns; i++)
145  {
146  tlC.iSubItem = i;
147  tlC.cx = pColsWidth[i];
148  tlC.fmt = pColsAlign[i];
149 
151 
152  if (TreeList_InsertColumn(hWndTreeList, i, &tlC) == -1)
153  return FALSE;
154  }
155 
156  return TRUE;
157 }
158 
159 // unused
160 VOID
162 {
163  HDEVINFO h;
164  HWND hList;
165  SP_DEVINFO_DATA DevInfoData;
166  DWORD i;
167 
169  if (h == INVALID_HANDLE_VALUE)
170  return;
171 
172  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
173  DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
174  for (i=0; SetupDiEnumDeviceInfo(h, i, &DevInfoData); i++)
175  {
176  DWORD DataT;
177  LPTSTR buffer = NULL;
178  DWORD buffersize = 0;
179 
181  &DevInfoData,
183  &DataT,
184  (PBYTE)buffer,
185  buffersize,
186  &buffersize))
187  {
189  {
190  if (buffer) LocalFree(buffer);
191  buffer = LocalAlloc(LPTR, buffersize * 2);
192  }
193  else
194  {
195  return;
196  }
197  }
198  if (buffer)
199  {
201  LocalFree(buffer);
202  }
203  }
205 }
206 
207 
208 HTLITEM
211  IN LPWSTR lpText,
212  IN INT iImage,
213  IN INT iSelectedImage,
214  IN LPARAM lParam)
215 {
216  TL_INSERTSTRUCTW Insert;
217 
218  ZeroMemory(&Insert, sizeof(Insert));
219 
220  Insert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
221  Insert.hInsertAfter = TVI_LAST;
222  Insert.hParent = hParent;
223  Insert.item.pszText = lpText;
224  Insert.item.iImage = iImage;
225  Insert.item.iSelectedImage = iSelectedImage;
226  Insert.item.lParam = lParam;
227 
228  // Insert.item.mask |= TVIF_STATE;
229  // Insert.item.stateMask = TVIS_OVERLAYMASK;
230  // Insert.item.state = INDEXTOOVERLAYMASK(1);
231 
232  return TreeList_InsertItem(hTreeList, &Insert);
233 }
234 
235 
236 VOID
238  IN PPARTENTRY PartEntry,
239  OUT PSTR strBuffer,
241 {
242  if (PartEntry->PartitionType == PARTITION_ENTRY_UNUSED)
243  {
244  StringCchCopyA(strBuffer, cchBuffer,
245  "Unused" /* MUIGetString(STRING_FORMATUNUSED) */);
246  }
247  else if (IsContainerPartition(PartEntry->PartitionType))
248  {
249  StringCchCopyA(strBuffer, cchBuffer,
250  "Extended Partition" /* MUIGetString(STRING_EXTENDED_PARTITION) */);
251  }
252  else
253  {
254  UINT i;
255 
256  /* Do the table lookup */
257  if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_MBR)
258  {
259  for (i = 0; i < ARRAYSIZE(MbrPartitionTypes); ++i)
260  {
261  if (PartEntry->PartitionType == MbrPartitionTypes[i].Type)
262  {
263  StringCchCopyA(strBuffer, cchBuffer,
265  return;
266  }
267  }
268  }
269 #if 0 // TODO: GPT support!
270  else if (PartEntry->DiskEntry->DiskStyle == PARTITION_STYLE_GPT)
271  {
272  for (i = 0; i < ARRAYSIZE(GptPartitionTypes); ++i)
273  {
274  if (IsEqualPartitionType(PartEntry->PartitionType,
276  {
277  StringCchCopyA(strBuffer, cchBuffer,
279  return;
280  }
281  }
282  }
283 #endif
284 
285  /* We are here because the partition type is unknown */
286  if (cchBuffer > 0) *strBuffer = '\0';
287  }
288 
289  if ((cchBuffer > 0) && (*strBuffer == '\0'))
290  {
291  StringCchPrintfA(strBuffer, cchBuffer,
292  // MUIGetString(STRING_PARTTYPE),
293  "Type 0x%02x",
294  PartEntry->PartitionType);
295  }
296 }
297 
298 static
299 HTLITEM
301  IN HWND hWndList,
302  IN PPARTLIST List,
303  IN HTLITEM htiParent,
304  IN PDISKENTRY DiskEntry,
305  IN PPARTENTRY PartEntry)
306 {
307  LARGE_INTEGER PartSize;
308  HTLITEM htiPart;
309  CHAR PartTypeString[32];
310  PCHAR PartType = PartTypeString;
311  WCHAR LineBuffer[128];
312 
313  /* Volume name */
314  if (PartEntry->IsPartitioned == FALSE)
315  {
316  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
317  // MUIGetString(STRING_UNPSPACE),
318  L"Unpartitioned space");
319  }
320  else
321  {
322  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
323  // MUIGetString(STRING_HDDINFOUNK5),
324  L"%s (%c%c)",
325  *PartEntry->VolumeLabel ? PartEntry->VolumeLabel : L"Partition",
326  (PartEntry->DriveLetter == 0) ? L'-' : PartEntry->DriveLetter,
327  (PartEntry->DriveLetter == 0) ? L'-' : L':');
328  }
329 
330  htiPart = TreeListAddItem(hWndList, htiParent, LineBuffer,
331  1, 1,
332  (LPARAM)PartEntry);
333 
334  /* Determine partition type */
335  *LineBuffer = 0;
336  if (PartEntry->IsPartitioned)
337  {
338  PartTypeString[0] = '\0';
339  if (PartEntry->New == TRUE)
340  {
341  PartType = "New (Unformatted)"; // MUIGetString(STRING_UNFORMATTED);
342  }
343  else if (PartEntry->IsPartitioned == TRUE)
344  {
345  GetPartitionTypeString(PartEntry,
346  PartTypeString,
347  ARRAYSIZE(PartTypeString));
348  PartType = PartTypeString;
349  }
350 
351  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
352  L"%S",
353  PartType);
354  }
355  TreeList_SetItemText(hWndList, htiPart, 1, LineBuffer);
356 
357  /* Format the disk size in KBs, MBs, etc... */
358  PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
359  if (StrFormatByteSizeW(PartSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
360  {
361  /* We failed for whatever reason, do the hardcoded way */
362  PWCHAR Unit;
363 
364 #if 0
365  if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
366  {
367  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
368  // Unit = MUIGetString(STRING_GB);
369  Unit = L"GB";
370  }
371  else
372 #endif
373  if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
374  {
375  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
376  // Unit = MUIGetString(STRING_MB);
377  Unit = L"MB";
378  }
379  else
380  {
381  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
382  // Unit = MUIGetString(STRING_KB);
383  Unit = L"KB";
384  }
385 
386  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
387  L"%6lu %s",
388  PartSize.u.LowPart,
389  Unit);
390  }
391  TreeList_SetItemText(hWndList, htiPart, 2, LineBuffer);
392 
393  /* Volume status */
394  *LineBuffer = 0;
395  if (PartEntry->IsPartitioned)
396  {
397  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
398  // MUIGetString(STRING_HDDINFOUNK5),
399  PartEntry->BootIndicator ? L"Active" : L"");
400  }
401  TreeList_SetItemText(hWndList, htiPart, 3, LineBuffer);
402 
403  return htiPart;
404 }
405 
406 static
407 VOID
409  IN HWND hWndList,
410  IN PPARTLIST List,
411  IN PDISKENTRY DiskEntry)
412 {
413  BOOL Success;
414  HANDLE hDevice;
415  PCHAR DiskName = NULL;
416  ULONG Length = 0;
417  PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
418  PLIST_ENTRY PrimaryEntry, LogicalEntry;
419  ULARGE_INTEGER DiskSize;
420  HTLITEM htiDisk, htiPart;
421  WCHAR LineBuffer[128];
422  UCHAR outBuf[512];
423 
424  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
425  // L"\\Device\\Harddisk%lu\\Partition%lu",
426  L"\\\\.\\PhysicalDrive%lu",
427  DiskEntry->DiskNumber);
428 
429  hDevice = CreateFileW(
430  LineBuffer, // device interface name
431  GENERIC_READ /*| GENERIC_WRITE*/, // dwDesiredAccess
432  FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
433  NULL, // lpSecurityAttributes
434  OPEN_EXISTING, // dwCreationDistribution
435  0, // dwFlagsAndAttributes
436  NULL // hTemplateFile
437  );
438  if (hDevice != INVALID_HANDLE_VALUE)
439  {
441 
442  Query.PropertyId = StorageDeviceProperty;
443  Query.QueryType = PropertyStandardQuery;
444 
445  Success = DeviceIoControl(hDevice,
447  &Query,
448  sizeof(Query),
449  &outBuf,
450  sizeof(outBuf),
451  &Length,
452  NULL);
453  if (Success)
454  {
456  if (devDesc->ProductIdOffset)
457  {
458  DiskName = (PCHAR)&outBuf[devDesc->ProductIdOffset];
459  Length -= devDesc->ProductIdOffset;
460  DiskName[min(Length, strlen(DiskName))] = 0;
461  // ( i = devDesc->ProductIdOffset; p[i] != 0 && i < Length; i++ )
462  }
463  }
464 
465  CloseHandle(hDevice);
466  }
467 
468  if (DiskName && *DiskName)
469  {
470  if (DiskEntry->DriverName.Length > 0)
471  {
472  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
473  // MUIGetString(STRING_HDDINFO_1),
474  L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
475  DiskEntry->DiskNumber,
476  DiskName,
477  DiskEntry->Port,
478  DiskEntry->Bus,
479  DiskEntry->Id,
480  &DiskEntry->DriverName);
481  }
482  else
483  {
484  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
485  // MUIGetString(STRING_HDDINFO_2),
486  L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu)",
487  DiskEntry->DiskNumber,
488  DiskName,
489  DiskEntry->Port,
490  DiskEntry->Bus,
491  DiskEntry->Id);
492  }
493  }
494  else
495  {
496  if (DiskEntry->DriverName.Length > 0)
497  {
498  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
499  // MUIGetString(STRING_HDDINFO_1),
500  L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
501  DiskEntry->DiskNumber,
502  DiskEntry->Port,
503  DiskEntry->Bus,
504  DiskEntry->Id,
505  &DiskEntry->DriverName);
506  }
507  else
508  {
509  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
510  // MUIGetString(STRING_HDDINFO_2),
511  L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
512  DiskEntry->DiskNumber,
513  DiskEntry->Port,
514  DiskEntry->Bus,
515  DiskEntry->Id);
516  }
517  }
518 
519  htiDisk = TreeListAddItem(hWndList, NULL, LineBuffer,
520  0, 0,
521  (LPARAM)DiskEntry);
522 
523  /* Disk type: MBR, GPT or RAW (Uninitialized) */
524  TreeList_SetItemText(hWndList, htiDisk, 1,
525  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? L"MBR" :
526  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? L"GPT" :
527  L"RAW");
528 
529  /* Format the disk size in KBs, MBs, etc... */
530  DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
531  if (StrFormatByteSizeW(DiskSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
532  {
533  /* We failed for whatever reason, do the hardcoded way */
534  PWCHAR Unit;
535 
536  if (DiskSize.QuadPart >= 10 * GB) /* 10 GB */
537  {
538  DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, GB);
539  // Unit = MUIGetString(STRING_GB);
540  Unit = L"GB";
541  }
542  else
543  {
544  DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, MB);
545  if (DiskSize.QuadPart == 0)
546  DiskSize.QuadPart = 1;
547  // Unit = MUIGetString(STRING_MB);
548  Unit = L"MB";
549  }
550 
551  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
552  L"%6lu %s",
553  DiskSize.u.LowPart,
554  Unit);
555  }
556  TreeList_SetItemText(hWndList, htiDisk, 2, LineBuffer);
557 
558 
559  /* Print partition lines */
560  for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
561  PrimaryEntry != &DiskEntry->PrimaryPartListHead;
562  PrimaryEntry = PrimaryEntry->Flink)
563  {
564  PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
565 
566  htiPart = PrintPartitionData(hWndList, List, htiDisk,
567  DiskEntry, PrimaryPartEntry);
568 
569  if (IsContainerPartition(PrimaryPartEntry->PartitionType))
570  {
571  for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
572  LogicalEntry != &DiskEntry->LogicalPartListHead;
573  LogicalEntry = LogicalEntry->Flink)
574  {
575  LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
576 
577  PrintPartitionData(hWndList, List, htiPart,
578  DiskEntry, LogicalPartEntry);
579  }
580 
581  /* Expand the extended partition node */
583  }
584  }
585 
586  /* Expand the disk node */
588 }
589 
590 VOID
592  IN HWND hWndList,
593  IN PPARTLIST List)
594 {
596  PDISKENTRY DiskEntry;
597 
598  for (Entry = List->DiskListHead.Flink;
599  Entry != &List->DiskListHead;
600  Entry = Entry->Flink)
601  {
602  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
603 
604  /* Print disk entry */
605  PrintDiskData(hWndList, List, DiskEntry);
606  }
607 }
608 
609 
610 
611 INT_PTR
612 CALLBACK
614  HWND hwndDlg,
615  UINT uMsg,
616  WPARAM wParam,
617  LPARAM lParam)
618 {
619  PSETUPDATA pSetupData;
620  HWND hList;
621  HIMAGELIST hSmall;
622 
623  /* Retrieve pointer to the global setup data */
624  pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
625 
626  switch (uMsg)
627  {
628  case WM_INITDIALOG:
629  {
630  /* Save pointer to the global setup data */
631  pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
632  SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
633 
634  /*
635  * Keep the "Next" button disabled. It will be enabled only
636  * when the user selects a valid partition.
637  */
639 
640  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
641 
643  // TreeList_SetExtendedStyleEx(hList, TVS_EX_FULLROWITEMS, TVS_EX_FULLROWITEMS);
644 
645  CreateTreeListColumns(pSetupData->hInstance,
646  hList,
647  column_ids,
651 
652  /* Create the ImageList */
655  ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
656  1, 1);
657 
658  /* Add event type icons to the ImageList */
659  ImageList_AddIcon(hSmall, LoadIconW(pSetupData->hInstance, MAKEINTRESOURCEW(IDI_DISKDRIVE)));
660  ImageList_AddIcon(hSmall, LoadIconW(pSetupData->hInstance, MAKEINTRESOURCEW(IDI_PARTITION)));
661 
662  /* Assign the ImageList to the List View */
664 
665  // DisplayStuffUsingWin32Setup(hwndDlg);
666  DrawPartitionList(hList, pSetupData->PartitionList);
667  break;
668  }
669 
670  case WM_DESTROY:
671  {
672  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
675  ImageList_Destroy(hSmall);
676  return TRUE;
677  }
678 
679  case WM_COMMAND:
680  {
681  switch (LOWORD(wParam))
682  {
683  case IDC_PARTMOREOPTS:
684  DialogBoxParamW(pSetupData->hInstance,
686  hwndDlg,
688  (LPARAM)pSetupData);
689  break;
690 
691  case IDC_PARTCREATE:
692  DialogBoxW(pSetupData->hInstance,
694  hwndDlg,
696  break;
697 
698  case IDC_PARTDELETE:
699  break;
700  }
701  break;
702  }
703 
704  case WM_NOTIFY:
705  {
706  LPNMHDR lpnm = (LPNMHDR)lParam;
707 
708  // On Vista+ we can use TVN_ITEMCHANGED instead, with NMTVITEMCHANGE* pointer
709  if (lpnm->idFrom == IDC_PARTITION && lpnm->code == TVN_SELCHANGED)
710  {
712 
713  // if (pnmv->uChanged & TVIF_STATE) /* The state has changed */
714  if (pnmv->itemNew.mask & TVIF_STATE)
715  {
716  /* The item has been (de)selected */
717  // if (pnmv->uNewState & TVIS_SELECTED)
718  if (pnmv->itemNew.state & TVIS_SELECTED)
719  {
720  HTLITEM hParentItem = TreeList_GetParent(lpnm->hwndFrom, pnmv->itemNew.hItem);
721  /* May or may not be a PPARTENTRY: this is a PPARTENTRY only when hParentItem != NULL */
722  PPARTENTRY PartEntry = (PPARTENTRY)pnmv->itemNew.lParam;
723 
724  if (!hParentItem || !PartEntry)
725  {
728  goto DisableWizNext;
729  }
730  else // if (hParentItem && PartEntry)
731  {
732  EnableWindow(GetDlgItem(hwndDlg, IDC_PARTCREATE), !PartEntry->IsPartitioned);
733  EnableWindow(GetDlgItem(hwndDlg, IDC_PARTDELETE), PartEntry->IsPartitioned);
734 
735  if (PartEntry->IsPartitioned &&
736  !IsContainerPartition(PartEntry->PartitionType) /* alternatively: PartEntry->PartitionNumber != 0 */ &&
737  // !PartEntry->New &&
738  (PartEntry->FormatState == Preformatted /* || PartEntry->FormatState == Formatted */))
739  {
741  }
742  else
743  {
744  goto DisableWizNext;
745  }
746  }
747  }
748  else
749  {
750 DisableWizNext:
751  /*
752  * Keep the "Next" button disabled. It will be enabled only
753  * when the user selects a valid partition.
754  */
756  }
757  }
758 
759  break;
760  }
761 
762  switch (lpnm->code)
763  {
764 #if 0
765  case PSN_SETACTIVE:
766  {
767  /*
768  * Keep the "Next" button disabled. It will be enabled only
769  * when the user selects a valid partition.
770  */
772  break;
773  }
774 #endif
775 
777  {
778  /* Give the focus on and select the first item */
779  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
780  // TreeList_SetFocusItem(hList, 1, 1);
783  return TRUE;
784  }
785 
786  case PSN_QUERYCANCEL:
787  {
788  if (MessageBoxW(GetParent(hwndDlg),
789  pSetupData->szAbortMessage,
790  pSetupData->szAbortTitle,
792  {
793  /* Go to the Terminate page */
795  }
796 
797  /* Do not close the wizard too soon */
799  return TRUE;
800  }
801 
802  case PSN_WIZNEXT: /* Set the selected data */
803  {
805 
806  /****/
807  // FIXME: This is my test disk encoding!
808  DISKENTRY DiskEntry;
809  PARTENTRY PartEntry;
810  DiskEntry.DiskNumber = 0;
811  DiskEntry.HwDiskNumber = 0;
812  DiskEntry.HwFixedDiskNumber = 0;
813  PartEntry.DiskEntry = &DiskEntry;
814  PartEntry.PartitionNumber = 1; // 4;
815  /****/
816 
817  Status = InitDestinationPaths(&pSetupData->USetupData,
818  NULL, // pSetupData->USetupData.InstallationDirectory,
819  &PartEntry);
820 
821  if (!NT_SUCCESS(Status))
822  {
823  DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
824  }
825 
826  break;
827  }
828 
829  default:
830  break;
831  }
832  }
833  break;
834 
835  default:
836  break;
837  }
838 
839  return FALSE;
840 }
841 
842 /* EOF */
#define IDC_PARTITION
Definition: resource.h:38
static INT_PTR CALLBACK PartitionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:99
signed char * PCHAR
Definition: retypes.h:7
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1783
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IN
Definition: typedefs.h:39
#define TreeList_SelectItem(h, i)
Definition: treelist.h:430
ULONG PartitionNumber
Definition: partlist.h:55
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:598
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define LVCF_WIDTH
Definition: commctrl.h:2587
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
static HTLITEM PrintPartitionData(IN HWND hWndList, IN PPARTLIST List, IN HTLITEM htiParent, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
Definition: drivepage.c:300
struct _Entry Entry
Definition: kefuncs.h:627
#define IDYES
Definition: winuser.h:829
#define LB_ADDSTRING
Definition: winuser.h:2014
Unit
Definition: gdiplusenums.h:25
#define LVCF_TEXT
Definition: commctrl.h:2588
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
static const INT column_alignment[MAX_LIST_COLUMNS]
Definition: drivepage.c:47
#define TVIS_SELECTED
Definition: commctrl.h:3280
char CHAR
Definition: xmlstorage.h:175
#define IDC_INSTFREELDR
Definition: resource.h:66
LONG NTSTATUS
Definition: precomp.h:26
#define LVCFMT_RIGHT
Definition: commctrl.h:2599
#define IDI_DISKDRIVE
Definition: resource.h:11
BOOL CreateTreeListColumns(IN HINSTANCE hInstance, IN HWND hWndTreeList, IN const UINT *pIDs, IN const INT *pColsWidth, IN const INT *pColsAlign, IN UINT nNumOfColumns)
Definition: drivepage.c:127
#define CALLBACK
Definition: compat.h:35
TCHAR szAbortMessage[512]
Definition: reactos.h:123
#define PSWIZB_NEXT
Definition: prsht.h:154
#define IDC_PARTMOREOPTS
Definition: resource.h:62
#define TreeList_Expand(h, i, c)
Definition: treelist.h:365
#define LVCFMT_LEFT
Definition: commctrl.h:2598
ULONG DiskNumber
Definition: partlist.h:111
#define LPNMTREEVIEW
Definition: commctrl.h:3643
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
#define IDC_PATH
Definition: resource.h:65
GLuint buffer
Definition: glext.h:5915
#define SM_CYSMICON
Definition: winuser.h:1003
#define SetupDiGetDeviceRegistryProperty
Definition: setupapi.h:2603
#define TL_INSERTSTRUCTW
Definition: treelist.h:462
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:316
#define TreeList_GetParent(h, i)
Definition: treelist.h:436
static VOID PrintDiskData(IN HWND hWndList, IN PPARTLIST List, IN PDISKENTRY DiskEntry)
Definition: drivepage.c:408
UINT_PTR WPARAM
Definition: windef.h:207
static const WCHAR Description[]
Definition: oid.c:1266
#define GetWindowLongPtrW
Definition: winuser.h:4805
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
uint16_t * PWCHAR
Definition: typedefs.h:56
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:64
static HWND hWndList[5+1]
Definition: SetParent.c:10
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define PSN_SETACTIVE
Definition: prsht.h:115
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:58
VOID GetPartitionTypeString(IN PPARTENTRY PartEntry, OUT PSTR strBuffer, IN ULONG cchBuffer)
Definition: drivepage.c:237
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define DWLP_MSGRESULT
Definition: winuser.h:864
struct tagNMHDR * LPNMHDR
#define FILE_SHARE_READ
Definition: compat.h:136
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
#define ILC_COLOR32
Definition: commctrl.h:358
#define TreeList_InsertColumn(h, i, p)
Definition: treelist.h:368
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define PSN_QUERYCANCEL
Definition: prsht.h:123
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
UINT code
Definition: winuser.h:3135
struct _ULARGE_INTEGER::@3886 u
#define MB
Definition: setuplib.h:56
HINSTANCE hInstance
Definition: charmap.c:20
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
* PSTORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
static const WCHAR szText[]
Definition: dialog.c:139
#define TreeList_GetImageList(h, i)
Definition: treelist.h:397
unsigned int BOOL
Definition: ntddk_ex.h:94
FORMATSTATE FormatState
Definition: partlist.h:61
UINT_PTR idFrom
Definition: winuser.h:3134
#define IDS_LIST_COLUMN_FIRST
Definition: drivepage.c:41
static DWORD cchBuffer
Definition: fusion.c:85
const GPT_PARTITION_TYPE GptPartitionTypes[NUM_GPT_PARTITION_TYPES]
Definition: partinfo.c:271
STRSAFEAPI StringCchPrintfA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:520
#define GWLP_USERDATA
Definition: treelist.c:63
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define MB_ICONQUESTION
Definition: winuser.h:783
#define PSN_WIZNEXT
Definition: prsht.h:121
LONG_PTR LPARAM
Definition: windef.h:208
#define TVI_LAST
Definition: commctrl.h:3370
VOID DrawPartitionList(IN HWND hWndList, IN PPARTLIST List)
Definition: drivepage.c:591
#define TreeList_InsertItem(h, p)
Definition: treelist.h:403
#define PropSheet_SetWizButtons(d, f)
Definition: prsht.h:357
#define OPEN_EXISTING
Definition: compat.h:634
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 DialogBoxW(i, t, p, f)
Definition: winuser.h:4375
#define WM_DESTROY
Definition: winuser.h:1592
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
#define PCHAR
Definition: match.c:90
#define IDC_PARTCREATE
Definition: resource.h:39
#define IDI_PARTITION
Definition: resource.h:12
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
UCHAR PartitionType
Definition: partlist.h:53
struct _DISKENTRY * DiskEntry
Definition: partlist.h:46
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PSWIZB_BACK
Definition: prsht.h:153
const MBR_PARTITION_TYPE MbrPartitionTypes[NUM_MBR_PARTITION_TYPES]
Definition: partinfo.c:46
#define TVN_SELCHANGED
Definition: commctrl.h:3735
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2889
HINSTANCE hInstance
Definition: reactos.h:114
#define IDC_PARTDELETE
Definition: resource.h:40
int WINAPI GetSystemMetrics(_In_ int)
#define IDD_RESTARTPAGE
Definition: resource.h:59
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG HwDiskNumber
Definition: partlist.h:105
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:540
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TreeList_SetImageList(h, l, i)
Definition: treelist.h:407
#define TreeList_SetItemText(hwndLV, hItem_, iSubItem_, pszText_)
Definition: treelist.h:467
#define SM_CXSMICON
Definition: winuser.h:1002
#define TreeList_SetExtendedStyleEx(h, d, m)
Definition: treelist.h:377
#define MAX_LIST_COLUMNS
Definition: drivepage.c:44
unsigned char UCHAR
Definition: xmlstorage.h:181
#define PropSheet_SetCurSelByID(d, i)
Definition: prsht.h:354
static const WCHAR L[]
Definition: oid.c:1250
INT_PTR CALLBACK DriveDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:613
PartType
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define ILC_MASK
Definition: commctrl.h:351
HTLITEM TreeListAddItem(IN HWND hTreeList, IN HTLITEM hParent, IN LPWSTR lpText, IN INT iImage, IN INT iSelectedImage, IN LPARAM lParam)
Definition: drivepage.c:209
TCHAR szAbortTitle[64]
Definition: reactos.h:124
#define SetupDiGetClassDevs
Definition: setupapi.h:2593
#define GENERIC_READ
Definition: compat.h:135
Definition: typedefs.h:119
#define WM_COMMAND
Definition: winuser.h:1723
#define SPDRP_DEVICEDESC
Definition: setupapi.h:507
HWND hwndFrom
Definition: winuser.h:3133
uint32_t DWORD_PTR
Definition: typedefs.h:65
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HWND hList
Definition: livecd.c:10
HWND WINAPI GetParent(_In_ HWND)
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define LVCF_FMT
Definition: commctrl.h:2586
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
struct _PARTENTRY * PPARTENTRY
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
#define TVIF_TEXT
Definition: commctrl.h:3266
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static const GUID GUID_DEVCLASS_DISKDRIVE
Definition: drvdefext.cpp:34
static INT_PTR CALLBACK MoreOptDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:52
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
ULONG HwFixedDiskNumber
Definition: partlist.h:106
signed char * PSTR
Definition: retypes.h:7
#define TVIF_IMAGE
Definition: commctrl.h:3267
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
USETUP_DATA USetupData
Definition: reactos.h:128
#define NULL
Definition: types.h:112
#define IDD_PARTITION
Definition: resource.h:70
#define BST_CHECKED
Definition: winuser.h:197
#define DPRINT1
Definition: precomp.h:8
#define CreateFileW
Definition: compat.h:600
static const INT column_widths[MAX_LIST_COLUMNS]
Definition: drivepage.c:46
#define IDD_BOOTOPTIONS
Definition: resource.h:64
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define OUT
Definition: typedefs.h:40
unsigned int ULONG
Definition: retypes.h:1
#define LPTR
Definition: winbase.h:378
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define TLCOLUMN
Definition: treelist.h:459
#define TVIF_STATE
Definition: commctrl.h:3269
#define SetWindowLongPtrW
Definition: winuser.h:5322
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GB
Definition: setuplib.h:57
#define TVIF_PARAM
Definition: commctrl.h:3268
static const UINT column_ids[MAX_LIST_COLUMNS]
Definition: drivepage.c:45
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define KB
Definition: setuplib.h:55
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
Definition: setuplib.c:627
BYTE * PBYTE
Definition: pedump.c:66
#define WM_INITDIALOG
Definition: winuser.h:1722
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define TVS_EX_FULLROWMARK
Definition: treelist.h:272
#define PSN_QUERYINITIALFOCUS
Definition: settings.cpp:98
struct _LARGE_INTEGER::@2239 u
base of all file and directory entries
Definition: entries.h:82
#define HTLITEM
Definition: treelist.h:460
#define WM_NOTIFY
Definition: richedit.h:61
LONGLONG QuadPart
Definition: typedefs.h:114
BOOLEAN IsPartitioned
Definition: partlist.h:66
#define DIGCF_PRESENT
Definition: setupapi.h:171
VOID DisplayStuffUsingWin32Setup(HWND hwndDlg)
Definition: drivepage.c:161
struct _SETUPDATA * PSETUPDATA
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10