ReactOS  0.4.13-dev-73-gcfe54aa
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 UCHAR partitionType,
239  OUT PCHAR strPartType,
240  IN ULONG cchPartType)
241 {
242  /* Determine partition type */
243 
244  if (IsContainerPartition(partitionType))
245  {
246  StringCchCopyA(strPartType, cchPartType, "Extended Partition" /* MUIGetString(STRING_EXTENDED_PARTITION) */);
247  }
248  else if (partitionType == PARTITION_ENTRY_UNUSED)
249  {
250  StringCchCopyA(strPartType, cchPartType, "Unused" /* MUIGetString(STRING_FORMATUNUSED) */);
251  }
252  else
253  {
254  UINT i;
255 
256  /* Do the table lookup */
257  for (i = 0; i < ARRAYSIZE(PartitionTypes); i++)
258  {
259  if (partitionType == PartitionTypes[i].Type)
260  {
261  StringCchCopyA(strPartType, cchPartType, PartitionTypes[i].Description);
262  return;
263  }
264  }
265 
266  /* We are here because the partition type is unknown */
267  StringCchCopyA(strPartType, cchPartType, "Unknown" /* MUIGetString(STRING_FORMATUNKNOWN) */);
268  }
269 }
270 
271 static
272 HTLITEM
274  IN HWND hWndList,
275  IN PPARTLIST List,
276  IN HTLITEM htiParent,
277  IN PDISKENTRY DiskEntry,
278  IN PPARTENTRY PartEntry)
279 {
280  LARGE_INTEGER PartSize;
281  HTLITEM htiPart;
282  CHAR PartTypeString[32];
283  PCHAR PartType = PartTypeString;
284  WCHAR LineBuffer[128];
285 
286  /* Volume name */
287  if (PartEntry->IsPartitioned == FALSE)
288  {
289  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
290  // MUIGetString(STRING_UNPSPACE),
291  L"Unpartitioned space");
292  }
293  else
294  {
295  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
296  // MUIGetString(STRING_HDDINFOUNK5),
297  L"%s (%c%c)",
298  *PartEntry->VolumeLabel ? PartEntry->VolumeLabel : L"Partition",
299  (PartEntry->DriveLetter == 0) ? L'-' : PartEntry->DriveLetter,
300  (PartEntry->DriveLetter == 0) ? L'-' : L':');
301  }
302 
303  htiPart = TreeListAddItem(hWndList, htiParent, LineBuffer,
304  1, 1,
305  (LPARAM)PartEntry);
306 
307  /* Determine partition type */
308  *LineBuffer = 0;
309  if (PartEntry->IsPartitioned)
310  {
311  PartTypeString[0] = '\0';
312  if (PartEntry->New == TRUE)
313  {
314  PartType = "New (Unformatted)"; // MUIGetString(STRING_UNFORMATTED);
315  }
316  else if (PartEntry->IsPartitioned == TRUE)
317  {
318  GetPartTypeStringFromPartitionType(PartEntry->PartitionType,
319  PartTypeString,
320  ARRAYSIZE(PartTypeString));
321  PartType = PartTypeString;
322  }
323 
324  if (strcmp(PartType, "Unknown" /* MUIGetString(STRING_FORMATUNKNOWN) */) == 0)
325  {
326  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
327  // MUIGetString(STRING_HDDINFOUNK5),
328  L"Type 0x%02x",
329  PartEntry->PartitionType);
330  }
331  else
332  {
333  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
334  L"%S",
335  PartType);
336  }
337  }
338  TreeList_SetItemText(hWndList, htiPart, 1, LineBuffer);
339 
340  /* Format the disk size in KBs, MBs, etc... */
341  PartSize.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
342  if (StrFormatByteSizeW(PartSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
343  {
344  /* We failed for whatever reason, do the hardcoded way */
345  PWCHAR Unit;
346 
347 #if 0
348  if (PartSize.QuadPart >= 10 * GB) /* 10 GB */
349  {
350  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, GB);
351  // Unit = MUIGetString(STRING_GB);
352  Unit = L"GB";
353  }
354  else
355 #endif
356  if (PartSize.QuadPart >= 10 * MB) /* 10 MB */
357  {
358  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, MB);
359  // Unit = MUIGetString(STRING_MB);
360  Unit = L"MB";
361  }
362  else
363  {
364  PartSize.QuadPart = RoundingDivide(PartSize.QuadPart, KB);
365  // Unit = MUIGetString(STRING_KB);
366  Unit = L"KB";
367  }
368 
369  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
370  L"%6lu %s",
371  PartSize.u.LowPart,
372  Unit);
373  }
374  TreeList_SetItemText(hWndList, htiPart, 2, LineBuffer);
375 
376  /* Volume status */
377  *LineBuffer = 0;
378  if (PartEntry->IsPartitioned)
379  {
380  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
381  // MUIGetString(STRING_HDDINFOUNK5),
382  PartEntry->BootIndicator ? L"Active" : L"");
383  }
384  TreeList_SetItemText(hWndList, htiPart, 3, LineBuffer);
385 
386  return htiPart;
387 }
388 
389 static
390 VOID
392  IN HWND hWndList,
393  IN PPARTLIST List,
394  IN PDISKENTRY DiskEntry)
395 {
396  BOOL Success;
397  HANDLE hDevice;
398  PCHAR DiskName = NULL;
399  ULONG Length = 0;
400  PPARTENTRY PrimaryPartEntry, LogicalPartEntry;
401  PLIST_ENTRY PrimaryEntry, LogicalEntry;
402  ULARGE_INTEGER DiskSize;
403  HTLITEM htiDisk, htiPart;
404  WCHAR LineBuffer[128];
405  UCHAR outBuf[512];
406 
407  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
408  // L"\\Device\\Harddisk%lu\\Partition%lu",
409  L"\\\\.\\PhysicalDrive%lu",
410  DiskEntry->DiskNumber);
411 
412  hDevice = CreateFileW(
413  LineBuffer, // device interface name
414  GENERIC_READ /*| GENERIC_WRITE*/, // dwDesiredAccess
415  FILE_SHARE_READ | FILE_SHARE_WRITE, // dwShareMode
416  NULL, // lpSecurityAttributes
417  OPEN_EXISTING, // dwCreationDistribution
418  0, // dwFlagsAndAttributes
419  NULL // hTemplateFile
420  );
421  if (hDevice != INVALID_HANDLE_VALUE)
422  {
424 
425  Query.PropertyId = StorageDeviceProperty;
426  Query.QueryType = PropertyStandardQuery;
427 
428  Success = DeviceIoControl(hDevice,
430  &Query,
431  sizeof(Query),
432  &outBuf,
433  sizeof(outBuf),
434  &Length,
435  NULL);
436  if (Success)
437  {
439  if (devDesc->ProductIdOffset)
440  {
441  DiskName = (PCHAR)&outBuf[devDesc->ProductIdOffset];
442  Length -= devDesc->ProductIdOffset;
443  DiskName[min(Length, strlen(DiskName))] = 0;
444  // ( i = devDesc->ProductIdOffset; p[i] != 0 && i < Length; i++ )
445  }
446  }
447 
448  CloseHandle(hDevice);
449  }
450 
451  if (DiskName && *DiskName)
452  {
453  if (DiskEntry->DriverName.Length > 0)
454  {
455  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
456  // MUIGetString(STRING_HDINFOPARTSELECT_1),
457  L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
458  DiskEntry->DiskNumber,
459  DiskName,
460  DiskEntry->Port,
461  DiskEntry->Bus,
462  DiskEntry->Id,
463  &DiskEntry->DriverName);
464  }
465  else
466  {
467  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
468  // MUIGetString(STRING_HDINFOPARTSELECT_2),
469  L"Harddisk %lu (%S) (Port=%hu, Bus=%hu, Id=%hu)",
470  DiskEntry->DiskNumber,
471  DiskName,
472  DiskEntry->Port,
473  DiskEntry->Bus,
474  DiskEntry->Id);
475  }
476  }
477  else
478  {
479  if (DiskEntry->DriverName.Length > 0)
480  {
481  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
482  // MUIGetString(STRING_HDINFOPARTSELECT_1),
483  L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu) on %wZ",
484  DiskEntry->DiskNumber,
485  DiskEntry->Port,
486  DiskEntry->Bus,
487  DiskEntry->Id,
488  &DiskEntry->DriverName);
489  }
490  else
491  {
492  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
493  // MUIGetString(STRING_HDINFOPARTSELECT_2),
494  L"Harddisk %lu (Port=%hu, Bus=%hu, Id=%hu)",
495  DiskEntry->DiskNumber,
496  DiskEntry->Port,
497  DiskEntry->Bus,
498  DiskEntry->Id);
499  }
500  }
501 
502  htiDisk = TreeListAddItem(hWndList, NULL, LineBuffer,
503  0, 0,
504  (LPARAM)DiskEntry);
505 
506  /* Disk type: MBR, GPT or RAW (Uninitialized) */
507  TreeList_SetItemText(hWndList, htiDisk, 1,
508  DiskEntry->DiskStyle == PARTITION_STYLE_MBR ? L"MBR" :
509  DiskEntry->DiskStyle == PARTITION_STYLE_GPT ? L"GPT" :
510  L"RAW");
511 
512  /* Format the disk size in KBs, MBs, etc... */
513  DiskSize.QuadPart = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
514  if (StrFormatByteSizeW(DiskSize.QuadPart, LineBuffer, ARRAYSIZE(LineBuffer)) == NULL)
515  {
516  /* We failed for whatever reason, do the hardcoded way */
517  PWCHAR Unit;
518 
519  if (DiskSize.QuadPart >= 10 * GB) /* 10 GB */
520  {
521  DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, GB);
522  // Unit = MUIGetString(STRING_GB);
523  Unit = L"GB";
524  }
525  else
526  {
527  DiskSize.QuadPart = RoundingDivide(DiskSize.QuadPart, MB);
528  if (DiskSize.QuadPart == 0)
529  DiskSize.QuadPart = 1;
530  // Unit = MUIGetString(STRING_MB);
531  Unit = L"MB";
532  }
533 
534  StringCchPrintfW(LineBuffer, ARRAYSIZE(LineBuffer),
535  L"%6lu %s",
536  DiskSize.u.LowPart,
537  Unit);
538  }
539  TreeList_SetItemText(hWndList, htiDisk, 2, LineBuffer);
540 
541 
542  /* Print partition lines */
543  for (PrimaryEntry = DiskEntry->PrimaryPartListHead.Flink;
544  PrimaryEntry != &DiskEntry->PrimaryPartListHead;
545  PrimaryEntry = PrimaryEntry->Flink)
546  {
547  PrimaryPartEntry = CONTAINING_RECORD(PrimaryEntry, PARTENTRY, ListEntry);
548 
549  htiPart = PrintPartitionData(hWndList, List, htiDisk,
550  DiskEntry, PrimaryPartEntry);
551 
552  if (IsContainerPartition(PrimaryPartEntry->PartitionType))
553  {
554  for (LogicalEntry = DiskEntry->LogicalPartListHead.Flink;
555  LogicalEntry != &DiskEntry->LogicalPartListHead;
556  LogicalEntry = LogicalEntry->Flink)
557  {
558  LogicalPartEntry = CONTAINING_RECORD(LogicalEntry, PARTENTRY, ListEntry);
559 
560  PrintPartitionData(hWndList, List, htiPart,
561  DiskEntry, LogicalPartEntry);
562  }
563 
564  /* Expand the extended partition node */
566  }
567  }
568 
569  /* Expand the disk node */
571 }
572 
573 VOID
575  IN HWND hWndList,
576  IN PPARTLIST List)
577 {
579  PDISKENTRY DiskEntry;
580 
581  for (Entry = List->DiskListHead.Flink;
582  Entry != &List->DiskListHead;
583  Entry = Entry->Flink)
584  {
585  DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
586 
587  /* Print disk entry */
588  PrintDiskData(hWndList, List, DiskEntry);
589  }
590 }
591 
592 
593 
594 INT_PTR
595 CALLBACK
597  HWND hwndDlg,
598  UINT uMsg,
599  WPARAM wParam,
600  LPARAM lParam)
601 {
602  PSETUPDATA pSetupData;
603  HWND hList;
604  HIMAGELIST hSmall;
605 
606  /* Retrieve pointer to the global setup data */
607  pSetupData = (PSETUPDATA)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
608 
609  switch (uMsg)
610  {
611  case WM_INITDIALOG:
612  {
613  /* Save pointer to the global setup data */
614  pSetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
615  SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pSetupData);
616 
617  /*
618  * Keep the "Next" button disabled. It will be enabled only
619  * when the user selects a valid partition.
620  */
622 
623  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
624 
626  // TreeList_SetExtendedStyleEx(hList, TVS_EX_FULLROWITEMS, TVS_EX_FULLROWITEMS);
627 
628  CreateTreeListColumns(pSetupData->hInstance,
629  hList,
630  column_ids,
634 
635  /* Create the ImageList */
638  ILC_COLOR32 | ILC_MASK, // ILC_COLOR24
639  1, 1);
640 
641  /* Add event type icons to the ImageList */
642  ImageList_AddIcon(hSmall, LoadIconW(pSetupData->hInstance, MAKEINTRESOURCEW(IDI_DISKDRIVE)));
643  ImageList_AddIcon(hSmall, LoadIconW(pSetupData->hInstance, MAKEINTRESOURCEW(IDI_PARTITION)));
644 
645  /* Assign the ImageList to the List View */
647 
648  // DisplayStuffUsingWin32Setup(hwndDlg);
649  DrawPartitionList(hList, pSetupData->PartitionList);
650  break;
651  }
652 
653  case WM_DESTROY:
654  {
655  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
658  ImageList_Destroy(hSmall);
659  return TRUE;
660  }
661 
662  case WM_COMMAND:
663  {
664  switch (LOWORD(wParam))
665  {
666  case IDC_PARTMOREOPTS:
667  DialogBoxParamW(pSetupData->hInstance,
669  hwndDlg,
671  (LPARAM)pSetupData);
672  break;
673 
674  case IDC_PARTCREATE:
675  DialogBoxW(pSetupData->hInstance,
677  hwndDlg,
679  break;
680 
681  case IDC_PARTDELETE:
682  break;
683  }
684  break;
685  }
686 
687  case WM_NOTIFY:
688  {
689  LPNMHDR lpnm = (LPNMHDR)lParam;
690 
691  // On Vista+ we can use TVN_ITEMCHANGED instead, with NMTVITEMCHANGE* pointer
692  if (lpnm->idFrom == IDC_PARTITION && lpnm->code == TVN_SELCHANGED)
693  {
695 
696  // if (pnmv->uChanged & TVIF_STATE) /* The state has changed */
697  if (pnmv->itemNew.mask & TVIF_STATE)
698  {
699  /* The item has been (de)selected */
700  // if (pnmv->uNewState & TVIS_SELECTED)
701  if (pnmv->itemNew.state & TVIS_SELECTED)
702  {
703  HTLITEM hParentItem = TreeList_GetParent(lpnm->hwndFrom, pnmv->itemNew.hItem);
704  /* May or may not be a PPARTENTRY: this is a PPARTENTRY only when hParentItem != NULL */
705  PPARTENTRY PartEntry = (PPARTENTRY)pnmv->itemNew.lParam;
706 
707  if (!hParentItem || !PartEntry)
708  {
711  goto DisableWizNext;
712  }
713  else // if (hParentItem && PartEntry)
714  {
715  EnableWindow(GetDlgItem(hwndDlg, IDC_PARTCREATE), !PartEntry->IsPartitioned);
716  EnableWindow(GetDlgItem(hwndDlg, IDC_PARTDELETE), PartEntry->IsPartitioned);
717 
718  if (PartEntry->IsPartitioned &&
719  !IsContainerPartition(PartEntry->PartitionType) /* alternatively: PartEntry->PartitionNumber != 0 */ &&
720  // !PartEntry->New &&
721  (PartEntry->FormatState == Preformatted /* || PartEntry->FormatState == Formatted */))
722  {
724  }
725  else
726  {
727  goto DisableWizNext;
728  }
729  }
730  }
731  else
732  {
733 DisableWizNext:
734  /*
735  * Keep the "Next" button disabled. It will be enabled only
736  * when the user selects a valid partition.
737  */
739  }
740  }
741 
742  break;
743  }
744 
745  switch (lpnm->code)
746  {
747 #if 0
748  case PSN_SETACTIVE:
749  {
750  /*
751  * Keep the "Next" button disabled. It will be enabled only
752  * when the user selects a valid partition.
753  */
755  break;
756  }
757 #endif
758 
760  {
761  /* Give the focus on and select the first item */
762  hList = GetDlgItem(hwndDlg, IDC_PARTITION);
763  // TreeList_SetFocusItem(hList, 1, 1);
766  return TRUE;
767  }
768 
769  case PSN_QUERYCANCEL:
770  {
771  if (MessageBoxW(GetParent(hwndDlg),
772  pSetupData->szAbortMessage,
773  pSetupData->szAbortTitle,
775  {
776  /* Go to the Terminate page */
778  }
779 
780  /* Do not close the wizard too soon */
782  return TRUE;
783  }
784 
785  case PSN_WIZNEXT: /* Set the selected data */
786  {
788 
789  /****/
790  // FIXME: This is my test disk encoding!
791  DISKENTRY DiskEntry;
792  PARTENTRY PartEntry;
793  DiskEntry.DiskNumber = 0;
794  DiskEntry.HwDiskNumber = 0;
795  DiskEntry.HwFixedDiskNumber = 0;
796  PartEntry.DiskEntry = &DiskEntry;
797  PartEntry.PartitionNumber = 1; // 4;
798  /****/
799 
800  Status = InitDestinationPaths(&pSetupData->USetupData,
801  NULL, // pSetupData->USetupData.InstallationDirectory,
802  &PartEntry);
803 
804  if (!NT_SUCCESS(Status))
805  {
806  DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
807  }
808 
809  break;
810  }
811 
812  default:
813  break;
814  }
815  }
816  break;
817 
818  default:
819  break;
820  }
821 
822  return FALSE;
823 }
824 
825 /* 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:1792
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IN
Definition: typedefs.h:38
#define TreeList_SelectItem(h, i)
Definition: treelist.h:430
ULONG PartitionNumber
Definition: partlist.h:49
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:398
#define LVCF_WIDTH
Definition: commctrl.h:2559
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:273
Type
Definition: Type.h:6
struct _Entry Entry
Definition: kefuncs.h:640
#define IDYES
Definition: winuser.h:829
#define LB_ADDSTRING
Definition: winuser.h:1992
Unit
Definition: gdiplusenums.h:25
#define LVCF_TEXT
Definition: commctrl.h:2560
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const INT column_alignment[MAX_LIST_COLUMNS]
Definition: drivepage.c:47
#define TVIS_SELECTED
Definition: commctrl.h:3252
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:2571
#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:27
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:2570
ULONG DiskNumber
Definition: partlist.h:105
#define LPNMTREEVIEW
Definition: commctrl.h:3615
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
#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:2597
#define TL_INSERTSTRUCTW
Definition: treelist.h:462
#define IsContainerPartition(PartitionType)
Definition: ntdddisk.h:245
#define TreeList_GetParent(h, i)
Definition: treelist.h:436
static VOID PrintDiskData(IN HWND hWndList, IN PPARTLIST List, IN PDISKENTRY DiskEntry)
Definition: drivepage.c:391
UINT_PTR WPARAM
Definition: windef.h:207
static const WCHAR Description[]
Definition: oid.c:1266
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3243
uint16_t * PWCHAR
Definition: typedefs.h:54
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:62
static HWND hWndList[5+1]
Definition: SetParent.c:10
#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:56
#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:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:893
#define ILC_COLOR32
Definition: commctrl.h:343
#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:2561
#define PARTITION_ENTRY_UNUSED
Definition: disk.h:86
UINT code
Definition: winuser.h:3112
#define MB
Definition: setuplib.h:53
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
HINSTANCE hInstance
Definition: charmap.c:20
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:769
* PSTORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:457
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#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:55
UINT_PTR idFrom
Definition: winuser.h:3111
#define IDS_LIST_COLUMN_FIRST
Definition: drivepage.c:41
#define GWLP_USERDATA
Definition: treelist.c:63
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
#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:3342
VOID DrawPartitionList(IN HWND hWndList, IN PPARTLIST List)
Definition: drivepage.c:574
#define TreeList_InsertItem(h, p)
Definition: treelist.h:403
#define PropSheet_SetWizButtons(d, f)
Definition: prsht.h:339
#define OPEN_EXISTING
Definition: compat.h:426
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:4268
#define WM_DESTROY
Definition: winuser.h:1591
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
struct _ULARGE_INTEGER::@3737 u
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:167
UCHAR PartitionType
Definition: partlist.h:46
struct _DISKENTRY * DiskEntry
Definition: partlist.h:39
LIST_ENTRY List
Definition: psmgr.c:57
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
if(!(yy_init))
Definition: macro.lex.yy.c:714
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
#define TVN_SELCHANGED
Definition: commctrl.h:3707
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
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:99
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
INT WINAPI ImageList_AddIcon(HIMAGELIST himl, HICON hIcon)
Definition: imagelist.c:505
#define TVE_EXPAND
Definition: commctrl.h:3395
#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:336
static const WCHAR L[]
Definition: oid.c:1250
PARTITION_TYPE PartitionTypes[NUM_PARTITION_TYPE_ENTRIES]
Definition: partlist.c:62
INT_PTR CALLBACK DriveDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drivepage.c:596
PartType
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define ILC_MASK
Definition: commctrl.h:336
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:2587
#define GENERIC_READ
Definition: compat.h:124
Definition: typedefs.h:117
#define WM_COMMAND
Definition: winuser.h:1716
#define SPDRP_DEVICEDESC
Definition: setupapi.h:502
HWND hwndFrom
Definition: winuser.h:3110
uint32_t DWORD_PTR
Definition: typedefs.h:63
Status
Definition: gdiplustypes.h:24
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:2558
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
Definition: partlist.c:273
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
#define TVIF_TEXT
Definition: commctrl.h:3238
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static const GUID GUID_DEVCLASS_DISKDRIVE
Definition: drvdefext.cpp:29
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:100
#define TVIF_IMAGE
Definition: commctrl.h:3239
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
VOID GetPartTypeStringFromPartitionType(IN UCHAR partitionType, OUT PCHAR strPartType, IN ULONG cchPartType)
Definition: drivepage.c:237
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
USETUP_DATA USetupData
Definition: reactos.h:128
#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:400
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:3415
struct _LARGE_INTEGER::@2192 u
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define LPTR
Definition: winbase.h:362
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define TLCOLUMN
Definition: treelist.h:459
#define TVIF_STATE
Definition: commctrl.h:3241
#define SetWindowLongPtrW
Definition: winuser.h:5215
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GB
Definition: setuplib.h:54
#define TVIF_PARAM
Definition: commctrl.h:3240
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:52
NTSTATUS InitDestinationPaths(IN OUT PUSETUP_DATA pSetupData, IN PCWSTR InstallationDir, IN PPARTENTRY PartEntry)
Definition: setuplib.c:624
BYTE * PBYTE
Definition: pedump.c:66
#define WM_INITDIALOG
Definition: winuser.h:1715
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
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:112
BOOLEAN IsPartitioned
Definition: partlist.h:60
#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