ReactOS  0.4.15-dev-2329-g3ad573f
drive.cpp
Go to the documentation of this file.
1 /*
2  * Shell Library Functions
3  *
4  * Copyright 2005 Johannes Anderwald
5  * Copyright 2017 Katayama Hirofumi MZ
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "precomp.h"
23 #include <process.h>
24 
26 
27 typedef struct
28 {
34 
35 EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
37 
38 static BOOL
39 GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
40 {
42 
43  if (!wcsicmp(szFs, L"FAT16") ||
44  !wcsicmp(szFs, L"FAT")) // REACTOS HACK
45  {
46  if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
47  ClusterSize = 2048;
48  else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
49  ClusterSize = 512;
50  else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
51  ClusterSize = 1024;
52  else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
53  ClusterSize = 2048;
54  else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
55  ClusterSize = 4096;
56  else if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
57  ClusterSize = 8192;
58  else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
59  ClusterSize = 16384;
60  else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
61  ClusterSize = 32768;
62  else if (TotalNumberOfBytes->QuadPart <= (4096LL * 1024LL * 1024LL))
63  ClusterSize = 8192;
64  else
65  return FALSE;
66  }
67  else if (!wcsicmp(szFs, L"FAT32"))
68  {
69  if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
70  ClusterSize = 512;
71  else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
72  ClusterSize = 1024;
73  else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
74  ClusterSize = 2048;
75  else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
76  ClusterSize = 2048;
77  else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
78  ClusterSize = 8192;
79  else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
80  ClusterSize = 16384;
81  else
82  return FALSE;
83  }
84  else if (!wcsicmp(szFs, L"FATX"))
85  {
86  if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
87  ClusterSize = 2048;
88  else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
89  ClusterSize = 512;
90  else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
91  ClusterSize = 1024;
92  else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
93  ClusterSize = 2048;
94  else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
95  ClusterSize = 4096;
96  else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
97  ClusterSize = 2048;
98  else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
99  ClusterSize = 8192;
100  else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
101  ClusterSize = 16384;
102  else
103  return FALSE;
104  }
105  else if (!wcsicmp(szFs, L"NTFS"))
106  {
107  if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
108  ClusterSize = 512;
109  else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
110  ClusterSize = 1024;
111  else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
112  ClusterSize = 2048;
113  else
114  ClusterSize = 2048;
115  }
116  else if (!wcsicmp(szFs, L"EXT2"))
117  {
118  // auto block size calculation
119  ClusterSize = 0;
120  }
121  else if (!wcsicmp(szFs, L"BtrFS"))
122  {
123  // auto block size calculation
124  ClusterSize = 0;
125  }
126  else
127  return FALSE;
128 
129  *pClusterSize = ClusterSize;
130  return TRUE;
131 }
132 
133 typedef struct _DRIVE_PROP_PAGE
134 {
139 
140 HRESULT
142 {
143  HPSXA hpsx = NULL;
145  PROPSHEETHEADERW psh;
146  CComObject<CDrvDefExt> *pDrvDefExt = NULL;
147  WCHAR wszName[256];
148 
149  ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
150  psh.dwSize = sizeof(PROPSHEETHEADERW);
151  psh.dwFlags = 0; // FIXME: make it modeless
152  psh.hwndParent = NULL;
153  psh.nStartPage = 0;
154  psh.phpage = hpsp;
155 
156  LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]);
157  if (!completePidl)
158  return E_OUTOFMEMORY;
159 
160  if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL))
161  {
162  psh.pszCaption = wszName;
163  psh.dwFlags |= PSH_PROPTITLE;
164  }
165 
166  ILFree(completePidl);
167 
168  CComPtr<IDataObject> pDataObj;
169  HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj));
170 
171  if (SUCCEEDED(hr))
172  {
173  hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
174  if (SUCCEEDED(hr))
175  {
176  pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
177  hr = pDrvDefExt->Initialize(pidlFolder, pDataObj, NULL);
178  if (SUCCEEDED(hr))
179  {
180  hr = pDrvDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&psh);
181  if (FAILED(hr))
182  ERR("AddPages failed\n");
183  } else
184  ERR("Initialize failed\n");
185  }
186 
188  if (hpsx)
190  }
191 
192  // NOTE: Currently property sheet is modal. If we make it modeless, then it returns HWND.
193  INT_PTR ret = PropertySheetW(&psh);
194 
195  if (hpsx)
197  if (pDrvDefExt)
198  pDrvDefExt->Release();
199 
200  if (ret > 0)
201  return S_OK;
202  if (ret == 0)
203  return S_FALSE;
204  return E_FAIL;
205 }
206 
207 static VOID
209 {
210  WCHAR wszBuf[100] = {0};
211  WCHAR wszDefaultSize[100] = {0};
212  PCWSTR pwszFsSizeLimit;
213  WCHAR szDrive[] = L"C:\\";
214  INT iSelIndex;
215  ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
217  LRESULT lIndex;
218  HWND hDlgCtrl;
219 
220  hDlgCtrl = GetDlgItem(hwndDlg, 28677);
221  iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0);
222  if (iSelIndex == CB_ERR)
223  return;
224 
225  if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
226  return;
227 
228  szDrive[0] = pContext->Drive + L'A';
229 
230  if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
231  return;
232 
233  if (!wcsicmp(wszBuf, L"FAT16") ||
234  !wcsicmp(wszBuf, L"FAT")) // REACTOS HACK
235  {
236  pwszFsSizeLimit = L"4GB";
237  }
238  else if (!wcsicmp(wszBuf, L"FAT32"))
239  {
240  pwszFsSizeLimit = L"32GB";
241  }
242  else if (!wcsicmp(wszBuf, L"FATX"))
243  {
244  pwszFsSizeLimit = L"1GB/32GB";
245  }
246  else if (!wcsicmp(wszBuf, L"NTFS"))
247  {
248  pwszFsSizeLimit = L"256TB";
249  }
250  else if (!wcsicmp(wszBuf, L"EXT2"))
251  {
252  pwszFsSizeLimit = L"32TB";
253  }
254  else
255  {
256  pwszFsSizeLimit = L"16EB";
257  }
258 
259  if (!wcsicmp(wszBuf, L"FAT16") ||
260  !wcsicmp(wszBuf, L"FAT") || // REACTOS HACK
261  !wcsicmp(wszBuf, L"FAT32") ||
262  !wcsicmp(wszBuf, L"FATX") ||
263  !wcsicmp(wszBuf, L"NTFS") ||
264  !wcsicmp(wszBuf, L"EXT2") ||
265  !wcsicmp(wszBuf, L"BtrFS"))
266  {
267  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
268  {
269  TRACE("%S is not supported on drive larger than %S, current size: %lu\n", wszBuf, pwszFsSizeLimit, TotalNumberOfBytes.QuadPart);
270  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
271  return;
272  }
273 
274  if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszDefaultSize, _countof(wszDefaultSize)))
275  {
276  hDlgCtrl = GetDlgItem(hwndDlg, 28680); // Get the window handle of "allocation unit size" combobox
277  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
278  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
279  if (lIndex != CB_ERR)
280  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
281  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
282  }
283 
284  if (!wcsicmp(wszBuf, L"NTFS"))
285  {
286  ClusterSize = 512;
287  for (lIndex = 0; lIndex < 4; lIndex++)
288  {
289  TotalNumberOfBytes.QuadPart = ClusterSize;
290  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszDefaultSize, _countof(wszDefaultSize)))
291  {
292  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
293  if (lIndex != CB_ERR)
294  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
295  }
296  ClusterSize *= 2;
297  }
298  }
299 
300  SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
301  if (!wcsicmp(wszBuf, L"EXT2") ||
302  !wcsicmp(wszBuf, L"BtrFS") ||
303  !wcsicmp(wszBuf, L"NTFS"))
304  {
305  /* Enable the "Enable Compression" button */
306  EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
307  }
308  else
309  {
310  /* Disable the "Enable Compression" button */
311  EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
312  }
313  }
314  else
315  {
316  FIXME("Unknown filesystem: %ls\n", wszBuf);
317  SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0);
318  return;
319  }
320 }
321 
322 static VOID
324 {
325  WCHAR szText[120];
326  WCHAR szDrive[] = L"C:\\";
327  WCHAR szFs[30] = L"";
328  INT cchText;
329  ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
330  DWORD dwIndex, dwDefault;
331  UCHAR uMinor, uMajor;
332  BOOLEAN Latest;
333  HWND hwndFileSystems;
334 
335  cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
336  if (cchText < 0)
337  cchText = 0;
338  szText[cchText++] = L' ';
339  szDrive[0] = pContext->Drive + L'A';
340  if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
341  {
342  if (szText[cchText] == UNICODE_NULL)
343  {
344  /* load default volume label */
346  }
347  else
348  {
349  /* set volume label */
350  SetDlgItemTextW(hwndDlg, 28679, &szText[cchText]);
352  }
353  }
354 
355  StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
356 
357  /* set window text */
358  SetWindowTextW(hwndDlg, szText);
359 
360  if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
361  {
362  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
363  {
364  /* add drive capacity */
365  SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
366  SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0);
367  }
368  }
369 
370  if (pContext->Options & SHFMT_OPT_FULL)
371  {
372  /* check quick format button */
373  SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0);
374  }
375 
376  /* enumerate all available filesystems */
377  dwIndex = 0;
378  dwDefault = 0;
379  hwndFileSystems = GetDlgItem(hwndDlg, 28677);
380 
381  while(QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest))
382  {
383  if (!wcsicmp(szText, szFs))
384  dwDefault = dwIndex;
385 
386  SendMessageW(hwndFileSystems, CB_ADDSTRING, 0, (LPARAM)szText);
387  dwIndex++;
388  }
389 
390  if (!dwIndex)
391  {
392  ERR("no filesystem providers\n");
393  return;
394  }
395 
396  /* select default filesys */
397  SendMessageW(hwndFileSystems, CB_SETCURSEL, dwDefault, 0);
398  /* setup cluster combo */
399  InsertDefaultClusterSizeForFs(hwndDlg, pContext);
400 }
401 
404 
405 static BOOLEAN NTAPI
408  IN ULONG SubAction,
409  IN PVOID ActionInfo)
410 {
411  PDWORD Progress;
412  PBOOLEAN pSuccess;
413  switch(Command)
414  {
415  case PROGRESS:
416  Progress = (PDWORD)ActionInfo;
417  SendDlgItemMessageW(FormatDrvDialog, 28678, PBM_SETPOS, (WPARAM)*Progress, 0);
418  break;
419  case DONE:
420  pSuccess = (PBOOLEAN)ActionInfo;
421  bSuccess = (*pSuccess);
424  break;
425 
426  case VOLUMEINUSE:
427  case INSUFFICIENTRIGHTS:
428  case FSNOTSUPPORTED:
429  case CLUSTERSIZETOOSMALL:
430  bSuccess = FALSE;
431  FIXME("Unsupported command in FormatExCB\n");
432  break;
433 
434  default:
435  break;
436  }
437 
438  return TRUE;
439 }
440 
441 VOID
443 {
444  WCHAR szDrive[4] = { L'C', ':', '\\', 0 };
445  WCHAR szFileSys[40] = {0};
446  WCHAR szLabel[40] = {0};
447  INT iSelIndex;
448  UINT Length;
449  HWND hDlgCtrl;
453  FMIFS_MEDIA_FLAG MediaFlag = FMIFS_HARDDISK;
454 
455  /* set volume path */
456  szDrive[0] = pContext->Drive + L'A';
457 
458  /* get filesystem */
459  hDlgCtrl = GetDlgItem(hwndDlg, 28677);
460  iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
461  if (iSelIndex == CB_ERR)
462  {
463  ERR("Unable to get file system selection\n");
464  return;
465  }
466  Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
467  if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
468  {
469  ERR("Unable to get file system selection\n");
470  return;
471  }
472 
473  /* retrieve the file system */
474  SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
475  szFileSys[_countof(szFileSys)-1] = L'\0';
476 
477  /* retrieve the volume label */
478  hDlgCtrl = GetWindow(hwndDlg, 28679);
479  Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
480  if (Length + 1 > _countof(szLabel))
481  {
482  ERR("Unable to get volume label\n");
483  return;
484  }
485  SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
486  szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
487 
488  /* check for quickformat */
489  if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED)
490  QuickFormat = TRUE;
491  else
492  QuickFormat = FALSE;
493 
494  /* get the cluster size */
495  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
496  iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
497  if (iSelIndex == CB_ERR)
498  {
499  FIXME("\n");
500  return;
501  }
502  ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0);
503  if ((int)ClusterSize == CB_ERR)
504  {
505  FIXME("\n");
506  return;
507  }
508 
509  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
510  SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
511  bSuccess = FALSE;
512 
513  /* FIXME
514  * will cause display problems
515  * when performing more than one format
516  */
517  FormatDrvDialog = hwndDlg;
518 
519  /* See if the drive is removable or not */
520  DriveType = GetDriveTypeW(szDrive);
521  switch (DriveType)
522  {
523  case DRIVE_UNKNOWN:
524  case DRIVE_REMOTE:
525  case DRIVE_CDROM:
526  case DRIVE_NO_ROOT_DIR:
527  {
528  FIXME("\n");
529  return;
530  }
531 
532  case DRIVE_REMOVABLE:
533  MediaFlag = FMIFS_FLOPPY;
534  break;
535 
536  case DRIVE_FIXED:
537  case DRIVE_RAMDISK:
538  MediaFlag = FMIFS_HARDDISK;
539  break;
540  }
541 
542  /* Format the drive */
543  FormatEx(szDrive,
544  MediaFlag,
545  szFileSys,
546  szLabel,
547  QuickFormat,
548  ClusterSize,
549  FormatExCB);
550 
552  if (!bSuccess)
553  {
554  pContext->Result = SHFMT_ERROR;
555  }
556  else if (QuickFormat)
557  {
558  pContext->Result = SHFMT_OPT_FULL;
559  }
560  else
561  {
562  pContext->Result = FALSE;
563  }
564 }
565 
567 {
570 };
571 
572 static unsigned __stdcall DoFormatDrive(void *args)
573 {
574  FORMAT_DRIVE_PARAMS *pParams = reinterpret_cast<FORMAT_DRIVE_PARAMS *>(args);
575  HWND hwndDlg = pParams->hwndDlg;
576  PFORMAT_DRIVE_CONTEXT pContext = pParams->pContext;
577 
578  /* Disable controls during format */
579  HMENU hSysMenu = GetSystemMenu(hwndDlg, FALSE);
581  EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
583  EnableWindow(GetDlgItem(hwndDlg, 28673), FALSE);
584  EnableWindow(GetDlgItem(hwndDlg, 28677), FALSE);
585  EnableWindow(GetDlgItem(hwndDlg, 28680), FALSE);
586  EnableWindow(GetDlgItem(hwndDlg, 28679), FALSE);
587  EnableWindow(GetDlgItem(hwndDlg, 28674), FALSE);
588 
589  FormatDrive(hwndDlg, pContext);
590 
591  /* Re-enable controls after format */
592  EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
593  EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), TRUE);
594  EnableWindow(GetDlgItem(hwndDlg, 28673), TRUE);
595  EnableWindow(GetDlgItem(hwndDlg, 28677), TRUE);
596  EnableWindow(GetDlgItem(hwndDlg, 28680), TRUE);
597  EnableWindow(GetDlgItem(hwndDlg, 28679), TRUE);
598  EnableWindow(GetDlgItem(hwndDlg, 28674), TRUE);
600  pContext->bFormattingNow = FALSE;
601 
602  delete pParams;
603  return 0;
604 }
605 
606 static INT_PTR CALLBACK
608 {
609  PFORMAT_DRIVE_CONTEXT pContext;
610 
611  switch(uMsg)
612  {
613  case WM_INITDIALOG:
616  return TRUE;
617  case WM_COMMAND:
618  switch(LOWORD(wParam))
619  {
620  case IDOK:
621  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
622  if (pContext->bFormattingNow)
623  break;
624 
625  if (ShellMessageBoxW(shell32_hInstance, hwndDlg,
629  {
630  pContext->bFormattingNow = TRUE;
631 
633  pParams->hwndDlg = hwndDlg;
634  pParams->pContext = pContext;
635 
636  unsigned tid;
637  HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, DoFormatDrive, pParams, 0, &tid);
639  }
640  break;
641  case IDCANCEL:
642  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
643  if (pContext->bFormattingNow)
644  break;
645 
646  EndDialog(hwndDlg, pContext->Result);
647  break;
648  case 28677: // filesystem combo
649  if (HIWORD(wParam) == CBN_SELENDOK)
650  {
651  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
652  if (pContext->bFormattingNow)
653  break;
654 
655  InsertDefaultClusterSizeForFs(hwndDlg, pContext);
656  }
657  break;
658  }
659  }
660  return FALSE;
661 }
662 
663 /*************************************************************************
664  * SHFormatDrive (SHELL32.@)
665  */
666 
667 DWORD
668 WINAPI
670 {
672  int result;
673 
674  TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
675 
676  Context.Drive = drive;
677  Context.Options = options;
678  Context.Result = FALSE;
679  Context.bFormattingNow = FALSE;
680 
682 
683  return result;
684 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2162
#define WM_GETTEXTLENGTH
Definition: winuser.h:1601
HWND hwndParent
Definition: prsht.h:295
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
#define CB_SETITEMDATA
Definition: winuser.h:1948
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
struct _DRIVE_PROP_PAGE DRIVE_PROP_PAGE
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define IN
Definition: typedefs.h:39
#define CB_GETLBTEXTLEN
Definition: winuser.h:1935
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:598
#define LL
Definition: tui.h:84
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:128
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MF_BYCOMMAND
Definition: winuser.h:202
HRESULT hr
Definition: shlfolder.c:183
GLuint64EXT * result
Definition: glext.h:11304
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HRESULT WINAPI SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv)
#define TRUE
Definition: types.h:120
#define CB_GETLBTEXT
Definition: winuser.h:1934
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1984
#define SHFMT_ERROR
Definition: shlobj.h:292
#define CB_GETITEMDATA
Definition: winuser.h:1932
#define WM_GETTEXT
Definition: winuser.h:1600
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define DRIVE_RAMDISK
Definition: winbase.h:252
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define CALLBACK
Definition: compat.h:35
Definition: fmifs.h:68
UINT DriveType
#define ZeroMemory
Definition: winbase.h:1664
#define PBM_SETPOS
Definition: commctrl.h:2180
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
struct _PROPSHEETHEADERW PROPSHEETHEADERW
Definition: shell.h:41
int32_t INT_PTR
Definition: typedefs.h:64
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
CALLBACKCOMMAND
Definition: fmifs.h:66
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
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
static BOOLEAN bSuccess
Definition: drive.cpp:403
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1925
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define DRIVE_REMOVABLE
Definition: winbase.h:248
#define MB_ICONWARNING
Definition: winuser.h:780
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:208
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
static HWND FormatDrvDialog
Definition: drive.cpp:402
#define PBM_SETRANGE
Definition: commctrl.h:2179
#define DRIVE_REMOTE
Definition: winbase.h:250
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define DRIVE_CDROM
Definition: machpc98.h:115
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
static const WCHAR szText[]
Definition: dialog.c:139
LPCWSTR pszCaption
Definition: prsht.h:301
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CBN_SELENDOK
Definition: winuser.h:1963
if SUCCEEDED(hr)
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define FIXME(fmt,...)
Definition: debug.h:111
#define S_FALSE
Definition: winerror.h:2357
#define CB_ADDSTRING
Definition: winuser.h:1918
unsigned char BOOLEAN
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
VOID FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:442
#define ILGDN_NORMAL
Definition: undocshell.h:69
LONG_PTR LPARAM
Definition: windef.h:208
#define MB_OKCANCEL
Definition: winuser.h:798
#define BM_GETCHECK
Definition: winuser.h:1900
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2905
const char * LPCSTR
Definition: xmlstorage.h:183
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
BOOL QuickFormat
Definition: format.c:66
#define CB_RESETCONTENT
Definition: winuser.h:1941
int options
Definition: main.c:106
#define DRIVE_UNKNOWN
Definition: winbase.h:253
#define CB_ERR
Definition: winuser.h:2410
_In_ int cchText
Definition: winuser.h:4440
#define BM_SETCHECK
Definition: winuser.h:1903
#define TRACE(s)
Definition: solgame.cpp:4
#define IDS_DRIVE_FIXED
Definition: shresdef.h:111
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PSH_PROPTITLE
Definition: prsht.h:40
LONG HRESULT
Definition: typedefs.h:79
VOID NTAPI FormatEx(IN PWCHAR DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PWCHAR Format, IN PWCHAR Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: format.c:38
#define IDS_FORMAT_WARNING
Definition: shresdef.h:197
#define _countof(array)
Definition: sndvol32.h:68
#define MF_ENABLED
Definition: winuser.h:128
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:406
DWORD ClusterSize
Definition: format.c:67
#define WINAPI
Definition: msvc.h:6
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define __stdcall
Definition: typedefs.h:25
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static VOID InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:323
#define IDS_FORMAT_TITLE
Definition: shresdef.h:196
#define wcsicmp
Definition: compat.h:15
#define MB_ICONINFORMATION
Definition: winuser.h:796
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
char * PBOOLEAN
Definition: retypes.h:11
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1250
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:482
#define DWLP_USER
Definition: winuser.h:866
#define IDS_FORMAT_COMPLETE
Definition: shresdef.h:198
#define CB_SETCURSEL
Definition: winuser.h:1943
#define WM_COMMAND
Definition: winuser.h:1722
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define BST_UNCHECKED
Definition: winuser.h:199
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:254
#define DRIVE_FIXED
Definition: winbase.h:249
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2871
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
#define ERR(fmt,...)
Definition: debug.h:110
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:669
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define S_OK
Definition: intsafe.h:51
static char drive[2]
Definition: batch.c:28
#define shell32_hInstance
HRESULT SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
Definition: drive.cpp:141
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:607
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
FxAutoRegKey hKey
PFORMAT_DRIVE_CONTEXT pContext
Definition: drive.cpp:569
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
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ShellMessageBoxW
Definition: precomp.h:58
DLGPROC dlgproc
Definition: drive.cpp:136
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
HANDLE hThread
Definition: wizard.c:28
DWORD * PDWORD
Definition: pedump.c:68
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:219
#define BST_CHECKED
Definition: winuser.h:197
#define SC_CLOSE
Definition: winuser.h:2567
#define SHFMT_OPT_FULL
Definition: shlobj.h:298
struct tagContext Context
Definition: acpixf.h:1034
#define SendMessage
Definition: winuser.h:5818
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
#define HIWORD(l)
Definition: typedefs.h:247
unsigned int ULONG
Definition: retypes.h:1
static unsigned __stdcall DoFormatDrive(void *args)
Definition: drive.cpp:572
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
#define DONE
Definition: rnr20lib.h:14
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
#define MF_GRAYED
Definition: winuser.h:129
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define CB_DELETESTRING
Definition: winuser.h:1919
LONG_PTR LRESULT
Definition: windef.h:209
#define EXTERN_C
Definition: basetyps.h:12
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPCSTR resname
Definition: drive.cpp:135
#define MAX_PROPERTY_SHEET_PAGE
static TfClientId tid
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
Definition: drive.cpp:39
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342
WINE_DEFAULT_DEBUG_CHANNEL(shell)
FMIFS_MEDIA_FLAG
Definition: fmifs.h:37
BOOLEAN NTAPI QueryAvailableFileSystemFormat(IN DWORD Index, IN OUT PWCHAR FileSystem, OUT UCHAR *Major, OUT UCHAR *Minor, OUT BOOLEAN *LatestVersion)
Definition: query.c:14
UINT nStartPage
Definition: prsht.h:304