ReactOS 0.4.15-dev-7788-g1ad9096
drive.cpp File Reference
#include "precomp.h"
#include <process.h>
Include dependency graph for drive.cpp:

Go to the source code of this file.

Classes

struct  FORMAT_DRIVE_CONTEXT
 
struct  _DRIVE_PROP_PAGE
 
struct  FORMAT_DRIVE_PARAMS
 

Typedefs

typedef struct FORMAT_DRIVE_CONTEXTPFORMAT_DRIVE_CONTEXT
 
typedef struct _DRIVE_PROP_PAGE DRIVE_PROP_PAGE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx (HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
 
HPROPSHEETPAGE SH_CreatePropertySheetPage (LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
 
static BOOL IsSystemDrive (PFORMAT_DRIVE_CONTEXT pContext)
 
static BOOL GetDefaultClusterSize (LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
 
BOOL SH_ShowDriveProperties (WCHAR *pwszDrive, IDataObject *pDataObj)
 
static VOID InsertDefaultClusterSizeForFs (HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
 
static VOID InitializeFormatDriveDlg (HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
 
static BOOLEAN NTAPI FormatExCB (IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
 
VOID FormatDrive (HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
 
static unsigned __stdcall DoFormatDrive (void *args)
 
static INT_PTR CALLBACK FormatDriveDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
DWORD WINAPI SHFormatDrive (HWND hwnd, UINT drive, UINT fmtID, UINT options)
 

Variables

static HWND FormatDrvDialog = NULL
 
static BOOLEAN bSuccess = FALSE
 

Typedef Documentation

◆ DRIVE_PROP_PAGE

◆ PFORMAT_DRIVE_CONTEXT

Function Documentation

◆ DoFormatDrive()

static unsigned __stdcall DoFormatDrive ( void args)
static

Definition at line 602 of file drive.cpp.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:472
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define args
Definition: format.c:66
PFORMAT_DRIVE_CONTEXT pContext
Definition: drive.cpp:599
#define MF_BYCOMMAND
Definition: winuser.h:202
#define IDCANCEL
Definition: winuser.h:831
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define MF_ENABLED
Definition: winuser.h:128
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SC_CLOSE
Definition: winuser.h:2592
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by FormatDriveDlg().

◆ FormatDrive()

VOID FormatDrive ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)

Definition at line 472 of file drive.cpp.

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}
UINT DriveType
BOOL QuickFormat
Definition: format.c:66
DWORD ClusterSize
Definition: format.c:67
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
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
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
static HWND FormatDrvDialog
Definition: drive.cpp:432
static BOOLEAN bSuccess
Definition: drive.cpp:433
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:436
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
#define DRIVE_CDROM
Definition: machpc98.h:119
unsigned int UINT
Definition: ndis.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define SHFMT_ERROR
Definition: shlobj.h:320
#define SHFMT_OPT_FULL
Definition: shlobj.h:326
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
#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
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define CB_GETLBTEXTLEN
Definition: winuser.h:1953
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define CB_ERR
Definition: winuser.h:2435
#define WM_GETTEXT
Definition: winuser.h:1618
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_GETITEMDATA
Definition: winuser.h:1950
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define CB_GETCURSEL
Definition: winuser.h:1943
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DoFormatDrive().

◆ FormatDriveDlg()

static INT_PTR CALLBACK FormatDriveDlg ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 637 of file drive.cpp.

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}
#define shell32_hInstance
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define CloseHandle
Definition: compat.h:739
#define ShellMessageBoxW
Definition: precomp.h:59
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
static VOID InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:353
static unsigned __stdcall DoFormatDrive(void *args)
Definition: drive.cpp:602
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:238
static TfClientId tid
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
HANDLE hThread
Definition: wizard.c:28
#define LOWORD(l)
Definition: pedump.c:82
_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 IDS_FORMAT_TITLE
Definition: shresdef.h:201
#define IDS_FORMAT_WARNING
Definition: shresdef.h:202
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
PVOID HANDLE
Definition: typedefs.h:73
#define HIWORD(l)
Definition: typedefs.h:247
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define MB_OKCANCEL
Definition: winuser.h:804
#define MB_ICONWARNING
Definition: winuser.h:786
#define CBN_SELENDOK
Definition: winuser.h:1981
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SHFormatDrive().

◆ FormatExCB()

static BOOLEAN NTAPI FormatExCB ( IN CALLBACKCOMMAND  Command,
IN ULONG  SubAction,
IN PVOID  ActionInfo 
)
static

Definition at line 436 of file drive.cpp.

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}
@ 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
DWORD * PDWORD
Definition: pedump.c:68
#define PBM_SETPOS
Definition: commctrl.h:2184
#define DONE
Definition: rnr20lib.h:14
#define IDS_FORMAT_COMPLETE
Definition: shresdef.h:203
Definition: shell.h:41
unsigned char * PBOOLEAN
Definition: typedefs.h:53
UINT_PTR WPARAM
Definition: windef.h:207
#define MB_OK
Definition: winuser.h:790
#define MB_ICONINFORMATION
Definition: winuser.h:802

Referenced by FormatDrive().

◆ GetDefaultClusterSize()

static BOOL GetDefaultClusterSize ( LPWSTR  szFs,
PDWORD  pClusterSize,
PULARGE_INTEGER  TotalNumberOfBytes 
)
static

Definition at line 68 of file drive.cpp.

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}
#define wcsicmp
Definition: compat.h:15
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by InsertDefaultClusterSizeForFs().

◆ InitializeFormatDriveDlg()

static VOID InitializeFormatDriveDlg ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)
static

Definition at line 353 of file drive.cpp.

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}
unsigned char BOOLEAN
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
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
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CB_SETCURSEL
Definition: winuser.h:1961
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define BM_SETCHECK
Definition: winuser.h:1921
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define CB_ADDSTRING
Definition: winuser.h:1936
_In_ int cchText
Definition: winuser.h:4465
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by FormatDriveDlg().

◆ InsertDefaultClusterSizeForFs()

static VOID InsertDefaultClusterSizeForFs ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)
static

Definition at line 238 of file drive.cpp.

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}
static BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
Definition: drive.cpp:68
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:228
#define TRACE(s)
Definition: solgame.cpp:4
const uint16_t * PCWSTR
Definition: typedefs.h:57
LONG_PTR LRESULT
Definition: windef.h:209
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define BST_UNCHECKED
Definition: winuser.h:199
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define SendMessage
Definition: winuser.h:5843
#define CB_DELETESTRING
Definition: winuser.h:1937

Referenced by FormatDriveDlg(), and InitializeFormatDriveDlg().

◆ IsSystemDrive()

static BOOL IsSystemDrive ( PFORMAT_DRIVE_CONTEXT  pContext)
static

Definition at line 51 of file drive.cpp.

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}
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325

Referenced by SHFormatDrive().

◆ SH_CreatePropertySheetPage()

◆ SH_ShowDriveProperties()

BOOL SH_ShowDriveProperties ( WCHAR pwszDrive,
IDataObject pDataObj 
)

Definition at line 170 of file drive.cpp.

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}
Arabic default style
Definition: afstyles.h:94
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2913
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:129
#define pt(x, y)
Definition: drawing.c:79
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define WS_CAPTION
Definition: pedump.c:624
#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
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2183
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2006
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:576
#define MAX_PROPERTY_SHEET_PAGE
HRESULT hr
Definition: shlfolder.c:183
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
Definition: stubgen.c:11
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
struct _stub stub
int32_t INT_PTR
Definition: typedefs.h:64
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define CW_USEDEFAULT
Definition: winuser.h:225

Referenced by DrivesContextMenuCallback(), and SH_ShowPropertiesDialog().

◆ SHCreatePropSheetExtArrayEx()

EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx ( HKEY  hKey,
LPCWSTR  pszSubKey,
UINT  max_iface,
IDataObject pDataObj 
)

Referenced by SH_ShowDriveProperties().

◆ SHFormatDrive()

DWORD WINAPI SHFormatDrive ( HWND  hwnd,
UINT  drive,
UINT  fmtID,
UINT  options 
)

Definition at line 699 of file drive.cpp.

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}
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:637
static BOOL IsSystemDrive(PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:51
GLuint64EXT * result
Definition: glext.h:11304
#define IDS_NO_FORMAT_TITLE
Definition: shresdef.h:206
#define IDS_NO_FORMAT
Definition: shresdef.h:207
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:515
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by format_drive_thread().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ bSuccess

BOOLEAN bSuccess = FALSE
static

Definition at line 433 of file drive.cpp.

Referenced by _ShowPropertiesDialogThread(), AsyncInetDownload(), CFSFolder::CallBack(), ChangeOutputCP_(), CopyKeyName(), CreateClientProcess(), CreateNewKey(), DoExport(), DoImport(), DoWriteFile(), DPLAYX_ConstructData(), DPLAYX_DestructData(), DPLAYX_GetConnectionSettingsA(), DPLAYX_GetConnectionSettingsW(), EnablePrivilege(), EnablePrivilegeInCurrentProcess(), RunOnceExEntry::Exec(), RunOnceExInstance::Exec(), RunOnceExSection::Exec(), FormatDrive(), FormatExCB(), FTP_Connect(), FTP_ConnectToHost(), FTP_ConvertFileProp(), FTP_DoPassive(), FTP_FtpCreateDirectoryW(), FTP_FtpDeleteFileW(), FTP_FtpGetCurrentDirectoryW(), FTP_FtpGetFileW(), FTP_FtpOpenFileW(), FTP_FtpPutFileW(), FTP_FtpRemoveDirectoryW(), FTP_FtpRenameFileW(), FTP_FtpSetCurrentDirectoryW(), FTP_InitListenSocket(), FTP_ParseDirectory(), FTP_ParsePermission(), FTP_SendAccount(), FTP_SendPassword(), FTP_SendPort(), FTP_SendStore(), FTP_SendType(), CInstalledApplicationInfo::GetApplicationRegString(), GetName(), hash_file(), Imm32LoadCtfIme(), CDeviceView::Initialize(), INTERNET_AsyncCall(), IntGdiGetFontResourceInfo(), IsUrlValid(), IsWlanAdapter(), LaunchProcess(), CDeviceView::ListDevicesByType(), LoadTextFileToEdit(), main(), MDEVOBJ_bDisable(), CNewMenu::NewItemByNonCommand(), NOTEPAD_FindNext(), CGridView::OnPaint(), OnTimer(), OpenAdapterHandle(), OpenDriverHandle(), ParseCommandPart(), ParsePrimary(), PipeReadThread(), CApplicationView::ProcessWindowMessage(), ReadText(), CDeviceView::RecurseChildDevices(), RecycleBinDlg(), RefreshTreeItem(), RenderFILENAMEA(), RenderFILENAMEW(), CShellLink::Resolve(), SaveServicesToFile(), SaveTextFileFromEdit(), SetDriverLoadPrivilege(), CShellLink::SetIconLocation(), SHGetPathFromIDListA(), CInstalledApplicationInfo::UninstallApplication(), WlanConnect(), WlanDisconnect(), WlanPrintCurrentStatus(), WlanScan(), wmain(), WriteEncodedText(), WriteEvent(), and wWinMain().

◆ FormatDrvDialog

HWND FormatDrvDialog = NULL
static

Definition at line 432 of file drive.cpp.

Referenced by FormatDrive(), and FormatExCB().