ReactOS  0.4.15-dev-5462-g4d0d22a
drvdefext.cpp File Reference
#include "precomp.h"
#include <math.h>
#include <devguid.h>
#include <ndk/iofuncs.h>
#include <ndk/obfuncs.h>
Include dependency graph for drvdefext.cpp:

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 
#define NTOS_MODE_USER
 

Typedefs

typedef enum HWPAGE_DISPLAYMODEPHWPAGE_DISPLAYMODE
 

Enumerations

enum  HWPAGE_DISPLAYMODE {
  HWPD_STANDARDLIST = 0, HWPD_LARGELIST, HWPD_MAX = HWPD_LARGELIST, HWPD_STANDARDLIST = 0,
  HWPD_LARGELIST, HWPD_MAX = HWPD_LARGELIST, HWPD_STANDARDLIST = 0, HWPD_LARGELIST,
  HWPD_MAX = HWPD_LARGELIST, HWPD_STANDARDLIST = 0, HWPD_LARGELIST, HWPD_MAX = HWPD_LARGELIST
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C HWND WINAPI DeviceCreateHardwarePageEx (HWND hWndParent, LPGUID lpGuids, UINT uNumberOfGuids, HWPAGE_DISPLAYMODE DisplayMode)
 
UINT SH_FormatByteSize (LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
 
static VOID GetDriveNameWithLetter (LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
 
static VOID InitializeChkDskDialog (HWND hwndDlg, LPCWSTR pwszDrive)
 
static BOOLEAN NTAPI ChkdskCallback (IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
 
static VOID ChkDskNow (HWND hwndDlg, LPCWSTR pwszDrive)
 
static INT_PTR CALLBACK ChkDskDlg (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL GetDriveTypeAndCharacteristics (HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
 
BOOL IsDriveFloppyW (LPCWSTR pszDriveRoot)
 
BOOL IsDriveFloppyA (LPCSTR pszDriveRoot)
 

Variables

static HWND hChkdskDrvDialog = NULL
 
static BOOLEAN bChkdskSuccess = FALSE
 

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 25 of file drvdefext.cpp.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 29 of file drvdefext.cpp.

Typedef Documentation

◆ PHWPAGE_DISPLAYMODE

Enumeration Type Documentation

◆ HWPAGE_DISPLAYMODE

Enumerator
HWPD_STANDARDLIST 
HWPD_LARGELIST 
HWPD_MAX 
HWPD_STANDARDLIST 
HWPD_LARGELIST 
HWPD_MAX 
HWPD_STANDARDLIST 
HWPD_LARGELIST 
HWPD_MAX 
HWPD_STANDARDLIST 
HWPD_LARGELIST 
HWPD_MAX 

Definition at line 35 of file drvdefext.cpp.

36 {
enum HWPAGE_DISPLAYMODE * PHWPAGE_DISPLAYMODE
HWPAGE_DISPLAYMODE
Definition: drvdefext.cpp:35

Function Documentation

◆ ChkdskCallback()

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

Definition at line 85 of file drvdefext.cpp.

89 {
90  PDWORD Progress;
91  PBOOLEAN pSuccess;
92  switch(Command)
93  {
94  case PROGRESS:
95  Progress = (PDWORD)ActionInfo;
96  SendDlgItemMessageW(hChkdskDrvDialog, 14002, PBM_SETPOS, (WPARAM)*Progress, 0);
97  break;
98  case DONE:
99  pSuccess = (PBOOLEAN)ActionInfo;
100  bChkdskSuccess = (*pSuccess);
101  break;
102 
103  case VOLUMEINUSE:
104  case INSUFFICIENTRIGHTS:
105  case FSNOTSUPPORTED:
106  case CLUSTERSIZETOOSMALL:
108  FIXME("\n");
109  break;
110 
111  default:
112  break;
113  }
114 
115  return TRUE;
116 }
#define TRUE
Definition: types.h:120
Definition: fmifs.h:68
#define PBM_SETPOS
Definition: commctrl.h:2184
UINT_PTR WPARAM
Definition: windef.h:207
Definition: shell.h:41
#define FALSE
Definition: types.h:117
static BOOLEAN bChkdskSuccess
Definition: drvdefext.cpp:82
#define FIXME(fmt,...)
Definition: debug.h:111
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char * PBOOLEAN
Definition: retypes.h:11
DWORD * PDWORD
Definition: pedump.c:68
static HWND hChkdskDrvDialog
Definition: drvdefext.cpp:81
#define DONE
Definition: rnr20lib.h:14

Referenced by ChkDskNow().

◆ ChkDskDlg()

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

Definition at line 160 of file drvdefext.cpp.

165 {
166  switch(uMsg)
167  {
168  case WM_INITDIALOG:
171  return TRUE;
172  case WM_COMMAND:
173  switch(LOWORD(wParam))
174  {
175  case IDCANCEL:
176  EndDialog(hwndDlg, 0);
177  break;
178  case IDOK:
179  {
180  LPCWSTR pwszDrive = (LPCWSTR)GetWindowLongPtr(hwndDlg, DWLP_USER);
181  ChkDskNow(hwndDlg, pwszDrive);
182  break;
183  }
184  }
185  break;
186  }
187 
188  return FALSE;
189 }
#define IDOK
Definition: winuser.h:824
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
static VOID ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:119
static VOID InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:69
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1730
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CDrvDefExt::ExtraPageProc().

◆ ChkDskNow()

static VOID ChkDskNow ( HWND  hwndDlg,
LPCWSTR  pwszDrive 
)
static

Definition at line 119 of file drvdefext.cpp.

120 {
121  //DWORD ClusterSize = 0;
122  WCHAR wszFs[30];
123  ULARGE_INTEGER TotalNumberOfFreeBytes, FreeBytesAvailableUser;
124  BOOLEAN bCorrectErrors = FALSE, bScanDrive = FALSE;
125 
126  if(!GetVolumeInformationW(pwszDrive, NULL, 0, NULL, NULL, NULL, wszFs, _countof(wszFs)))
127  {
128  FIXME("failed to get drive fs type\n");
129  return;
130  }
131 
132  if (!GetDiskFreeSpaceExW(pwszDrive, &FreeBytesAvailableUser, &TotalNumberOfFreeBytes, NULL))
133  {
134  FIXME("failed to get drive space type\n");
135  return;
136  }
137 
138  /*if (!GetDefaultClusterSize(wszFs, &ClusterSize, &TotalNumberOfFreeBytes))
139  {
140  FIXME("invalid cluster size\n");
141  return;
142  }*/
143 
144  if (SendDlgItemMessageW(hwndDlg, 14000, BM_GETCHECK, 0, 0) == BST_CHECKED)
145  bCorrectErrors = TRUE;
146 
147  if (SendDlgItemMessageW(hwndDlg, 14001, BM_GETCHECK, 0, 0) == BST_CHECKED)
148  bScanDrive = TRUE;
149 
150  hChkdskDrvDialog = hwndDlg;
152  SendDlgItemMessageW(hwndDlg, 14002, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
153  Chkdsk((LPWSTR)pwszDrive, (LPWSTR)wszFs, bCorrectErrors, TRUE, FALSE, bScanDrive, NULL, NULL, ChkdskCallback); // FIXME: casts
154 
157 }
static BOOLEAN NTAPI ChkdskCallback(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drvdefext.cpp:85
#define TRUE
Definition: types.h:120
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define FALSE
Definition: types.h:117
static BOOLEAN bChkdskSuccess
Definition: drvdefext.cpp:82
#define FIXME(fmt,...)
Definition: debug.h:111
unsigned char BOOLEAN
#define BM_GETCHECK
Definition: winuser.h:1908
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
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
VOID NTAPI Chkdsk(IN PWCHAR DriveRoot, IN PWCHAR Format, IN BOOLEAN CorrectErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID Unused2, IN PVOID Unused3, IN PFMIFSCALLBACK Callback)
Definition: chkdsk.c:18
#define NULL
Definition: types.h:112
static HWND hChkdskDrvDialog
Definition: drvdefext.cpp:81
#define BST_CHECKED
Definition: winuser.h:197
WCHAR * LPWSTR
Definition: xmlstorage.h:184
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 ChkDskDlg().

◆ DeviceCreateHardwarePageEx()

EXTERN_C HWND WINAPI DeviceCreateHardwarePageEx ( HWND  hWndParent,
LPGUID  lpGuids,
UINT  uNumberOfGuids,
HWPAGE_DISPLAYMODE  DisplayMode 
)

◆ GetDriveNameWithLetter()

static VOID GetDriveNameWithLetter ( LPWSTR  pwszText,
UINT  cchTextMax,
LPCWSTR  pwszDrive 
)
static

Definition at line 50 of file drvdefext.cpp.

51 {
52  DWORD dwMaxComp, dwFileSys;
53  SIZE_T cchText = 0;
54 
55  if (GetVolumeInformationW(pwszDrive, pwszText, cchTextMax, NULL, &dwMaxComp, &dwFileSys, NULL, 0))
56  {
57  cchText = wcslen(pwszText);
58  if (cchText == 0)
59  {
60  /* load default volume label */
61  cchText = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, pwszText, cchTextMax);
62  }
63  }
64 
65  StringCchPrintfW(pwszText + cchText, cchTextMax - cchText, L" (%c:)", pwszDrive[0]);
66 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define L(x)
Definition: ntvdm.h:50
_In_ int cchText
Definition: winuser.h:4455
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
unsigned long DWORD
Definition: ntddk_ex.h:95
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
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define shell32_hInstance
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by InitializeChkDskDialog().

◆ GetDriveTypeAndCharacteristics()

static BOOL GetDriveTypeAndCharacteristics ( HANDLE  hDevice,
DEVICE_TYPE pDeviceType,
ULONG pCharacteristics 
)
static

Definition at line 287 of file drvdefext.cpp.

288 {
292 
294  &DeviceInfo, sizeof(DeviceInfo),
296  if (Status == NO_ERROR)
297  {
298  *pDeviceType = DeviceInfo.DeviceType;
299  *pCharacteristics = DeviceInfo.Characteristics;
300  return TRUE;
301  }
302 
303  return FALSE;
304 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
struct _DeviceInfo DeviceInfo
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by IsDriveFloppyW().

◆ InitializeChkDskDialog()

static VOID InitializeChkDskDialog ( HWND  hwndDlg,
LPCWSTR  pwszDrive 
)
static

Definition at line 69 of file drvdefext.cpp.

70 {
71  WCHAR wszText[100];
72  UINT Length;
73  SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pwszDrive);
74 
75  Length = GetWindowTextW(hwndDlg, wszText, sizeof(wszText) / sizeof(WCHAR));
76  wszText[Length] = L' ';
77  GetDriveNameWithLetter(&wszText[Length + 1], (sizeof(wszText) / sizeof(WCHAR)) - Length - 1, pwszDrive);
78  SetWindowText(hwndDlg, wszText);
79 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
int32_t INT_PTR
Definition: typedefs.h:64
#define SetWindowLongPtr
Definition: treelist.c:70
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWLP_USER
Definition: winuser.h:866
static VOID GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:50
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#define SetWindowText
Definition: winuser.h:5847
unsigned int UINT
Definition: ndis.h:50

Referenced by ChkDskDlg().

◆ IsDriveFloppyA()

BOOL IsDriveFloppyA ( LPCSTR  pszDriveRoot)

Definition at line 372 of file drvdefext.cpp.

373 {
374  WCHAR szRoot[8];
375  MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
376  return IsDriveFloppyW(szRoot);
377 }
#define CP_ACP
Definition: compat.h:109
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MultiByteToWideChar
Definition: compat.h:110
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:306

Referenced by CDrivesExtractIcon_CreateInstance(), and CDrivesFolder::GetDetailsOf().

◆ IsDriveFloppyW()

BOOL IsDriveFloppyW ( LPCWSTR  pszDriveRoot)

Definition at line 306 of file drvdefext.cpp.

307 {
308  LPCWSTR RootPath = pszDriveRoot;
309  WCHAR szRoot[16], szDeviceName[16];
310  UINT uType;
311  HANDLE hDevice;
313  ULONG ulCharacteristics;
314  BOOL ret;
315 
316  lstrcpynW(szRoot, RootPath, _countof(szRoot));
317 
318  if (L'a' <= szRoot[0] && szRoot[0] <= 'z')
319  {
320  szRoot[0] += ('A' - 'a');
321  }
322 
323  if ('A' <= szRoot[0] && szRoot[0] <= L'Z' &&
324  szRoot[1] == L':' && szRoot[2] == 0)
325  {
326  // 'C:' --> 'C:\'
327  szRoot[2] = L'\\';
328  szRoot[3] = 0;
329  }
330 
331  if (!PathIsRootW(szRoot))
332  {
333  return FALSE;
334  }
335 
336  uType = GetDriveTypeW(szRoot);
337  if (uType == DRIVE_REMOVABLE)
338  {
339  if (szRoot[0] == L'A' || szRoot[0] == L'B')
340  return TRUE;
341  }
342  else
343  {
344  return FALSE;
345  }
346 
348  szDeviceName[4] = szRoot[0];
349  szDeviceName[5] = L':';
351 
354  NULL, OPEN_EXISTING, 0, NULL);
355  if (hDevice == INVALID_HANDLE_VALUE)
356  {
357  return FALSE;
358  }
359 
360  ret = FALSE;
361  if (GetDriveTypeAndCharacteristics(hDevice, &DeviceType, &ulCharacteristics))
362  {
363  if ((ulCharacteristics & FILE_FLOPPY_DISKETTE) == FILE_FLOPPY_DISKETTE)
364  ret = TRUE;
365  }
366 
367  CloseHandle(hDevice);
368 
369  return ret;
370 }
#define CloseHandle
Definition: compat.h:739
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:136
#define DRIVE_REMOVABLE
Definition: winbase.h:251
#define lstrcpynW
Definition: compat.h:738
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
DeviceType
Definition: mmdrv.h:41
#define OPEN_EXISTING
Definition: compat.h:775
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1641
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
static BOOL GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
Definition: drvdefext.cpp:287
int ret
static const WCHAR szDeviceName[]
Definition: provider.c:56
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DEVICE_TYPE
Definition: guid.c:10
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CreateFileW
Definition: compat.h:741
unsigned int ULONG
Definition: retypes.h:1
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809

Referenced by CDrvDefExt::InitGeneralPage(), and IsDriveFloppyA().

◆ SH_FormatByteSize()

UINT SH_FormatByteSize ( LONGLONG  cbSize,
LPWSTR  pwszResult,
UINT  cchResultMax 
)

Definition at line 236 of file filedefext.cpp.

237 {
238  /* Write formated bytes count */
239  INT cchWritten = SH_FormatInteger(cbSize, pwszResult, cchResultMax);
240  if (!cchWritten)
241  return 0;
242 
243  /* Copy " bytes" to buffer */
244  LPWSTR pwszEnd = pwszResult + cchWritten;
245  size_t cchRemaining = cchResultMax - cchWritten;
246  StringCchCopyExW(pwszEnd, cchRemaining, L" ", &pwszEnd, &cchRemaining, 0);
247  cchWritten = LoadStringW(shell32_hInstance, IDS_BYTES_FORMAT, pwszEnd, cchRemaining);
248  cchRemaining -= cchWritten;
249 
250  return cchResultMax - cchRemaining;
251 }
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:58
#define L(x)
Definition: ntvdm.h:50
#define IDS_BYTES_FORMAT
Definition: resource.h:120
UINT SH_FormatInteger(LONGLONG Num, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:180
STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags)
Definition: strsafe.h:184
#define shell32_hInstance
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CDrvDefExt::InitGeneralPage(), and SH_FormatFileSizeWithBytes().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ bChkdskSuccess

BOOLEAN bChkdskSuccess = FALSE
static

Definition at line 82 of file drvdefext.cpp.

Referenced by ChkdskCallback(), and ChkDskNow().

◆ hChkdskDrvDialog

HWND hChkdskDrvDialog = NULL
static

Definition at line 81 of file drvdefext.cpp.

Referenced by ChkdskCallback(), and ChkDskNow().