ReactOS  r76032
wbemprox_private.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef _WBEMPROX_PRIVATE_H_
20 #define _WBEMPROX_PRIVATE_H_
21 
22 #include <config.h>
23 
24 #include <stdarg.h>
25 
26 #define _INC_WINDOWS
27 #define COM_NO_WINDOWS_H
28 
29 #define COBJMACROS
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
32 
33 #include <ntstatus.h>
34 #define WIN32_NO_STATUS
35 #include <windef.h>
36 #include <winbase.h>
37 #include <winsvc.h>
38 #include <objbase.h>
39 #include <oleauto.h>
40 #include <wbemcli.h>
41 
42 #include <wine/debug.h>
43 #include <wine/list.h>
44 #include <wine/unicode.h>
45 
47 
49 struct list *table_list DECLSPEC_HIDDEN;
50 
51 #define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
52 
54 {
55  PARAM_OUT = -1,
58 };
59 
60 #define CIM_TYPE_MASK 0x00000fff
61 
62 #define COL_TYPE_MASK 0x0000ffff
63 #define COL_FLAG_DYNAMIC 0x00010000
64 #define COL_FLAG_KEY 0x00020000
65 #define COL_FLAG_METHOD 0x00040000
66 
68 
69 enum operator
70 {
71  OP_EQ = 1,
72  OP_AND = 2,
73  OP_OR = 3,
74  OP_GT = 4,
75  OP_LT = 5,
76  OP_LE = 6,
77  OP_GE = 7,
78  OP_NE = 8,
79  OP_ISNULL = 9,
80  OP_NOTNULL = 10,
81  OP_LIKE = 11,
82  OP_NOT = 12
83 };
84 
85 struct expr;
86 struct complex_expr
87 {
88  enum operator op;
89  struct expr *left;
90  struct expr *right;
91 };
92 
94 {
98  EXPR_SVAL = 4,
99  EXPR_IVAL = 5,
101 };
102 
103 struct expr
104 {
106  union
107  {
108  struct complex_expr expr;
109  const struct property *propval;
110  const WCHAR *sval;
111  int ival;
112  } u;
113 };
114 
115 struct column
116 {
117  const WCHAR *name;
119  VARTYPE vartype; /* 0 for default mapping */
120 };
121 
123 {
127 };
128 
129 #define TABLE_FLAG_DYNAMIC 0x00000001
130 
131 struct table
132 {
133  const WCHAR *name;
135  const struct column *columns;
139  enum fill_status (*fill)(struct table *, const struct expr *cond);
141  struct list entry;
143 };
144 
145 struct property
146 {
147  const WCHAR *name;
148  const WCHAR *class;
149  const struct property *next;
150 };
151 
152 struct array
153 {
155  void *ptr;
156 };
157 
158 struct field
159 {
161  VARTYPE vartype; /* 0 for default mapping */
162  union
163  {
166  struct array *aval;
167  } u;
168 };
169 
170 struct record
171 {
173  struct field *fields;
174  struct table *table;
175 };
176 
177 struct view
178 {
179  const struct property *proplist;
180  struct table *table;
181  const struct expr *cond;
184 };
185 
186 struct query
187 {
189  struct view *view;
190  struct list mem;
191 };
192 
193 struct query *create_query(void) DECLSPEC_HIDDEN;
194 void free_query( struct query * ) DECLSPEC_HIDDEN;
195 struct query *addref_query( struct query * ) DECLSPEC_HIDDEN;
196 void release_query( struct query *query ) DECLSPEC_HIDDEN;
197 HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
198 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
200  struct view ** ) DECLSPEC_HIDDEN;
201 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
202 HRESULT execute_view( struct view * ) DECLSPEC_HIDDEN;
203 void init_table_list( void ) DECLSPEC_HIDDEN;
204 struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
205 struct table *addref_table( struct table * ) DECLSPEC_HIDDEN;
206 void release_table( struct table * ) DECLSPEC_HIDDEN;
207 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *,
208  enum fill_status (*)(struct table *, const struct expr *) ) DECLSPEC_HIDDEN;
209 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
210 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
211 void free_row_values( const struct table *, UINT ) DECLSPEC_HIDDEN;
212 void clear_table( struct table * ) DECLSPEC_HIDDEN;
213 void free_table( struct table * ) DECLSPEC_HIDDEN;
214 UINT get_type_size( CIMTYPE ) DECLSPEC_HIDDEN;
215 HRESULT eval_cond( const struct table *, UINT, const struct expr *, LONGLONG *, UINT * ) DECLSPEC_HIDDEN;
216 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
217 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
218 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
219 HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
220 BOOL is_method( const struct table *, UINT ) DECLSPEC_HIDDEN;
221 HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
222 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
223  CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
224 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
225 HRESULT to_longlong( VARIANT *, LONGLONG *, CIMTYPE * ) DECLSPEC_HIDDEN;
226 SAFEARRAY *to_safearray( const struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
227 VARTYPE to_vartype( CIMTYPE ) DECLSPEC_HIDDEN;
228 void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
229 BOOL is_selected_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN;
230 HRESULT get_properties( const struct view *, LONG, SAFEARRAY ** ) DECLSPEC_HIDDEN;
231 HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
232 BSTR get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
233 void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN;
235  IWbemClassObject ** ) DECLSPEC_HIDDEN;
236 
237 HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN;
238 HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
240  struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
242 HRESULT WbemQualifierSet_create(const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
243 
244 HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
245 HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
246 HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
247 HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
248 HRESULT service_pause_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
249 HRESULT service_resume_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
250 HRESULT service_start_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
251 HRESULT service_stop_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
252 HRESULT security_get_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
253 HRESULT security_set_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
254 
255 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
256 {
257  return HeapAlloc(GetProcessHeap(), 0, size);
258 }
259 
260 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
261 {
262  return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
263 }
264 
265 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
266 {
267  return HeapReAlloc(GetProcessHeap(), 0, mem, size);
268 }
269 
270 static inline BOOL heap_free(void *mem)
271 {
272  return HeapFree(GetProcessHeap(), 0, mem);
273 }
274 
275 static inline WCHAR *heap_strdupW( const WCHAR *src )
276 {
277  WCHAR *dst;
278  if (!src) return NULL;
279  if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
280  return dst;
281 }
282 
283 static const WCHAR class_processW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
284 static const WCHAR class_serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
285 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
286 static const WCHAR class_systemsecurityW[] = {'_','_','S','y','s','t','e','m','S','e','c','u','r','i','t','y',0};
287 
288 static const WCHAR prop_nameW[] = {'N','a','m','e',0};
289 
290 static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0};
291 static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0};
292 static const WCHAR method_getownerW[] = {'G','e','t','O','w','n','e','r',0};
293 static const WCHAR method_getsdW[] = {'G','e','t','S','D',0};
294 static const WCHAR method_getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
295 static const WCHAR method_pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
296 static const WCHAR method_resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
297 static const WCHAR method_setsdW[] = {'S','e','t','S','D',0};
298 static const WCHAR method_startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
299 static const WCHAR method_stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
300 
301 static const WCHAR param_defkeyW[] = {'h','D','e','f','K','e','y',0};
302 static const WCHAR param_domainW[] = {'D','o','m','a','i','n',0};
303 static const WCHAR param_namesW[] = {'s','N','a','m','e','s',0};
304 static const WCHAR param_returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
305 static const WCHAR param_sdW[] = {'S','D',0};
306 static const WCHAR param_subkeynameW[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
307 static const WCHAR param_typesW[] = {'T','y','p','e','s',0};
308 static const WCHAR param_userW[] = {'U','s','e','r',0};
309 static const WCHAR param_valueW[] = {'s','V','a','l','u','e',0};
310 static const WCHAR param_valuenameW[] = {'s','V','a','l','u','e','N','a','m','e',0};
311 
312 #endif /* _WBEMPROX_PRIVATE_H_ */
HRESULT set_value(const struct table *, UINT, UINT, LONGLONG, CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:199
UINT num_cols
struct query * addref_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:450
BSTR get_value_bstr(const struct table *, UINT, UINT) DECLSPEC_HIDDEN
Definition: table.c:139
void destroy_array(struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: class.c:224
HRESULT( class_method)(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
BOOL is_selected_prop(const struct view *, const WCHAR *) DECLSPEC_HIDDEN
Definition: query.c:479
static const WCHAR method_getsdW[]
const WCHAR * name
HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:317
HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: process.c:54
void release_query(struct query *query) DECLSPEC_HIDDEN
Definition: query.c:456
void set_variant(VARTYPE, LONGLONG, void *, VARIANT *) DECLSPEC_HIDDEN
Definition: query.c:766
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT execute_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:395
void release_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:333
UINT num_rows
static const WCHAR method_enumvaluesW[]
static const WCHAR class_systemsecurityW[]
HRESULT put_propval(const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:1011
HRESULT get_object(const WCHAR *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: services.c:403
VARTYPE vartype
static const WCHAR method_pauseserviceW[]
const struct column * columns
static void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
HRESULT to_longlong(VARIANT *, LONGLONG *, CIMTYPE *) DECLSPEC_HIDDEN
Definition: query.c:961
static const WCHAR method_resumeserviceW[]
struct table * addref_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:338
static BOOL heap_free(void *mem)
void free_columns(struct column *, UINT) DECLSPEC_HIDDEN
Definition: table.c:309
HRESULT get_column_index(const struct table *, const WCHAR *, UINT *) DECLSPEC_HIDDEN
Definition: table.c:23
SAFEARRAY * to_safearray(const struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:734
struct field * fields
const WCHAR * sval
expr_type
void destroy_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:38
OLECHAR * BSTR
Definition: compat.h:1927
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN
Definition: wbemlocator.c:201
IClientSecurity client_security DECLSPEC_HIDDEN
Definition: query.h:74
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:66
static const WCHAR param_subkeynameW[]
struct array * aval
UINT count
static void * heap_alloc(size_t len)
Definition: appwiz.h:61
const struct expr * cond
static const WCHAR method_enumkeyW[]
HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: services.c:868
WCHAR * sval
HRESULT get_value(const struct table *, UINT, UINT, LONGLONG *) DECLSPEC_HIDDEN
Definition: table.c:84
HRESULT get_method(const struct table *, const WCHAR *, class_method **) DECLSPEC_HIDDEN
Definition: table.c:248
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
struct table * table
HRESULT security_get_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:122
static const WCHAR param_typesW[]
const WCHAR * name
int type
Definition: query.h:76
long LONG
Definition: pedump.c:60
const struct property * next
struct list entry
static const WCHAR param_namesW[]
HRESULT service_stop_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:226
HRESULT parse_query(const WCHAR *, struct view **, struct list *) DECLSPEC_HIDDEN
Definition: wql.tab.c:2040
UINT * result
HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:234
smooth NULL
Definition: ftsmooth.c:557
BSTR get_method_name(const WCHAR *, UINT) DECLSPEC_HIDDEN
Definition: table.c:396
static const WCHAR class_stdregprovW[]
static const WCHAR method_setsdW[]
struct table * table
HRESULT create_signature(const WCHAR *, const WCHAR *, enum param_direction, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: class.c:802
void free_row_values(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: table.c:271
#define inline
Definition: compiler.h:135
HRESULT security_set_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:177
HRESULT exec_query(const WCHAR *, IEnumWbemClassObject **) DECLSPEC_HIDDEN
Definition: query.c:461
const struct property * proplist
int64_t LONGLONG
Definition: typedefs.h:66
#define const
Definition: zconf.h:230
static const WCHAR prop_nameW[]
union expr::@466 u
static const WCHAR param_valuenameW[]
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HRESULT service_start_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:181
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
UINT num_rows_allocated
struct expr * right
Definition: query.h:56
HRESULT service_pause_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:67
UINT get_type_size(CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:37
static const WCHAR class_serviceW[]
HRESULT get_propval(const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG *) DECLSPEC_HIDDEN
Definition: query.c:809
static const WCHAR method_startserviceW[]
void free_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:440
HRESULT eval_cond(const struct table *, UINT, const struct expr *, LONGLONG *, UINT *) DECLSPEC_HIDDEN
Definition: query.c:354
void free_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:317
struct table * create_table(const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *, enum fill_status(*)(struct table *, const struct expr *)) DECLSPEC_HIDDEN
enum fill_status(* fill)(struct table *, const struct expr *cond)
HRESULT create_view(const struct property *, const WCHAR *, const struct expr *, struct view **) DECLSPEC_HIDDEN
Definition: query.c:23
VARTYPE vartype
HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:124
HRESULT get_properties(const struct view *, LONG, SAFEARRAY **) DECLSPEC_HIDDEN
Definition: query.c:1032
UINT op
Definition: query.h:54
static WCHAR * heap_strdupW(const WCHAR *src)
static const WCHAR method_getownerW[]
HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT, struct record *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: class.c:1001
static const WCHAR method_getstringvalueW[]
static const WCHAR param_userW[]
static const WCHAR param_defkeyW[]
Definition: _list.h:228
long CIMTYPE
Definition: wbemcli.idl:258
HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN
Definition: class.c:182
BOOL add_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:379
param_direction
static const WCHAR class_processW[]
unsigned char BYTE
Definition: ntddk_ex.h:96
static const WCHAR method_stopserviceW[]
static const WCHAR param_domainW[]
void clear_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:293
static const WCHAR param_sdW[]
fill_status
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
void * ptr
const WCHAR * name
BYTE * data
struct table * grab_table(const WCHAR *) DECLSPEC_HIDDEN
Definition: table.c:344
HRESULT WbemQualifierSet_create(const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: qualifier.c:237
GLsizeiptr size
Definition: glext.h:5919
#define HeapReAlloc
Definition: compat.h:393
unsigned short VARTYPE
Definition: compat.h:1888
WINE_DEFAULT_DEBUG_CHANNEL(wbemprox)
struct view * view
const struct property * propval
unsigned int UINT
Definition: ndis.h:50
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
static const WCHAR param_valueW[]
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
union field::@538 u
HRESULT service_resume_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:112
void init_table_list(void) DECLSPEC_HIDDEN
Definition: builtin.c:3329
Definition: mem.c:156
static const WCHAR param_returnvalueW[]
#define HRESULT
Definition: msvc.h:21
VARTYPE to_vartype(CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:712
LONGLONG ival
struct query * create_query(void) DECLSPEC_HIDDEN
Definition: query.c:430
BOOL is_method(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: query.c:618
#define HeapFree(x, y, z)
Definition: compat.h:394
struct expr * left
Definition: query.h:55