2 * Copyright 2009 Hans Leidekker for CodeWeavers
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.
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.
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
19 #include "wine/list.h"
20 #include "wine/unicode.h"
22 IClientSecurity client_security;
23 struct list *table_list;
25 #define SIZEOF(array) (sizeof(array)/sizeof((array)[0]))
34 #define CIM_TYPE_MASK 0x00000fff
36 #define COL_TYPE_MASK 0x0000ffff
37 #define COL_FLAG_DYNAMIC 0x00010000
38 #define COL_FLAG_KEY 0x00020000
39 #define COL_FLAG_METHOD 0x00040000
41 typedef HRESULT (class_method)(IWbemClassObject *, IWbemClassObject **);
47 VARTYPE vartype; /* 0 for default mapping */
50 #define TABLE_FLAG_DYNAMIC 0x00000001
56 const struct column *columns;
59 void (*fill)(struct table *);
69 const struct property *next;
81 VARTYPE vartype; /* 0 for default mapping */
134 struct complex_expr expr;
135 const struct property *propval;
143 const struct property *proplist;
145 const struct expr *cond;
157 void addref_query( struct query * ) DECLSPEC_HIDDEN;
158 void release_query( struct query *query ) DECLSPEC_HIDDEN;
159 HRESULT exec_query( const WCHAR *, IEnumWbemClassObject ** ) DECLSPEC_HIDDEN;
160 HRESULT parse_query( const WCHAR *, struct view **, struct list * ) DECLSPEC_HIDDEN;
161 HRESULT create_view( const struct property *, const WCHAR *, const struct expr *,
162 struct view ** ) DECLSPEC_HIDDEN;
163 void destroy_view( struct view * ) DECLSPEC_HIDDEN;
164 void init_table_list( void ) DECLSPEC_HIDDEN;
165 struct table *grab_table( const WCHAR * ) DECLSPEC_HIDDEN;
166 void release_table( struct table * ) DECLSPEC_HIDDEN;
167 struct table *create_table( const WCHAR *, UINT, const struct column *, UINT,
168 BYTE *, void (*)(struct table *)) DECLSPEC_HIDDEN;
169 BOOL add_table( struct table * ) DECLSPEC_HIDDEN;
170 void free_columns( struct column *, UINT ) DECLSPEC_HIDDEN;
171 void free_table( struct table * ) DECLSPEC_HIDDEN;
172 UINT get_type_size( CIMTYPE ) DECLSPEC_HIDDEN;
173 HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC_HIDDEN;
174 HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN;
175 BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN;
176 HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN;
177 HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN;
178 HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
179 CIMTYPE *, LONG * ) DECLSPEC_HIDDEN;
180 HRESULT put_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE ) DECLSPEC_HIDDEN;
181 HRESULT to_longlong( VARIANT *, LONGLONG *, CIMTYPE * ) DECLSPEC_HIDDEN;
182 SAFEARRAY *to_safearray( const struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
183 VARTYPE to_vartype( CIMTYPE ) DECLSPEC_HIDDEN;
184 void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN;
185 HRESULT get_properties( const struct view *, SAFEARRAY ** ) DECLSPEC_HIDDEN;
186 HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN;
187 BSTR get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
188 BSTR get_property_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN;
189 void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN;
190 HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
191 IWbemClassObject ** ) DECLSPEC_HIDDEN;
193 HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
194 HRESULT WbemServices_create(IUnknown *, const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
195 HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT,
196 struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
197 HRESULT EnumWbemClassObject_create(IUnknown *, struct query *, LPVOID *) DECLSPEC_HIDDEN;
199 HRESULT reg_enum_key(IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
200 HRESULT reg_enum_values(IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
201 HRESULT reg_get_stringvalue(IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN;
203 static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
204 static inline void *heap_alloc( size_t len )
206 return HeapAlloc( GetProcessHeap(), 0, len );
209 static void *heap_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
210 static inline void *heap_realloc( void *mem, size_t len )
212 return HeapReAlloc( GetProcessHeap(), 0, mem, len );
215 static void *heap_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
216 static inline void *heap_alloc_zero( size_t len )
218 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
221 static inline BOOL heap_free( void *mem )
223 return HeapFree( GetProcessHeap(), 0, mem );
226 static inline WCHAR *heap_strdupW( const WCHAR *src )
229 if (!src) return NULL;
230 if ((dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) ))) strcpyW( dst, src );
234 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
236 static const WCHAR method_enumkeyW[] = {'E','n','u','m','K','e','y',0};
237 static const WCHAR method_enumvaluesW[] = {'E','n','u','m','V','a','l','u','e','s',0};
238 static const WCHAR method_getstringvalueW[] = {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
240 static const WCHAR param_defkeyW[] = {'h','D','e','f','K','e','y',0};
241 static const WCHAR param_namesW[] = {'s','N','a','m','e','s',0};
242 static const WCHAR param_returnvalueW[] = {'R','e','t','u','r','n','V','a','l','u','e',0};
243 static const WCHAR param_subkeynameW[] = {'s','S','u','b','K','e','y','N','a','m','e',0};
244 static const WCHAR param_typesW[] = {'T','y','p','e','s',0};
245 static const WCHAR param_valueW[] = {'s','V','a','l','u','e',0};
246 static const WCHAR param_valuenameW[] = {'s','V','a','l','u','e','N','a','m','e',0};