1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 use ctypes::{c_char, wchar_t};
7 use shared::basetsd::{ULONG32, ULONG64};
8 use shared::guiddef::GUID;
9 use shared::minwindef::{BYTE, DWORD, UINT, WORD, WPARAM};
10 use um::winnt::{HANDLE, LONG};
11 use um::winuser::HDEVNOTIFY;
12 pub const WM_DEVICECHANGE: UINT = 0x0219;
13 pub const BSF_QUERY: DWORD = 0x00000001;
14 pub const BSF_IGNORECURRENTTASK: DWORD = 0x00000002;
15 pub const BSF_FLUSHDISK: DWORD = 0x00000004;
16 pub const BSF_NOHANG: DWORD = 0x00000008;
17 pub const BSF_POSTMESSAGE: DWORD = 0x00000010;
18 pub const BSF_FORCEIFHUNG: DWORD = 0x00000020;
19 pub const BSF_NOTIMEOUTIFNOTHUNG: DWORD = 0x00000040;
20 pub const BSF_MSGSRV32ISOK: DWORD = 0x80000000;
21 pub const BSF_MSGSRV32ISOK_BIT: usize = 31;
22 pub const BSM_ALLCOMPONENTS: DWORD = 0x00000000;
23 pub const BSM_VXDS: DWORD = 0x00000001;
24 pub const BSM_NETDRIVER: DWORD = 0x00000002;
25 pub const BSM_INSTALLABLEDRIVERS: DWORD = 0x00000004;
26 pub const BSM_APPLICATIONS: DWORD = 0x00000008;
27 pub const DBT_APPYBEGIN: WPARAM = 0x0000;
28 pub const DBT_APPYEND: WPARAM = 0x0001;
29 pub const DBT_DEVNODES_CHANGED: WPARAM = 0x0007;
30 pub const DBT_QUERYCHANGECONFIG: WPARAM = 0x0017;
31 pub const DBT_CONFIGCHANGED: WPARAM = 0x0018;
32 pub const DBT_CONFIGCHANGECANCELED: WPARAM = 0x0019;
33 pub const DBT_MONITORCHANGE: WPARAM = 0x001B;
34 pub const DBT_SHELLLOGGEDON: WPARAM = 0x0020;
35 pub const DBT_CONFIGMGAPI32: WPARAM = 0x0022;
36 pub const DBT_VXDINITCOMPLETE: WPARAM = 0x0023;
37 pub const DBT_VOLLOCKQUERYLOCK: WPARAM = 0x8041;
38 pub const DBT_VOLLOCKLOCKTAKEN: WPARAM = 0x8042;
39 pub const DBT_VOLLOCKLOCKFAILED: WPARAM = 0x8043;
40 pub const DBT_VOLLOCKQUERYUNLOCK: WPARAM = 0x8044;
41 pub const DBT_VOLLOCKLOCKRELEASED: WPARAM = 0x8045;
42 pub const DBT_VOLLOCKUNLOCKFAILED: WPARAM = 0x8046;
43 STRUCT!{struct DEV_BROADCAST_HDR {
44     dbch_size: DWORD,
45     dbch_devicetype: DWORD,
46     dbch_reserved: DWORD,
47 }}
48 pub type PDEV_BROADCAST_HDR = *mut DEV_BROADCAST_HDR;
49 STRUCT!{struct VolLockBroadcast {
50     vlb_dbh: DEV_BROADCAST_HDR,
51     vlb_owner: DWORD,
52     vlb_perms: BYTE,
53     vlb_lockType: BYTE,
54     vlb_drive: BYTE,
55     vlb_flags: BYTE,
56 }}
57 pub type pVolLockBroadcast = *mut VolLockBroadcast;
58 pub const LOCKP_ALLOW_WRITES: BYTE = 0x01;
59 pub const LOCKP_FAIL_WRITES: BYTE = 0x00;
60 pub const LOCKP_FAIL_MEM_MAPPING: BYTE = 0x02;
61 pub const LOCKP_ALLOW_MEM_MAPPING: BYTE = 0x00;
62 pub const LOCKP_USER_MASK: BYTE = 0x03;
63 pub const LOCKP_LOCK_FOR_FORMAT: BYTE = 0x04;
64 pub const LOCKF_LOGICAL_LOCK: BYTE = 0x00;
65 pub const LOCKF_PHYSICAL_LOCK: BYTE = 0x01;
66 pub const DBT_NO_DISK_SPACE: WPARAM = 0x0047;
67 pub const DBT_LOW_DISK_SPACE: WPARAM = 0x0048;
68 pub const DBT_CONFIGMGPRIVATE: WPARAM = 0x7FFF;
69 pub const DBT_DEVICEARRIVAL: WPARAM = 0x8000;
70 pub const DBT_DEVICEQUERYREMOVE: WPARAM = 0x8001;
71 pub const DBT_DEVICEQUERYREMOVEFAILED: WPARAM = 0x8002;
72 pub const DBT_DEVICEREMOVEPENDING: WPARAM = 0x8003;
73 pub const DBT_DEVICEREMOVECOMPLETE: WPARAM = 0x8004;
74 pub const DBT_DEVICETYPESPECIFIC: WPARAM = 0x8005;
75 pub const DBT_CUSTOMEVENT: WPARAM = 0x8006;
76 pub const DBT_DEVTYP_OEM: DWORD = 0x00000000;
77 pub const DBT_DEVTYP_DEVNODE: DWORD = 0x00000001;
78 pub const DBT_DEVTYP_VOLUME: DWORD = 0x00000002;
79 pub const DBT_DEVTYP_PORT: DWORD = 0x00000003;
80 pub const DBT_DEVTYP_NET: DWORD = 0x00000004;
81 pub const DBT_DEVTYP_DEVICEINTERFACE: DWORD = 0x00000005;
82 pub const DBT_DEVTYP_HANDLE: DWORD = 0x00000006;
83 STRUCT!{struct _DEV_BROADCAST_HEADER {
84     dbcd_size: DWORD,
85     dbcd_devicetype: DWORD,
86     dbcd_reserved: DWORD,
87 }}
88 STRUCT!{struct DEV_BROADCAST_OEM {
89     dbco_size: DWORD,
90     dbco_devicetype: DWORD,
91     dbco_reserved: DWORD,
92     dbco_identifier: DWORD,
93     dbco_suppfunc: DWORD,
94 }}
95 pub type PDEV_BROADCAST_OEM = *mut DEV_BROADCAST_OEM;
96 STRUCT!{struct DEV_BROADCAST_DEVNODE {
97     dbcd_size: DWORD,
98     dbcd_devicetype: DWORD,
99     dbcd_reserved: DWORD,
100     dbcd_devnode: DWORD,
101 }}
102 pub type PDEV_BROADCAST_DEVNODE = *mut DEV_BROADCAST_DEVNODE;
103 STRUCT!{struct DEV_BROADCAST_VOLUME {
104     dbcv_size: DWORD,
105     dbcv_devicetype: DWORD,
106     dbcv_reserved: DWORD,
107     dbcv_unitmask: DWORD,
108     dbcv_flags: WORD,
109 }}
110 pub type PDEV_BROADCAST_VOLUME = *mut DEV_BROADCAST_VOLUME;
111 pub const DBTF_MEDIA: WORD = 0x0001;
112 pub const DBTF_NET: WORD = 0x0002;
113 STRUCT!{struct DEV_BROADCAST_PORT_A {
114     dbcp_size: DWORD,
115     dbcp_devicetype: DWORD,
116     dbcp_reserved: DWORD,
117     dbcp_name: [c_char; 1],
118 }}
119 pub type PDEV_BROADCAST_PORT_A = *mut DEV_BROADCAST_PORT_A;
120 STRUCT!{struct DEV_BROADCAST_PORT_W {
121     dbcp_size: DWORD,
122     dbcp_devicetype: DWORD,
123     dbcp_reserved: DWORD,
124     dbcp_name: [wchar_t; 1],
125 }}
126 pub type PDEV_BROADCAST_PORT_W = *mut DEV_BROADCAST_PORT_W;
127 STRUCT!{struct DEV_BROADCAST_NET {
128     dbcn_size: DWORD,
129     dbcn_devicetype: DWORD,
130     dbcn_reserved: DWORD,
131     dbcn_resource: DWORD,
132     dbcn_flags: DWORD,
133 }}
134 pub type PDEV_BROADCAST_NET = *mut DEV_BROADCAST_NET;
135 STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_A {
136     dbcc_size: DWORD,
137     dbcc_devicetype: DWORD,
138     dbcc_reserved: DWORD,
139     dbcc_classguid: GUID,
140     dbcc_name: [c_char; 1],
141 }}
142 pub type PDEV_BROADCAST_DEVICEINTERFACE_A = *mut DEV_BROADCAST_DEVICEINTERFACE_A;
143 STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_W {
144     dbcc_size: DWORD,
145     dbcc_devicetype: DWORD,
146     dbcc_reserved: DWORD,
147     dbcc_classguid: GUID,
148     dbcc_name: [wchar_t; 1],
149 }}
150 pub type PDEV_BROADCAST_DEVICEINTERFACE_W = *mut DEV_BROADCAST_DEVICEINTERFACE_W;
151 STRUCT!{struct DEV_BROADCAST_HANDLE {
152     dbch_size: DWORD,
153     dbch_devicetype: DWORD,
154     dbch_reserved: DWORD,
155     dbch_handle: HANDLE,
156     dbch_hdevnotify: HDEVNOTIFY,
157     dbch_eventguid: GUID,
158     dbch_nameoffset: LONG,
159     dbch_data: [BYTE; 1],
160 }}
161 pub type PDEV_BROADCAST_HANDLE = *mut DEV_BROADCAST_HANDLE;
162 STRUCT!{struct DEV_BROADCAST_HANDLE32 {
163     dbch_size: DWORD,
164     dbch_devicetype: DWORD,
165     dbch_reserved: DWORD,
166     dbch_handle: ULONG32,
167     dbch_hdevnotify: ULONG32,
168     dbch_eventguid: GUID,
169     dbch_nameoffset: LONG,
170     dbch_data: [BYTE; 1],
171 }}
172 pub type PDEV_BROADCAST_HANDLE32 = *mut DEV_BROADCAST_HANDLE32;
173 STRUCT!{struct DEV_BROADCAST_HANDLE64 {
174     dbch_size: DWORD,
175     dbch_devicetype: DWORD,
176     dbch_reserved: DWORD,
177     dbch_handle: ULONG64,
178     dbch_hdevnotify: ULONG64,
179     dbch_eventguid: GUID,
180     dbch_nameoffset: LONG,
181     dbch_data: [BYTE; 1],
182 }}
183 pub type PDEV_BROADCAST_HANDLE64 = *mut DEV_BROADCAST_HANDLE64;
184 pub const DBTF_RESOURCE: DWORD = 0x00000001;
185 pub const DBTF_XPORT: DWORD = 0x00000002;
186 pub const DBTF_SLOWNET: DWORD = 0x00000004;
187 pub const DBT_VPOWERDAPI: WPARAM = 0x8100;
188 pub const DBT_USERDEFINED: WPARAM = 0xFFFF;
189 STRUCT!{struct _DEV_BROADCAST_USERDEFINED {
190     dbud_dbh: DEV_BROADCAST_HDR,
191     dbud_szName: [c_char; 1],
192 }}
193