ReactOS  0.4.15-dev-499-g1f31905
hotplug.c
Go to the documentation of this file.
1 /*
2 * PROJECT: Safely Remove Hardware Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/hotplug/hotplug.c
5 * PURPOSE: applet initialization
6 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
7 */
8 
9 #include "hotplug.h"
10 
11 #include <initguid.h>
12 #include <devguid.h>
13 
14 #define NDEBUG
15 #include <debug.h>
16 
17 
18 typedef struct _HOTPLUG_DATA
19 {
24 
25 
26 // globals
28 
29 /* Applets */
31 {
33 };
34 
35 static
36 DWORD
38 {
39  HKEY hKey = NULL;
40  DWORD dwFlags = 0;
41  DWORD dwSize, dwError;
42 
45  0,
46  KEY_READ,
47  &hKey);
48  if (dwError != ERROR_SUCCESS)
49  goto done;
50 
51  dwSize = sizeof(dwFlags);
52  dwError = RegQueryValueExW(hKey,
53  L"HotPlugFlags",
54  NULL,
55  NULL,
56  (LPBYTE)&dwFlags,
57  &dwSize);
58  if (dwError != ERROR_SUCCESS)
59  dwFlags = 0;
60 
61 done:
62  if (hKey != NULL)
63  RegCloseKey(hKey);
64 
65  return dwFlags;
66 }
67 
68 
69 static
70 DWORD
73 {
74  HKEY hKey = NULL;
75  DWORD dwError;
76 
79  0,
80  NULL,
82  KEY_WRITE,
83  NULL,
84  &hKey,
85  NULL);
86  if (dwError != ERROR_SUCCESS)
87  goto done;
88 
89  dwError = RegSetValueExW(hKey,
90  L"HotPlugFlags",
91  0,
92  REG_DWORD,
93  (LPBYTE)&dwFlags,
94  sizeof(dwFlags));
95 
96 done:
97  if (hKey != NULL)
98  RegCloseKey(hKey);
99 
100  return dwError;
101 }
102 
103 
104 static
105 HTREEITEM
107  _In_ HWND hwndDeviceTree,
109  _In_ DWORD DevInst,
110  _In_ PHOTPLUG_DATA pHotplugData)
111 {
112  WCHAR szDisplayName[40];
113  WCHAR szGuidString[MAX_GUID_STRING_LEN];
114  TVINSERTSTRUCTW tvItem;
115  GUID ClassGuid;
116  INT nClassImage;
117  DWORD dwSize;
118  CONFIGRET cr;
119 
120  /* Get the device description */
121  dwSize = sizeof(szDisplayName);
124  NULL,
125  szDisplayName,
126  &dwSize,
127  0);
128  if (cr != CR_SUCCESS)
129  wcscpy(szDisplayName, L"Unknown Device");
130 
131  /* Get the class GUID */
132  dwSize = sizeof(szGuidString);
135  NULL,
136  szGuidString,
137  &dwSize,
138  0);
139  if (cr == CR_SUCCESS)
140  {
141  pSetupGuidFromString(szGuidString, &ClassGuid);
142  }
143  else
144  {
145  memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID));
146  }
147 
148  /* Get the image for the class this device is in */
149  SetupDiGetClassImageIndex(&pHotplugData->ImageListData,
150  &ClassGuid,
151  &nClassImage);
152 
153  /* Add it to the device tree */
154  ZeroMemory(&tvItem, sizeof(tvItem));
155  tvItem.hParent = hParent;
156  tvItem.hInsertAfter = TVI_LAST;
157 
158  tvItem.item.mask = TVIF_STATE | TVIF_TEXT /*| TVIF_PARAM*/ | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
159  tvItem.item.state = TVIS_EXPANDED;
160  tvItem.item.stateMask = TVIS_EXPANDED;
161  tvItem.item.pszText = szDisplayName;
162  tvItem.item.iImage = nClassImage;
163  tvItem.item.iSelectedImage = nClassImage;
164  tvItem.item.lParam = (LPARAM)NULL;
165 
166  return TreeView_InsertItem(hwndDeviceTree, &tvItem);
167 }
168 
169 
170 static
171 VOID
173  _In_ HWND hwndDeviceTree,
174  _In_ HTREEITEM hParentItem,
175  _In_ DWORD ParentDevInst,
176  _In_ PHOTPLUG_DATA pHotplugData)
177 {
178  HTREEITEM hTreeItem;
179  DEVINST ChildDevInst;
180  CONFIGRET cr;
181 
182  DPRINT("RecursiveInsertSubDevices()\n");
183 
184  cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0);
185  if (cr != CR_SUCCESS)
186  {
187  DPRINT("No child! %lu\n", cr);
188  return;
189  }
190 
191  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
192  hParentItem,
193  ChildDevInst,
194  pHotplugData);
195  if (hTreeItem != NULL)
196  {
197  RecursiveInsertSubDevices(hwndDeviceTree,
198  hTreeItem,
199  ChildDevInst,
200  pHotplugData);
201  }
202 
203  for (;;)
204  {
205  cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0);
206  if (cr != CR_SUCCESS)
207  {
208  DPRINT("No sibling! %lu\n", cr);
209  return;
210  }
211 
212  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
213  hParentItem,
214  ChildDevInst,
215  pHotplugData);
216  if (hTreeItem != NULL)
217  {
218  RecursiveInsertSubDevices(hwndDeviceTree,
219  hTreeItem,
220  ChildDevInst,
221  pHotplugData);
222  }
223  }
224 }
225 
226 
227 static
228 VOID
230  HWND hwndDeviceTree,
231  PHOTPLUG_DATA pHotplugData)
232 {
233  SP_DEVINFO_DATA did = { 0 };
234  HDEVINFO hdev;
235  int idev;
236  DWORD dwCapabilities, dwSize;
237  ULONG ulStatus, ulProblem;
238  HTREEITEM hTreeItem;
239  CONFIGRET cr;
240 
241  DPRINT1("EnumHotpluggedDevices()\n");
242 
243  TreeView_DeleteAllItems(hwndDeviceTree);
244 
246  if (hdev == INVALID_HANDLE_VALUE)
247  return;
248 
249  did.cbSize = sizeof(did);
250 
251  /* Enumerate all the attached devices */
252  for (idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
253  {
254  ulStatus = 0;
255  ulProblem = 0;
256 
257  cr = CM_Get_DevNode_Status(&ulStatus,
258  &ulProblem,
259  did.DevInst,
260  0);
261  if (cr != CR_SUCCESS)
262  continue;
263 
264  dwCapabilities = 0,
265  dwSize = sizeof(dwCapabilities);
268  NULL,
269  &dwCapabilities,
270  &dwSize,
271  0);
272  if (cr != CR_SUCCESS)
273  continue;
274 
275  /* Add devices that require safe removal to the device tree */
276  if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) &&
277  !(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
278  !(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
279  ((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
280  ulProblem == 0)
281  {
282  hTreeItem = InsertDeviceTreeItem(hwndDeviceTree,
283  TVI_ROOT,
284  did.DevInst,
285  pHotplugData);
286 
287  if ((hTreeItem != NULL) && (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS))
288  {
289  RecursiveInsertSubDevices(hwndDeviceTree,
290  hTreeItem,
291  did.DevInst,
292  pHotplugData);
293  }
294  }
295  }
296 
298 }
299 
300 
301 static
302 VOID
304  HWND hwndDlg)
305 {
306  BOOL bEnabled;
307 
308  bEnabled = (TreeView_GetCount(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE)) != 0);
309 
311  EnableWindow(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_STOP), bEnabled);
312 }
313 
314 
315 static
316 VOID
318  HWND hwndDlg,
320  PHOTPLUG_DATA pHotplugData)
321 {
322  HTREEITEM hTreeItem;
323  RECT rc;
324  POINT pt;
325 
326  hTreeItem = TreeView_GetSelection(hwndTreeView);
327  if (hTreeItem == NULL)
328  return;
329 
330  TreeView_GetItemRect(hwndTreeView, hTreeItem, &rc, TRUE);
331 
332  pt.x = (rc.left + rc.right) / 2;
333  pt.y = (rc.top + rc.bottom) / 2;
335  TrackPopupMenu(GetSubMenu(pHotplugData->hPopupMenu, 0),
337  pt.x,
338  pt.y,
339  0,
340  hwndDlg,
341  NULL);
342 }
343 
344 
345 INT_PTR
346 CALLBACK
348  HWND hwndDlg,
349  UINT uMsg,
350  WPARAM wParam,
351  LPARAM lParam)
352 {
353  PHOTPLUG_DATA pHotplugData;
354 
355  pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
356 
357  switch (uMsg)
358  {
359  case WM_INITDIALOG:
360  pHotplugData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HOTPLUG_DATA));
361  if (pHotplugData != NULL)
362  {
363  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
364 
365  pHotplugData->ImageListData.cbSize = sizeof(pHotplugData->ImageListData);
366  SetupDiGetClassImageList(&pHotplugData->ImageListData);
367 
368  pHotplugData->hPopupMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDM_POPUP_DEVICE_TREE));
369 
370  pHotplugData->dwFlags = GetHotPlugFlags();
371 
372  if (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)
374 
376  pHotplugData->ImageListData.ImageList,
377  TVSIL_NORMAL);
378 
380  pHotplugData);
381  UpdateButtons(hwndDlg);
382  }
383  return TRUE;
384 
385  case WM_COMMAND:
386  switch (LOWORD(wParam))
387  {
388  case IDCLOSE:
389  KillTimer(hwndDlg, 1);
390  EndDialog(hwndDlg, TRUE);
391  break;
392 
394  if (HIWORD(wParam) == BN_CLICKED)
395  {
396  if (pHotplugData != NULL)
397  {
400  else
401  pHotplugData->dwFlags &= ~HOTPLUG_DISPLAY_DEVICE_COMPONENTS;
402 
403  SetHotPlugFlags(pHotplugData->dwFlags);
404 
406  pHotplugData);
407  }
408  }
409  break;
410  }
411  break;
412 
413  case WM_DEVICECHANGE:
414  switch (wParam)
415  {
417  SetTimer(hwndDlg, 1, 500, NULL);
418  break;
419  }
420  break;
421 
422  case WM_TIMER:
423  if (wParam == 1)
424  {
425  KillTimer(hwndDlg, 1);
426 
427  if (pHotplugData != NULL)
428  {
430  pHotplugData);
431  UpdateButtons(hwndDlg);
432  }
433  }
434  break;
435 
436  case WM_NOTIFY:
437  if (((LPNMHDR)lParam)->idFrom == IDC_SAFE_REMOVE_DEVICE_TREE)
438  {
439  if (((LPNMHDR)lParam)->code == NM_RCLICK)
440  {
441  if (pHotplugData != NULL)
442  {
443  ShowContextMenu(hwndDlg,
444  ((LPNMHDR)lParam)->hwndFrom,
445  pHotplugData);
446  return TRUE;
447  }
448  }
449  }
450  break;
451 
452  case WM_CLOSE:
453  KillTimer(hwndDlg, 1);
454  EndDialog(hwndDlg, TRUE);
455  break;
456 
457  case WM_DESTROY:
458  if (pHotplugData != NULL)
459  {
460  if (pHotplugData->hPopupMenu != NULL)
461  DestroyMenu(pHotplugData->hPopupMenu);
462 
464 
465  HeapFree(GetProcessHeap(), 0, pHotplugData);
467  }
468  break;
469  }
470 
471  return FALSE;
472 }
473 
474 
475 LONG
476 APIENTRY
478  HWND hwnd,
479  UINT uMsg,
480  LPARAM wParam,
481  LPARAM lParam)
482 {
483  DPRINT("InitApplet()\n");
484 
487  hwnd,
489 
490  // TODO
491  return TRUE;
492 }
493 
494 
495 LONG
496 CALLBACK
498  HWND hwndCPl,
499  UINT uMsg,
500  LPARAM lParam1,
501  LPARAM lParam2)
502 {
503  UINT i = (UINT)lParam1;
504 
505  switch(uMsg)
506  {
507  case CPL_INIT:
508  return TRUE;
509 
510  case CPL_GETCOUNT:
511  return NUM_APPLETS;
512 
513  case CPL_INQUIRE:
514  {
515  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
516  CPlInfo->lData = 0;
517  CPlInfo->idIcon = Applets[i].idIcon;
518  CPlInfo->idName = Applets[i].idName;
519  CPlInfo->idInfo = Applets[i].idDescription;
520  }
521  break;
522 
523  case CPL_DBLCLK:
524  Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
525  break;
526 
527  case CPL_STARTWPARMSW:
528  return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
529  }
530  return FALSE;
531 }
532 
533 
534 INT
535 WINAPI
537  HINSTANCE hinstDLL,
538  DWORD dwReason,
540 {
542 
543  switch (dwReason)
544  {
545  case DLL_PROCESS_ATTACH:
546  case DLL_THREAD_ATTACH:
547  hApplet = hinstDLL;
548  break;
549  }
550  return TRUE;
551 }
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1792
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
#define CM_DEVCAP_REMOVABLE
Definition: cfgmgr32.h:737
HTREEITEM hParent
Definition: commctrl.h:3389
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3425
Definition: cpl.h:24
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define DBT_DEVNODES_CHANGED
Definition: dbt.h:28
#define CM_DEVCAP_EJECTSUPPORTED
Definition: cfgmgr32.h:736
HINSTANCE hApplet
Definition: hotplug.c:27
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3413
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2352
#define DLL_THREAD_ATTACH
Definition: compat.h:121
#define IDC_SAFE_REMOVE_STOP
Definition: resource.h:14
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define TreeView_GetCount(hwnd)
Definition: commctrl.h:3428
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
#define CALLBACK
Definition: compat.h:27
static DWORD SetHotPlugFlags(_In_ DWORD dwFlags)
Definition: hotplug.c:71
int idInfo
Definition: cpl.h:27
LONG top
Definition: windef.h:307
DWORD dwFlags
Definition: hotplug.c:22
#define DN_DISABLEABLE
Definition: cfg.h:131
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
#define ZeroMemory
Definition: winbase.h:1648
#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS
Definition: hotplug.h:24
CONFIGRET WINAPI CM_Get_Sibling(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:5522
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
UINT_PTR WPARAM
Definition: windef.h:207
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3267
LONG left
Definition: windef.h:306
int32_t INT_PTR
Definition: typedefs.h:63
#define IDI_HOTPLUG
Definition: resource.h:4
LONG right
Definition: windef.h:308
BOOL WINAPI SetupDiGetClassImageList(OUT PSP_CLASSIMAGELIST_DATA ClassImageListData)
Definition: devclass.c:441
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
struct _HOTPLUG_DATA HOTPLUG_DATA
static IN DWORD IN LPVOID lpvReserved
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#define CPL_DBLCLK
Definition: cpl.h:16
static VOID RecursiveInsertSubDevices(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParentItem, _In_ DWORD ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:172
static VOID UpdateButtons(HWND hwndDlg)
Definition: hotplug.c:303
APPLET Applets[NUM_APPLETS]
Definition: hotplug.c:30
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3408
DWORD dwReason
Definition: misc.cpp:154
#define DialogBox
Definition: winuser.h:5736
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDS_CPLNAME
Definition: resource.h:8
static HTREEITEM InsertDeviceTreeItem(_In_ HWND hwndDeviceTree, _In_ HTREEITEM hParent, _In_ DWORD DevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:106
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
HTREEITEM hInsertAfter
Definition: commctrl.h:3390
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REGSTR_PATH_SYSTRAY
Definition: regstr.h:531
long LONG
Definition: pedump.c:60
#define TPM_TOPALIGN
Definition: winuser.h:2358
CONFIGRET WINAPI CM_Get_Child(_Out_ PDEVINST pdnDevInst, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:2522
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
BOOL WINAPI SetupDiDestroyClassImageList(IN PSP_CLASSIMAGELIST_DATA ClassImageListData)
Definition: devclass.c:85
LONG_PTR LPARAM
Definition: windef.h:208
void DPRINT(...)
Definition: polytest.cpp:61
#define TVI_LAST
Definition: commctrl.h:3366
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3443
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define IDS_CPLDESCRIPTION
Definition: resource.h:9
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
INT WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: hotplug.c:536
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3469
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
static VOID EnumHotpluggedDevices(HWND hwndDeviceTree, PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:229
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
APPLET_PROC AppletProc
Definition: hotplug.h:38
#define IDM_POPUP_DEVICE_TREE
Definition: resource.h:20
#define WM_TIMER
Definition: winuser.h:1724
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2898
#define WM_CLOSE
Definition: winuser.h:1603
#define WINAPI
Definition: msvc.h:6
#define Button_GetCheck(hwndCtl)
Definition: windowsx.h:6
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hotplug.c:20
BOOL WINAPI SetupDiGetClassImageIndex(IN PSP_CLASSIMAGELIST_DATA ClassImageListData, IN CONST GUID *ClassGuid, OUT PINT ImageIndex)
Definition: devclass.c:396
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define CPL_INIT
Definition: cpl.h:12
#define TVI_ROOT
Definition: commctrl.h:3364
#define DIGCF_ALLCLASSES
Definition: setupapi.h:172
HWND hwndTreeView
Definition: eventvwr.c:82
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define CPL_INQUIRE
Definition: cpl.h:14
static const WCHAR L[]
Definition: oid.c:1250
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
struct _HOTPLUG_DATA * PHOTPLUG_DATA
#define DWLP_USER
Definition: winuser.h:866
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SetupDiGetClassDevs
Definition: setupapi.h:2588
LONG_PTR lData
Definition: cpl.h:28
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
int idName
Definition: cpl.h:26
#define IDD_SAFE_REMOVE_HARDWARE_DIALOG
Definition: resource.h:9
LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: hotplug.c:497
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define TVIS_EXPANDED
Definition: commctrl.h:3280
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define _In_
Definition: no_sal2.h:204
static DWORD GetHotPlugFlags(VOID)
Definition: hotplug.c:37
DWORD DEVINST
Definition: cfgmgr32.h:76
#define LoadMenu
Definition: winuser.h:5792
#define TVIF_TEXT
Definition: commctrl.h:3262
#define NM_RCLICK
Definition: commctrl.h:133
#define TVIF_IMAGE
Definition: commctrl.h:3263
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDC_SAFE_REMOVE_DEVICE_TREE
Definition: resource.h:11
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define BST_CHECKED
Definition: winuser.h:197
#define WM_DEVICECHANGE
Definition: winuser.h:1793
#define DPRINT1
Definition: precomp.h:8
#define Button_SetCheck(hwndCtl, check)
Definition: windowsx.h:10
CONFIGRET WINAPI CM_Get_DevNode_Status(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:3565
#define TVSIL_NORMAL
Definition: commctrl.h:3439
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG bottom
Definition: windef.h:309
#define TVIF_STATE
Definition: commctrl.h:3265
INT_PTR CALLBACK SafeRemovalDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hotplug.c:347
LONG APIENTRY InitApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: hotplug.c:477
#define CM_DEVCAP_SURPRISEREMOVALOK
Definition: cfgmgr32.h:742
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDC_SAFE_REMOVE_PROPERTIES
Definition: resource.h:13
#define CM_DEVCAP_DOCKDEVICE
Definition: cfgmgr32.h:738
static VOID ShowContextMenu(HWND hwndDlg, HWND hwndTreeView, PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:317
#define NUM_APPLETS
Definition: access.c:14
HMENU hPopupMenu
Definition: hotplug.c:21
#define REG_DWORD
Definition: sdbapi.c:596
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define IDC_SAFE_REMOVE_DISPLAY_COMPONENTS
Definition: resource.h:15
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
_In_ HDEV hdev
Definition: winddi.h:3449
#define HeapFree(x, y, z)
Definition: compat.h:403
#define CPL_GETCOUNT
Definition: cpl.h:13
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define WM_NOTIFY
Definition: richedit.h:61
#define APIENTRY
Definition: api.h:79
Definition: hotplug.h:33
#define DIGCF_PRESENT
Definition: setupapi.h:171
DWORD WINAPI pSetupGuidFromString(PCWSTR pString, LPGUID lpGUID)
Definition: misc.c:1751