ReactOS 0.4.15-dev-5666-gc548b97
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
169BOOL
171{
172 HPSXA hpsx = NULL;
174 CComObject<CDrvDefExt> *pDrvDefExt = NULL;
175
176 CDataObjectHIDA cida(pDataObj);
177 if (FAILED_UNEXPECTEDLY(cida.hr()))
178 return FAILED(cida.hr());
179
180 RECT rcPosition = {CW_USEDEFAULT, CW_USEDEFAULT, 0, 0};
181 POINT pt;
182 if (SUCCEEDED(DataObject_GetOffset(pDataObj, &pt)))
183 {
184 rcPosition.left = pt.x;
185 rcPosition.top = pt.y;
186 }
187
191 if (!stub.Create(NULL, rcPosition, NULL, style, exstyle))
192 {
193 ERR("StubWindow32 creation failed\n");
194 return FALSE;
195 }
196
197 PROPSHEETHEADERW psh = {sizeof(PROPSHEETHEADERW)};
199 psh.pszCaption = pwszDrive;
200 psh.hwndParent = stub;
201 psh.nStartPage = 0;
202 psh.phpage = hpsp;
203
204 HRESULT hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
205 if (SUCCEEDED(hr))
206 {
207 pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
208 hr = pDrvDefExt->Initialize(HIDA_GetPIDLFolder(cida), pDataObj, NULL);
209 if (SUCCEEDED(hr))
210 {
211 hr = pDrvDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&psh);
212 if (FAILED(hr))
213 ERR("AddPages failed\n");
214 }
215 else
216 {
217 ERR("Initialize failed\n");
218 }
219 }
220
222 if (hpsx)
224
225 INT_PTR ret = PropertySheetW(&psh);
226
227 if (hpsx)
229 if (pDrvDefExt)
230 pDrvDefExt->Release();
231
232 stub.DestroyWindow();
233
234 return ret != -1;
235}
236
237static VOID
239{
240 WCHAR wszBuf[100] = {0};
241 WCHAR wszDefaultSize[100] = {0};
242 PCWSTR pwszFsSizeLimit;
243 WCHAR szDrive[] = L"C:\\";
244 INT iSelIndex;
245 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
247 LRESULT lIndex;
248 HWND hDlgCtrl;
249
250 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
251 iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0);
252 if (iSelIndex == CB_ERR)
253 return;
254
255 if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
256 return;
257
258 szDrive[0] = pContext->Drive + L'A';
259
260 if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
261 return;
262
263 if (!wcsicmp(wszBuf, L"FAT16") ||
264 !wcsicmp(wszBuf, L"FAT")) // REACTOS HACK
265 {
266 pwszFsSizeLimit = L"4GB";
267 }
268 else if (!wcsicmp(wszBuf, L"FAT32"))
269 {
270 pwszFsSizeLimit = L"32GB";
271 }
272 else if (!wcsicmp(wszBuf, L"FATX"))
273 {
274 pwszFsSizeLimit = L"1GB/32GB";
275 }
276 else if (!wcsicmp(wszBuf, L"NTFS"))
277 {
278 pwszFsSizeLimit = L"256TB";
279 }
280 else if (!wcsicmp(wszBuf, L"EXT2"))
281 {
282 pwszFsSizeLimit = L"32TB";
283 }
284 else
285 {
286 pwszFsSizeLimit = L"16EB";
287 }
288
289 if (!wcsicmp(wszBuf, L"FAT16") ||
290 !wcsicmp(wszBuf, L"FAT") || // REACTOS HACK
291 !wcsicmp(wszBuf, L"FAT32") ||
292 !wcsicmp(wszBuf, L"FATX") ||
293 !wcsicmp(wszBuf, L"NTFS") ||
294 !wcsicmp(wszBuf, L"EXT2") ||
295 !wcsicmp(wszBuf, L"BtrFS"))
296 {
297 if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
298 {
299 TRACE("%S is not supported on drive larger than %S, current size: %lu\n", wszBuf, pwszFsSizeLimit, TotalNumberOfBytes.QuadPart);
300 SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
301 return;
302 }
303
304 if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszDefaultSize, _countof(wszDefaultSize)))
305 {
306 hDlgCtrl = GetDlgItem(hwndDlg, 28680); // Get the window handle of "allocation unit size" combobox
307 SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
308 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
309 if (lIndex != CB_ERR)
310 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
311 SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
312 }
313
314 if (!wcsicmp(wszBuf, L"NTFS"))
315 {
316 ClusterSize = 512;
317 for (lIndex = 0; lIndex < 4; lIndex++)
318 {
319 TotalNumberOfBytes.QuadPart = ClusterSize;
320 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszDefaultSize, _countof(wszDefaultSize)))
321 {
322 lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszDefaultSize);
323 if (lIndex != CB_ERR)
324 SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
325 }
326 ClusterSize *= 2;
327 }
328 }
329
330 SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
331 if (!wcsicmp(wszBuf, L"EXT2") ||
332 !wcsicmp(wszBuf, L"BtrFS") ||
333 !wcsicmp(wszBuf, L"NTFS"))
334 {
335 /* Enable the "Enable Compression" button */
336 EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
337 }
338 else
339 {
340 /* Disable the "Enable Compression" button */
341 EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
342 }
343 }
344 else
345 {
346 FIXME("Unknown filesystem: %ls\n", wszBuf);
347 SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0);
348 return;
349 }
350}
351
352static VOID
354{
355 WCHAR szText[120];
356 WCHAR szDrive[] = L"C:\\";
357 WCHAR szFs[30] = L"";
358 INT cchText;
359 ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
360 DWORD dwIndex, dwDefault;
361 UCHAR uMinor, uMajor;
362 BOOLEAN Latest;
363 HWND hwndFileSystems;
364
365 cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
366 if (cchText < 0)
367 cchText = 0;
368 szText[cchText++] = L' ';
369 szDrive[0] = pContext->Drive + L'A';
370 if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
371 {
372 if (szText[cchText] == UNICODE_NULL)
373 {
374 /* load default volume label */
376 }
377 else
378 {
379 /* set volume label */
380 SetDlgItemTextW(hwndDlg, 28679, &szText[cchText]);
381 cchText += wcslen(&szText[cchText]);
382 }
383 }
384
385 StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
386
387 /* set window text */
388 SetWindowTextW(hwndDlg, szText);
389
390 if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
391 {
392 if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
393 {
394 /* add drive capacity */
395 SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
396 SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0);
397 }
398 }
399
400 if (pContext->Options & SHFMT_OPT_FULL)
401 {
402 /* check quick format button */
403 SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0);
404 }
405
406 /* enumerate all available filesystems */
407 dwIndex = 0;
408 dwDefault = 0;
409 hwndFileSystems = GetDlgItem(hwndDlg, 28677);
410
411 while(QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest))
412 {
413 if (!wcsicmp(szText, szFs))
414 dwDefault = dwIndex;
415
416 SendMessageW(hwndFileSystems, CB_ADDSTRING, 0, (LPARAM)szText);
417 dwIndex++;
418 }
419
420 if (!dwIndex)
421 {
422 ERR("no filesystem providers\n");
423 return;
424 }
425
426 /* select default filesys */
427 SendMessageW(hwndFileSystems, CB_SETCURSEL, dwDefault, 0);
428 /* setup cluster combo */
429 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
430}
431
434
435static BOOLEAN NTAPI
438 IN ULONG SubAction,
439 IN PVOID ActionInfo)
440{
441 PDWORD Progress;
442 PBOOLEAN pSuccess;
443 switch(Command)
444 {
445 case PROGRESS:
446 Progress = (PDWORD)ActionInfo;
448 break;
449 case DONE:
450 pSuccess = (PBOOLEAN)ActionInfo;
451 bSuccess = (*pSuccess);
454 break;
455
456 case VOLUMEINUSE:
458 case FSNOTSUPPORTED:
460 bSuccess = FALSE;
461 FIXME("Unsupported command in FormatExCB\n");
462 break;
463
464 default:
465 break;
466 }
467
468 return TRUE;
469}
470
471VOID
473{
474 WCHAR szDrive[4] = { L'C', ':', '\\', 0 };
475 WCHAR szFileSys[40] = {0};
476 WCHAR szLabel[40] = {0};
477 INT iSelIndex;
478 UINT Length;
479 HWND hDlgCtrl;
484
485 /* set volume path */
486 szDrive[0] = pContext->Drive + L'A';
487
488 /* get filesystem */
489 hDlgCtrl = GetDlgItem(hwndDlg, 28677);
490 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
491 if (iSelIndex == CB_ERR)
492 {
493 ERR("Unable to get file system selection\n");
494 return;
495 }
496 Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
497 if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
498 {
499 ERR("Unable to get file system selection\n");
500 return;
501 }
502
503 /* retrieve the file system */
504 SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
505 szFileSys[_countof(szFileSys)-1] = L'\0';
506
507 /* retrieve the volume label */
508 hDlgCtrl = GetWindow(hwndDlg, 28679);
509 Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
510 if (Length + 1 > _countof(szLabel))
511 {
512 ERR("Unable to get volume label\n");
513 return;
514 }
515 SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
516 szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
517
518 /* check for quickformat */
519 if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED)
521 else
523
524 /* get the cluster size */
525 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
526 iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
527 if (iSelIndex == CB_ERR)
528 {
529 FIXME("\n");
530 return;
531 }
532 ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0);
533 if ((int)ClusterSize == CB_ERR)
534 {
535 FIXME("\n");
536 return;
537 }
538
539 hDlgCtrl = GetDlgItem(hwndDlg, 28680);
540 SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
541 bSuccess = FALSE;
542
543 /* FIXME
544 * will cause display problems
545 * when performing more than one format
546 */
547 FormatDrvDialog = hwndDlg;
548
549 /* See if the drive is removable or not */
550 DriveType = GetDriveTypeW(szDrive);
551 switch (DriveType)
552 {
553 case DRIVE_UNKNOWN:
554 case DRIVE_REMOTE:
555 case DRIVE_CDROM:
557 {
558 FIXME("\n");
559 return;
560 }
561
562 case DRIVE_REMOVABLE:
563 MediaFlag = FMIFS_FLOPPY;
564 break;
565
566 case DRIVE_FIXED:
567 case DRIVE_RAMDISK:
568 MediaFlag = FMIFS_HARDDISK;
569 break;
570 }
571
572 /* Format the drive */
573 FormatEx(szDrive,
574 MediaFlag,
575 szFileSys,
576 szLabel,
579 FormatExCB);
580
582 if (!bSuccess)
583 {
584 pContext->Result = SHFMT_ERROR;
585 }
586 else if (QuickFormat)
587 {
588 pContext->Result = SHFMT_OPT_FULL;
589 }
590 else
591 {
592 pContext->Result = FALSE;
593 }
594}
595
597{
600};
601
602static unsigned __stdcall DoFormatDrive(void *args)
603{
604 FORMAT_DRIVE_PARAMS *pParams = reinterpret_cast<FORMAT_DRIVE_PARAMS *>(args);
605 HWND hwndDlg = pParams->hwndDlg;
606 PFORMAT_DRIVE_CONTEXT pContext = pParams->pContext;
607
608 /* Disable controls during format */
609 HMENU hSysMenu = GetSystemMenu(hwndDlg, FALSE);
611 EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
613 EnableWindow(GetDlgItem(hwndDlg, 28673), FALSE);
614 EnableWindow(GetDlgItem(hwndDlg, 28677), FALSE);
615 EnableWindow(GetDlgItem(hwndDlg, 28680), FALSE);
616 EnableWindow(GetDlgItem(hwndDlg, 28679), FALSE);
617 EnableWindow(GetDlgItem(hwndDlg, 28674), FALSE);
618
619 FormatDrive(hwndDlg, pContext);
620
621 /* Re-enable controls after format */
622 EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE);
624 EnableWindow(GetDlgItem(hwndDlg, 28673), TRUE);
625 EnableWindow(GetDlgItem(hwndDlg, 28677), TRUE);
626 EnableWindow(GetDlgItem(hwndDlg, 28680), TRUE);
627 EnableWindow(GetDlgItem(hwndDlg, 28679), TRUE);
628 EnableWindow(GetDlgItem(hwndDlg, 28674), TRUE);
630 pContext->bFormattingNow = FALSE;
631
632 delete pParams;
633 return 0;
634}
635
636static INT_PTR CALLBACK
638{
639 PFORMAT_DRIVE_CONTEXT pContext;
640
641 switch(uMsg)
642 {
643 case WM_INITDIALOG:
646 return TRUE;
647 case WM_COMMAND:
648 switch(LOWORD(wParam))
649 {
650 case IDOK:
652 if (pContext->bFormattingNow)
653 break;
654
659 {
660 pContext->bFormattingNow = TRUE;
661
663 pParams->hwndDlg = hwndDlg;
664 pParams->pContext = pContext;
665
666 unsigned tid;
669 }
670 break;
671 case IDCANCEL:
673 if (pContext->bFormattingNow)
674 break;
675
676 EndDialog(hwndDlg, pContext->Result);
677 break;
678 case 28677: // filesystem combo
679 if (HIWORD(wParam) == CBN_SELENDOK)
680 {
682 if (pContext->bFormattingNow)
683 break;
684
685 InsertDefaultClusterSizeForFs(hwndDlg, pContext);
686 }
687 break;
688 }
689 }
690 return FALSE;
691}
692
693/*************************************************************************
694 * SHFormatDrive (SHELL32.@)
695 */
696
697DWORD
698WINAPI
700{
702 int result;
703
704 TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
705
706 Context.Drive = drive;
707 Context.Options = options;
708 Context.Result = FALSE;
709 Context.bFormattingNow = FALSE;
710
711 if (!IsSystemDrive(&Context))
712 {
714 }
715 else
716 {
719 TRACE("SHFormatDrive(): The provided drive for format is a system volume! Aborting...\n");
720 }
721
722 return result;
723}
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
BOOL QuickFormat
Definition: format.c:66
DWORD ClusterSize
Definition: format.c:67
#define EXTERN_C
Definition: basetyps.h:12
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
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:2905
#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
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
#define ShellMessageBoxW
Definition: precomp.h:59
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:129
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
#define pt(x, y)
Definition: drawing.c:79
static HWND FormatDrvDialog
Definition: drive.cpp:432
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
static BOOLEAN bSuccess
Definition: drive.cpp:433
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:436
BOOL SH_ShowDriveProperties(WCHAR *pwszDrive, IDataObject *pDataObj)
Definition: drive.cpp:170
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:637
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:472
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:353
DWORD WINAPI SHFormatDrive(HWND hwnd, UINT drive, UINT fmtID, UINT options)
Definition: drive.cpp:699
static unsigned __stdcall DoFormatDrive(void *args)
Definition: drive.cpp:602
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:238
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
char * PBOOLEAN
Definition: retypes.h:11
unsigned int ULONG
Definition: retypes.h:1
#define DRIVE_CDROM
Definition: machpc98.h:115
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:60
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
#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:2150
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1973
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:564
#define MAX_PROPERTY_SHEET_PAGE
HRESULT hr
Definition: shlfolder.c:183
#define SHFMT_ERROR
Definition: shlobj.h:292
#define SHFMT_OPT_FULL
Definition: shlobj.h:298
#define IDS_FORMAT_COMPLETE
Definition: shresdef.h:200
#define IDS_NO_FORMAT_TITLE
Definition: shresdef.h:203
#define IDS_FORMAT_TITLE
Definition: shresdef.h:198
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
#define IDS_NO_FORMAT
Definition: shresdef.h:204
#define IDS_FORMAT_WARNING
Definition: shresdef.h:199
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:496
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:225
#define _countof(array)
Definition: sndvol32.h:68
#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
PFORMAT_DRIVE_CONTEXT pContext
Definition: drive.cpp:599
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
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
#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
#define HIWORD(l)
Definition: typedefs.h:247
int ret
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#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:1956
#define WM_GETTEXTLENGTH
Definition: winuser.h:1609
#define CB_GETLBTEXTLEN
Definition: winuser.h:1943
#define MF_BYCOMMAND
Definition: winuser.h:202
#define DWLP_USER
Definition: winuser.h:866
#define CB_GETLBTEXT
Definition: winuser.h:1942
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define IDCANCEL
Definition: winuser.h:825
#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:1730
#define CB_ERR
Definition: winuser.h:2425
#define CB_SETCURSEL
Definition: winuser.h:1951
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_GETTEXT
Definition: winuser.h:1608
#define CB_RESETCONTENT
Definition: winuser.h:1949
#define WM_INITDIALOG
Definition: winuser.h:1729
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
#define BM_SETCHECK
Definition: winuser.h:1911
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_OKCANCEL
Definition: winuser.h:798
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MF_ENABLED
Definition: winuser.h:128
#define CB_ADDSTRING
Definition: winuser.h:1926
_In_ int cchText
Definition: winuser.h:4455
#define CB_GETITEMDATA
Definition: winuser.h:1940
#define SendMessage
Definition: winuser.h:5833
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SC_CLOSE
Definition: winuser.h:2582
#define MB_OK
Definition: winuser.h:784
#define MB_ICONWARNING
Definition: winuser.h:780
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define CBN_SELENDOK
Definition: winuser.h:1971
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_GETCURSEL
Definition: winuser.h:1933
#define CB_DELETESTRING
Definition: winuser.h:1927
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:1908
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define MF_GRAYED
Definition: winuser.h:129
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