ReactOS  0.4.15-dev-449-g64abd9f
drvdefext.cpp
Go to the documentation of this file.
1 /*
2  * Provides default drive shell extension
3  *
4  * Copyright 2005 Johannes Anderwald
5  * Copyright 2012 Rafal Harabien
6  * Copyright 2020 Katayama Hirofumi MZ
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #include "precomp.h"
24 
25 #define _USE_MATH_DEFINES
26 #include <math.h>
27 
28 #define NTOS_MODE_USER
29 #include <ndk/iofuncs.h>
30 #include <ndk/obfuncs.h>
31 
33 
34 static const GUID GUID_DEVCLASS_DISKDRIVE = {0x4d36e967L, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}};
35 
36 typedef enum
37 {
42 
45  LPGUID lpGuids,
46  UINT uNumberOfGuids,
48 UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax);
49 
50 static VOID
51 GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
52 {
53  DWORD dwMaxComp, dwFileSys;
54  SIZE_T cchText = 0;
55 
56  if (GetVolumeInformationW(pwszDrive, pwszText, cchTextMax, NULL, &dwMaxComp, &dwFileSys, NULL, 0))
57  {
58  cchText = wcslen(pwszText);
59  if (cchText == 0)
60  {
61  /* load default volume label */
62  cchText = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, pwszText, cchTextMax);
63  }
64  }
65 
66  StringCchPrintfW(pwszText + cchText, cchTextMax - cchText, L" (%c:)", pwszDrive[0]);
67 }
68 
69 static VOID
70 InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
71 {
72  WCHAR wszText[100];
73  UINT Length;
74  SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pwszDrive);
75 
76  Length = GetWindowTextW(hwndDlg, wszText, sizeof(wszText) / sizeof(WCHAR));
77  wszText[Length] = L' ';
78  GetDriveNameWithLetter(&wszText[Length + 1], (sizeof(wszText) / sizeof(WCHAR)) - Length - 1, pwszDrive);
79  SetWindowText(hwndDlg, wszText);
80 }
81 
84 
85 static BOOLEAN NTAPI
88  IN ULONG SubAction,
89  IN PVOID ActionInfo)
90 {
91  PDWORD Progress;
92  PBOOLEAN pSuccess;
93  switch(Command)
94  {
95  case PROGRESS:
96  Progress = (PDWORD)ActionInfo;
97  SendDlgItemMessageW(hChkdskDrvDialog, 14002, PBM_SETPOS, (WPARAM)*Progress, 0);
98  break;
99  case DONE:
100  pSuccess = (PBOOLEAN)ActionInfo;
101  bChkdskSuccess = (*pSuccess);
102  break;
103 
104  case VOLUMEINUSE:
105  case INSUFFICIENTRIGHTS:
106  case FSNOTSUPPORTED:
107  case CLUSTERSIZETOOSMALL:
109  FIXME("\n");
110  break;
111 
112  default:
113  break;
114  }
115 
116  return TRUE;
117 }
118 
119 static VOID
120 ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
121 {
122  //DWORD ClusterSize = 0;
123  WCHAR wszFs[30];
124  ULARGE_INTEGER TotalNumberOfFreeBytes, FreeBytesAvailableUser;
125  BOOLEAN bCorrectErrors = FALSE, bScanDrive = FALSE;
126 
127  if(!GetVolumeInformationW(pwszDrive, NULL, 0, NULL, NULL, NULL, wszFs, _countof(wszFs)))
128  {
129  FIXME("failed to get drive fs type\n");
130  return;
131  }
132 
133  if (!GetDiskFreeSpaceExW(pwszDrive, &FreeBytesAvailableUser, &TotalNumberOfFreeBytes, NULL))
134  {
135  FIXME("failed to get drive space type\n");
136  return;
137  }
138 
139  /*if (!GetDefaultClusterSize(wszFs, &ClusterSize, &TotalNumberOfFreeBytes))
140  {
141  FIXME("invalid cluster size\n");
142  return;
143  }*/
144 
145  if (SendDlgItemMessageW(hwndDlg, 14000, BM_GETCHECK, 0, 0) == BST_CHECKED)
146  bCorrectErrors = TRUE;
147 
148  if (SendDlgItemMessageW(hwndDlg, 14001, BM_GETCHECK, 0, 0) == BST_CHECKED)
149  bScanDrive = TRUE;
150 
151  hChkdskDrvDialog = hwndDlg;
153  SendDlgItemMessageW(hwndDlg, 14002, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
154  Chkdsk((LPWSTR)pwszDrive, (LPWSTR)wszFs, bCorrectErrors, TRUE, FALSE, bScanDrive, NULL, NULL, ChkdskCallback); // FIXME: casts
155 
158 }
159 
160 static INT_PTR CALLBACK
162  HWND hwndDlg,
163  UINT uMsg,
164  WPARAM wParam,
165  LPARAM lParam)
166 {
167  switch(uMsg)
168  {
169  case WM_INITDIALOG:
172  return TRUE;
173  case WM_COMMAND:
174  switch(LOWORD(wParam))
175  {
176  case IDCANCEL:
177  EndDialog(hwndDlg, 0);
178  break;
179  case IDOK:
180  {
181  LPCWSTR pwszDrive = (LPCWSTR)GetWindowLongPtr(hwndDlg, DWLP_USER);
182  ChkDskNow(hwndDlg, pwszDrive);
183  break;
184  }
185  }
186  break;
187  }
188 
189  return FALSE;
190 }
191 
192 VOID
194 {
195  HBRUSH hBrush;
196 
197  if (pDrawItem->CtlID == 14013)
198  {
199  hBrush = CreateSolidBrush(RGB(0, 0, 255));
200  if (hBrush)
201  {
202  FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
203  DeleteObject((HGDIOBJ)hBrush);
204  }
205  }
206  else if (pDrawItem->CtlID == 14014)
207  {
208  hBrush = CreateSolidBrush(RGB(255, 0, 255));
209  if (hBrush)
210  {
211  FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
212  DeleteObject((HGDIOBJ)hBrush);
213  }
214  }
215  else if (pDrawItem->CtlID == 14015)
216  {
217  HBRUSH hBlueBrush = CreateSolidBrush(RGB(0, 0, 255));
218  HBRUSH hMagBrush = CreateSolidBrush(RGB(255, 0, 255));
219  HBRUSH hbrOld;
220  HPEN hDarkBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 128));
221  HPEN hDarkMagPen = CreatePen(PS_SOLID, 1, RGB(128, 0, 128));
222  HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen);
223  INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right) / 2;
224  INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10) / 2;
225  INT cx = pDrawItem->rcItem.right - pDrawItem->rcItem.left;
226  INT cy = pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - 10;
227  INT xRadial = xCenter + (INT)(cos(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cx / 2);
228  INT yRadial = yCenter - (INT)(sin(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cy / 2);
229 
230  TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc / 100.0f * M_PI * 2.0f, cx);
231 
232  for (INT x = pDrawItem->rcItem.left; x < pDrawItem->rcItem.right; ++x)
233  {
234  double cos_val = (x - xCenter) * 2.0f / cx;
235  INT y = yCenter + (INT)(sin(acos(cos_val)) * cy / 2) - 1;
236 
237  if (m_FreeSpacePerc < 50 && x == xRadial)
238  SelectObject(pDrawItem->hDC, hDarkBluePen);
239 
240  MoveToEx(pDrawItem->hDC, x, y, NULL);
241  LineTo(pDrawItem->hDC, x, y + 10);
242  }
243 
244  SelectObject(pDrawItem->hDC, hOldPen);
245 
246  if (m_FreeSpacePerc > 50)
247  {
248  hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush);
249 
250  Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
251  pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
252 
253  SelectObject(pDrawItem->hDC, hBlueBrush);
254 
255  if (m_FreeSpacePerc < 100)
256  {
257  Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
258  pDrawItem->rcItem.bottom - 10, xRadial, yRadial, pDrawItem->rcItem.left, yCenter);
259  }
260  }
261  else
262  {
263  hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hBlueBrush);
264 
265  Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
266  pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
267 
268  SelectObject(pDrawItem->hDC, hMagBrush);
269 
270  if (m_FreeSpacePerc > 0)
271  {
272  Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
273  pDrawItem->rcItem.bottom - 10, pDrawItem->rcItem.left, yCenter, xRadial, yRadial);
274  }
275  }
276 
277  SelectObject(pDrawItem->hDC, hbrOld);
278 
279  DeleteObject(hBlueBrush);
280  DeleteObject(hMagBrush);
281  DeleteObject(hDarkBluePen);
282  DeleteObject(hDarkMagPen);
283  }
284 }
285 
286 // https://stackoverflow.com/questions/3098696/get-information-about-disk-drives-result-on-windows7-32-bit-system/3100268#3100268
287 static BOOL
288 GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
289 {
293 
295  &DeviceInfo, sizeof(DeviceInfo),
297  if (Status == NO_ERROR)
298  {
299  *pDeviceType = DeviceInfo.DeviceType;
300  *pCharacteristics = DeviceInfo.Characteristics;
301  return TRUE;
302  }
303 
304  return FALSE;
305 }
306 
308 {
309  LPCWSTR RootPath = pszDriveRoot;
310  WCHAR szRoot[16], szDeviceName[16];
311  UINT uType;
312  HANDLE hDevice;
314  ULONG ulCharacteristics;
315  BOOL ret;
316 
317  lstrcpynW(szRoot, RootPath, _countof(szRoot));
318 
319  if (L'a' <= szRoot[0] && szRoot[0] <= 'z')
320  {
321  szRoot[0] += ('A' - 'a');
322  }
323 
324  if ('A' <= szRoot[0] && szRoot[0] <= L'Z' &&
325  szRoot[1] == L':' && szRoot[2] == 0)
326  {
327  // 'C:' --> 'C:\'
328  szRoot[2] = L'\\';
329  szRoot[3] = 0;
330  }
331 
332  if (!PathIsRootW(szRoot))
333  {
334  return FALSE;
335  }
336 
337  uType = GetDriveTypeW(szRoot);
338  if (uType == DRIVE_REMOVABLE)
339  {
340  if (szRoot[0] == L'A' || szRoot[0] == L'B')
341  return TRUE;
342  }
343  else
344  {
345  return FALSE;
346  }
347 
349  szDeviceName[4] = szRoot[0];
350  szDeviceName[5] = L':';
352 
355  NULL, OPEN_EXISTING, 0, NULL);
356  if (hDevice == INVALID_HANDLE_VALUE)
357  {
358  return FALSE;
359  }
360 
361  ret = FALSE;
362  if (GetDriveTypeAndCharacteristics(hDevice, &DeviceType, &ulCharacteristics))
363  {
364  if ((ulCharacteristics & FILE_FLOPPY_DISKETTE) == FILE_FLOPPY_DISKETTE)
365  ret = TRUE;
366  }
367 
368  CloseHandle(hDevice);
369 
370  return ret;
371 }
372 
374 {
375  WCHAR szRoot[8];
376  MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
377  return IsDriveFloppyW(szRoot);
378 }
379 
380 VOID
382 {
383  WCHAR wszVolumeName[MAX_PATH+1] = {0};
384  WCHAR wszFileSystem[MAX_PATH+1] = {0};
385  WCHAR wszBuf[128];
386  BOOL bRet;
387 
388  bRet = GetVolumeInformationW(m_wszDrive, wszVolumeName, _countof(wszVolumeName), NULL, NULL, NULL, wszFileSystem, _countof(wszFileSystem));
389  if (bRet)
390  {
391  /* Set volume label and filesystem */
392  SetDlgItemTextW(hwndDlg, 14000, wszVolumeName);
393  SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
394  }
395  else
396  {
397  LoadStringW(shell32_hInstance, IDS_FS_UNKNOWN, wszFileSystem, _countof(wszFileSystem));
398  SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
399  }
400 
401  /* Set drive type and icon */
403  UINT IconId, TypeStrId = 0;
404  switch (DriveType)
405  {
406  case DRIVE_REMOVABLE:
408  IconId = IDI_SHELL_3_14_FLOPPY;
409  else
410  IconId = IDI_SHELL_REMOVEABLE;
411  break;
412  case DRIVE_CDROM: IconId = IDI_SHELL_CDROM; TypeStrId = IDS_DRIVE_CDROM; break;
413  case DRIVE_REMOTE: IconId = IDI_SHELL_NETDRIVE; TypeStrId = IDS_DRIVE_NETWORK; break;
414  case DRIVE_RAMDISK: IconId = IDI_SHELL_RAMDISK; break;
415  default: IconId = IDI_SHELL_DRIVE; TypeStrId = IDS_DRIVE_FIXED;
416  }
417 
419  {
420  /* volume label textbox */
421  SendMessage(GetDlgItem(hwndDlg, 14000), EM_SETREADONLY, TRUE, 0);
422 
423  /* disk compression */
424  ShowWindow(GetDlgItem(hwndDlg, 14011), FALSE);
425 
426  /* index */
427  ShowWindow(GetDlgItem(hwndDlg, 14012), FALSE);
428  }
429 
431  if (hIcon)
432  SendDlgItemMessageW(hwndDlg, 14016, STM_SETICON, (WPARAM)hIcon, 0);
433  if (TypeStrId && LoadStringW(shell32_hInstance, TypeStrId, wszBuf, _countof(wszBuf)))
434  SetDlgItemTextW(hwndDlg, 14001, wszBuf);
435 
436  ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes;
437  if(GetDiskFreeSpaceExW(m_wszDrive, &FreeBytesAvailable, &TotalNumberOfBytes, NULL))
438  {
439  /* Init free space percentage used for drawing piechart */
440  m_FreeSpacePerc = (UINT)(FreeBytesAvailable.QuadPart * 100ull / TotalNumberOfBytes.QuadPart);
441 
442  /* Used space */
443  if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
444  SetDlgItemTextW(hwndDlg, 14003, wszBuf);
445 
446  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
447  SetDlgItemTextW(hwndDlg, 14004, wszBuf);
448 
449  /* Free space */
450  if (SH_FormatByteSize(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
451  SetDlgItemTextW(hwndDlg, 14005, wszBuf);
452 
453  if (StrFormatByteSizeW(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
454  SetDlgItemTextW(hwndDlg, 14006, wszBuf);
455 
456  /* Total space */
457  if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
458  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
459 
460  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
461  SetDlgItemTextW(hwndDlg, 14008, wszBuf);
462  }
463  else
464  {
465  m_FreeSpacePerc = 0;
466 
467  if (SH_FormatByteSize(0, wszBuf, _countof(wszBuf)))
468  {
469  SetDlgItemTextW(hwndDlg, 14003, wszBuf);
470  SetDlgItemTextW(hwndDlg, 14005, wszBuf);
471  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
472  }
473  if (StrFormatByteSizeW(0, wszBuf, _countof(wszBuf)))
474  {
475  SetDlgItemTextW(hwndDlg, 14004, wszBuf);
476  SetDlgItemTextW(hwndDlg, 14006, wszBuf);
477  SetDlgItemTextW(hwndDlg, 14008, wszBuf);
478  }
479  }
480 
481  /* Set drive description */
482  WCHAR wszFormat[50];
483  GetDlgItemTextW(hwndDlg, 14009, wszFormat, _countof(wszFormat));
484  swprintf(wszBuf, wszFormat, m_wszDrive[0]);
485  SetDlgItemTextW(hwndDlg, 14009, wszBuf);
486 
487  /* show disk cleanup button only for fixed drives */
488  ShowWindow(GetDlgItem(hwndDlg, 14010), DriveType == DRIVE_FIXED);
489 }
490 
493  HWND hwndDlg,
494  UINT uMsg,
495  WPARAM wParam,
496  LPARAM lParam)
497 {
498  switch(uMsg)
499  {
500  case WM_INITDIALOG:
501  {
503  if (ppsp == NULL)
504  break;
505 
506  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(ppsp->lParam);
507  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDrvDefExt);
508  pDrvDefExt->InitGeneralPage(hwndDlg);
509  return TRUE;
510  }
511  case WM_DRAWITEM:
512  {
514 
515  if (pDrawItem->CtlID >= 14013 && pDrawItem->CtlID <= 14015)
516  {
517  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
518  pDrvDefExt->PaintStaticControls(hwndDlg, pDrawItem);
519  return TRUE;
520  }
521  break;
522  }
523  case WM_PAINT:
524  break;
525  case WM_COMMAND:
526  if (LOWORD(wParam) == 14010) /* Disk Cleanup */
527  {
528  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
529  WCHAR wszBuf[256];
530  DWORD cbBuf = sizeof(wszBuf);
531 
533  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath",
534  NULL,
536  NULL,
537  (PVOID)wszBuf,
538  &cbBuf) == ERROR_SUCCESS)
539  {
540  WCHAR wszCmd[MAX_PATH];
541 
542  StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
543 
544  if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
545  ERR("Failed to create cleanup process %ls\n", wszCmd);
546  }
547  }
548  else if (LOWORD(wParam) == 14000) /* Label */
549  {
550  if (HIWORD(wParam) == EN_CHANGE)
551  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
552  }
553  break;
554  case WM_NOTIFY:
555  if (((LPNMHDR)lParam)->hwndFrom == GetParent(hwndDlg))
556  {
557  /* Property Sheet */
558  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
559 
560  if (lppsn->hdr.code == PSN_APPLY)
561  {
562  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
563  WCHAR wszBuf[256];
564 
565  if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf)))
566  SetVolumeLabelW(pDrvDefExt->m_wszDrive, wszBuf);
568  return TRUE;
569  }
570  }
571  break;
572 
573  default:
574  break;
575  }
576 
577  return FALSE;
578 }
579 
582  HWND hwndDlg,
583  UINT uMsg,
584  WPARAM wParam,
585  LPARAM lParam)
586 {
587  switch (uMsg)
588  {
589  case WM_INITDIALOG:
590  {
592  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)ppsp->lParam);
593  return TRUE;
594  }
595  case WM_COMMAND:
596  {
597  WCHAR wszBuf[MAX_PATH];
598  DWORD cbBuf = sizeof(wszBuf);
599  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
600 
601  switch(LOWORD(wParam))
602  {
603  case 14000:
605  break;
606  case 14001:
608  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\DefragPath",
609  NULL,
611  NULL,
612  (PVOID)wszBuf,
613  &cbBuf) == ERROR_SUCCESS)
614  {
615  WCHAR wszCmd[MAX_PATH];
616 
617  StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
618 
619  if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
620  ERR("Failed to create defrag process %ls\n", wszCmd);
621  }
622  break;
623  case 14002:
625  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\BackupPath",
626  NULL,
628  NULL,
629  (PVOID)wszBuf,
630  &cbBuf) == ERROR_SUCCESS)
631  {
632  if (ShellExecuteW(hwndDlg, NULL, wszBuf, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
633  ERR("Failed to create backup process %ls\n", wszBuf);
634  }
635  }
636  break;
637  }
638  }
639  return FALSE;
640 }
641 
644  HWND hwndDlg,
645  UINT uMsg,
646  WPARAM wParam,
647  LPARAM lParam)
648 {
651 
652  switch(uMsg)
653  {
654  case WM_INITDIALOG:
655  {
657 
658  /* create the hardware page */
660  break;
661  }
662  }
663 
664  return FALSE;
665 }
666 
668 {
669  m_wszDrive[0] = L'\0';
670 }
671 
673 {
674 
675 }
676 
678 CDrvDefExt::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
679 {
680  FORMATETC format;
681  STGMEDIUM stgm;
682  HRESULT hr;
683 
684  TRACE("%p %p %p %p\n", this, pidlFolder, pDataObj, hkeyProgID);
685 
686  if (!pDataObj)
687  return E_FAIL;
688 
689  format.cfFormat = CF_HDROP;
690  format.ptd = NULL;
691  format.dwAspect = DVASPECT_CONTENT;
692  format.lindex = -1;
693  format.tymed = TYMED_HGLOBAL;
694 
695  hr = pDataObj->GetData(&format, &stgm);
696  if (FAILED(hr))
697  return hr;
698 
699  if (!DragQueryFileW((HDROP)stgm.hGlobal, 0, m_wszDrive, _countof(m_wszDrive)))
700  {
701  ERR("DragQueryFileW failed\n");
702  ReleaseStgMedium(&stgm);
703  return E_FAIL;
704  }
705 
706  ReleaseStgMedium(&stgm);
707  TRACE("Drive properties %ls\n", m_wszDrive);
708 
709  return S_OK;
710 }
711 
713 CDrvDefExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
714 {
716  return E_NOTIMPL;
717 }
718 
721 {
723  return E_NOTIMPL;
724 }
725 
727 CDrvDefExt::GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
728 {
730  return E_NOTIMPL;
731 }
732 
735 {
736  HPROPSHEETPAGE hPage;
737 
740  (LPARAM)this,
741  NULL);
742  if (hPage)
743  pfnAddPage(hPage, lParam);
744 
746  {
749  (LPARAM)this,
750  NULL);
751  if (hPage)
752  pfnAddPage(hPage, lParam);
753  }
754 
756  {
759  (LPARAM)this,
760  NULL);
761  if (hPage)
762  pfnAddPage(hPage, lParam);
763  }
764 
765  return S_OK;
766 }
767 
770 {
772  return E_NOTIMPL;
773 }
774 
777 {
779  return E_NOTIMPL;
780 }
781 
783 CDrvDefExt::GetSite(REFIID iid, void **ppvSite)
784 {
786  return E_NOTIMPL;
787 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
static INT_PTR CALLBACK ExtraPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drvdefext.cpp:581
static BOOLEAN NTAPI ChkdskCallback(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drvdefext.cpp:86
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2376
#define STM_SETICON
Definition: winuser.h:2074
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IN
Definition: typedefs.h:39
static HICON
Definition: imagelist.c:84
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2271
#define IDI_SHELL_DRIVE
Definition: shresdef.h:487
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:407
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:182
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
static HMENU hmenu
Definition: win.c:66
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drvdefext.cpp:492
#define RGB(r, g, b)
Definition: precomp.h:62
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define EM_SETREADONLY
Definition: winuser.h:1997
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
struct _PSHNOTIFY * LPPSHNOTIFY
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
DeviceType
Definition: mmdrv.h:41
#define CP_ACP
Definition: compat.h:99
virtual HRESULT WINAPI GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
Definition: drvdefext.cpp:727
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
LONG NTSTATUS
Definition: precomp.h:26
#define INT
Definition: polytest.cpp:20
#define DRIVE_RAMDISK
Definition: winbase.h:252
#define CALLBACK
Definition: compat.h:27
LONG top
Definition: windef.h:307
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:486
#define IDD_DRIVE_PROPERTIES
Definition: shresdef.h:337
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
Definition: fmifs.h:68
UINT DriveType
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot)
Definition: drvdefext.cpp:373
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define PBM_SETPOS
Definition: commctrl.h:2180
virtual HRESULT WINAPI ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
Definition: drvdefext.cpp:769
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
UINT_PTR WPARAM
Definition: windef.h:207
#define PSN_APPLY
Definition: prsht.h:117
Definition: shell.h:41
LONG left
Definition: windef.h:306
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
UINT uFlags
Definition: api.c:59
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT_PTR
Definition: typedefs.h:63
CALLBACKCOMMAND
Definition: fmifs.h:66
char * LPSTR
Definition: xmlstorage.h:182
LONG right
Definition: windef.h:308
#define NO_ERROR
Definition: dderror.h:5
#define E_FAIL
Definition: ddrawi.h:102
virtual HRESULT WINAPI SetSite(IUnknown *punk)
Definition: drvdefext.cpp:776
#define IDS_DRIVE_CDROM
Definition: shresdef.h:106
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:57
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define FILE_SHARE_READ
Definition: compat.h:125
#define DRIVE_REMOVABLE
Definition: winbase.h:248
#define lstrcpynW
Definition: compat.h:406
HWPAGE_DISPLAYMODE
Definition: main.h:22
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
static INT_PTR CALLBACK ChkDskDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drvdefext.cpp:161
enum HWPAGE_DISPLAYMODE * PHWPAGE_DISPLAYMODE
UINT code
Definition: winuser.h:3134
#define PBM_SETRANGE
Definition: commctrl.h:2179
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
NMHDR hdr
Definition: prsht.h:330
#define PS_SOLID
Definition: wingdi.h:585
valarray< _Tp > acos(const valarray< _Tp > &__x)
Definition: _valarray.h:901
#define DRIVE_REMOTE
Definition: winbase.h:250
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define DRIVE_CDROM
Definition: machpc98.h:115
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static BOOLEAN bChkdskSuccess
Definition: drvdefext.cpp:83
#define FIXME(fmt,...)
Definition: debug.h:111
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
unsigned char BOOLEAN
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
struct _PROPSHEETPAGEW * LPPROPSHEETPAGEW
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define CF_HDROP
Definition: constants.h:410
LONG_PTR LPARAM
Definition: windef.h:208
#define BM_GETCHECK
Definition: winuser.h:1900
EXTERN_C HWND WINAPI DeviceCreateHardwarePageEx(HWND hWndParent, LPGUID lpGuids, UINT uNumberOfGuids, HWPAGE_DISPLAYMODE DisplayMode)
const char * LPCSTR
Definition: xmlstorage.h:183
#define SW_SHOW
Definition: winuser.h:769
VOID InitGeneralPage(HWND hwndDlg)
Definition: drvdefext.cpp:381
#define OPEN_EXISTING
Definition: compat.h:435
UINT m_FreeSpacePerc
Definition: drvdefext.h:40
_In_ int cchText
Definition: winuser.h:4440
VOID PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT pDrawItem)
Definition: drvdefext.cpp:193
#define IDD_DRIVE_HARDWARE
Definition: shresdef.h:339
int64_t LONGLONG
Definition: typedefs.h:67
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1621
GLfloat f
Definition: glext.h:7540
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:485
#define TRACE(s)
Definition: solgame.cpp:4
#define IDS_DRIVE_FIXED
Definition: shresdef.h:105
HWPAGE_DISPLAYMODE
Definition: drvdefext.cpp:36
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI Pie(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
LONG HRESULT
Definition: typedefs.h:78
BOOL WINAPI SetVolumeLabelW(IN LPCWSTR lpRootPathName, IN LPCWSTR lpVolumeName OPTIONAL)
Definition: volume.c:503
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:6
struct _DeviceInfo DeviceInfo
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UINT cchMax
#define IDD_DRIVE_TOOLS
Definition: shresdef.h:338
#define WM_PAINT
Definition: winuser.h:1602
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define PSNRET_NOERROR
Definition: prsht.h:129
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:115
static BOOL GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
Definition: drvdefext.cpp:288
int ret
char * PBOOLEAN
Definition: retypes.h:11
static VOID ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:120
static const WCHAR L[]
Definition: oid.c:1250
LPARAM lParam
Definition: prsht.h:227
static VOID InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:70
#define DWLP_USER
Definition: winuser.h:866
WCHAR m_wszDrive[MAX_PATH]
Definition: drvdefext.h:39
#define WM_COMMAND
Definition: winuser.h:1722
virtual HRESULT WINAPI AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
Definition: drvdefext.cpp:734
static const WCHAR szDeviceName[]
Definition: provider.c:56
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
static VOID GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:51
#define DRIVE_FIXED
Definition: winbase.h:249
Status
Definition: gdiplustypes.h:24
#define IDS_DRIVE_NETWORK
Definition: shresdef.h:107
#define ERR(fmt,...)
Definition: debug.h:110
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:79
HWND WINAPI GetParent(_In_ HWND)
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define S_OK
Definition: intsafe.h:59
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
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 IDD_CHECK_DISK
Definition: shresdef.h:453
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
HICON hIcon
Definition: msconfig.c:44
static const GUID GUID_DEVCLASS_DISKDRIVE
Definition: drvdefext.cpp:34
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define E_NOTIMPL
Definition: ddrawi.h:99
#define DEVICE_TYPE
Definition: guid.c:10
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define SetWindowText
Definition: winuser.h:5832
#define M_PI
Definition: macros.h:263
unsigned int UINT
Definition: ndis.h:50
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDI_SHELL_CDROM
Definition: shresdef.h:490
DWORD * PDWORD
Definition: pedump.c:68
virtual HRESULT WINAPI GetSite(REFIID iid, void **ppvSite)
Definition: drvdefext.cpp:783
#define MultiByteToWideChar
Definition: compat.h:100
#define BST_CHECKED
Definition: winuser.h:197
static HWND hChkdskDrvDialog
Definition: drvdefext.cpp:82
#define CreateFileW
Definition: compat.h:409
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:307
#define WM_DRAWITEM
Definition: winuser.h:1627
_Out_opt_ int * cx
Definition: commctrl.h:581
#define SendMessage
Definition: winuser.h:5818
virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
Definition: drvdefext.cpp:720
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274
virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
Definition: drvdefext.cpp:678
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
LONG bottom
Definition: windef.h:309
#define IDI_SHELL_RAMDISK
Definition: shresdef.h:491
#define LoadImage
Definition: winuser.h:5790
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:488
#define DONE
Definition: rnr20lib.h:14
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define GetWindowLongPtr
Definition: treelist.c:73
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define IDS_FS_UNKNOWN
Definition: shresdef.h:110
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define EXTERN_C
Definition: basetyps.h:12
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
virtual HRESULT WINAPI QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
Definition: drvdefext.cpp:713
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define WM_NOTIFY
Definition: richedit.h:61
static INT_PTR CALLBACK HardwarePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drvdefext.cpp:643
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define EN_CHANGE
Definition: winuser.h:2004