ReactOS 0.4.15-dev-8434-g155a7c7
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
27typedef struct
28{
34
37
38/*
39 * TODO: In Windows the Shell doesn't know by itself if a drive is
40 * a system one or not but rather a packet message is being sent by
41 * FMIFS library code and further translated into specific packet
42 * status codes in the Shell, the packet being _FMIFS_PACKET_TYPE.
43 *
44 * With that being said, most of this code as well as FMIFS library code
45 * have to be refactored in order to comply with the way Windows works.
46 *
47 * See the enum definition for more details:
48 * https://github.com/microsoft/winfile/blob/master/src/fmifs.h#L23
49 */
50static BOOL
52{
53 WCHAR wszDriveLetter[6], wszSystemDrv[6];
54
55 wszDriveLetter[0] = pContext->Drive + L'A';
56 StringCchCatW(wszDriveLetter, _countof(wszDriveLetter), L":");
57
58 if (!GetEnvironmentVariableW(L"SystemDrive", wszSystemDrv, _countof(wszSystemDrv)))
59 return FALSE;
60
61 if (!wcsicmp(wszDriveLetter, wszSystemDrv))
62 return TRUE;
63
64 return FALSE;
65}
66
67static BOOL
68GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
69{
71
72 if (!wcsicmp(szFs, L"FAT16") ||
73 !wcsicmp(szFs, L"FAT")) // REACTOS HACK
74 {
75 if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
76 ClusterSize = 2048;
77 else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
78 ClusterSize = 512;
79 else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
80 ClusterSize = 1024;
81 else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
82 ClusterSize = 2048;
83 else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
84 ClusterSize = 4096;
85 else if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
86 ClusterSize = 8192;
87 else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
88 ClusterSize = 16384;
89 else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
90 ClusterSize = 32768;
91 else if (TotalNumberOfBytes->QuadPart <= (4096LL * 1024LL * 1024LL))
92 ClusterSize = 8192;
93 else
94 return FALSE;
95 }
96 else if (!wcsicmp(szFs, L"FAT32"))
97 {
98 if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
99 ClusterSize = 512;
100 else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
101 ClusterSize = 1024;
102 else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
103 ClusterSize = 2048;
104 else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
105 ClusterSize = 2048;
106 else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
107 ClusterSize = 8192;
108 else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
109 ClusterSize = 16384;
110 else
111 return FALSE;
112 }
113 else if (!wcsicmp(szFs, L"FATX"))
114 {
115 if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
116 ClusterSize = 2048;
117 else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
118 ClusterSize = 512;
119 else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
120 ClusterSize = 1024;
121 else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
122 ClusterSize = 2048;
123 else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
124 ClusterSize = 4096;
125 else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
126 ClusterSize = 2048;
127 else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
128 ClusterSize = 8192;
129 else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
130 ClusterSize = 16384;
131 else
132 return FALSE;
133 }
134 else if (!wcsicmp(szFs, L"NTFS"))
135 {
136 if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
137 ClusterSize = 512;
138 else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
139 ClusterSize = 1024;
140 else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
141 ClusterSize = 2048;
142 else
143 ClusterSize = 2048;
144 }
145 else if (!wcsicmp(szFs, L"EXT2"))
146 {
147 // auto block size calculation
148 ClusterSize = 0;
149 }
150 else if (!wcsicmp(szFs, L"BtrFS"))
151 {
152 // auto block size calculation
153 ClusterSize = 0;
154 }
155 else
156 return FALSE;
157
158 *pClusterSize = ClusterSize;
159 return TRUE;
160}
161
162typedef struct _DRIVE_PROP_PAGE
163{
168
170{
173};
174
175static DWORD WINAPI
177{
179 CHeapPtr<WCHAR, CComAllocator> pwszDrive(pPropData->pwszDrive);
180
181 // Unmarshall IDataObject from IStream
182 CComPtr<IDataObject> pDataObj;
183 CoGetInterfaceAndReleaseStream(pPropData->pStream, IID_PPV_ARG(IDataObject, &pDataObj));
184
185 HPSXA hpsx = NULL;
187 CComObject<CDrvDefExt> *pDrvDefExt = NULL;
188
189 CDataObjectHIDA cida(pDataObj);
190 if (FAILED_UNEXPECTEDLY(cida.hr()))
191 return FAILED(cida.hr());
192
193 RECT rcPosition = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0};
194 POINT pt;
195 if (SUCCEEDED(DataObject_GetOffset(pDataObj, &pt)))
196 {
197 rcPosition.left = pt.x;
198 rcPosition.top = pt.y;
199 }
200
204 if (!stub.Create(NULL, rcPosition, NULL, style, exstyle))
205 {
206 ERR("StubWindow32 creation failed\n");
207 return FALSE;
208 }
209
210 PROPSHEETHEADERW psh = {sizeof(PROPSHEETHEADERW)};
212 psh.pszCaption = pwszDrive;
213 psh.hwndParent = stub;
214 psh.nStartPage = 0;
215 psh.phpage = hpsp;
216
217 HRESULT hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
218 if (SUCCEEDED(hr))
219 {
220 pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
221 hr = pDrvDefExt->Initialize(HIDA_GetPIDLFolder(cida), pDataObj, NULL);
222 if (SUCCEEDED(hr))
223 {
224 hr = pDrvDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&psh);
225 if (FAILED(hr))
226 ERR("AddPages failed\n");
227 }
228 else
229 {
230 ERR("Initialize failed\n");
231 }
232 }
233
235 if (hpsx)
237
238 INT_PTR ret = PropertySheetW(&psh);
239
240 if (hpsx)
242 if (pDrvDefExt)
243 pDrvDefExt->Release();
244
245 stub.DestroyWindow();
246
247 return ret != -1;
248}
249
250BOOL
252{
253 HRESULT hr = SHStrDupW(pwszDrive, &pwszDrive);
255 return FALSE;
256
257 // Prepare data for thread
259 if (!pData)
260 {
261 SHFree(pwszDrive);
262 return FALSE;
263 }
264 pData->pwszDrive = pwszDrive;
265
266 // Marshall IDataObject to IStream
268 if (SUCCEEDED(hr))
269 {
270 // Run a property sheet in another thread
272 return TRUE; // Success
273
274 pData->pStream->Release();
275 }
276 SHFree(pData);
277 SHFree(pwszDrive);
278 return FALSE; // Failed
279}
280
281static VOID
283{
284 WCHAR wszBuf[100] = {0};
285 WCHAR wszDefaultSize[100] = {0};
286 PCWSTR pwszFsSizeLimit;
287 WCHAR szDrive[] = L"C:\\";
288 INT iSelIndex;
289 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
291 LRESULT lIndex;
292 HWND hDlgCtrl;
293
294 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
295 iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0);
296 if (iSelIndex == CB_ERR)
297 return;
298
299 if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
300 return;
301
302 szDrive[0] = pContext->Drive + L'A';
303
304 if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
305 return;
306
307 if (!wcsicmp(wszBuf, L"FAT16") ||
308 !wcsicmp(wszBuf, L"FAT")) // REACTOS HACK
309 {
310 pwszFsSizeLimit = L"4GB";
311 }
312 else if (!wcsicmp(wszBuf, L"FAT32"))
313 {
314 pwszFsSizeLimit = L"32GB";
315 }
316 else if (!wcsicmp(wszBuf, L"FATX"))
317 {
318 pwszFsSizeLimit = L"1GB/32GB";
319 }
320 else if (!wcsicmp(wszBuf, L"NTFS"))
321 {
322 pwszFsSizeLimit = L"256TB";
323 }
324 else if (!wcsicmp(wszBuf, L"EXT2"))
325 {
326 pwszFsSizeLimit = L"32TB";
327 }
328 else
329 {
330 pwszFsSizeLimit = L"16EB";
331 }
332
333 if (!wcsicmp(wszBuf, L"FAT16") ||
334 !wcsicmp(wszBuf, L"FAT") || // REACTOS HACK
335 !wcsicmp(wszBuf, L"FAT32") ||
336 !wcsicmp(wszBuf, L"FATX") ||
337 !wcsicmp(wszBuf, L"NTFS") ||
338 !wcsicmp(wszBuf, L"EXT2") ||
339 !wcsicmp(wszBuf, L"BtrFS"))
340 {
341 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
342 {
343 TRACE("%S is not supported on drive larger than %S, current size: %lu\n", wszBuf, pwszFsSizeLimit, TotalNumberOfBytes.QuadPart);
344 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
345 return;
346 }
347
348 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszDefaultSize, _countof(wszDefaultSize)))
349 {
350 hDlgCtrl = GetDlgItem(hwndDlg, 28680); // Get the window handle of "allocation unit size" combobox
351 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
352 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
353 if (lIndex != CB_ERR)
354 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
355 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
356 }
357
358 if (!wcsicmp(wszBuf, L"NTFS"))
359 {
360 ClusterSize = 512;
361 for (lIndex = 0; lIndex < 4; lIndex++)
362 {
363 TotalNumberOfBytes.QuadPart = ClusterSize;
364 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszDefaultSize, _countof(wszDefaultSize)))
365 {
366 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
367 if (lIndex != CB_ERR)
368 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
369 }
370 ClusterSize *= 2;
371 }
372 }
373
374 SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
375 if (!wcsicmp(wszBuf, L"EXT2") ||
376 !wcsicmp(wszBuf, L"BtrFS") ||
377 !wcsicmp(wszBuf, L"NTFS"))
378 {
379 /* Enable the "Enable Compression" button */
380 EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
381 }
382 else
383 {
384 /* Disable the "Enable Compression" button */
385 EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
386 }
387 }
388 else
389 {
390 FIXME("Unknown filesystem: %ls\n", wszBuf);
391 SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0);
392 return;
393 }
394}
395
396static VOID
398{
399 WCHAR szText[120];
400 WCHAR szDrive[] = L"C:\\";
401 WCHAR szFs[30] = L"";
402 INT cchText;
403 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
404 DWORD dwIndex, dwDefault;
405 UCHAR uMinor, uMajor;
406 BOOLEAN Latest;
407 HWND hwndFileSystems;
408
409 cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
410 if (cchText < 0)
411 cchText = 0;
412 szText[cchText++] = L' ';
413 szDrive[0] = pContext->Drive + L'A';
414 if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
415 {
416 if (szText[cchText] == UNICODE_NULL)
417 {
418 /* load default volume label */
420 }
421 else
422 {
423 /* set volume label */
424 SetDlgItemTextW(hwndDlg, 28679, &szText[cchText]);
425 cchText += wcslen(&szText[cchText]);
426 }
427 }
428
429 StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
430
431 /* set window text */
432 SetWindowTextW(hwndDlg, szText);
433
434 if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
435 {
436 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
437 {
438 /* add drive capacity */
439 SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
440 SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0);
441 }
442 }
443
444 if (pContext->Options & SHFMT_OPT_FULL)
445 {
446 /* check quick format button */
447 SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0);
448 }
449
450 /* enumerate all available filesystems */
451 dwIndex = 0;
452 dwDefault = 0;
453 hwndFileSystems = GetDlgItem(hwndDlg, 28677);
454
455 while(QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest))
456 {
457 if (!wcsicmp(szText, szFs))
458 dwDefault = dwIndex;
459
460 SendMessageW(hwndFileSystems, CB_ADDSTRING, 0, (LPARAM)szText);
461 dwIndex++;
462 }
463
464 if (!dwIndex)
465 {
466 ERR("no filesystem providers\n");
467 return;
468 }
469
470 /* select default filesys */
471 SendMessageW(hwndFileSystems, CB_SETCURSEL, dwDefault, 0);
472 /* setup cluster combo */
473 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
474}
475
478
479static BOOLEAN NTAPI
482 IN ULONG SubAction,
483 IN PVOID ActionInfo)
484{
485 PDWORD Progress;
486 PBOOLEAN pSuccess;
487 switch(Command)
488 {
489 case PROGRESS:
490 Progress = (PDWORD)ActionInfo;
492 break;
493 case DONE:
494 pSuccess = (PBOOLEAN)ActionInfo;
495 bSuccess = (*pSuccess);
498 break;
499
500 case VOLUMEINUSE:
502 case FSNOTSUPPORTED:
504 bSuccess = FALSE;
505 FIXME("Unsupported command in FormatExCB\n");
506 break;
507
508 default:
509 break;
510 }
511
512 return TRUE;
513}
514
515VOID
517{
518 WCHAR szDrive[4] = { L'C', ':', '\\', 0 };
519 WCHAR szFileSys[40] = {0};
520 WCHAR szLabel[40] = {0};
521 INT iSelIndex;
522 UINT Length;
523 HWND hDlgCtrl;
528
529 /* set volume path */
530 szDrive[0] = pContext->Drive + L'A';
531
532 /* get filesystem */
533 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
534 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
535 if (iSelIndex == CB_ERR)
536 {
537 ERR("Unable to get file system selection\n");
538 return;
539 }
540 Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
541 if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
542 {
543 ERR("Unable to get file system selection\n");
544 return;
545 }
546
547 /* retrieve the file system */
548 SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
549 szFileSys[_countof(szFileSys)-1] = L'\0';
550
551 /* retrieve the volume label */
552 hDlgCtrl = GetWindow(hwndDlg, 28679);
553 Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
554 if (Length + 1 > _countof(szLabel))
555 {
556 ERR("Unable to get volume label\n");
557 return;
558 }
559 SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
560 szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
561
562 /* check for quickformat */
563 if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED)
565 else
567
568 /* get the cluster size */
569 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
570 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
571 if (iSelIndex == CB_ERR)
572 {
573 FIXME("\n");
574 return;
575 }
576 ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0);
577 if ((int)ClusterSize == CB_ERR)
578 {
579 FIXME("\n");
580 return;
581 }
582
583 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
584 SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
585 bSuccess = FALSE;
586
587 /* FIXME
588 * will cause display problems
589 * when performing more than one format
590 */
591 FormatDrvDialog = hwndDlg;
592
593 /* See if the drive is removable or not */
594 DriveType = GetDriveTypeW(szDrive);
595 switch (DriveType)
596 {
597 case DRIVE_UNKNOWN:
598 case DRIVE_REMOTE:
599 case DRIVE_CDROM:
601 {
602 FIXME("\n");
603 return;
604 }
605
606 case DRIVE_REMOVABLE:
607 MediaFlag = FMIFS_FLOPPY;
608 break;
609
610 case DRIVE_FIXED:
611 case DRIVE_RAMDISK:
612 MediaFlag = FMIFS_HARDDISK;
613 break;
614 }
615
616 /* Format the drive */
617 FormatEx(szDrive,
618 MediaFlag,
619 szFileSys,
620 szLabel,
623 FormatExCB);
624
626 if (!bSuccess)
627 {
628 pContext->Result = SHFMT_ERROR;
629 }
630 else if (QuickFormat)
631 {
632 pContext->Result = SHFMT_OPT_FULL;
633 }
634 else
635 {
636 pContext->Result = FALSE;
637 }
638}
639
641{
644};
645
646static unsigned __stdcall DoFormatDrive(void *args)
647{
648 FORMAT_DRIVE_PARAMS *pParams = reinterpret_cast<FORMAT_DRIVE_PARAMS *>(args);
649 HWND hwndDlg = pParams->hwndDlg;
650 PFORMAT_DRIVE_CONTEXT pContext = pParams->pContext;
651
652 /* Disable controls during format */
653 HMENU hSysMenu = GetSystemMenu(hwndDlg, FALSE);
655 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
657 EnableWindow(GetDlgItem(hwndDlg, 28673), FALSE);
658 EnableWindow(GetDlgItem(hwndDlg, 28677), FALSE);
659 EnableWindow(GetDlgItem(hwndDlg, 28680), FALSE);
660 EnableWindow(GetDlgItem(hwndDlg, 28679), FALSE);
661 EnableWindow(GetDlgItem(hwndDlg, 28674), FALSE);
662
663 FormatDrive(hwndDlg, pContext);
664
665 /* Re-enable controls after format */
666 EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
668 EnableWindow(GetDlgItem(hwndDlg, 28673), TRUE);
669 EnableWindow(GetDlgItem(hwndDlg, 28677), TRUE);
670 EnableWindow(GetDlgItem(hwndDlg, 28680), TRUE);
671 EnableWindow(GetDlgItem(hwndDlg, 28679), TRUE);
672 EnableWindow(GetDlgItem(hwndDlg, 28674), TRUE);
674 pContext->bFormattingNow = FALSE;
675
676 delete pParams;
677 return 0;
678}
679
680static INT_PTR CALLBACK
682{
683 PFORMAT_DRIVE_CONTEXT pContext;
684
685 switch(uMsg)
686 {
687 case WM_INITDIALOG:
690 return TRUE;
691 case WM_COMMAND:
692 switch(LOWORD(wParam))
693 {
694 case IDOK:
696 if (pContext->bFormattingNow)
697 break;
698
703 {
704 pContext->bFormattingNow = TRUE;
705
707 pParams->hwndDlg = hwndDlg;
708 pParams->pContext = pContext;
709
710 unsigned tid;
713 }
714 break;
715 case IDCANCEL:
717 if (pContext->bFormattingNow)
718 break;
719
720 EndDialog(hwndDlg, pContext->Result);
721 break;
722 case 28677: // filesystem combo
723 if (HIWORD(wParam) == CBN_SELENDOK)
724 {
726 if (pContext->bFormattingNow)
727 break;
728
729 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
730 }
731 break;
732 }
733 }
734 return FALSE;
735}
736
737/*************************************************************************
738 * SHFormatDrive (SHELL32.@)
739 */
740
741DWORD
742WINAPI
744{
746 int result;
747
748 TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
749
750 Context.Drive = drive;
751 Context.Options = options;
752 Context.Result = FALSE;
753 Context.bFormattingNow = FALSE;
754
755 if (!IsSystemDrive(&Context))
756 {
758 }
759 else
760 {
763 TRACE("SHFormatDrive(): The provided drive for format is a system volume! Aborting...\n");
764 }
765
766 return result;
767}
UINT DriveType
unsigned char BOOLEAN
#define shell32_hInstance
Arabic default style
Definition: afstyles.h:94
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL QuickFormat
Definition: format.c:66
DWORD ClusterSize
Definition: format.c:67
#define EXTERN_C
Definition: basetyps.h:12
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DLGPROC
Definition: maze.c:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2913
#define CloseHandle
Definition: compat.h:739
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define CALLBACK
Definition: compat.h:35
#define wcsicmp
Definition: compat.h:15
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
BOOLEAN NTAPI QueryAvailableFileSystemFormat(IN DWORD Index, IN OUT PWCHAR FileSystem, OUT UCHAR *Major, OUT UCHAR *Minor, OUT BOOLEAN *LatestVersion)
Definition: query.c:14
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
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
HRESULT WINAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM *ppStm)
Definition: marshal.c:2100
HRESULT WINAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID riid, LPVOID *ppv)
Definition: marshal.c:2144
#define ShellMessageBoxW
Definition: precomp.h:62
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:135
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2012
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
#define pt(x, y)
Definition: drawing.c:79
static HWND FormatDrvDialog
Definition: drive.cpp:476
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
static BOOLEAN bSuccess
Definition: drive.cpp:477
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:480
BOOL SH_ShowDriveProperties(WCHAR *pwszDrive, IDataObject *pDataObj)
Definition: drive.cpp:251
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
static DWORD WINAPI ShowDrivePropThreadProc(LPVOID pParam)
Definition: drive.cpp:176
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:681
static BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
Definition: drive.cpp:68
VOID FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:516
struct _DRIVE_PROP_PAGE DRIVE_PROP_PAGE
static BOOL IsSystemDrive(PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:51
static VOID InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:397
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:743
static unsigned __stdcall DoFormatDrive(void *args)
Definition: drive.cpp:646
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:282
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FMIFS_MEDIA_FLAG
Definition: fmifs.h:38
@ FMIFS_FLOPPY
Definition: fmifs.h:47
@ FMIFS_HARDDISK
Definition: fmifs.h:51
CALLBACKCOMMAND
Definition: fmifs.h:67
@ FSNOTSUPPORTED
Definition: fmifs.h:75
@ VOLUMEINUSE
Definition: fmifs.h:76
@ CLUSTERSIZETOOSMALL
Definition: fmifs.h:84
@ INSUFFICIENTRIGHTS
Definition: fmifs.h:74
@ PROGRESS
Definition: fmifs.h:68
FxAutoRegKey hKey
GLuint64EXT * result
Definition: glext.h:11304
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define DRIVE_CDROM
Definition: machpc98.h:119
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static TfClientId tid
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
const GUID IID_IDataObject
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CAPTION
Definition: pedump.c:624
DWORD * PDWORD
Definition: pedump.c:68
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define PSH_PROPTITLE
Definition: prsht.h:40
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PBM_SETPOS
Definition: commctrl.h:2184
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define DONE
Definition: rnr20lib.h:14
_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)
#define args
Definition: format.c:66
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2390
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2213
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:617
#define MAX_PROPERTY_SHEET_PAGE
HRESULT hr
Definition: shlfolder.c:183
#define SHFMT_ERROR
Definition: shlobj.h:327
#define SHFMT_OPT_FULL
Definition: shlobj.h:333
#define CTF_COINIT
Definition: shlwapi.h:1936
#define IDS_FORMAT_COMPLETE
Definition: shresdef.h:206
#define IDS_NO_FORMAT_TITLE
Definition: shresdef.h:209
#define IDS_FORMAT_TITLE
Definition: shresdef.h:204
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
#define IDS_NO_FORMAT
Definition: shresdef.h:210
#define IDS_FORMAT_WARNING
Definition: shresdef.h:205
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:522
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:231
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
Definition: shell.h:41
PWSTR pwszDrive
Definition: drive.cpp:171
IStream * pStream
Definition: drive.cpp:172
PFORMAT_DRIVE_CONTEXT pContext
Definition: drive.cpp:643
DLGPROC dlgproc
Definition: drive.cpp:165
LPCSTR resname
Definition: drive.cpp:164
DWORD dwFlags
Definition: prsht.h:294
HWND hwndParent
Definition: prsht.h:295
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
UINT nStartPage
Definition: prsht.h:304
LPCWSTR pszCaption
Definition: prsht.h:301
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
Definition: stubgen.c:11
Definition: match.c:390
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
struct _stub stub
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
#define __stdcall
Definition: typedefs.h:25
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
int ret
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
#define DRIVE_UNKNOWN
Definition: winbase.h:256
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:257
#define DRIVE_REMOTE
Definition: winbase.h:253
#define DRIVE_RAMDISK
Definition: winbase.h:255
#define DRIVE_FIXED
Definition: winbase.h:252
#define DRIVE_REMOVABLE
Definition: winbase.h:251
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define CB_GETLBTEXTLEN
Definition: winuser.h:1953
#define MF_BYCOMMAND
Definition: winuser.h:202
#define DWLP_USER
Definition: winuser.h:872
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define IDCANCEL
Definition: winuser.h:831
#define BST_UNCHECKED
Definition: winuser.h:199
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_ERR
Definition: winuser.h:2435
#define CB_SETCURSEL
Definition: winuser.h:1961
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_GETTEXT
Definition: winuser.h:1618
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define WM_INITDIALOG
Definition: winuser.h:1739
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define BM_SETCHECK
Definition: winuser.h:1921
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_OKCANCEL
Definition: winuser.h:804
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MF_ENABLED
Definition: winuser.h:128
#define CB_ADDSTRING
Definition: winuser.h:1936
_In_ int cchText
Definition: winuser.h:4465
#define CB_GETITEMDATA
Definition: winuser.h:1950
#define SendMessage
Definition: winuser.h:5852
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SC_CLOSE
Definition: winuser.h:2592
#define MB_OK
Definition: winuser.h:790
#define MB_ICONWARNING
Definition: winuser.h:786
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define MB_ICONINFORMATION
Definition: winuser.h:802
#define CBN_SELENDOK
Definition: winuser.h:1981
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_GETCURSEL
Definition: winuser.h:1943
#define CB_DELETESTRING
Definition: winuser.h:1937
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define BM_GETCHECK
Definition: winuser.h:1918
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define MF_GRAYED
Definition: winuser.h:129
#define IID_PPV_ARG(Itype, ppType)
const char * LPCSTR
Definition: xmlstorage.h:183
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185