ReactOS  0.4.13-dev-247-g0f29b3f
drive.cpp File Reference
#include "precomp.h"
Include dependency graph for drive.cpp:

Go to the source code of this file.

Classes

struct  FORMAT_DRIVE_CONTEXT
 
struct  _DRIVE_PROP_PAGE
 

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 GetDefaultClusterSize (LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
 
HRESULT SH_ShowDriveProperties (WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
 
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 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

◆ FormatDrive()

VOID FormatDrive ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)

Definition at line 456 of file drive.cpp.

457 {
458  WCHAR szDrive[4] = { L'C', ':', '\\', 0 };
459  WCHAR szFileSys[40] = {0};
460  WCHAR szLabel[40] = {0};
461  INT iSelIndex;
462  UINT Length;
463  HWND hDlgCtrl;
467  FMIFS_MEDIA_FLAG MediaFlag = FMIFS_HARDDISK;
468 
469  /* set volume path */
470  szDrive[0] = pContext->Drive + L'A';
471 
472  /* get filesystem */
473  hDlgCtrl = GetDlgItem(hwndDlg, 28677);
474  iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
475  if (iSelIndex == CB_ERR)
476  {
477  FIXME("\n");
478  return;
479  }
480  Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
481  if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
482  {
483  FIXME("\n");
484  return;
485  }
486 
487  /* retrieve the file system */
488  SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
489  szFileSys[_countof(szFileSys)-1] = L'\0';
490 
491  /* retrieve the volume label */
492  hDlgCtrl = GetWindow(hwndDlg, 28679);
493  Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
494  if (Length + 1 > _countof(szLabel))
495  {
496  FIXME("\n");
497  return;
498  }
499  SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
500  szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
501 
502  /* check for quickformat */
503  if (SendDlgItemMessageW(hwndDlg, 28674, BM_GETCHECK, 0, 0) == BST_CHECKED)
504  QuickFormat = TRUE;
505  else
506  QuickFormat = FALSE;
507 
508  /* get the cluster size */
509  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
510  iSelIndex = SendMessageW(hDlgCtrl, CB_GETCURSEL, 0, 0);
511  if (iSelIndex == CB_ERR)
512  {
513  FIXME("\n");
514  return;
515  }
516  ClusterSize = SendMessageW(hDlgCtrl, CB_GETITEMDATA, iSelIndex, 0);
517  if ((int)ClusterSize == CB_ERR)
518  {
519  FIXME("\n");
520  return;
521  }
522 
523  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
524  SendMessageW(hDlgCtrl, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
525  bSuccess = FALSE;
526 
527  /* FIXME
528  * will cause display problems
529  * when performing more than one format
530  */
531  FormatDrvDialog = hwndDlg;
532 
533  /* See if the drive is removable or not */
534  DriveType = GetDriveTypeW(szDrive);
535  switch (DriveType)
536  {
537  case DRIVE_UNKNOWN:
538  case DRIVE_REMOTE:
539  case DRIVE_CDROM:
540  case DRIVE_NO_ROOT_DIR:
541  {
542  FIXME("\n");
543  return;
544  }
545 
546  case DRIVE_REMOVABLE:
547  MediaFlag = FMIFS_FLOPPY;
548  break;
549 
550  case DRIVE_FIXED:
551  case DRIVE_RAMDISK:
552  MediaFlag = FMIFS_HARDDISK;
553  break;
554  }
555 
556  /* Format the drive */
557  FormatEx(szDrive,
558  MediaFlag,
559  szFileSys,
560  szLabel,
561  QuickFormat,
562  ClusterSize,
563  FormatExCB);
564 
566  if (!bSuccess)
567  {
568  pContext->Result = SHFMT_ERROR;
569  }
570  else if (QuickFormat)
571  {
572  pContext->Result = SHFMT_OPT_FULL;
573  }
574  else
575  {
576  pContext->Result = FALSE;
577  }
578 }
#define WM_GETTEXTLENGTH
Definition: winuser.h:1601
#define CB_GETLBTEXTLEN
Definition: winuser.h:1914
#define TRUE
Definition: types.h:120
#define CB_GETLBTEXT
Definition: winuser.h:1913
#define SHFMT_ERROR
Definition: shlobj.h:292
#define _countof(array)
Definition: fontsub.cpp:30
#define CB_GETITEMDATA
Definition: winuser.h:1911
#define WM_GETTEXT
Definition: winuser.h:1600
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define DRIVE_RAMDISK
Definition: winbase.h:252
UINT DriveType
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
#define CB_GETCURSEL
Definition: winuser.h:1904
#define DRIVE_REMOVABLE
Definition: winbase.h:248
static HWND FormatDrvDialog
Definition: drive.cpp:416
#define PBM_SETRANGE
Definition: commctrl.h:2155
#define DRIVE_REMOTE
Definition: winbase.h:250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define BM_GETCHECK
Definition: winuser.h:1879
BOOL QuickFormat
Definition: format.c:66
#define DRIVE_UNKNOWN
Definition: winbase.h:253
#define CB_ERR
Definition: winuser.h:2389
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
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
static BOOLEAN NTAPI FormatExCB(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drive.cpp:420
DWORD ClusterSize
Definition: format.c:67
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1250
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:254
#define DRIVE_FIXED
Definition: winbase.h:249
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DRIVE_CDROM
Definition: winbase.h:251
unsigned int UINT
Definition: ndis.h:50
#define BST_CHECKED
Definition: winuser.h:197
#define SHFMT_OPT_FULL
Definition: shlobj.h:298
FMIFS_MEDIA_FLAG
Definition: fmifs.h:37

Referenced by FormatDriveDlg().

◆ FormatDriveDlg()

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

Definition at line 581 of file drive.cpp.

582 {
583  PFORMAT_DRIVE_CONTEXT pContext;
584 
585  switch(uMsg)
586  {
587  case WM_INITDIALOG:
590  return TRUE;
591  case WM_COMMAND:
592  switch(LOWORD(wParam))
593  {
594  case IDOK:
596  {
597  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
598  FormatDrive(hwndDlg, pContext);
599  }
600  break;
601  case IDCANCEL:
602  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
603  EndDialog(hwndDlg, pContext->Result);
604  break;
605  case 28677: // filesystem combo
606  if (HIWORD(wParam) == CBN_SELENDOK)
607  {
608  pContext = (PFORMAT_DRIVE_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
609  InsertDefaultClusterSizeForFs(hwndDlg, pContext);
610  }
611  break;
612  }
613  }
614  return FALSE;
615 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define MB_ICONWARNING
Definition: winuser.h:780
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:185
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define CBN_SELENDOK
Definition: winuser.h:1942
VOID FormatDrive(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:456
#define MB_OKCANCEL
Definition: winuser.h:798
#define IDS_FORMAT_WARNING
Definition: shresdef.h:190
int ShellMessageBoxW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,...)
Definition: shellord.c:337
static VOID InitializeFormatDriveDlg(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:337
#define IDS_FORMAT_TITLE
Definition: shresdef.h:189
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1716
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
struct FORMAT_DRIVE_CONTEXT * PFORMAT_DRIVE_CONTEXT
#define HIWORD(l)
Definition: typedefs.h:246
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by SHFormatDrive().

◆ FormatExCB()

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

Definition at line 420 of file drive.cpp.

424 {
425  PDWORD Progress;
426  PBOOLEAN pSuccess;
427  switch(Command)
428  {
429  case PROGRESS:
430  Progress = (PDWORD)ActionInfo;
431  SendDlgItemMessageW(FormatDrvDialog, 28678, PBM_SETPOS, (WPARAM)*Progress, 0);
432  break;
433  case DONE:
434  pSuccess = (PBOOLEAN)ActionInfo;
435  bSuccess = (*pSuccess);
438  break;
439 
440  case VOLUMEINUSE:
441  case INSUFFICIENTRIGHTS:
442  case FSNOTSUPPORTED:
443  case CLUSTERSIZETOOSMALL:
444  bSuccess = FALSE;
445  FIXME("\n");
446  break;
447 
448  default:
449  break;
450  }
451 
452  return TRUE;
453 }
#define TRUE
Definition: types.h:120
Definition: fmifs.h:68
#define PBM_SETPOS
Definition: commctrl.h:2156
UINT_PTR WPARAM
Definition: windef.h:207
Definition: shell.h:41
static BOOLEAN bSuccess
Definition: drive.cpp:417
static HWND FormatDrvDialog
Definition: drive.cpp:416
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define FIXME(fmt,...)
Definition: debug.h:110
int ShellMessageBoxW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,...)
Definition: shellord.c:337
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDS_FORMAT_TITLE
Definition: shresdef.h:189
#define MB_ICONINFORMATION
Definition: winuser.h:796
char * PBOOLEAN
Definition: retypes.h:11
#define IDS_FORMAT_COMPLETE
Definition: shresdef.h:191
#define MB_OK
Definition: winuser.h:784
DWORD * PDWORD
Definition: pedump.c:68
#define DONE
Definition: rnr20lib.h:14
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by FormatDrive().

◆ GetDefaultClusterSize()

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

Definition at line 37 of file drive.cpp.

38 {
40 
41  if (!wcsicmp(szFs, L"FAT16") ||
42  !wcsicmp(szFs, L"FAT")) //REACTOS HACK
43  {
44  if (TotalNumberOfBytes->QuadPart <= (16 * 1024 * 1024))
45  ClusterSize = 2048;
46  else if (TotalNumberOfBytes->QuadPart <= (32 * 1024 * 1024))
47  ClusterSize = 512;
48  else if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
49  ClusterSize = 1024;
50  else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
51  ClusterSize = 2048;
52  else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
53  ClusterSize = 4096;
54  else if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
55  ClusterSize = 8192;
56  else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
57  ClusterSize = 16384;
58  else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
59  ClusterSize = 32768;
60  else if (TotalNumberOfBytes->QuadPart <= (4096LL * 1024LL * 1024LL))
61  ClusterSize = 8192;
62  else
63  return FALSE;
64  }
65  else if (!wcsicmp(szFs, L"FAT32"))
66  {
67  if (TotalNumberOfBytes->QuadPart <= (64 * 1024 * 1024))
68  ClusterSize = 512;
69  else if (TotalNumberOfBytes->QuadPart <= (128 * 1024 * 1024))
70  ClusterSize = 1024;
71  else if (TotalNumberOfBytes->QuadPart <= (256 * 1024 * 1024))
72  ClusterSize = 2048;
73  else if (TotalNumberOfBytes->QuadPart <= (8192LL * 1024LL * 1024LL))
74  ClusterSize = 2048;
75  else if (TotalNumberOfBytes->QuadPart <= (16384LL * 1024LL * 1024LL))
76  ClusterSize = 8192;
77  else if (TotalNumberOfBytes->QuadPart <= (32768LL * 1024LL * 1024LL))
78  ClusterSize = 16384;
79  else
80  return FALSE;
81  }
82  else if (!wcsicmp(szFs, L"NTFS"))
83  {
84  if (TotalNumberOfBytes->QuadPart <= (512 * 1024 * 1024))
85  ClusterSize = 512;
86  else if (TotalNumberOfBytes->QuadPart <= (1024 * 1024 * 1024))
87  ClusterSize = 1024;
88  else if (TotalNumberOfBytes->QuadPart <= (2048LL * 1024LL * 1024LL))
89  ClusterSize = 2048;
90  else
91  ClusterSize = 2048;
92  }
93  else if (!wcsicmp(szFs, L"EXT2"))
94  {
95  // auto block size calculation
96  ClusterSize = 0;
97  }
98  else if (!wcsicmp(szFs, L"BtrFS"))
99  {
100  // auto block size calculation
101  ClusterSize = 0;
102  }
103  else
104  return FALSE;
105 
106  *pClusterSize = ClusterSize;
107  return TRUE;
108 }
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:72
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
DWORD ClusterSize
Definition: format.c:67
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152

Referenced by InsertDefaultClusterSizeForFs().

◆ InitializeFormatDriveDlg()

static VOID InitializeFormatDriveDlg ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)
static

Definition at line 337 of file drive.cpp.

338 {
339  WCHAR szText[120];
340  WCHAR szDrive[] = L"C:\\";
341  WCHAR szFs[30] = L"";
342  INT cchText;
343  ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
344  DWORD dwIndex, dwDefault;
345  UCHAR uMinor, uMajor;
346  BOOLEAN Latest;
347  HWND hwndFileSystems;
348 
349  cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
350  if (cchText < 0)
351  cchText = 0;
352  szText[cchText++] = L' ';
353  szDrive[0] = pContext->Drive + L'A';
354  if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
355  {
356  if (szText[cchText] == UNICODE_NULL)
357  {
358  /* load default volume label */
360  }
361  else
362  {
363  /* set volume label */
364  SetDlgItemTextW(hwndDlg, 28679, &szText[cchText]);
366  }
367  }
368 
369  StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
370 
371  /* set window text */
372  SetWindowTextW(hwndDlg, szText);
373 
374  if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
375  {
376  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
377  {
378  /* add drive capacity */
379  SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
380  SendDlgItemMessageW(hwndDlg, 28673, CB_SETCURSEL, 0, (LPARAM)0);
381  }
382  }
383 
384  if (pContext->Options & SHFMT_OPT_FULL)
385  {
386  /* check quick format button */
387  SendDlgItemMessageW(hwndDlg, 28674, BM_SETCHECK, BST_CHECKED, 0);
388  }
389 
390  /* enumerate all available filesystems */
391  dwIndex = 0;
392  dwDefault = 0;
393  hwndFileSystems = GetDlgItem(hwndDlg, 28677);
394 
395  while(QueryAvailableFileSystemFormat(dwIndex, szText, &uMajor, &uMinor, &Latest))
396  {
397  if (!wcsicmp(szText, szFs))
398  dwDefault = dwIndex;
399 
400  SendMessageW(hwndFileSystems, CB_ADDSTRING, 0, (LPARAM)szText);
401  dwIndex++;
402  }
403 
404  if (!dwIndex)
405  {
406  ERR("no filesystem providers\n");
407  return;
408  }
409 
410  /* select default filesys */
411  SendMessageW(hwndFileSystems, CB_SETCURSEL, dwDefault, 0);
412  /* setup cluster combo */
413  InsertDefaultClusterSizeForFs(hwndDlg, pContext);
414 }
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
static VOID InsertDefaultClusterSizeForFs(HWND hwndDlg, PFORMAT_DRIVE_CONTEXT pContext)
Definition: drive.cpp:185
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define UNICODE_NULL
static const WCHAR szText[]
Definition: dialog.c:139
#define CB_ADDSTRING
Definition: winuser.h:1897
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
_In_ int cchText
Definition: winuser.h:4334
#define BM_SETCHECK
Definition: winuser.h:1882
#define IDS_DRIVE_FIXED
Definition: shresdef.h:105
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
#define CB_SETCURSEL
Definition: winuser.h:1922
#define wcsicmp
Definition: string.h:1152
#define ERR(fmt,...)
Definition: debug.h:109
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
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define BST_CHECKED
Definition: winuser.h:197
#define SHFMT_OPT_FULL
Definition: shlobj.h:298
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342
BOOLEAN NTAPI QueryAvailableFileSystemFormat(IN DWORD Index, IN OUT PWCHAR FileSystem, OUT UCHAR *Major, OUT UCHAR *Minor, OUT BOOLEAN *LatestVersion)
Definition: query.c:14

Referenced by FormatDriveDlg().

◆ InsertDefaultClusterSizeForFs()

static VOID InsertDefaultClusterSizeForFs ( HWND  hwndDlg,
PFORMAT_DRIVE_CONTEXT  pContext 
)
static

Definition at line 185 of file drive.cpp.

186 {
187  WCHAR wszBuf[100] = {0};
188  WCHAR szDrive[] = L"C:\\";
189  INT iSelIndex;
190  ULARGE_INTEGER FreeBytesAvailableUser, TotalNumberOfBytes;
192  LRESULT lIndex;
193  HWND hDlgCtrl;
194 
195  hDlgCtrl = GetDlgItem(hwndDlg, 28677);
196  iSelIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, 0, 0);
197  if (iSelIndex == CB_ERR)
198  return;
199 
200  if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
201  return;
202 
203  szDrive[0] = pContext->Drive + L'A';
204 
205  if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
206  return;
207 
208  if (!wcsicmp(wszBuf, L"FAT16") ||
209  !wcsicmp(wszBuf, L"FAT")) //REACTOS HACK
210  {
211  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
212  {
213  TRACE("FAT16 is not supported on hdd larger than 4G current %lu\n", TotalNumberOfBytes.QuadPart);
214  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
215  return;
216  }
217 
219  {
220  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
221  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
222  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
223  if (lIndex != CB_ERR)
224  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
225  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
226  }
227 
228  SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
229  EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
230  }
231  else if (!wcsicmp(wszBuf, L"FAT32"))
232  {
233  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
234  {
235  TRACE("FAT32 is not supported on hdd larger than 32G current %lu\n", TotalNumberOfBytes.QuadPart);
236  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
237  return;
238  }
239 
241  {
242  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
243  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
244  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
245  if (lIndex != CB_ERR)
246  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
247  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
248  }
249 
250  SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
251  EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
252  }
253  else if (!wcsicmp(wszBuf, L"NTFS"))
254  {
255  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
256  {
257  TRACE("NTFS is not supported on hdd larger than 2TB current %lu\n", TotalNumberOfBytes.QuadPart);
258  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
259  return;
260  }
261 
262  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
264  {
265  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
266  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
267  if (lIndex != CB_ERR)
268  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
269  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
270  }
271  ClusterSize = 512;
272  for (lIndex = 0; lIndex < 4; lIndex++)
273  {
274  TotalNumberOfBytes.QuadPart = ClusterSize;
275  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
276  {
277  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
278  if (lIndex != CB_ERR)
279  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
280  }
281  ClusterSize *= 2;
282  }
283 
284  EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
285  }
286  else if (!wcsicmp(wszBuf, L"EXT2"))
287  {
288  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
289  {
290  TRACE("EXT2 is not supported on hdd larger than 32T current %lu\n", TotalNumberOfBytes.QuadPart);
291  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
292  return;
293  }
294 
296  {
297  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
298  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
299  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
300  if (lIndex != CB_ERR)
301  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
302  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
303  }
304 
305  EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
306  }
307  else if (!wcsicmp(wszBuf, L"BtrFS"))
308  {
309  if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
310  {
311  TRACE("BtrFS is not supported on hdd larger than 16E current %lu\n", TotalNumberOfBytes.QuadPart);
312  SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
313  return;
314  }
315 
317  {
318  hDlgCtrl = GetDlgItem(hwndDlg, 28680);
319  SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
320  lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
321  if (lIndex != CB_ERR)
322  SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
323  SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
324  }
325 
326  EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
327  }
328  else
329  {
330  FIXME("unknown fs\n");
331  SendDlgItemMessageW(hwndDlg, 28680, CB_RESETCONTENT, iSelIndex, 0);
332  return;
333  }
334 }
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
#define CB_SETITEMDATA
Definition: winuser.h:1927
#define TRUE
Definition: types.h:120
#define CB_GETLBTEXT
Definition: winuser.h:1913
#define _countof(array)
Definition: fontsub.cpp:30
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1904
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FIXME(fmt,...)
Definition: debug.h:110
#define CB_ADDSTRING
Definition: winuser.h:1897
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_RESETCONTENT
Definition: winuser.h:1920
#define CB_ERR
Definition: winuser.h:2389
#define BM_SETCHECK
Definition: winuser.h:1882
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD ClusterSize
Definition: format.c:67
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static const WCHAR L[]
Definition: oid.c:1250
#define CB_SETCURSEL
Definition: winuser.h:1922
#define BST_UNCHECKED
Definition: winuser.h:199
#define wcsicmp
Definition: string.h:1152
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDS_DEFAULT_CLUSTER_SIZE
Definition: shresdef.h:211
#define SendMessage
Definition: winuser.h:5709
#define CB_DELETESTRING
Definition: winuser.h:1898
LONG_PTR LRESULT
Definition: windef.h:209
static BOOL GetDefaultClusterSize(LPWSTR szFs, PDWORD pClusterSize, PULARGE_INTEGER TotalNumberOfBytes)
Definition: drive.cpp:37
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342

Referenced by FormatDriveDlg(), and InitializeFormatDriveDlg().

◆ SH_CreatePropertySheetPage()

HPROPSHEETPAGE SH_CreatePropertySheetPage ( LPCSTR  resname,
DLGPROC  dlgproc,
LPARAM  lParam,
LPWSTR  szTitle 
)

◆ SH_ShowDriveProperties()

HRESULT SH_ShowDriveProperties ( WCHAR pwszDrive,
LPCITEMIDLIST  pidlFolder,
PCUITEMID_CHILD_ARRAY  apidl 
)

Definition at line 118 of file drive.cpp.

119 {
120  HPSXA hpsx = NULL;
122  PROPSHEETHEADERW psh;
123  CComObject<CDrvDefExt> *pDrvDefExt = NULL;
124  WCHAR wszName[256];
125 
126  ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
127  psh.dwSize = sizeof(PROPSHEETHEADERW);
128  psh.dwFlags = 0; // FIXME: make it modeless
129  psh.hwndParent = NULL;
130  psh.nStartPage = 0;
131  psh.phpage = hpsp;
132 
133  LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]);
134  if (!completePidl)
135  return E_OUTOFMEMORY;
136 
137  if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL))
138  {
139  psh.pszCaption = wszName;
140  psh.dwFlags |= PSH_PROPTITLE;
141  }
142 
143  ILFree(completePidl);
144 
145  CComPtr<IDataObject> pDataObj;
146  HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj));
147 
148  if (SUCCEEDED(hr))
149  {
150  hr = CComObject<CDrvDefExt>::CreateInstance(&pDrvDefExt);
151  if (SUCCEEDED(hr))
152  {
153  pDrvDefExt->AddRef(); // CreateInstance returns object with 0 ref count
154  hr = pDrvDefExt->Initialize(pidlFolder, pDataObj, NULL);
155  if (SUCCEEDED(hr))
156  {
157  hr = pDrvDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&psh);
158  if (FAILED(hr))
159  ERR("AddPages failed\n");
160  } else
161  ERR("Initialize failed\n");
162  }
163 
165  if (hpsx)
167  }
168 
169  // NOTE: Currently property sheet is modal. If we make it modeless, then it returns HWND.
170  INT_PTR ret = PropertySheetW(&psh);
171 
172  if (hpsx)
174  if (pDrvDefExt)
175  pDrvDefExt->Release();
176 
177  if (ret > 0)
178  return S_OK;
179  if (ret == 0)
180  return S_FALSE;
181  return E_FAIL;
182 }
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:1755
HWND hwndParent
Definition: prsht.h:277
BOOL CALLBACK AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
Definition: precomp.h:112
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv)
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:1577
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define ZeroMemory
Definition: winbase.h:1635
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:309
struct _PROPSHEETHEADERW PROPSHEETHEADERW
int32_t INT_PTR
Definition: typedefs.h:62
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LPCWSTR pszCaption
Definition: prsht.h:283
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define ILGDN_NORMAL
Definition: undocshell.h:69
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2896
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PSH_PROPTITLE
Definition: prsht.h:40
LONG HRESULT
Definition: typedefs.h:77
DWORD dwSize
Definition: prsht.h:275
DWORD dwFlags
Definition: prsht.h:276
int ret
static const WCHAR L[]
Definition: oid.c:1250
HPROPSHEETPAGE * phpage
Definition: prsht.h:291
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define MAX_PROPERTY_SHEET_PAGE
#define SUCCEEDED(hr)
Definition: intsafe.h:57
UINT nStartPage
Definition: prsht.h:286

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 623 of file drive.cpp.

624 {
626  int result;
627 
628  TRACE("%p, 0x%08x, 0x%08x, 0x%08x - stub\n", hwnd, drive, fmtID, options);
629 
630  Context.Drive = drive;
631  Context.Options = options;
632 
634 
635  return result;
636 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
LONG_PTR LPARAM
Definition: windef.h:208
int options
Definition: main.c:106
#define TRACE(s)
Definition: solgame.cpp:4
#define IDD_FORMAT_DRIVE
Definition: shresdef.h:437
static char drive[2]
Definition: batch.c:28
static INT_PTR CALLBACK FormatDriveDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drive.cpp:581
struct tagContext Context
Definition: acpixf.h:1012
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
GLuint64EXT * result
Definition: glext.h:11304

Referenced by DrivesContextMenuCallback().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ bSuccess

BOOLEAN bSuccess = FALSE
static

Definition at line 417 of file drive.cpp.

Referenced by AllowWinstaAccess(), CopyKeyName(), CreateClientProcess(), CreateNewKey(), DoExport(), DoImport(), DoWriteFile(), DPLAYX_ConstructData(), DPLAYX_DestructData(), DPLAYX_GetConnectionSettingsA(), DPLAYX_GetConnectionSettingsW(), EnablePrivilege(), EnablePrivilegeInCurrentProcess(), 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(), GetName(), CDeviceView::Initialize(), INTERNET_AsyncCall(), IntGdiGetFontResourceInfo(), IsWlanAdapter(), CDeviceView::ListDevicesByType(), LoadDIBImage(), LoadTextFileToEdit(), main(), CNewMenu::NewItemByNonCommand(), NOTEPAD_FindNext(), CGridView::OnPaint(), OpenAdapterHandle(), OpenDriverHandle(), PipeReadThread(), ReadText(), CDeviceView::RecurseChildDevices(), RecycleBinDlg(), RefreshTreeItem(), RenderFILENAMEA(), RenderFILENAMEW(), CShellLink::Resolve(), SaveServicesToFile(), SaveTextFileFromEdit(), SetDriverLoadPrivilege(), CShellLink::SetIconLocation(), SHGetPathFromIDListA(), WlanConnect(), WlanDisconnect(), WlanPrintCurrentStatus(), WlanScan(), WriteEncodedText(), and WriteEvent().

◆ FormatDrvDialog

HWND FormatDrvDialog = NULL
static

Definition at line 416 of file drive.cpp.

Referenced by FormatDrive(), and FormatExCB().