ReactOS 0.4.15-dev-8348-gc1b9bb5
hotplug.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <wincon.h>
#include <winreg.h>
#include <windowsx.h>
#include <commctrl.h>
#include <cpl.h>
#include <tchar.h>
#include <limits.h>
#include <setupapi.h>
#include <cfgmgr32.h>
#include <dbt.h>
#include <regstr.h>
#include "resource.h"
Include dependency graph for hotplug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  APPLET
 
struct  _HOTPLUG_DATA
 

Macros

#define WIN32_NO_STATUS
 
#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS   0x00000002
 
#define NUM_APPLETS   (1)
 

Typedefs

typedef struct APPLETPAPPLET
 
typedef struct _HOTPLUG_DATA HOTPLUG_DATA
 
typedef struct _HOTPLUG_DATAPHOTPLUG_DATA
 

Functions

DEVINST GetDeviceInstForRemoval (_In_ PHOTPLUG_DATA pHotplugData)
 
INT_PTR CALLBACK ConfirmRemovalDlgProc (_In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
VOID EnumHotpluggedDevices (_In_ PHOTPLUG_DATA pHotplugData)
 
VOID CfmListEnumDevices (_In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData)
 
LONG APIENTRY InitApplet (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 

Variables

HINSTANCE hApplet
 

Macro Definition Documentation

◆ HOTPLUG_DISPLAY_DEVICE_COMPONENTS

#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS   0x00000002

Definition at line 24 of file hotplug.h.

◆ NUM_APPLETS

#define NUM_APPLETS   (1)

Definition at line 30 of file hotplug.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 3 of file hotplug.h.

Typedef Documentation

◆ HOTPLUG_DATA

◆ PAPPLET

typedef struct APPLET * PAPPLET

◆ PHOTPLUG_DATA

Function Documentation

◆ CfmListEnumDevices()

VOID CfmListEnumDevices ( _In_ HWND  hwndCfmDeviceList,
_In_ PHOTPLUG_DATA  pHotplugData 
)

Definition at line 272 of file enum.c.

275{
276 DEVINST DevInst;
277
278 DevInst = GetDeviceInstForRemoval(pHotplugData);
279 if (DevInst != 0)
280 {
281 InsertConfirmDeviceListItem(hwndCfmDeviceList, DevInst, pHotplugData);
282 CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, DevInst, pHotplugData);
283 }
284}
DWORD DEVINST
Definition: cfgmgr32.h:76
static VOID InsertConfirmDeviceListItem(_In_ HWND hwndCfmDeviceList, _In_ DEVINST DevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: enum.c:218
static VOID CfmListRecursiveInsertSubDevices(_In_ HWND hwndCfmDeviceList, _In_ DEVINST ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: enum.c:245
DEVINST GetDeviceInstForRemoval(_In_ PHOTPLUG_DATA pHotplugData)
Definition: eject.c:13

Referenced by FillConfirmDeviceList().

◆ ConfirmRemovalDlgProc()

INT_PTR CALLBACK ConfirmRemovalDlgProc ( _In_ HWND  hwndDlg,
_In_ UINT  uMsg,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)

Definition at line 84 of file eject.c.

89{
90 PHOTPLUG_DATA pHotplugData;
91
92 pHotplugData = (PHOTPLUG_DATA)GetWindowLongPtrW(hwndDlg, DWLP_USER);
93
94 switch (uMsg)
95 {
96 case WM_INITDIALOG:
97 {
98 HWND hwndDevList;
99
100 pHotplugData = (PHOTPLUG_DATA)lParam;
101 SetWindowLongPtrW(hwndDlg, DWLP_USER, (LONG_PTR)pHotplugData);
102
103 hwndDevList = GetDlgItem(hwndDlg, IDC_CONFIRM_STOP_DEVICE_LIST);
104
105 ListView_SetImageList(hwndDevList,
106 pHotplugData->ImageListData.ImageList,
108
109 FillConfirmDeviceList(hwndDevList, pHotplugData);
110
111 return TRUE;
112 }
113
114 case WM_COMMAND:
115 {
116 switch (LOWORD(wParam))
117 {
118 case IDOK:
119 SafeRemoveDevice(GetDeviceInstForRemoval(pHotplugData), hwndDlg);
120 EndDialog(hwndDlg, LOWORD(wParam));
121 break;
122
123 case IDCANCEL:
124 EndDialog(hwndDlg, LOWORD(wParam));
125 break;
126 }
127
128 break;
129 }
130
131 case WM_DESTROY:
133 break;
134 }
135
136 return FALSE;
137}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_CONFIRM_STOP_DEVICE_LIST
Definition: resource.h:18
static VOID FillConfirmDeviceList(_In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData)
Definition: eject.c:42
static VOID SafeRemoveDevice(_In_ DEVINST DevInst, _In_opt_ HWND hwndDlg)
Definition: eject.c:60
struct _HOTPLUG_DATA * PHOTPLUG_DATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
SP_CLASSIMAGELIST_DATA ImageListData
Definition: hotplug.h:45
#define DWLP_USER
Definition: winuser.h:872
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define WM_DESTROY
Definition: winuser.h:1609
#define SetWindowLongPtrW
Definition: winuser.h:5355
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by SafeRemovalDlgProc().

◆ EnumHotpluggedDevices()

VOID EnumHotpluggedDevices ( _In_ PHOTPLUG_DATA  pHotplugData)

Definition at line 150 of file enum.c.

152{
153 SP_DEVINFO_DATA did = { 0 };
155 int idev;
156 DWORD dwCapabilities, dwSize;
157 ULONG ulStatus, ulProblem;
158 HTREEITEM hTreeItem;
159 CONFIGRET cr;
160
161 TreeView_DeleteAllItems(pHotplugData->hwndDeviceTree);
162
165 return;
166
167 did.cbSize = sizeof(did);
168
169 /* Enumerate all the attached devices */
170 for (idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++)
171 {
172 ulStatus = 0;
173 ulProblem = 0;
174
175 cr = CM_Get_DevNode_Status(&ulStatus,
176 &ulProblem,
177 did.DevInst,
178 0);
179 if (cr != CR_SUCCESS)
180 continue;
181
182 dwCapabilities = 0,
183 dwSize = sizeof(dwCapabilities);
186 NULL,
187 &dwCapabilities,
188 &dwSize,
189 0);
190 if (cr != CR_SUCCESS)
191 continue;
192
193 /* Add devices that require safe removal to the device tree */
194 if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) &&
195 !(dwCapabilities & CM_DEVCAP_DOCKDEVICE) &&
196 !(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) &&
197 ((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) &&
198 ulProblem == 0)
199 {
200 hTreeItem = InsertDeviceTreeItem(TVI_ROOT,
201 did.DevInst,
202 pHotplugData);
203
204 if ((hTreeItem != NULL) && (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS))
205 {
207 did.DevInst,
208 pHotplugData);
209 }
210 }
211 }
212
214}
#define DN_DISABLEABLE
Definition: cfg.h:131
#define CM_DEVCAP_EJECTSUPPORTED
Definition: cfgmgr32.h:736
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
#define CM_Get_DevNode_Registry_Property
Definition: cfgmgr32.h:1733
#define CM_DEVCAP_SURPRISEREMOVALOK
Definition: cfgmgr32.h:742
#define CM_DEVCAP_DOCKDEVICE
Definition: cfgmgr32.h:738
#define CM_DEVCAP_REMOVABLE
Definition: cfgmgr32.h:737
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_SUCCESS
Definition: cfgmgr32.h:842
CONFIGRET WINAPI CM_Get_DevNode_Status(_Out_ PULONG pulStatus, _Out_ PULONG pulProblemNumber, _In_ DEVINST dnDevInst, _In_ ULONG ulFlags)
Definition: cfgmgr.c:3572
static HTREEITEM InsertDeviceTreeItem(_In_ HTREEITEM hParent, _In_ DEVINST DevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: enum.c:76
static VOID DevTreeRecursiveInsertSubDevices(_In_ HTREEITEM hParentItem, _In_ DEVINST ParentDevInst, _In_ PHOTPLUG_DATA pHotplugData)
Definition: enum.c:108
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, PSP_DEVINFO_DATA info)
Definition: devinst.c:1787
BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
Definition: devinst.c:2893
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HOTPLUG_DISPLAY_DEVICE_COMPONENTS
Definition: hotplug.h:24
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define TVI_ROOT
Definition: commctrl.h:3368
#define DIGCF_ALLCLASSES
Definition: setupapi.h:172
#define SetupDiGetClassDevs
Definition: setupapi.h:2593
#define DIGCF_PRESENT
Definition: setupapi.h:171
uint32_t ULONG
Definition: typedefs.h:59
_In_ HDEV hdev
Definition: winddi.h:3449

Referenced by SafeRemovalDlgProc().

◆ GetDeviceInstForRemoval()

DEVINST GetDeviceInstForRemoval ( _In_ PHOTPLUG_DATA  pHotplugData)

Definition at line 13 of file eject.c.

15{
16 HTREEITEM hItem, hParentItem;
17 TVITEMW tvItem;
18
19 hItem = TreeView_GetSelection(pHotplugData->hwndDeviceTree);
20 if (!hItem)
21 return 0;
22
23 /* Find root item */
24 hParentItem = TreeView_GetParent(pHotplugData->hwndDeviceTree, hItem);
25 while (hParentItem)
26 {
27 hItem = hParentItem;
28 hParentItem = TreeView_GetParent(pHotplugData->hwndDeviceTree, hItem);
29 }
30
31 ZeroMemory(&tvItem, sizeof(tvItem));
32 tvItem.mask = TVIF_PARAM;
33 tvItem.hItem = hItem;
34
35 TreeView_GetItem(pHotplugData->hwndDeviceTree, &tvItem);
36
37 return tvItem.lParam;
38}
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TVIF_PARAM
Definition: commctrl.h:3268
HTREEITEM hItem
Definition: commctrl.h:3317
LPARAM lParam
Definition: commctrl.h:3325
UINT mask
Definition: commctrl.h:3316
HTREEITEM hItem
Definition: treelist.h:37
#define ZeroMemory
Definition: winbase.h:1712

Referenced by CfmListEnumDevices(), and ConfirmRemovalDlgProc().

◆ InitApplet()

LONG APIENTRY InitApplet ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)

Definition at line 380 of file hotplug.c.

385{
386 DPRINT("InitApplet()\n");
387
390 hwnd,
392
393 // TODO
394 return TRUE;
395}
#define IDD_SAFE_REMOVE_HARDWARE_DIALOG
Definition: resource.h:9
INT_PTR CALLBACK SafeRemovalDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: hotplug.c:202
HINSTANCE hApplet
Definition: hotplug.c:15
#define DPRINT
Definition: sndvol32.h:73
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DialogBox
Definition: winuser.h:5770

Variable Documentation

◆ hApplet

HINSTANCE hApplet
extern

Definition at line 17 of file access.c.