ReactOS  0.4.14-dev-593-g1793dcc
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 #pragma once
20 
21 #include "wine/debug.h"
22 #include "wine/heap.h"
23 #include "wine/list.h"
24 #ifdef __REACTOS__
25 #include <winnls.h>
26 #endif
27 
29 struct list *table_list DECLSPEC_HIDDEN;
30 
32 {
33  PARAM_OUT = -1,
36 };
37 
38 #define CIM_TYPE_MASK 0x00000fff
39 
40 #define COL_TYPE_MASK 0x0000ffff
41 #define COL_FLAG_DYNAMIC 0x00010000
42 #define COL_FLAG_KEY 0x00020000
43 #define COL_FLAG_METHOD 0x00040000
44 
46 
47 enum operator
48 {
49  OP_EQ = 1,
50  OP_AND = 2,
51  OP_OR = 3,
52  OP_GT = 4,
53  OP_LT = 5,
54  OP_LE = 6,
55  OP_GE = 7,
56  OP_NE = 8,
57  OP_ISNULL = 9,
58  OP_NOTNULL = 10,
59  OP_LIKE = 11,
60  OP_NOT = 12
61 };
62 
63 struct expr;
64 struct complex_expr
65 {
66  enum operator op;
67  struct expr *left;
68  struct expr *right;
69 };
70 
72 {
76  EXPR_SVAL = 4,
77  EXPR_IVAL = 5,
79 };
80 
81 struct expr
82 {
84  union
85  {
86  struct complex_expr expr;
87  const struct property *propval;
88  const WCHAR *sval;
89  int ival;
90  } u;
91 };
92 
93 struct column
94 {
95  const WCHAR *name;
97 };
98 
100 {
104 };
105 
106 #define TABLE_FLAG_DYNAMIC 0x00000001
107 
108 struct table
109 {
110  const WCHAR *name;
112  const struct column *columns;
116  enum fill_status (*fill)(struct table *, const struct expr *cond);
118  struct list entry;
120 };
121 
122 struct property
123 {
124  const WCHAR *name;
125  const WCHAR *class;
126  const struct property *next;
127 };
128 
129 struct array
130 {
133  void *ptr;
134 };
135 
136 struct field
137 {
139  union
140  {
143  struct array *aval;
144  } u;
145 };
146 
147 struct record
148 {
150  struct field *fields;
151  struct table *table;
152 };
153 
154 struct keyword
155 {
156  const WCHAR *name;
157  const WCHAR *value;
158  const struct keyword *next;
159 };
160 
162 {
165 };
166 
167 struct view
168 {
170  const WCHAR *path; /* ASSOCIATORS OF query */
171  const struct keyword *keywordlist;
172  const struct property *proplist; /* SELECT query */
173  const struct expr *cond;
175  struct table **table;
178 };
179 
180 struct query
181 {
183  struct view *view;
184  struct list mem;
185 };
186 
187 struct path
188 {
189  WCHAR *class;
193 };
194 
195 HRESULT parse_path( const WCHAR *, struct path ** ) DECLSPEC_HIDDEN;
196 void free_path( struct path * ) DECLSPEC_HIDDEN;
197 WCHAR *query_from_path( const struct path * ) DECLSPEC_HIDDEN;
198 
199 struct query *create_query(void) DECLSPEC_HIDDEN;
200 void free_query( struct query * ) DECLSPEC_HIDDEN;
201 struct query *addref_query( struct query * ) DECLSPEC_HIDDEN;
202 void release_query( struct query *query ) DECLSPEC_HIDDEN;
204 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
205 HRESULT create_view( enum view_type, const WCHAR *, const struct keyword *, const WCHAR *, const struct property *,
206  const struct expr *, struct view ** ) DECLSPEC_HIDDEN;
207 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
209 struct table *get_view_table( const struct view *, UINT ) DECLSPEC_HIDDEN;
210 void init_table_list( void ) DECLSPEC_HIDDEN;
211 struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
212 struct table *addref_table( struct table * ) DECLSPEC_HIDDEN;
213 void release_table( struct table * ) DECLSPEC_HIDDEN;
214 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *,
215  enum fill_status (*)(struct table *, const struct expr *) ) DECLSPEC_HIDDEN;
216 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
217 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
218 void free_row_values( const struct table *, UINT ) DECLSPEC_HIDDEN;
219 void clear_table( struct table * ) DECLSPEC_HIDDEN;
220 void free_table( struct table * ) DECLSPEC_HIDDEN;
222 HRESULT eval_cond( const struct table *, UINT, const struct expr *, LONGLONG *, UINT * ) DECLSPEC_HIDDEN;
223 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
224 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
225 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
227 BOOL is_method( const struct table *, UINT ) DECLSPEC_HIDDEN;
228 HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
229 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
230 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
234 void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
235 BOOL is_result_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN;
240 HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
242 
249 
261 
262 static inline WCHAR *heap_strdupW( const WCHAR *src )
263 {
264  WCHAR *dst;
265  if (!src) return NULL;
266  if ((dst = heap_alloc( (lstrlenW( src ) + 1) * sizeof(WCHAR) ))) lstrcpyW( dst, src );
267  return dst;
268 }
269 
270 static inline WCHAR *heap_strdupAW( const char *src )
271 {
272  int len;
273  WCHAR *dst;
274  if (!src) return NULL;
275  len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
276  if ((dst = heap_alloc( len * sizeof(*dst) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
277  return dst;
278 }
279 
280 static const WCHAR class_processW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
281 static const WCHAR class_serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
282 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
283 static const WCHAR class_systemsecurityW[] = {'_','_','S','y','s','t','e','m','S','e','c','u','r','i','t','y',0};
284 
285 static const WCHAR prop_nameW[] = {'N','a','m','e',0};
286 
287 static const WCHAR method_createkeyW[] = {'C','r','e','a','t','e','K','e','y',0};
288 static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0};
289 static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0};
290 static const WCHAR method_getownerW[] = {'G','e','t','O','w','n','e','r',0};
291 static const WCHAR method_getsdW[] = {'G','e','t','S','D',0};
292 static const WCHAR method_getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
293 static const WCHAR method_pauseserviceW[] = {'P','a','u','s','e','S','e','r','v','i','c','e',0};
294 static const WCHAR method_resumeserviceW[] = {'R','e','s','u','m','e','S','e','r','v','i','c','e',0};
295 static const WCHAR method_setsdW[] = {'S','e','t','S','D',0};
296 static const WCHAR method_startserviceW[] = {'S','t','a','r','t','S','e','r','v','i','c','e',0};
297 static const WCHAR method_stopserviceW[] = {'S','t','o','p','S','e','r','v','i','c','e',0};
298 
299 static const WCHAR param_defkeyW[] = {'h','D','e','f','K','e','y',0};
300 static const WCHAR param_domainW[] = {'D','o','m','a','i','n',0};
301 static const WCHAR param_namesW[] = {'s','N','a','m','e','s',0};
302 static const WCHAR param_returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
303 static const WCHAR param_sdW[] = {'S','D',0};
304 static const WCHAR param_subkeynameW[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
305 static const WCHAR param_typesW[] = {'T','y','p','e','s',0};
306 static const WCHAR param_userW[] = {'U','s','e','r',0};
307 static const WCHAR param_valueW[] = {'s','V','a','l','u','e',0};
308 static const WCHAR param_valuenameW[] = {'s','V','a','l','u','e','N','a','m','e',0};
void free_path(struct path *) DECLSPEC_HIDDEN
Definition: services.c:413
HRESULT set_value(const struct table *, UINT, UINT, LONGLONG, CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:219
UINT num_cols
#define HRESULT
Definition: msvc.h:7
WCHAR * filter
struct query * addref_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:775
const WCHAR * value
BSTR get_value_bstr(const struct table *, UINT, UINT) DECLSPEC_HIDDEN
Definition: table.c:158
void destroy_array(struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: class.c:240
static const WCHAR method_getsdW[]
const WCHAR * name
HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:391
HRESULT process_get_owner(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: process.c:65
void release_query(struct query *query) DECLSPEC_HIDDEN
Definition: query.c:781
void set_variant(VARTYPE, LONGLONG, void *, VARIANT *) DECLSPEC_HIDDEN
Definition: query.c:1093
HRESULT execute_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:739
#define CP_ACP
Definition: compat.h:99
void release_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:354
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:1375
HRESULT get_object(const WCHAR *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: services.c:458
static const WCHAR method_pauseserviceW[]
const struct column * columns
HRESULT to_longlong(VARIANT *, LONGLONG *, CIMTYPE *) DECLSPEC_HIDDEN
Definition: query.c:1325
static const WCHAR method_resumeserviceW[]
struct table * addref_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:359
void free_columns(struct column *, UINT) DECLSPEC_HIDDEN
Definition: table.c:330
HRESULT get_column_index(const struct table *, const WCHAR *, UINT *) DECLSPEC_HIDDEN
Definition: table.c:35
SAFEARRAY * to_safearray(const struct array *, CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:1062
struct field * fields
const WCHAR * sval
expr_type
void destroy_view(struct view *) DECLSPEC_HIDDEN
Definition: query.c:83
view_type
OLECHAR * BSTR
Definition: compat.h:1942
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN
Definition: wbemlocator.c:212
IClientSecurity client_security DECLSPEC_HIDDEN
#define lstrlenW
Definition: compat.h:415
Definition: query.h:86
static const WCHAR param_subkeynameW[]
struct array * aval
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
const struct expr * cond
static const WCHAR method_enumkeyW[]
UINT result_count
HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: services.c:925
enum fill_status(* fill)(struct table *, const struct expr *cond)
WCHAR * sval
const struct keyword * keywordlist
UINT class_len
HRESULT get_value(const struct table *, UINT, UINT, LONGLONG *) DECLSPEC_HIDDEN
Definition: table.c:99
union field::@573 u
HRESULT get_method(const struct table *, const WCHAR *, class_method **) DECLSPEC_HIDDEN
Definition: table.c:269
struct table * table
HRESULT security_get_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:132
static const WCHAR param_typesW[]
const WCHAR * name
unsigned int BOOL
Definition: ntddk_ex.h:94
int type
Definition: query.h:88
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:238
HRESULT parse_query(const WCHAR *, struct view **, struct list *) DECLSPEC_HIDDEN
Definition: wql.tab.c:2227
UINT * result
HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:308
smooth NULL
Definition: ftsmooth.c:416
WCHAR * query_from_path(const struct path *) DECLSPEC_HIDDEN
Definition: services.c:421
BSTR get_method_name(const WCHAR *, UINT) DECLSPEC_HIDDEN
Definition: table.c:417
static const WCHAR class_stdregprovW[]
static const WCHAR method_setsdW[]
union expr::@490 u
HRESULT create_signature(const WCHAR *, const WCHAR *, enum param_direction, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: class.c:819
static WCHAR * heap_strdupAW(const char *src)
void free_row_values(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: table.c:292
HRESULT security_set_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: security.c:187
HRESULT exec_query(const WCHAR *, IEnumWbemClassObject **) DECLSPEC_HIDDEN
Definition: query.c:786
const struct property * proplist
int64_t LONGLONG
Definition: typedefs.h:66
const struct keyword * next
static const WCHAR prop_nameW[]
static const WCHAR param_valuenameW[]
UINT filter_len
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT service_start_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:193
Definition: parser.c:43
LONG HRESULT
Definition: typedefs.h:77
UINT num_rows_allocated
struct expr * right
Definition: query.h:68
HRESULT service_pause_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:79
UINT get_type_size(CIMTYPE) DECLSPEC_HIDDEN
Definition: table.c:49
static const WCHAR class_serviceW[]
HRESULT get_propval(const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG *) DECLSPEC_HIDDEN
Definition: query.c:1177
static const WCHAR method_startserviceW[]
void free_query(struct query *) DECLSPEC_HIDDEN
Definition: query.c:765
HRESULT eval_cond(const struct table *, UINT, const struct expr *, LONGLONG *, UINT *) DECLSPEC_HIDDEN
Definition: query.c:440
void free_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:338
struct table * create_table(const WCHAR *, UINT, const struct column *, UINT, UINT, BYTE *, enum fill_status(*)(struct table *, const struct expr *)) DECLSPEC_HIDDEN
HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:198
UINT elem_size
UINT op
Definition: query.h:66
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:1021
static const WCHAR method_getstringvalueW[]
static const WCHAR param_userW[]
static const WCHAR param_defkeyW[]
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
Definition: _list.h:228
long CIMTYPE
Definition: wbemcli.idl:258
HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN
Definition: class.c:199
GLenum src
Definition: glext.h:6340
BOOL add_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:400
param_direction
const WCHAR * name
static const WCHAR class_processW[]
struct table ** table
HRESULT() class_method(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **)
static const WCHAR method_stopserviceW[]
static const WCHAR param_domainW[]
void clear_table(struct table *) DECLSPEC_HIDDEN
Definition: table.c:314
static const WCHAR param_sdW[]
fill_status
UINT table_count
void * ptr
#define lstrcpyW
Definition: compat.h:414
const WCHAR * name
BYTE * data
struct table * grab_table(const WCHAR *) DECLSPEC_HIDDEN
Definition: table.c:365
HRESULT WbemQualifierSet_create(const WCHAR *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN
Definition: qualifier.c:293
GLenum GLenum dst
Definition: glext.h:6340
unsigned short VARTYPE
Definition: compat.h:1903
struct view * view
const struct property * propval
unsigned int UINT
Definition: ndis.h:50
static const WCHAR param_valueW[]
#define MultiByteToWideChar
Definition: compat.h:100
enum view_type type
HRESULT service_resume_service(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: service.c:124
void init_table_list(void) DECLSPEC_HIDDEN
Definition: builtin.c:4591
static const WCHAR method_createkeyW[]
HRESULT parse_path(const WCHAR *, struct path **) DECLSPEC_HIDDEN
Definition: services.c:326
Definition: mem.c:156
struct table * get_view_table(const struct view *, UINT) DECLSPEC_HIDDEN
Definition: query.c:1161
static const WCHAR param_returnvalueW[]
HRESULT reg_create_key(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN
Definition: reg.c:99
HRESULT create_view(enum view_type, const WCHAR *, const struct keyword *, const WCHAR *, const struct property *, const struct expr *, struct view **) DECLSPEC_HIDDEN
Definition: query.c:44
BOOL is_result_prop(const struct view *, const WCHAR *) DECLSPEC_HIDDEN
Definition: query.c:804
VARTYPE to_vartype(CIMTYPE) DECLSPEC_HIDDEN
Definition: query.c:1032
LONGLONG ival
struct query * create_query(void) DECLSPEC_HIDDEN
Definition: query.c:755
BOOL is_method(const struct table *, UINT) DECLSPEC_HIDDEN
Definition: query.c:917
const WCHAR * path
HRESULT get_properties(const struct view *, UINT, LONG, SAFEARRAY **) DECLSPEC_HIDDEN
Definition: query.c:1401
struct expr * left
Definition: query.h:67