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_long, c_ulong};
7 use shared::minwindef::{BYTE, DWORD};
8 use shared::winerror::HRESULT;
9 use shared::wtypes::BSTR;
10 use um::oaidl::{VARIANT};
11 use um::unknwnbase::{IUnknown, IUnknownVtbl};
12 use um::wbemcli::{
13     IWbemClassObject, IWbemContext, IWbemHiPerfEnum, IWbemObjectAccess, IWbemObjectSink,
14     IWbemObjectSinkVtbl, IWbemRefresher, IWbemServices
15 };
16 use um::winnt::{LONG, LPCWSTR, LPWSTR, WCHAR};
17 pub type WBEM_VARIANT = VARIANT;
18 pub type WBEM_WSTR = LPWSTR;
19 pub type WBEM_CWSTR = LPCWSTR;
20 ENUM!{enum WBEM_PROVIDER_REQUIREMENTS_TYPE {
21     WBEM_REQUIREMENTS_START_POSTFILTER = 0,
22     WBEM_REQUIREMENTS_STOP_POSTFILTER = 1,
23     WBEM_REQUIREMENTS_RECHECK_SUBSCRIPTIONS = 2,
24 }}
25 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0000_v0_0_c_ifspec;
26 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0000_v0_0_s_ifspec;
27 // EXTERN_C const IID LIBID_WbemProviders_v1;
28 // EXTERN_C const IID IID_IWbemPropertyProvider;
29 DEFINE_GUID!{IID_IWbemPropertyProvider,
30     0xce61e841, 0x65bc, 0x11d0, 0xb6, 0xbd, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7}
31 RIDL!{#[uuid(0xce61e841, 0x65bc, 0x11d0, 0xb6, 0xbd, 0x00, 0xaa, 0x00, 0x32, 0x40, 0xc7)]
32 interface IWbemPropertyProvider(IWbemPropertyProviderVtbl): IUnknown(IUnknownVtbl) {
33     fn GetProperty(
34         lFlags: c_long,
35         strLocale: BSTR,
36         strClassMapping: BSTR,
37         strInstMapping: BSTR,
38         strPropMapping: BSTR,
39         pvValue: *mut VARIANT,
40     ) -> HRESULT,
41     fn PutProperty(
42         lFlags: c_long,
43         strLocale: BSTR,
44         strClassMapping: BSTR,
45         strInstMapping: BSTR,
46         strPropMapping: BSTR,
47         pvValue: *const VARIANT,
48     ) -> HRESULT,
49 }}
50 // EXTERN_C const IID IID_IWbemUnboundObjectSink;
51 DEFINE_GUID!{IID_IWbemUnboundObjectSink,
52     0xe246107b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
53 RIDL!{#[uuid(0xe246107b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)]
54 interface IWbemUnboundObjectSink(IWbemUnboundObjectSinkVtbl): IUnknown(IUnknownVtbl) {
55     fn IndicateToConsumer(
56         pLogicalConsumer: *mut IWbemClassObject,
57         lNumObjects: c_long,
58         apObjects: *mut *mut IWbemClassObject,
59     ) -> HRESULT,
60 }}
61 // EXTERN_C const IID IID_IWbemEventProvider;
62 DEFINE_GUID!{IID_IWbemEventProvider,
63     0xe245105b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
64 RIDL!{#[uuid(0xe245105b, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)]
65 interface IWbemEventProvider(IWbemEventProviderVtbl): IUnknown(IUnknownVtbl) {
66     fn ProvideEvents(
67         pSink: *mut IWbemObjectSink,
68         lFlags: c_long,
69     ) -> HRESULT,
70 }}
71 // EXTERN_C const IID IID_IWbemEventProviderQuerySink;
72 DEFINE_GUID!{IID_IWbemEventProviderQuerySink,
73     0x580acaf8, 0xfa1c, 0x11d0, 0xad, 0x72, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
74 RIDL!{#[uuid(0x580acaf8, 0xfa1c, 0x11d0, 0xad, 0x72, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)]
75 interface IWbemEventProviderQuerySink(IWbemEventProviderQuerySinkVtbl): IUnknown(IUnknownVtbl) {
76     fn NewQuery(
77         dwId: c_ulong,
78         wszQueryLanguage: WBEM_WSTR,
79         wszQuery: WBEM_WSTR,
80     ) -> HRESULT,
81     fn CancelQuery(
82         dwId: c_ulong,
83     ) -> HRESULT,
84 }}
85 // EXTERN_C const IID IID_IWbemEventProviderSecurity;
86 DEFINE_GUID!{IID_IWbemEventProviderSecurity,
87     0x631f7d96, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf}
88 RIDL!{#[uuid(0x631f7d96, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf)]
89 interface IWbemEventProviderSecurity(IWbemEventProviderSecurityVtbl): IUnknown(IUnknownVtbl) {
90     fn AccessCheck(
91         wszQueryLanguage: WBEM_CWSTR,
92         wszQuery: WBEM_CWSTR,
93         lSidLength: c_long,
94         pSid: *const BYTE,
95     ) -> HRESULT,
96 }}
97 // EXTERN_C const IID IID_IWbemEventConsumerProvider;
98 DEFINE_GUID!{IID_IWbemEventConsumerProvider,
99     0xe246107a, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
100 RIDL!{#[uuid(0xe246107a, 0xb06e, 0x11d0, 0xad, 0x61, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff)]
101 interface IWbemEventConsumerProvider(IWbemEventConsumerProviderVtbl): IUnknown(IUnknownVtbl) {
102     fn FindConsumer(
103         pLogicalConsumer: *mut IWbemClassObject,
104         ppConsumer: *mut *mut IWbemUnboundObjectSink,
105     ) -> HRESULT,
106 }}
107 // EXTERN_C const IID IID_IWbemProviderInitSink;
108 DEFINE_GUID!{IID_IWbemProviderInitSink,
109     0x1be41571, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20}
110 RIDL!{#[uuid(0x1be41571, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)]
111 interface IWbemProviderInitSink(IWbemProviderInitSinkVtbl): IUnknown(IUnknownVtbl) {
112     fn SetStatus(
113         lStatus: LONG,
114         lFlags: LONG,
115     ) -> HRESULT,
116 }}
117 // EXTERN_C const IID IID_IWbemProviderInit;
118 DEFINE_GUID!{IID_IWbemProviderInit,
119     0x1be41572, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20}
120 RIDL!{#[uuid(0x1be41572, 0x91dd, 0x11d1, 0xae, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)]
121 interface IWbemProviderInit(IWbemProviderInitVtbl): IUnknown(IUnknownVtbl) {
122     fn Initialize(
123         wszUser: LPWSTR,
124         lFlags: LONG,
125         wszNamespace: LPWSTR,
126         wszLocale: LPWSTR,
127         pNamespace: *mut IWbemServices,
128         pCtx: *mut IWbemContext,
129         pInitSink: *mut IWbemProviderInitSink,
130     ) -> HRESULT,
131 }}
132 // EXTERN_C const IID IID_IWbemHiPerfProvider;
133 DEFINE_GUID!{IID_IWbemHiPerfProvider,
134     0x49353c93, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20}
135 RIDL!{#[uuid(0x49353c93, 0x516b, 0x11d1, 0xae, 0xa6, 0x00, 0xc0, 0x4f, 0xb6, 0x88, 0x20)]
136 interface IWbemHiPerfProvider(IWbemHiPerfProviderVtbl): IUnknown(IUnknownVtbl) {
137     fn QueryInstances(
138         pNamespace: *mut IWbemServices,
139         wszClass: *mut WCHAR,
140         lFlags: c_long,
141         pCtx: *mut IWbemContext,
142         pSink: *mut IWbemObjectSink,
143     ) -> HRESULT,
144     fn CreateRefresher(
145         pNamespace: *mut IWbemServices,
146         lFlags: c_long,
147         ppRefresher: *mut *mut IWbemRefresher,
148     ) -> HRESULT,
149     fn CreateRefreshableObject(
150         pNamespace: *mut IWbemServices,
151         pTemplate: *mut IWbemObjectAccess,
152         pRefresher: *mut IWbemRefresher,
153         lFlags: c_long,
154         pContext: *mut IWbemContext,
155         ppRefreshable: *mut *mut IWbemObjectAccess,
156         plId: *mut c_long,
157     ) -> HRESULT,
158     fn StopRefreshing(
159         pRefresher: *mut IWbemRefresher,
160         lId: c_long,
161         lFlags: c_long,
162     ) -> HRESULT,
163     fn CreateRefreshableEnum(
164         pNamespace: *mut IWbemServices,
165         wszClass: LPCWSTR,
166         pRefresher: *mut IWbemRefresher,
167         lFlags: c_long,
168         pContext: *mut IWbemContext,
169         pHiPerfEnum: *mut IWbemHiPerfEnum,
170         plId: *mut c_long,
171     ) -> HRESULT,
172     fn GetObjects(
173         pNamespace: *mut IWbemServices,
174         lNumObjects: c_long,
175         apObj: *mut *mut IWbemObjectAccess,
176         lFlags: c_long,
177         pContext: *mut IWbemContext,
178     ) -> HRESULT,
179 }}
180 // EXTERN_C const IID IID_IWbemDecoupledRegistrar;
181 DEFINE_GUID!{IID_IWbemDecoupledRegistrar,
182     0x1005cbcf, 0xe64f, 0x4646, 0xbc, 0xd3, 0x3a, 0x08, 0x9d, 0x8a, 0x84, 0xb4}
183 RIDL!{#[uuid(0x1005cbcf, 0xe64f, 0x4646, 0xbc, 0xd3, 0x3a, 0x08, 0x9d, 0x8a, 0x84, 0xb4)]
184 interface IWbemDecoupledRegistrar(IWbemDecoupledRegistrarVtbl): IUnknown(IUnknownVtbl) {
185     fn Register(
186         a_Flags: c_long,
187         a_Context: *mut IWbemContext,
188         a_User: LPCWSTR,
189         a_Locale: LPCWSTR,
190         a_Scope: LPCWSTR,
191         a_Registration: LPCWSTR,
192         pIUnknown: *mut IUnknown,
193     ) -> HRESULT,
194     fn UnRegister() -> HRESULT,
195 }}
196 DEFINE_GUID!{CLSID_WbemAdministrativeLocator,
197     0xcb8555cc, 0x9128, 0x11d1, 0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
198 // class DECLSPEC_UUID("cb8555cc-9128-11d1-ad9b-00c04fd8fdff")
199 // WbemAdministrativeLocator;
200 DEFINE_GUID!{CLSID_WbemAuthenticatedLocator,
201     0xcd184336, 0x9128, 0x11d1, 0xad, 0x9b, 0x00, 0xc0, 0x4f, 0xd8, 0xfd, 0xff}
202 // class DECLSPEC_UUID("cd184336-9128-11d1-ad9b-00c04fd8fdff")
203 // WbemAuthenticatedLocator;
204 DEFINE_GUID!{CLSID_WbemUnauthenticatedLocator,
205     0x443E7B79, 0xDE31, 0x11d2, 0xB3, 0x40, 0x00, 0x10, 0x4B, 0xCC, 0x4B, 0x4A}
206 // class DECLSPEC_UUID("443E7B79-DE31-11d2-B340-00104BCC4B4A")
207 // WbemUnauthenticatedLocator;
208 DEFINE_GUID!{CLSID_WbemDecoupledRegistrar,
209     0x4cfc7932, 0x0f9d, 0x4bef, 0x9c, 0x32, 0x8e, 0xa2, 0xa6, 0xb5, 0x6f, 0xcb}
210 // class DECLSPEC_UUID("4cfc7932-0f9d-4bef-9c32-8ea2a6b56fcb")
211 // WbemDecoupledRegistrar;
212 DEFINE_GUID!{CLSID_WbemDecoupledBasicEventProvider,
213     0xf5f75737, 0x2843, 0x4f22, 0x93, 0x3d, 0xc7, 0x6a, 0x97, 0xcd, 0xa6, 0x2f}
214 // class DECLSPEC_UUID("f5f75737-2843-4f22-933d-c76a97cda62f")
215 // WbemDecoupledBasicEventProvider;
216 // EXTERN_C const IID IID_IWbemProviderIdentity;
217 DEFINE_GUID!{IID_IWbemProviderIdentity,
218     0x631f7d97, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf}
219 RIDL!{#[uuid(0x631f7d97, 0xd993, 0x11d2, 0xb3, 0x39, 0x00, 0x10, 0x5a, 0x1f, 0x4a, 0xaf)]
220 interface IWbemProviderIdentity(IWbemProviderIdentityVtbl): IUnknown(IUnknownVtbl) {
221     fn SetRegistrationObject(
222         lFlags: c_long,
223         pProvReg: *mut IWbemClassObject,
224     ) -> HRESULT,
225 }}
226 ENUM!{enum WBEM_EXTRA_RETURN_CODES {
227     WBEM_S_INITIALIZED = 0,
228     WBEM_S_LIMITED_SERVICE = 0x43001,
229     WBEM_S_INDIRECTLY_UPDATED = WBEM_S_LIMITED_SERVICE + 1,
230     WBEM_S_SUBJECT_TO_SDS = WBEM_S_INDIRECTLY_UPDATED + 1,
231     WBEM_E_RETRY_LATER = 0x80043001,
232     WBEM_E_RESOURCE_CONTENTION = WBEM_E_RETRY_LATER + 1,
233 }}
234 ENUM!{enum WBEM_PROVIDER_FLAGS {
235     WBEM_FLAG_OWNER_UPDATE = 0x10000,
236 }}
237 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0008_v0_0_c_ifspec;
238 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0008_v0_0_s_ifspec;
239 // EXTERN_C const IID IID_IWbemDecoupledBasicEventProvider;
240 DEFINE_GUID!{IID_IWbemDecoupledBasicEventProvider,
241     0x86336d20, 0xca11, 0x4786, 0x9e, 0xf1, 0xbc, 0x8a, 0x94, 0x6b, 0x42, 0xfc}
242 RIDL!{#[uuid(0x86336d20, 0xca11, 0x4786, 0x9e, 0xf1, 0xbc, 0x8a, 0x94, 0x6b, 0x42, 0xfc)]
243 interface IWbemDecoupledBasicEventProvider(IWbemDecoupledBasicEventProviderVtbl):
244     IWbemDecoupledRegistrar(IWbemDecoupledRegistrarVtbl) {
245     fn GetSink(
246         a_Flags: c_long,
247         a_Context: *mut IWbemContext,
248         a_Sink: *mut *mut IWbemObjectSink,
249     ) -> HRESULT,
250     fn GetService(
251         a_Flags: c_long,
252         a_Context: *mut IWbemContext,
253         a_Service: *mut *mut IWbemServices,
254     ) -> HRESULT,
255 }}
256 ENUM!{enum WBEM_BATCH_TYPE {
257     WBEM_FLAG_BATCH_IF_NEEDED = 0,
258     WBEM_FLAG_MUST_BATCH = 0x1,
259     WBEM_FLAG_MUST_NOT_BATCH = 0x2,
260 }}
261 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0013_v0_0_c_ifspec;
262 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0013_v0_0_s_ifspec;
263 // EXTERN_C const IID IID_IWbemEventSink;
264 DEFINE_GUID!{IID_IWbemEventSink,
265     0x3ae0080a, 0x7e3a, 0x4366, 0xbf, 0x89, 0x0f, 0xee, 0xdc, 0x93, 0x16, 0x59}
266 RIDL!{#[uuid(0x3ae0080a, 0x7e3a, 0x4366, 0xbf, 0x89, 0x0f, 0xee, 0xdc, 0x93, 0x16, 0x59)]
267 interface IWbemEventSink(IWbemEventSinkVtbl): IWbemObjectSink(IWbemObjectSinkVtbl) {
268     fn SetSinkSecurity(
269         lSDLength: c_long,
270         pSD: *mut BYTE,
271     ) -> HRESULT,
272     fn IsActive() -> HRESULT,
273     fn GetRestrictedSink(
274         lNumQueries: c_long,
275         awszQueries: *const LPCWSTR,
276         pCallback: *mut IUnknown,
277         ppSink: *mut *mut IWbemEventSink,
278     ) -> HRESULT,
279     fn SetBatchingParameters(
280         lFlags: LONG,
281         dwMaxBufferSize: DWORD,
282         dwMaxSendLatency: DWORD,
283     ) -> HRESULT,
284 }}
285 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0014_v0_0_c_ifspec;
286 // extern RPC_IF_HANDLE __MIDL_itf_wbemprov_0000_0014_v0_0_s_ifspec;
287 // unsigned c_long __RPC_USER BSTR_UserSize( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in BSTR * );
288 // unsigned char * __RPC_USER BSTR_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * );
289 // unsigned char * __RPC_USER BSTR_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * );
290 // void __RPC_USER BSTR_UserFree( __RPC__in unsigned c_long *, __RPC__in BSTR * );
291 // unsigned c_long __RPC_USER VARIANT_UserSize( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in VARIANT * );
292 // unsigned char * __RPC_USER VARIANT_UserMarshal( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * );
293 // unsigned char * __RPC_USER VARIANT_UserUnmarshal(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * );
294 // void __RPC_USER VARIANT_UserFree( __RPC__in unsigned c_long *, __RPC__in VARIANT * );
295 // unsigned c_long __RPC_USER BSTR_UserSize64( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in BSTR * );
296 // unsigned char * __RPC_USER BSTR_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * );
297 // unsigned char * __RPC_USER BSTR_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * );
298 // void __RPC_USER BSTR_UserFree64( __RPC__in unsigned c_long *, __RPC__in BSTR * );
299 // unsigned c_long __RPC_USER VARIANT_UserSize64( __RPC__in unsigned c_long *, unsigned c_long, __RPC__in VARIANT * );
300 // unsigned char * __RPC_USER VARIANT_UserMarshal64( __RPC__in unsigned c_long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in VARIANT * );
301 // unsigned char * __RPC_USER VARIANT_UserUnmarshal64(__RPC__in unsigned c_long *, __RPC__in_xcount(0) unsigned char *, __RPC__out VARIANT * );
302 // void __RPC_USER VARIANT_UserFree64( __RPC__in unsigned c_long *, __RPC__in VARIANT * );
303