ReactOS 0.4.15-dev-8434-g155a7c7
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  DRIVE_PROP_DATA
 
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)
 
static DWORD WINAPI ShowDrivePropThreadProc (LPVOID pParam)
 
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 646 of file drive.cpp.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:516
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:643
#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 516 of file drive.cpp.

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}
UINT DriveType
#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 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:476
static BOOLEAN bSuccess
Definition: drive.cpp:477
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:480
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:327
#define SHFMT_OPT_FULL
Definition: shlobj.h:333
#define _countof(array)
Definition: sndvol32.h:70
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 681 of file drive.cpp.

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}
#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:62
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
static VOID InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:397
static unsigned __stdcall DoFormatDrive(void *args)
Definition: drive.cpp:646
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:282
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:204
#define IDS_FORMAT_WARNING
Definition: shresdef.h:205
#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 480 of file drive.cpp.

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}
@ 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:206
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 397 of file drive.cpp.

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}
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:2388
_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:1384
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 282 of file drive.cpp.

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}
static BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
Definition: drive.cpp:68
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:231
#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:5852
#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 251 of file drive.cpp.

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}
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM *ppStm)
Definition: marshal.c:2100
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
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
static DWORD WINAPI ShowDrivePropThreadProc(LPVOID pParam)
Definition: drive.cpp:176
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const GUID IID_IDataObject
HRESULT hr
Definition: shlfolder.c:183
#define CTF_COINIT
Definition: shlwapi.h:1936
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by DrivesContextMenuCallback(), and SH_ShowPropertiesDialog().

◆ SHCreatePropSheetExtArrayEx()

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

Referenced by ShowDrivePropThreadProc().

◆ SHFormatDrive()

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

Definition at line 743 of file drive.cpp.

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}
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:681
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:209
#define IDS_NO_FORMAT
Definition: shresdef.h:210
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:522
_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().

◆ ShowDrivePropThreadProc()

static DWORD WINAPI ShowDrivePropThreadProc ( LPVOID  pParam)
static

Definition at line 176 of file drive.cpp.

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}
Arabic default style
Definition: afstyles.h:94
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2913
HRESULT WINAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID riid, LPVOID *ppv)
Definition: marshal.c:2144
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:135
#define pt(x, y)
Definition: drawing.c:79
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
#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: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
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
#define IID_PPV_ARG(Itype, ppType)

Referenced by SH_ShowDriveProperties().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ bSuccess

BOOLEAN bSuccess = FALSE
static

Definition at line 477 of file drive.cpp.

Referenced by _ShowPropertiesDialogThread(), AsyncInetDownload(), BrFolder_GetName(), 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(), GetPreviousMenuItemInfo(), 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 476 of file drive.cpp.

Referenced by FormatDrive(), and FormatExCB().