ReactOS 0.4.15-dev-7994-gb388cb6
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{
HWPAGE_DISPLAYMODE
Definition: drvdefext.cpp:36
@ HWPD_STANDARDLIST
Definition: drvdefext.cpp:37
@ HWPD_LARGELIST
Definition: drvdefext.cpp:38
@ HWPD_MAX
Definition: drvdefext.cpp:39
enum HWPAGE_DISPLAYMODE * PHWPAGE_DISPLAYMODE

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;
97 break;
98 case DONE:
99 pSuccess = (PBOOLEAN)ActionInfo;
100 bChkdskSuccess = (*pSuccess);
101 break;
102
103 case VOLUMEINUSE:
105 case FSNOTSUPPORTED:
108 FIXME("\n");
109 break;
110
111 default:
112 break;
113 }
114
115 return TRUE;
116}
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HWND hChkdskDrvDialog
Definition: drvdefext.cpp:81
static BOOLEAN bChkdskSuccess
Definition: drvdefext.cpp:82
@ 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
Definition: shell.h:41
unsigned char * PBOOLEAN
Definition: typedefs.h:53
UINT_PTR WPARAM
Definition: windef.h:207
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ 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}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static VOID ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:119
static VOID InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:69
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWLP_USER
Definition: winuser.h:872
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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}
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
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
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
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define _countof(array)
Definition: sndvol32.h:68
PFMIFSCALLBACK ChkdskCallback
Definition: vfatlib.c:43
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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}
#define shell32_hInstance
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
_In_ int cchText
Definition: winuser.h:4465

Referenced by InitializeChkDskDialog().

◆ GetDriveTypeAndCharacteristics()

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

Definition at line 301 of file drvdefext.cpp.

302{
306
308 &DeviceInfo, sizeof(DeviceInfo),
310 if (Status == NO_ERROR)
311 {
312 *pDeviceType = DeviceInfo.DeviceType;
313 *pCharacteristics = DeviceInfo.Characteristics;
314 return TRUE;
315 }
316
317 return FALSE;
318}
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
@ FileFsDeviceInformation
Definition: from_kernel.h:222
Status
Definition: gdiplustypes.h:25
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)

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];
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}
static VOID GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:50
unsigned int UINT
Definition: ndis.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
int32_t INT_PTR
Definition: typedefs.h:64
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#define SetWindowText
Definition: winuser.h:5857

Referenced by ChkDskDlg().

◆ IsDriveFloppyA()

BOOL IsDriveFloppyA ( LPCSTR  pszDriveRoot)

Definition at line 386 of file drvdefext.cpp.

387{
388 WCHAR szRoot[8];
389 MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
390 return IsDriveFloppyW(szRoot);
391}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:320

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

◆ IsDriveFloppyW()

BOOL IsDriveFloppyW ( LPCWSTR  pszDriveRoot)

Definition at line 320 of file drvdefext.cpp.

321{
322 LPCWSTR RootPath = pszDriveRoot;
323 WCHAR szRoot[16], szDeviceName[16];
324 UINT uType;
325 HANDLE hDevice;
327 ULONG ulCharacteristics;
328 BOOL ret;
329
330 lstrcpynW(szRoot, RootPath, _countof(szRoot));
331
332 if (L'a' <= szRoot[0] && szRoot[0] <= 'z')
333 {
334 szRoot[0] += ('A' - 'a');
335 }
336
337 if ('A' <= szRoot[0] && szRoot[0] <= L'Z' &&
338 szRoot[1] == L':' && szRoot[2] == 0)
339 {
340 // 'C:' --> 'C:\'
341 szRoot[2] = L'\\';
342 szRoot[3] = 0;
343 }
344
345 if (!PathIsRootW(szRoot))
346 {
347 return FALSE;
348 }
349
350 uType = GetDriveTypeW(szRoot);
351 if (uType == DRIVE_REMOVABLE)
352 {
353 if (szRoot[0] == L'A' || szRoot[0] == L'B')
354 return TRUE;
355 }
356 else
357 {
358 return FALSE;
359 }
360
362 szDeviceName[4] = szRoot[0];
363 szDeviceName[5] = L':';
365
368 NULL, OPEN_EXISTING, 0, NULL);
369 if (hDevice == INVALID_HANDLE_VALUE)
370 {
371 return FALSE;
372 }
373
374 ret = FALSE;
375 if (GetDriveTypeAndCharacteristics(hDevice, &DeviceType, &ulCharacteristics))
376 {
377 if ((ulCharacteristics & FILE_FLOPPY_DISKETTE) == FILE_FLOPPY_DISKETTE)
378 ret = TRUE;
379 }
380
381 CloseHandle(hDevice);
382
383 return ret;
384}
static const WCHAR szDeviceName[]
Definition: provider.c:56
#define DEVICE_TYPE
Definition: guid.c:10
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrcpynW
Definition: compat.h:738
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1642
static BOOL GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
Definition: drvdefext.cpp:301
unsigned int BOOL
Definition: ntddk_ex.h:94
DeviceType
Definition: mmdrv.h:42
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define UNICODE_NULL
uint32_t ULONG
Definition: typedefs.h:59
int ret
#define DRIVE_REMOVABLE
Definition: winbase.h:251

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}
#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
int32_t INT
Definition: typedefs.h:58

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().