Leaked source code of windows server 2003
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.

485 lines
15 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) Copyright MICROSOFT Corp., 1993-1999
  4. *
  5. * Title: DBT.H - Equates for WM_DEVICECHANGE and BroadcastSystemMessage
  6. *
  7. * Version: 4.00
  8. *
  9. * Date: 24-May-1993
  10. *
  11. * Author: rjc
  12. *
  13. *----------------------------------------------------------------------------
  14. *
  15. * Change log:
  16. *
  17. * DATE REV DESCRIPTION
  18. * ----------- --- ----------------------------------------------------------
  19. *
  20. *****************************************************************************/
  21. #ifndef _DBT_H
  22. #define _DBT_H
  23. #if _MSC_VER > 1000
  24. #pragma once
  25. #endif
  26. /*
  27. * BroadcastSpecialMessage constants.
  28. */
  29. #define WM_DEVICECHANGE 0x0219
  30. /* XLATOFF */
  31. #ifdef IS_32
  32. #define DBTFAR
  33. #else
  34. #define DBTFAR far
  35. #endif
  36. /* XLATON */
  37. #if !defined(_WCHAR_T_DEFINED) && !defined(_NATIVE_WCHAR_T_DEFINED)
  38. typedef unsigned short wchar_t;
  39. #define _WCHAR_T_DEFINED
  40. #endif
  41. #ifndef GUID_DEFINED
  42. #include <guiddef.h>
  43. #endif // !defined(GUID_DEFINED)
  44. /*
  45. * Broadcast message and receipient flags.
  46. *
  47. * Note that there is a third "flag". If the wParam has:
  48. *
  49. * bit 15 on: lparam is a pointer and bit 14 is meaningfull.
  50. * bit 15 off: lparam is just a UNLONG data type.
  51. *
  52. * bit 14 on: lparam is a pointer to an ASCIIZ string.
  53. * bit 14 off: lparam is a pointer to a binary struture starting with
  54. * a dword describing the length of the structure.
  55. */
  56. #define BSF_QUERY 0x00000001
  57. #define BSF_IGNORECURRENTTASK 0x00000002 /* Meaningless for VxDs */
  58. #define BSF_FLUSHDISK 0x00000004 /* Shouldn't be used by VxDs */
  59. #define BSF_NOHANG 0x00000008
  60. #define BSF_POSTMESSAGE 0x00000010
  61. #define BSF_FORCEIFHUNG 0x00000020
  62. #define BSF_NOTIMEOUTIFNOTHUNG 0x00000040
  63. #define BSF_MSGSRV32ISOK 0x80000000 /* Called synchronously from PM API */
  64. #define BSF_MSGSRV32ISOK_BIT 31 /* Called synchronously from PM API */
  65. #define BSM_ALLCOMPONENTS 0x00000000
  66. #define BSM_VXDS 0x00000001
  67. #define BSM_NETDRIVER 0x00000002
  68. #define BSM_INSTALLABLEDRIVERS 0x00000004
  69. #define BSM_APPLICATIONS 0x00000008
  70. /*
  71. * Message = WM_DEVICECHANGE
  72. * wParam = DBT_APPYBEGIN
  73. * lParam = (not used)
  74. *
  75. * 'Appy-time is now available. This message is itself sent
  76. * at 'Appy-time.
  77. *
  78. * Message = WM_DEVICECHANGE
  79. * wParam = DBT_APPYEND
  80. * lParam = (not used)
  81. *
  82. * 'Appy-time is no longer available. This message is *NOT* sent
  83. * at 'Appy-time. (It cannot be, because 'Appy-time is gone.)
  84. *
  85. * NOTE! It is possible for DBT_APPYBEGIN and DBT_APPYEND to be sent
  86. * multiple times during a single Windows session. Each appearance of
  87. * 'Appy-time is bracketed by these two messages, but 'Appy-time may
  88. * momentarily become unavailable during otherwise normal Windows
  89. * processing. The current status of 'Appy-time availability can always
  90. * be obtained from a call to _SHELL_QueryAppyTimeAvailable.
  91. */
  92. #define DBT_APPYBEGIN 0x0000
  93. #define DBT_APPYEND 0x0001
  94. /*
  95. * Message = WM_DEVICECHANGE
  96. * wParam = DBT_DEVNODES_CHANGED
  97. * lParam = 0
  98. *
  99. * send when configmg finished a process tree batch. Some devnodes
  100. * may have been added or removed. This is used by ring3 people which
  101. * need to be refreshed whenever any devnode changed occur (like
  102. * device manager). People specific to certain devices should use
  103. * DBT_DEVICE* instead.
  104. */
  105. #define DBT_DEVNODES_CHANGED 0x0007
  106. /*
  107. * Message = WM_DEVICECHANGE
  108. * wParam = DBT_QUERYCHANGECONFIG
  109. * lParam = 0
  110. *
  111. * sent to ask if a config change is allowed
  112. */
  113. #define DBT_QUERYCHANGECONFIG 0x0017
  114. /*
  115. * Message = WM_DEVICECHANGE
  116. * wParam = DBT_CONFIGCHANGED
  117. * lParam = 0
  118. *
  119. * sent when a config has changed
  120. */
  121. #define DBT_CONFIGCHANGED 0x0018
  122. /*
  123. * Message = WM_DEVICECHANGE
  124. * wParam = DBT_CONFIGCHANGECANCELED
  125. * lParam = 0
  126. *
  127. * someone cancelled the config change
  128. */
  129. #define DBT_CONFIGCHANGECANCELED 0x0019
  130. /*
  131. * Message = WM_DEVICECHANGE
  132. * wParam = DBT_MONITORCHANGE
  133. * lParam = new resolution to use (LOWORD=x, HIWORD=y)
  134. * if 0, use the default res for current config
  135. *
  136. * this message is sent when the display monitor has changed
  137. * and the system should change the display mode to match it.
  138. */
  139. #define DBT_MONITORCHANGE 0x001B
  140. /*
  141. * Message = WM_DEVICECHANGE
  142. * wParam = DBT_SHELLLOGGEDON
  143. * lParam = 0
  144. *
  145. * The shell has finished login on: VxD can now do Shell_EXEC.
  146. */
  147. #define DBT_SHELLLOGGEDON 0x0020
  148. /*
  149. * Message = WM_DEVICECHANGE
  150. * wParam = DBT_CONFIGMGAPI
  151. * lParam = CONFIGMG API Packet
  152. *
  153. * CONFIGMG ring 3 call.
  154. */
  155. #define DBT_CONFIGMGAPI32 0x0022
  156. /*
  157. * Message = WM_DEVICECHANGE
  158. * wParam = DBT_VXDINITCOMPLETE
  159. * lParam = 0
  160. *
  161. * CONFIGMG ring 3 call.
  162. */
  163. #define DBT_VXDINITCOMPLETE 0x0023
  164. /*
  165. * Message = WM_DEVICECHANGE
  166. * wParam = DBT_VOLLOCK*
  167. * lParam = pointer to VolLockBroadcast structure described below
  168. *
  169. * Messages issued by IFSMGR for volume locking purposes on WM_DEVICECHANGE.
  170. * All these messages pass a pointer to a struct which has no pointers.
  171. */
  172. #define DBT_VOLLOCKQUERYLOCK 0x8041
  173. #define DBT_VOLLOCKLOCKTAKEN 0x8042
  174. #define DBT_VOLLOCKLOCKFAILED 0x8043
  175. #define DBT_VOLLOCKQUERYUNLOCK 0x8044
  176. #define DBT_VOLLOCKLOCKRELEASED 0x8045
  177. #define DBT_VOLLOCKUNLOCKFAILED 0x8046
  178. /*
  179. * Device broadcast header
  180. */
  181. struct _DEV_BROADCAST_HDR { /* */
  182. DWORD dbch_size;
  183. DWORD dbch_devicetype;
  184. DWORD dbch_reserved;
  185. };
  186. typedef struct _DEV_BROADCAST_HDR DEV_BROADCAST_HDR;
  187. typedef DEV_BROADCAST_HDR DBTFAR *PDEV_BROADCAST_HDR;
  188. /*
  189. * Structure for volume lock broadcast
  190. */
  191. typedef struct VolLockBroadcast VolLockBroadcast;
  192. typedef VolLockBroadcast *pVolLockBroadcast;
  193. struct VolLockBroadcast {
  194. struct _DEV_BROADCAST_HDR vlb_dbh;
  195. DWORD vlb_owner; // thread on which lock request is being issued
  196. BYTE vlb_perms; // lock permission flags defined below
  197. BYTE vlb_lockType; // type of lock
  198. BYTE vlb_drive; // drive on which lock is issued
  199. BYTE vlb_flags; // miscellaneous flags
  200. };
  201. /*
  202. * Values for vlb_perms
  203. */
  204. #define LOCKP_ALLOW_WRITES 0x01 // Bit 0 set - allow writes
  205. #define LOCKP_FAIL_WRITES 0x00 // Bit 0 clear - fail writes
  206. #define LOCKP_FAIL_MEM_MAPPING 0x02 // Bit 1 set - fail memory mappings
  207. #define LOCKP_ALLOW_MEM_MAPPING 0x00 // Bit 1 clear - allow memory mappings
  208. #define LOCKP_USER_MASK 0x03 // Mask for user lock flags
  209. #define LOCKP_LOCK_FOR_FORMAT 0x04 // Level 0 lock for format
  210. /*
  211. * Values for vlb_flags
  212. */
  213. #define LOCKF_LOGICAL_LOCK 0x00 // Bit 0 clear - logical lock
  214. #define LOCKF_PHYSICAL_LOCK 0x01 // Bit 0 set - physical lock
  215. /*
  216. * Message = WM_DEVICECHANGE
  217. * wParam = DBT_NODISKSPACE
  218. * lParam = drive number of drive that is out of disk space (1-based)
  219. *
  220. * Message issued by IFS manager when it detects that a drive is run out of
  221. * free space.
  222. */
  223. #define DBT_NO_DISK_SPACE 0x0047
  224. /*
  225. * Message = WM_DEVICECHANGE
  226. * wParam = DBT_LOW_DISK_SPACE
  227. * lParam = drive number of drive that is low on disk space (1-based)
  228. *
  229. * Message issued by VFAT when it detects that a drive it has mounted
  230. * has the remaning free space below a threshold specified by the
  231. * registry or by a disk space management application.
  232. * The broadcast is issued by VFAT ONLY when space is either allocated
  233. * or freed by VFAT.
  234. */
  235. #define DBT_LOW_DISK_SPACE 0x0048
  236. #define DBT_CONFIGMGPRIVATE 0x7FFF
  237. /*
  238. * The following messages are for WM_DEVICECHANGE. The immediate list
  239. * is for the wParam. ALL THESE MESSAGES PASS A POINTER TO A STRUCT
  240. * STARTING WITH A DWORD SIZE AND HAVING NO POINTER IN THE STRUCT.
  241. *
  242. */
  243. #define DBT_DEVICEARRIVAL 0x8000 // system detected a new device
  244. #define DBT_DEVICEQUERYREMOVE 0x8001 // wants to remove, may fail
  245. #define DBT_DEVICEQUERYREMOVEFAILED 0x8002 // removal aborted
  246. #define DBT_DEVICEREMOVEPENDING 0x8003 // about to remove, still avail.
  247. #define DBT_DEVICEREMOVECOMPLETE 0x8004 // device is gone
  248. #define DBT_DEVICETYPESPECIFIC 0x8005 // type specific event
  249. #if(WINVER >= 0x040A)
  250. #define DBT_CUSTOMEVENT 0x8006 // user-defined event
  251. #endif /* WINVER >= 0x040A */
  252. #define DBT_DEVTYP_OEM 0x00000000 // oem-defined device type
  253. #define DBT_DEVTYP_DEVNODE 0x00000001 // devnode number
  254. #define DBT_DEVTYP_VOLUME 0x00000002 // logical volume
  255. #define DBT_DEVTYP_PORT 0x00000003 // serial, parallel
  256. #define DBT_DEVTYP_NET 0x00000004 // network resource
  257. #if(WINVER >= 0x040A)
  258. #define DBT_DEVTYP_DEVICEINTERFACE 0x00000005 // device interface class
  259. #define DBT_DEVTYP_HANDLE 0x00000006 // file system handle
  260. #endif /* WINVER >= 0x040A */
  261. struct _DEV_BROADCAST_HEADER { /* */
  262. DWORD dbcd_size;
  263. DWORD dbcd_devicetype;
  264. DWORD dbcd_reserved;
  265. };
  266. struct _DEV_BROADCAST_OEM { /* */
  267. DWORD dbco_size;
  268. DWORD dbco_devicetype;
  269. DWORD dbco_reserved;
  270. DWORD dbco_identifier;
  271. DWORD dbco_suppfunc;
  272. };
  273. typedef struct _DEV_BROADCAST_OEM DEV_BROADCAST_OEM;
  274. typedef DEV_BROADCAST_OEM DBTFAR *PDEV_BROADCAST_OEM;
  275. struct _DEV_BROADCAST_DEVNODE { /* */
  276. DWORD dbcd_size;
  277. DWORD dbcd_devicetype;
  278. DWORD dbcd_reserved;
  279. DWORD dbcd_devnode;
  280. };
  281. typedef struct _DEV_BROADCAST_DEVNODE DEV_BROADCAST_DEVNODE;
  282. typedef DEV_BROADCAST_DEVNODE DBTFAR *PDEV_BROADCAST_DEVNODE;
  283. struct _DEV_BROADCAST_VOLUME { /* */
  284. DWORD dbcv_size;
  285. DWORD dbcv_devicetype;
  286. DWORD dbcv_reserved;
  287. DWORD dbcv_unitmask;
  288. WORD dbcv_flags;
  289. };
  290. typedef struct _DEV_BROADCAST_VOLUME DEV_BROADCAST_VOLUME;
  291. typedef DEV_BROADCAST_VOLUME DBTFAR *PDEV_BROADCAST_VOLUME;
  292. #define DBTF_MEDIA 0x0001 // media comings and goings
  293. #define DBTF_NET 0x0002 // network volume
  294. typedef struct _DEV_BROADCAST_PORT_A {
  295. DWORD dbcp_size;
  296. DWORD dbcp_devicetype;
  297. DWORD dbcp_reserved;
  298. char dbcp_name[1];
  299. } DEV_BROADCAST_PORT_A, *PDEV_BROADCAST_PORT_A;
  300. typedef struct _DEV_BROADCAST_PORT_W {
  301. DWORD dbcp_size;
  302. DWORD dbcp_devicetype;
  303. DWORD dbcp_reserved;
  304. wchar_t dbcp_name[1];
  305. } DEV_BROADCAST_PORT_W, DBTFAR *PDEV_BROADCAST_PORT_W;
  306. #ifdef UNICODE
  307. typedef DEV_BROADCAST_PORT_W DEV_BROADCAST_PORT;
  308. typedef PDEV_BROADCAST_PORT_W PDEV_BROADCAST_PORT;
  309. #else
  310. typedef DEV_BROADCAST_PORT_A DEV_BROADCAST_PORT;
  311. typedef PDEV_BROADCAST_PORT_A PDEV_BROADCAST_PORT;
  312. #endif
  313. struct _DEV_BROADCAST_NET { /* */
  314. DWORD dbcn_size;
  315. DWORD dbcn_devicetype;
  316. DWORD dbcn_reserved;
  317. DWORD dbcn_resource;
  318. DWORD dbcn_flags;
  319. };
  320. typedef struct _DEV_BROADCAST_NET DEV_BROADCAST_NET;
  321. typedef DEV_BROADCAST_NET DBTFAR *PDEV_BROADCAST_NET;
  322. #if(WINVER >= 0x040A)
  323. typedef struct _DEV_BROADCAST_DEVICEINTERFACE_A {
  324. DWORD dbcc_size;
  325. DWORD dbcc_devicetype;
  326. DWORD dbcc_reserved;
  327. GUID dbcc_classguid;
  328. char dbcc_name[1];
  329. } DEV_BROADCAST_DEVICEINTERFACE_A, *PDEV_BROADCAST_DEVICEINTERFACE_A;
  330. typedef struct _DEV_BROADCAST_DEVICEINTERFACE_W {
  331. DWORD dbcc_size;
  332. DWORD dbcc_devicetype;
  333. DWORD dbcc_reserved;
  334. GUID dbcc_classguid;
  335. wchar_t dbcc_name[1];
  336. } DEV_BROADCAST_DEVICEINTERFACE_W, *PDEV_BROADCAST_DEVICEINTERFACE_W;
  337. #ifdef UNICODE
  338. typedef DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE;
  339. typedef PDEV_BROADCAST_DEVICEINTERFACE_W PDEV_BROADCAST_DEVICEINTERFACE;
  340. #else
  341. typedef DEV_BROADCAST_DEVICEINTERFACE_A DEV_BROADCAST_DEVICEINTERFACE;
  342. typedef PDEV_BROADCAST_DEVICEINTERFACE_A PDEV_BROADCAST_DEVICEINTERFACE;
  343. #endif
  344. typedef struct _DEV_BROADCAST_HANDLE {
  345. DWORD dbch_size;
  346. DWORD dbch_devicetype;
  347. DWORD dbch_reserved;
  348. HANDLE dbch_handle; // file handle used in call to RegisterDeviceNotification
  349. HDEVNOTIFY dbch_hdevnotify; // returned from RegisterDeviceNotification
  350. //
  351. // The following 3 fields are only valid if wParam is DBT_CUSTOMEVENT.
  352. //
  353. GUID dbch_eventguid;
  354. LONG dbch_nameoffset; // offset (bytes) of variable-length string buffer (-1 if none)
  355. BYTE dbch_data[1]; // variable-sized buffer, potentially containing binary and/or text data
  356. } DEV_BROADCAST_HANDLE, *PDEV_BROADCAST_HANDLE;
  357. #if(WINVER >= 0x0501)
  358. //
  359. // Define 32-bit and 64-bit versions of the DEV_BROADCAST_HANDLE structure
  360. // for WOW64. These must be kept in sync with the above structure.
  361. //
  362. typedef struct _DEV_BROADCAST_HANDLE32 {
  363. DWORD dbch_size;
  364. DWORD dbch_devicetype;
  365. DWORD dbch_reserved;
  366. ULONG32 dbch_handle;
  367. ULONG32 dbch_hdevnotify;
  368. GUID dbch_eventguid;
  369. LONG dbch_nameoffset;
  370. BYTE dbch_data[1];
  371. } DEV_BROADCAST_HANDLE32, *PDEV_BROADCAST_HANDLE32;
  372. typedef struct _DEV_BROADCAST_HANDLE64 {
  373. DWORD dbch_size;
  374. DWORD dbch_devicetype;
  375. DWORD dbch_reserved;
  376. ULONG64 dbch_handle;
  377. ULONG64 dbch_hdevnotify;
  378. GUID dbch_eventguid;
  379. LONG dbch_nameoffset;
  380. BYTE dbch_data[1];
  381. } DEV_BROADCAST_HANDLE64, *PDEV_BROADCAST_HANDLE64;
  382. #endif /* WINVER >= 0x0501 */
  383. #endif /* WINVER >= 0x040A */
  384. #define DBTF_RESOURCE 0x00000001 // network resource
  385. #define DBTF_XPORT 0x00000002 // new transport coming or going
  386. #define DBTF_SLOWNET 0x00000004 // new incoming transport is slow
  387. // (dbcn_resource undefined for now)
  388. #define DBT_VPOWERDAPI 0x8100 // VPOWERD API for Win95
  389. /*
  390. * User-defined message types all use wParam = 0xFFFF with the
  391. * lParam a pointer to the structure below.
  392. *
  393. * dbud_dbh - DEV_BROADCAST_HEADER must be filled in as usual.
  394. *
  395. * dbud_szName contains a case-sensitive ASCIIZ name which names the
  396. * message. The message name consists of the vendor name, a backslash,
  397. * then arbitrary user-defined ASCIIZ text. For example:
  398. *
  399. * "WidgetWare\QueryScannerShutdown"
  400. * "WidgetWare\Video Q39S\AdapterReady"
  401. *
  402. * After the ASCIIZ name, arbitrary information may be provided.
  403. * Make sure that dbud_dbh.dbch_size is big enough to encompass
  404. * all the data. And remember that nothing in the structure may
  405. * contain pointers.
  406. */
  407. #define DBT_USERDEFINED 0xFFFF
  408. struct _DEV_BROADCAST_USERDEFINED { /* */
  409. struct _DEV_BROADCAST_HDR dbud_dbh;
  410. char dbud_szName[1]; /* ASCIIZ name */
  411. /* BYTE dbud_rgbUserDefined[];*/ /* User-defined contents */
  412. };
  413. #endif // _DBT_H