Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

384 lines
6.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 2000
  6. //
  7. // File: hotplug.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //
  11. // 2001/02/01 - Disable support for *both* arrival bubbles and departure
  12. // bubbles (hotplug.dll must be kept in sync here.) This code is disabled for
  13. // beta2, and should be removed afterwards if feedback is positive.
  14. //
  15. // (Note that HotPlugSurpriseWarnW would need to be put back into hotplug.def
  16. // were this stuff reenabled. Several dialogs would need to be recovered as
  17. // well...)
  18. //
  19. #define BUBBLES 0
  20. #define UNDOCK_WARNINGS 0
  21. #include <nt.h>
  22. #include <ntrtl.h>
  23. #include <nturtl.h>
  24. #include <windows.h>
  25. #include <windowsx.h>
  26. #include <stdio.h>
  27. #include <cpl.h>
  28. #include <commctrl.h>
  29. #include <shellapi.h>
  30. #include <shlwapi.h>
  31. #include <devguid.h>
  32. #include <dbt.h>
  33. #include <help.h>
  34. #include <systrayp.h>
  35. #include <shobjidl.h>
  36. extern "C" {
  37. #include <setupapi.h>
  38. #include <spapip.h>
  39. #include <cfgmgr32.h>
  40. #include <shimdb.h>
  41. #include <regstr.h>
  42. }
  43. #include "resource.h"
  44. #include "devicecol.h"
  45. #define STWM_NOTIFYHOTPLUG STWM_NOTIFYPCMCIA
  46. #define STSERVICE_HOTPLUG STSERVICE_PCMCIA
  47. #define HOTPLUG_REGFLAG_NOWARN PCMCIA_REGFLAG_NOWARN
  48. #define HOTPLUG_REGFLAG_VIEWALL (PCMCIA_REGFLAG_NOWARN << 1)
  49. #define TIMERID_DEVICECHANGE 4321
  50. #define ARRAYLEN(array) (sizeof(array) / sizeof(array[0]))
  51. LRESULT CALLBACK
  52. DevTreeDlgProc(
  53. HWND hDlg,
  54. UINT message,
  55. WPARAM wParam,
  56. LPARAM lParam
  57. );
  58. LRESULT CALLBACK
  59. RemoveConfirmDlgProc(
  60. HWND hDlg,
  61. UINT message,
  62. WPARAM wParam,
  63. LPARAM lParam
  64. );
  65. LRESULT CALLBACK
  66. SurpriseWarnDlgProc(
  67. HWND hDlg,
  68. UINT message,
  69. WPARAM wParam,
  70. LPARAM lParam
  71. );
  72. #if BUBBLES
  73. LRESULT CALLBACK
  74. SurpriseWarnBalloonProc(
  75. HWND hWnd,
  76. UINT message,
  77. WPARAM wParam,
  78. LPARAM lParam
  79. );
  80. #endif
  81. LRESULT CALLBACK
  82. SafeRemovalBalloonProc(
  83. HWND hWnd,
  84. UINT message,
  85. WPARAM wParam,
  86. LPARAM lParam
  87. );
  88. LRESULT CALLBACK
  89. DockSafeRemovalBalloonProc(
  90. HWND hWnd,
  91. UINT message,
  92. WPARAM wParam,
  93. LPARAM lParam
  94. );
  95. extern HMODULE hHotPlug;
  96. typedef struct _DeviceTreeNode {
  97. LIST_ENTRY SiblingEntry;
  98. LIST_ENTRY ChildSiblingList;
  99. PTCHAR InstanceId;
  100. PTCHAR FriendlyName;
  101. PTCHAR DeviceDesc;
  102. PTCHAR ClassName;
  103. PTCHAR DriveList;
  104. PTCHAR Location;
  105. struct _DeviceTreeNode *ParentNode;
  106. struct _DeviceTreeNode *NextChildRemoval;
  107. HTREEITEM hTreeItem;
  108. DEVINST DevInst;
  109. GUID ClassGuid;
  110. DWORD Capabilities;
  111. int TreeDepth;
  112. PDEVINST EjectRelations;
  113. USHORT NumEjectRelations;
  114. PDEVINST RemovalRelations;
  115. USHORT NumRemovalRelations;
  116. ULONG Problem;
  117. ULONG DevNodeStatus;
  118. BOOL bCopy;
  119. } DEVTREENODE, *PDEVTREENODE;
  120. typedef struct _DeviceTreeData {
  121. DWORD Size;
  122. HWND hwndTree;
  123. HWND hDlg;
  124. HWND hwndRemove;
  125. HMACHINE hMachine;
  126. int TreeDepth;
  127. PDEVTREENODE SelectedTreeNode;
  128. PDEVTREENODE ChildRemovalList;
  129. LIST_ENTRY ChildSiblingList;
  130. DEVINST DevInst;
  131. PTCHAR EjectDeviceInstanceId;
  132. SP_CLASSIMAGELIST_DATA ClassImageList;
  133. BOOLEAN ComplexView;
  134. BOOLEAN HotPlugTree;
  135. BOOLEAN AllowRefresh;
  136. BOOLEAN RedrawWait;
  137. BOOLEAN RefreshEvent;
  138. BOOLEAN HideUI;
  139. TCHAR MachineName[MAX_COMPUTERNAME_LENGTH+1];
  140. } DEVICETREE, *PDEVICETREE;
  141. #define SIZECHARS(x) (sizeof((x))/sizeof(TCHAR))
  142. void
  143. OnContextHelp(
  144. LPHELPINFO HelpInfo,
  145. PDWORD ContextHelpIDs
  146. );
  147. //
  148. // from init.c
  149. //
  150. DWORD
  151. WINAPI
  152. HandleVetoedOperation(
  153. LPWSTR szCmd,
  154. VETOED_OPERATION RemovalVetoType
  155. );
  156. //
  157. // from devtree.c
  158. //
  159. LONG
  160. AddChildSiblings(
  161. PDEVICETREE DeviceTree,
  162. PDEVTREENODE ParentNode,
  163. DEVINST DeviceInstance,
  164. int TreeDepth,
  165. BOOL Recurse
  166. );
  167. void
  168. RemoveChildSiblings(
  169. PDEVICETREE DeviceTree,
  170. PLIST_ENTRY ChildSiblingList
  171. );
  172. PTCHAR
  173. FetchDeviceName(
  174. PDEVTREENODE DeviceTreeNode
  175. );
  176. BOOL
  177. DisplayChildSiblings(
  178. PDEVICETREE DeviceTree,
  179. PLIST_ENTRY ChildSiblingList,
  180. HTREEITEM hParentTreeItem,
  181. BOOL RemovableParent
  182. );
  183. void
  184. AddChildRemoval(
  185. PDEVICETREE DeviceTree,
  186. PLIST_ENTRY ChildSiblingList
  187. );
  188. void
  189. ClearRemovalList(
  190. PDEVICETREE DeviceTree
  191. );
  192. PDEVTREENODE
  193. DevTreeNodeByInstanceId(
  194. PTCHAR InstanceId,
  195. PLIST_ENTRY ChildSiblingList
  196. );
  197. PDEVTREENODE
  198. DevTreeNodeByDevInst(
  199. DEVINST DevInst,
  200. PLIST_ENTRY ChildSiblingList
  201. );
  202. PDEVTREENODE
  203. TopLevelRemovalNode(
  204. PDEVICETREE DeviceTree,
  205. PDEVTREENODE DeviceTreeNode
  206. );
  207. void
  208. AddEjectToRemoval(
  209. PDEVICETREE DeviceTree
  210. );
  211. extern TCHAR szUnknown[64];
  212. extern TCHAR szHotPlugFlags[];
  213. //
  214. // notify.c
  215. //
  216. void
  217. OnTimerDeviceChange(
  218. PDEVICETREE DeviceTree
  219. );
  220. BOOL
  221. RefreshTree(
  222. PDEVICETREE DeviceTree
  223. );
  224. //
  225. // miscutil.c
  226. //
  227. void
  228. SetDlgText(
  229. HWND hDlg,
  230. int iControl,
  231. int nStartString,
  232. int nEndString
  233. );
  234. VOID
  235. HotPlugPropagateMessage(
  236. HWND hWnd,
  237. UINT uMessage,
  238. WPARAM wParam,
  239. LPARAM lParam
  240. );
  241. BOOL
  242. RemovalPermission(
  243. void
  244. );
  245. int
  246. HPMessageBox(
  247. HWND hWnd,
  248. int IdText,
  249. int IdCaption,
  250. UINT Type
  251. );
  252. void
  253. InvalidateTreeItemRect(
  254. HWND hwndTree,
  255. HTREEITEM hTreeItem
  256. );
  257. DWORD
  258. GetHotPlugFlags(
  259. PHKEY phKey
  260. );
  261. PTCHAR
  262. BuildFriendlyName(
  263. DEVINST DevInst,
  264. HMACHINE hMachine
  265. );
  266. PTCHAR
  267. BuildLocationInformation(
  268. DEVINST DevInst,
  269. HMACHINE hMachine
  270. );
  271. LPTSTR
  272. DevNodeToDriveLetter(
  273. DEVINST DevInst
  274. );
  275. BOOL
  276. IsHotPlugDevice(
  277. DEVINST DevInst,
  278. HMACHINE hMachine
  279. );
  280. BOOL
  281. OpenPipeAndEventHandles(
  282. LPWSTR szCmd,
  283. LPHANDLE lphHotPlugPipe,
  284. LPHANDLE lphHotPlugEvent
  285. );
  286. BOOL
  287. VetoedRemovalUI(
  288. IN PVETO_DEVICE_COLLECTION VetoedRemovalCollection
  289. );
  290. void
  291. DisplayDriverBlockBalloon(
  292. IN PDEVICE_COLLECTION blockedDriverCollection
  293. );
  294. #if BUBBLES
  295. VOID
  296. OpenGetSurpriseUndockObjects(
  297. OUT HANDLE *SurpriseUndockTimer,
  298. OUT HANDLE *SurpriseUndockEvent
  299. );
  300. //
  301. // We suppress bubbles for some period of time after a dock event. Free build,
  302. // ~15 secs, Checked build ~60.
  303. //
  304. #if DBG
  305. #define BUBBLE_SUPPRESSION_TIME 60
  306. #else
  307. #define BUBBLE_SUPPRESSION_TIME 15
  308. #endif
  309. #endif // BUBBLES
  310. #define WUM_EJECTDEVINST (WM_USER+279)