ReactOS  0.4.15-dev-5496-g599ba9c
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 #include <devguid.h>
28 
29 #define NTOS_MODE_USER
30 #include <ndk/iofuncs.h>
31 #include <ndk/obfuncs.h>
32 
34 
35 typedef enum
36 {
41 
44  LPGUID lpGuids,
45  UINT uNumberOfGuids,
47 UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax);
48 
49 static VOID
50 GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
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 }
67 
68 static VOID
69 InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
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 }
80 
83 
84 static BOOLEAN NTAPI
87  IN ULONG SubAction,
88  IN PVOID ActionInfo)
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 }
117 
118 static VOID
119 ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
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 }
158 
159 static INT_PTR CALLBACK
161  HWND hwndDlg,
162  UINT uMsg,
163  WPARAM wParam,
164  LPARAM lParam)
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 }
190 
191 VOID
193 {
194  HBRUSH hBrush;
195 
196  if (pDrawItem->CtlID == 14013)
197  {
198  hBrush = CreateSolidBrush(RGB(0, 0, 255));
199  if (hBrush)
200  {
201  FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
202  DeleteObject((HGDIOBJ)hBrush);
203  }
204  }
205  else if (pDrawItem->CtlID == 14014)
206  {
207  hBrush = CreateSolidBrush(RGB(255, 0, 255));
208  if (hBrush)
209  {
210  FillRect(pDrawItem->hDC, &pDrawItem->rcItem, hBrush);
211  DeleteObject((HGDIOBJ)hBrush);
212  }
213  }
214  else if (pDrawItem->CtlID == 14015)
215  {
216  HBRUSH hBlueBrush = CreateSolidBrush(RGB(0, 0, 255));
217  HBRUSH hMagBrush = CreateSolidBrush(RGB(255, 0, 255));
218  HBRUSH hbrOld;
219  HPEN hDarkBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 128));
220  HPEN hDarkMagPen = CreatePen(PS_SOLID, 1, RGB(128, 0, 128));
221  HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen);
222  INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right) / 2;
223  INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10) / 2;
224  INT cx = pDrawItem->rcItem.right - pDrawItem->rcItem.left;
225  INT cy = pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - 10;
226  INT xRadial = xCenter + (INT)(cos(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cx / 2);
227  INT yRadial = yCenter - (INT)(sin(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cy / 2);
228 
229  TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc / 100.0f * M_PI * 2.0f, cx);
230 
231  for (INT x = pDrawItem->rcItem.left; x < pDrawItem->rcItem.right; ++x)
232  {
233  double cos_val = (x - xCenter) * 2.0f / cx;
234  INT y = yCenter + (INT)(sin(acos(cos_val)) * cy / 2) - 1;
235 
236  if (m_FreeSpacePerc < 50 && x == xRadial)
237  SelectObject(pDrawItem->hDC, hDarkBluePen);
238 
239  MoveToEx(pDrawItem->hDC, x, y, NULL);
240  LineTo(pDrawItem->hDC, x, y + 10);
241  }
242 
243  SelectObject(pDrawItem->hDC, hOldPen);
244 
245  if (m_FreeSpacePerc > 50)
246  {
247  hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush);
248 
249  Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
250  pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
251 
252  SelectObject(pDrawItem->hDC, hBlueBrush);
253 
254  if (m_FreeSpacePerc < 100)
255  {
256  Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
257  pDrawItem->rcItem.bottom - 10, xRadial, yRadial, pDrawItem->rcItem.left, yCenter);
258  }
259  }
260  else
261  {
262  hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hBlueBrush);
263 
264  Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
265  pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
266 
267  SelectObject(pDrawItem->hDC, hMagBrush);
268 
269  if (m_FreeSpacePerc > 0)
270  {
271  Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
272  pDrawItem->rcItem.bottom - 10, pDrawItem->rcItem.left, yCenter, xRadial, yRadial);
273  }
274  }
275 
276  SelectObject(pDrawItem->hDC, hbrOld);
277 
278  DeleteObject(hBlueBrush);
279  DeleteObject(hMagBrush);
280  DeleteObject(hDarkBluePen);
281  DeleteObject(hDarkMagPen);
282  }
283 }
284 
285 // https://stackoverflow.com/questions/3098696/get-information-about-disk-drives-result-on-windows7-32-bit-system/3100268#3100268
286 static BOOL
287 GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
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 }
305 
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 }
371 
373 {
374  WCHAR szRoot[8];
375  MultiByteToWideChar(CP_ACP, 0, pszDriveRoot, -1, szRoot, _countof(szRoot));
376  return IsDriveFloppyW(szRoot);
377 }
378 
379 VOID
381 {
382  WCHAR wszVolumeName[MAX_PATH+1] = {0};
383  WCHAR wszFileSystem[MAX_PATH+1] = {0};
384  WCHAR wszBuf[128];
385  BOOL bRet;
386 
387  bRet = GetVolumeInformationW(m_wszDrive, wszVolumeName, _countof(wszVolumeName), NULL, NULL, NULL, wszFileSystem, _countof(wszFileSystem));
388  if (bRet)
389  {
390  /* Set volume label and filesystem */
391  SetDlgItemTextW(hwndDlg, 14000, wszVolumeName);
392  SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
393  }
394  else
395  {
396  LoadStringW(shell32_hInstance, IDS_FS_UNKNOWN, wszFileSystem, _countof(wszFileSystem));
397  SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
398  }
399 
400  /* Set drive type and icon */
402  UINT IconId, TypeStrId = 0;
403  switch (DriveType)
404  {
405  case DRIVE_REMOVABLE:
407  IconId = IDI_SHELL_3_14_FLOPPY;
408  else
409  IconId = IDI_SHELL_REMOVEABLE;
410  break;
411  case DRIVE_CDROM: IconId = IDI_SHELL_CDROM; TypeStrId = IDS_DRIVE_CDROM; break;
412  case DRIVE_REMOTE: IconId = IDI_SHELL_NETDRIVE; TypeStrId = IDS_DRIVE_NETWORK; break;
413  case DRIVE_RAMDISK: IconId = IDI_SHELL_RAMDISK; break;
414  default: IconId = IDI_SHELL_DRIVE; TypeStrId = IDS_DRIVE_FIXED;
415  }
416 
418  {
419  /* volume label textbox */
420  SendMessage(GetDlgItem(hwndDlg, 14000), EM_SETREADONLY, TRUE, 0);
421 
422  /* disk compression */
423  ShowWindow(GetDlgItem(hwndDlg, 14011), FALSE);
424 
425  /* index */
426  ShowWindow(GetDlgItem(hwndDlg, 14012), FALSE);
427  }
428 
430  if (hIcon)
431  SendDlgItemMessageW(hwndDlg, 14016, STM_SETICON, (WPARAM)hIcon, 0);
432  if (TypeStrId && LoadStringW(shell32_hInstance, TypeStrId, wszBuf, _countof(wszBuf)))
433  SetDlgItemTextW(hwndDlg, 14001, wszBuf);
434 
435  ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes;
436  if(GetDiskFreeSpaceExW(m_wszDrive, &FreeBytesAvailable, &TotalNumberOfBytes, NULL))
437  {
438  /* Init free space percentage used for drawing piechart */
439  m_FreeSpacePerc = (UINT)(FreeBytesAvailable.QuadPart * 100ull / TotalNumberOfBytes.QuadPart);
440 
441  /* Used space */
442  if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
443  SetDlgItemTextW(hwndDlg, 14003, wszBuf);
444 
445  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart - FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
446  SetDlgItemTextW(hwndDlg, 14004, wszBuf);
447 
448  /* Free space */
449  if (SH_FormatByteSize(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
450  SetDlgItemTextW(hwndDlg, 14005, wszBuf);
451 
452  if (StrFormatByteSizeW(FreeBytesAvailable.QuadPart, wszBuf, _countof(wszBuf)))
453  SetDlgItemTextW(hwndDlg, 14006, wszBuf);
454 
455  /* Total space */
456  if (SH_FormatByteSize(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
457  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
458 
459  if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
460  SetDlgItemTextW(hwndDlg, 14008, wszBuf);
461  }
462  else
463  {
464  m_FreeSpacePerc = 0;
465 
466  if (SH_FormatByteSize(0, wszBuf, _countof(wszBuf)))
467  {
468  SetDlgItemTextW(hwndDlg, 14003, wszBuf);
469  SetDlgItemTextW(hwndDlg, 14005, wszBuf);
470  SetDlgItemTextW(hwndDlg, 14007, wszBuf);
471  }
472  if (StrFormatByteSizeW(0, wszBuf, _countof(wszBuf)))
473  {
474  SetDlgItemTextW(hwndDlg, 14004, wszBuf);
475  SetDlgItemTextW(hwndDlg, 14006, wszBuf);
476  SetDlgItemTextW(hwndDlg, 14008, wszBuf);
477  }
478  }
479 
480  /* Set drive description */
481  WCHAR wszFormat[50];
482  GetDlgItemTextW(hwndDlg, 14009, wszFormat, _countof(wszFormat));
483  swprintf(wszBuf, wszFormat, m_wszDrive[0]);
484  SetDlgItemTextW(hwndDlg, 14009, wszBuf);
485 
486  /* show disk cleanup button only for fixed drives */
487  ShowWindow(GetDlgItem(hwndDlg, 14010), DriveType == DRIVE_FIXED);
488 }
489 
492  HWND hwndDlg,
493  UINT uMsg,
494  WPARAM wParam,
495  LPARAM lParam)
496 {
497  switch(uMsg)
498  {
499  case WM_INITDIALOG:
500  {
502  if (ppsp == NULL)
503  break;
504 
505  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(ppsp->lParam);
506  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDrvDefExt);
507  pDrvDefExt->InitGeneralPage(hwndDlg);
508  return TRUE;
509  }
510  case WM_DRAWITEM:
511  {
513 
514  if (pDrawItem->CtlID >= 14013 && pDrawItem->CtlID <= 14015)
515  {
516  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
517  pDrvDefExt->PaintStaticControls(hwndDlg, pDrawItem);
518  return TRUE;
519  }
520  break;
521  }
522  case WM_PAINT:
523  break;
524  case WM_COMMAND:
525  if (LOWORD(wParam) == 14010) /* Disk Cleanup */
526  {
527  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
528  WCHAR wszBuf[256];
529  DWORD cbBuf = sizeof(wszBuf);
530 
532  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath",
533  NULL,
535  NULL,
536  (PVOID)wszBuf,
537  &cbBuf) == ERROR_SUCCESS)
538  {
539  WCHAR wszCmd[MAX_PATH];
540 
541  StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
542 
543  if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
544  ERR("Failed to create cleanup process %ls\n", wszCmd);
545  }
546  }
547  else if (LOWORD(wParam) == 14000) /* Label */
548  {
549  if (HIWORD(wParam) == EN_CHANGE)
550  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
551  }
552  break;
553  case WM_NOTIFY:
554  if (((LPNMHDR)lParam)->hwndFrom == GetParent(hwndDlg))
555  {
556  /* Property Sheet */
557  LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
558 
559  if (lppsn->hdr.code == PSN_APPLY)
560  {
561  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
562  WCHAR wszBuf[256];
563 
564  if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf)))
565  SetVolumeLabelW(pDrvDefExt->m_wszDrive, wszBuf);
567  return TRUE;
568  }
569  }
570  break;
571 
572  default:
573  break;
574  }
575 
576  return FALSE;
577 }
578 
581  HWND hwndDlg,
582  UINT uMsg,
583  WPARAM wParam,
584  LPARAM lParam)
585 {
586  switch (uMsg)
587  {
588  case WM_INITDIALOG:
589  {
591  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)ppsp->lParam);
592  return TRUE;
593  }
594  case WM_COMMAND:
595  {
596  WCHAR wszBuf[MAX_PATH];
597  DWORD cbBuf = sizeof(wszBuf);
598  CDrvDefExt *pDrvDefExt = reinterpret_cast<CDrvDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
599 
600  switch(LOWORD(wParam))
601  {
602  case 14000:
604  break;
605  case 14001:
607  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\DefragPath",
608  NULL,
610  NULL,
611  (PVOID)wszBuf,
612  &cbBuf) == ERROR_SUCCESS)
613  {
614  WCHAR wszCmd[MAX_PATH];
615 
616  StringCbPrintfW(wszCmd, sizeof(wszCmd), wszBuf, pDrvDefExt->m_wszDrive[0]);
617 
618  if (ShellExecuteW(hwndDlg, NULL, wszCmd, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
619  ERR("Failed to create defrag process %ls\n", wszCmd);
620  }
621  break;
622  case 14002:
624  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\BackupPath",
625  NULL,
627  NULL,
628  (PVOID)wszBuf,
629  &cbBuf) == ERROR_SUCCESS)
630  {
631  if (ShellExecuteW(hwndDlg, NULL, wszBuf, NULL, NULL, SW_SHOW) <= (HINSTANCE)32)
632  ERR("Failed to create backup process %ls\n", wszBuf);
633  }
634  }
635  break;
636  }
637  }
638  return FALSE;
639 }
640 
643  HWND hwndDlg,
644  UINT uMsg,
645  WPARAM wParam,
646  LPARAM lParam)
647 {
650 
651  switch(uMsg)
652  {
653  case WM_INITDIALOG:
654  {
655  GUID Guids[2];
656  Guids[0] = GUID_DEVCLASS_DISKDRIVE;
657  Guids[1] = GUID_DEVCLASS_CDROM;
658 
659  /* create the hardware page */
660  DeviceCreateHardwarePageEx(hwndDlg, Guids, _countof(Guids), HWPD_STANDARDLIST);
661  break;
662  }
663  }
664 
665  return FALSE;
666 }
667 
669 {
670  m_wszDrive[0] = L'\0';
671 }
672 
674 {
675 
676 }
677 
679 CDrvDefExt::Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
680 {
681  FORMATETC format;
682  STGMEDIUM stgm;
683  HRESULT hr;
684 
685  TRACE("%p %p %p %p\n", this, pidlFolder, pDataObj, hkeyProgID);
686 
687  if (!pDataObj)
688  return E_FAIL;
689 
690  format.cfFormat = CF_HDROP;
691  format.ptd = NULL;
692  format.dwAspect = DVASPECT_CONTENT;
693  format.lindex = -1;
694  format.tymed = TYMED_HGLOBAL;
695 
696  hr = pDataObj->GetData(&format, &stgm);
697  if (FAILED(hr))
698  return hr;
699 
700  if (!DragQueryFileW((HDROP)stgm.hGlobal, 0, m_wszDrive, _countof(m_wszDrive)))
701  {
702  ERR("DragQueryFileW failed\n");
703  ReleaseStgMedium(&stgm);
704  return E_FAIL;
705  }
706 
707  ReleaseStgMedium(&stgm);
708  TRACE("Drive properties %ls\n", m_wszDrive);
709 
710  return S_OK;
711 }
712 
714 CDrvDefExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
715 {
717  return E_NOTIMPL;
718 }
719 
722 {
724  return E_NOTIMPL;
725 }
726 
728 CDrvDefExt::GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
729 {
731  return E_NOTIMPL;
732 }
733 
736 {
737  HPROPSHEETPAGE hPage;
738 
741  (LPARAM)this,
742  NULL);
743  if (hPage)
744  pfnAddPage(hPage, lParam);
745 
747  {
750  (LPARAM)this,
751  NULL);
752  if (hPage)
753  pfnAddPage(hPage, lParam);
754  }
755 
757  {
760  (LPARAM)this,
761  NULL);
762  if (hPage)
763  pfnAddPage(hPage, lParam);
764  }
765 
766  return S_OK;
767 }
768 
771 {
773  return E_NOTIMPL;
774 }
775 
778 {
780  return E_NOTIMPL;
781 }
782 
784 CDrvDefExt::GetSite(REFIID iid, void **ppvSite)
785 {
787  return E_NOTIMPL;
788 }
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:580
static BOOLEAN NTAPI ChkdskCallback(IN CALLBACKCOMMAND Command, IN ULONG SubAction, IN PVOID ActionInfo)
Definition: drvdefext.cpp:85
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2380
#define STM_SETICON
Definition: winuser.h:2082
#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:2263
#define IDI_SHELL_DRIVE
Definition: shresdef.h:538
#define REFIID
Definition: guiddef.h:118
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:739
#define LR_SHARED
Definition: winuser.h:1094
#define IMAGE_ICON
Definition: winuser.h:212
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UINT SH_FormatByteSize(LONGLONG cbSize, LPWSTR pwszResult, UINT cchResultMax)
Definition: filedefext.cpp:236
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:491
#define RGB(r, g, b)
Definition: precomp.h:62
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define EM_SETREADONLY
Definition: winuser.h:2005
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
struct _PSHNOTIFY * LPPSHNOTIFY
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CP_ACP
Definition: compat.h:109
virtual HRESULT WINAPI GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax)
Definition: drvdefext.cpp:728
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
LONG NTSTATUS
Definition: precomp.h:26
#define INT
Definition: polytest.cpp:20
#define DRIVE_RAMDISK
Definition: winbase.h:255
#define CALLBACK
Definition: compat.h:35
LONG top
Definition: windef.h:307
#define IDI_SHELL_REMOVEABLE
Definition: shresdef.h:537
#define IDD_DRIVE_PROPERTIES
Definition: shresdef.h:374
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
Definition: fmifs.h:68
UINT DriveType
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot)
Definition: drvdefext.cpp:372
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:2184
virtual HRESULT WINAPI ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam)
Definition: drvdefext.cpp:770
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:64
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:777
#define IDS_DRIVE_CDROM
Definition: shresdef.h:114
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 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:136
#define DRIVE_REMOVABLE
Definition: winbase.h:251
#define lstrcpynW
Definition: compat.h:738
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:160
enum HWPAGE_DISPLAYMODE * PHWPAGE_DISPLAYMODE
UINT code
Definition: winuser.h:3149
#define PBM_SETRANGE
Definition: commctrl.h:2183
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
NMHDR hdr
Definition: prsht.h:330
#define PS_SOLID
Definition: wingdi.h:586
valarray< _Tp > acos(const valarray< _Tp > &__x)
Definition: _valarray.h:901
#define L(x)
Definition: ntvdm.h:50
#define DRIVE_REMOTE
Definition: winbase.h:253
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
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
static BOOLEAN bChkdskSuccess
Definition: drvdefext.cpp:82
#define FIXME(fmt,...)
Definition: debug.h:111
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:585
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
unsigned char BOOLEAN
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:1908
EXTERN_C HWND WINAPI DeviceCreateHardwarePageEx(HWND hWndParent, LPGUID lpGuids, UINT uNumberOfGuids, HWPAGE_DISPLAYMODE DisplayMode)
DeviceType
Definition: mmdrv.h:41
const char * LPCSTR
Definition: xmlstorage.h:183
#define SW_SHOW
Definition: winuser.h:769
VOID InitGeneralPage(HWND hwndDlg)
Definition: drvdefext.cpp:380
#define OPEN_EXISTING
Definition: compat.h:775
UINT m_FreeSpacePerc
Definition: drvdefext.h:40
_In_ int cchText
Definition: winuser.h:4455
Status
Definition: gdiplustypes.h:24
VOID PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT pDrawItem)
Definition: drvdefext.cpp:192
#define IDD_DRIVE_HARDWARE
Definition: shresdef.h:376
int64_t LONGLONG
Definition: typedefs.h:68
BOOL WINAPI PathIsRootW(LPCWSTR lpszPath)
Definition: path.c:1641
GLfloat f
Definition: glext.h:7540
#define IDI_SHELL_3_14_FLOPPY
Definition: shresdef.h:536
#define TRACE(s)
Definition: solgame.cpp:4
#define IDS_DRIVE_FIXED
Definition: shresdef.h:113
HWPAGE_DISPLAYMODE
Definition: drvdefext.cpp:35
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:79
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:34
#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
UINT cchMax
#define IDD_DRIVE_TOOLS
Definition: shresdef.h:375
#define WM_PAINT
Definition: winuser.h:1610
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define PSNRET_NOERROR
Definition: prsht.h:129
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117
static BOOL GetDriveTypeAndCharacteristics(HANDLE hDevice, DEVICE_TYPE *pDeviceType, ULONG *pCharacteristics)
Definition: drvdefext.cpp:287
int ret
char * PBOOLEAN
Definition: retypes.h:11
static VOID ChkDskNow(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:119
#define M_PI
Definition: dib.cpp:249
LPARAM lParam
Definition: prsht.h:227
static VOID InitializeChkDskDialog(HWND hwndDlg, LPCWSTR pwszDrive)
Definition: drvdefext.cpp:69
#define DWLP_USER
Definition: winuser.h:866
WCHAR m_wszDrive[MAX_PATH]
Definition: drvdefext.h:39
#define WM_COMMAND
Definition: winuser.h:1730
virtual HRESULT WINAPI AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
Definition: drvdefext.cpp:735
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:50
int _cdecl swprintf(const WCHAR *,...)
#define DRIVE_FIXED
Definition: winbase.h:252
#define IDS_DRIVE_NETWORK
Definition: shresdef.h:115
#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:80
HWND WINAPI GetParent(_In_ HWND)
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define S_OK
Definition: intsafe.h:52
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define shell32_hInstance
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:497
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
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:5847
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDI_SHELL_CDROM
Definition: shresdef.h:541
DWORD * PDWORD
Definition: pedump.c:68
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
virtual HRESULT WINAPI GetSite(REFIID iid, void **ppvSite)
Definition: drvdefext.cpp:784
#define MultiByteToWideChar
Definition: compat.h:110
#define BST_CHECKED
Definition: winuser.h:197
static HWND hChkdskDrvDialog
Definition: drvdefext.cpp:81
#define CreateFileW
Definition: compat.h:741
BOOL IsDriveFloppyW(LPCWSTR pszDriveRoot)
Definition: drvdefext.cpp:306
#define WM_DRAWITEM
Definition: winuser.h:1635
_Out_opt_ int * cx
Definition: commctrl.h:585
#define SendMessage
Definition: winuser.h:5833
virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
Definition: drvdefext.cpp:721
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2346
virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pDataObj, HKEY hkeyProgID)
Definition: drvdefext.cpp:679
#define HIWORD(l)
Definition: typedefs.h:247
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:542
#define LoadImage
Definition: winuser.h:5805
#define IDI_SHELL_NETDRIVE
Definition: shresdef.h:539
#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:118
#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:714
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:622
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
static INT_PTR CALLBACK HardwarePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: drvdefext.cpp:642
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:2012