wbemprox: Implement more properties of Win32_OperatingSystem.
[wine.git] / dlls / wbemprox / builtin.c
blob54f44c5de12c5967d74dbb2d04521937687abc00
1 /*
2 * Copyright 2012 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 #define COBJMACROS
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
23 #include "config.h"
24 #include <stdarg.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "initguid.h"
31 #include "wbemcli.h"
32 #include "wbemprov.h"
33 #include "winsock2.h"
34 #include "iphlpapi.h"
35 #include "tlhelp32.h"
36 #include "d3d10.h"
37 #include "winternl.h"
38 #include "winioctl.h"
39 #include "winsvc.h"
40 #include "winver.h"
42 #include "wine/debug.h"
43 #include "wbemprox_private.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
47 static const WCHAR class_baseboardW[] =
48 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
49 static const WCHAR class_biosW[] =
50 {'W','i','n','3','2','_','B','I','O','S',0};
51 static const WCHAR class_cdromdriveW[] =
52 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
53 static const WCHAR class_compsysW[] =
54 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
55 static const WCHAR class_datafileW[] =
56 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
57 static const WCHAR class_directoryW[] =
58 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
59 static const WCHAR class_diskdriveW[] =
60 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
61 static const WCHAR class_diskpartitionW[] =
62 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
63 static const WCHAR class_logicaldiskW[] =
64 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
65 static const WCHAR class_logicaldisk2W[] =
66 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
67 static const WCHAR class_networkadapterW[] =
68 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
69 static const WCHAR class_networkadapterconfigW[] =
70 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
71 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
72 static const WCHAR class_osW[] =
73 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
74 static const WCHAR class_paramsW[] =
75 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
76 static const WCHAR class_physicalmediaW[] =
77 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
78 static const WCHAR class_physicalmemoryW[] =
79 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
80 static const WCHAR class_qualifiersW[] =
81 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
82 static const WCHAR class_process_getowner_outW[] =
83 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
84 'N','E','R','_','O','U','T',0};
85 static const WCHAR class_processorW[] =
86 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
87 static const WCHAR class_sounddeviceW[] =
88 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
89 static const WCHAR class_videocontrollerW[] =
90 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
92 static const WCHAR prop_acceptpauseW[] =
93 {'A','c','c','e','p','t','P','a','u','s','e',0};
94 static const WCHAR prop_acceptstopW[] =
95 {'A','c','c','e','p','t','S','t','o','p',0};
96 static const WCHAR prop_accessmaskW[] =
97 {'A','c','c','e','s','s','M','a','s','k',0};
98 static const WCHAR prop_adapterdactypeW[] =
99 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
100 static const WCHAR prop_adapterramW[] =
101 {'A','d','a','p','t','e','r','R','A','M',0};
102 static const WCHAR prop_adaptertypeW[] =
103 {'A','d','a','p','t','e','r','T','y','p','e',0};
104 static const WCHAR prop_addresswidthW[] =
105 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
106 static const WCHAR prop_bootableW[] =
107 {'B','o','o','t','a','b','l','e',0};
108 static const WCHAR prop_bootpartitionW[] =
109 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
110 static const WCHAR prop_buildnumberW[] =
111 {'B','u','i','l','d','N','u','m','b','e','r',0};
112 static const WCHAR prop_capacityW[] =
113 {'C','a','p','a','c','i','t','y',0};
114 static const WCHAR prop_captionW[] =
115 {'C','a','p','t','i','o','n',0};
116 static const WCHAR prop_classW[] =
117 {'C','l','a','s','s',0};
118 static const WCHAR prop_codesetW[] =
119 {'C','o','d','e','S','e','t',0};
120 static const WCHAR prop_commandlineW[] =
121 {'C','o','m','m','a','n','d','L','i','n','e',0};
122 static const WCHAR prop_countrycodeW[] =
123 {'C','o','u','n','t','r','y','C','o','d','e',0};
124 static const WCHAR prop_cpustatusW[] =
125 {'C','p','u','S','t','a','t','u','s',0};
126 static const WCHAR prop_csdversionW[] =
127 {'C','S','D','V','e','r','s','i','o','n',0};
128 static const WCHAR prop_currentbitsperpixelW[] =
129 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
130 static const WCHAR prop_currenthorizontalresW[] =
131 {'C','u','r','r','e','n','t','H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
132 static const WCHAR prop_currentverticalresW[] =
133 {'C','u','r','r','e','n','t','V','e','r','t','i','c','a','l','R','e','s','o','l','u','t','i','o','n',0};
134 static const WCHAR prop_defaultvalueW[] =
135 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
136 static const WCHAR prop_descriptionW[] =
137 {'D','e','s','c','r','i','p','t','i','o','n',0};
138 static const WCHAR prop_deviceidW[] =
139 {'D','e','v','i','c','e','I','d',0};
140 static const WCHAR prop_directionW[] =
141 {'D','i','r','e','c','t','i','o','n',0};
142 static const WCHAR prop_displaynameW[] =
143 {'D','i','s','p','l','a','y','N','a','m','e',0};
144 static const WCHAR prop_diskindexW[] =
145 {'D','i','s','k','I','n','d','e','x',0};
146 static const WCHAR prop_domainW[] =
147 {'D','o','m','a','i','n',0};
148 static const WCHAR prop_domainroleW[] =
149 {'D','o','m','a','i','n','R','o','l','e',0};
150 static const WCHAR prop_driveW[] =
151 {'D','r','i','v','e',0};
152 static const WCHAR prop_drivetypeW[] =
153 {'D','r','i','v','e','T','y','p','e',0};
154 static const WCHAR prop_familyW[] =
155 {'F','a','m','i','l','y',0};
156 static const WCHAR prop_filesystemW[] =
157 {'F','i','l','e','S','y','s','t','e','m',0};
158 static const WCHAR prop_flavorW[] =
159 {'F','l','a','v','o','r',0};
160 static const WCHAR prop_freespaceW[] =
161 {'F','r','e','e','S','p','a','c','e',0};
162 static const WCHAR prop_handleW[] =
163 {'H','a','n','d','l','e',0};
164 static const WCHAR prop_idW[] =
165 {'I','D',0};
166 static const WCHAR prop_identificationcodeW[] =
167 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
168 static const WCHAR prop_indexW[] =
169 {'I','n','d','e','x',0};
170 static const WCHAR prop_installdateW[] =
171 {'I','n','s','t','a','l','l','D','a','t','e',0};
172 static const WCHAR prop_interfaceindexW[] =
173 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
174 static const WCHAR prop_intvalueW[] =
175 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
176 static const WCHAR prop_ipconnectionmetricW[] =
177 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
178 static const WCHAR prop_ipenabledW[] =
179 {'I','P','E','n','a','b','l','e','d',0};
180 static const WCHAR prop_lastbootuptimeW[] =
181 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
182 static const WCHAR prop_localdatetimeW[] =
183 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
184 static const WCHAR prop_localeW[] =
185 {'L','o','c','a','l','e',0};
186 static const WCHAR prop_macaddressW[] =
187 {'M','A','C','A','d','d','r','e','s','s',0};
188 static const WCHAR prop_manufacturerW[] =
189 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
190 static const WCHAR prop_maxclockspeedW[] =
191 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
192 static const WCHAR prop_mediatypeW[] =
193 {'M','e','d','i','a','T','y','p','e',0};
194 static const WCHAR prop_memberW[] =
195 {'M','e','m','b','e','r',0};
196 static const WCHAR prop_methodW[] =
197 {'M','e','t','h','o','d',0};
198 static const WCHAR prop_modelW[] =
199 {'M','o','d','e','l',0};
200 static const WCHAR prop_netconnectionstatusW[] =
201 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
202 static const WCHAR prop_numcoresW[] =
203 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
204 static const WCHAR prop_numlogicalprocessorsW[] =
205 {'N','u','m','b','e','r','O','f','L','o','g','i','c','a','l','P','r','o','c','e','s','s','o','r','s',0};
206 static const WCHAR prop_numprocessorsW[] =
207 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
208 static const WCHAR prop_osarchitectureW[] =
209 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
210 static const WCHAR prop_oslanguageW[] =
211 {'O','S','L','a','n','g','u','a','g','e',0};
212 static const WCHAR prop_osproductsuiteW[] =
213 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
214 static const WCHAR prop_ostypeW[] =
215 {'O','S','T','y','p','e',0};
216 static const WCHAR prop_parameterW[] =
217 {'P','a','r','a','m','e','t','e','r',0};
218 static const WCHAR prop_physicaladapterW[] =
219 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
220 static const WCHAR prop_pnpdeviceidW[] =
221 {'P','N','P','D','e','v','i','c','e','I','D',0};
222 static const WCHAR prop_pprocessidW[] =
223 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
224 static const WCHAR prop_processidW[] =
225 {'P','r','o','c','e','s','s','I','D',0};
226 static const WCHAR prop_processoridW[] =
227 {'P','r','o','c','e','s','s','o','r','I','d',0};
228 static const WCHAR prop_productnameW[] =
229 {'P','r','o','d','u','c','t','N','a','m','e',0};
230 static const WCHAR prop_releasedateW[] =
231 {'R','e','l','e','a','s','e','D','a','t','e',0};
232 static const WCHAR prop_serialnumberW[] =
233 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
234 static const WCHAR prop_servicepackmajorW[] =
235 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
236 static const WCHAR prop_servicepackminorW[] =
237 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
238 static const WCHAR prop_servicetypeW[] =
239 {'S','e','r','v','i','c','e','T','y','p','e',0};
240 static const WCHAR prop_smbiosbiosversionW[] =
241 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
242 static const WCHAR prop_startmodeW[] =
243 {'S','t','a','r','t','M','o','d','e',0};
244 static const WCHAR prop_sizeW[] =
245 {'S','i','z','e',0};
246 static const WCHAR prop_speedW[] =
247 {'S','p','e','e','d',0};
248 static const WCHAR prop_startingoffsetW[] =
249 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
250 static const WCHAR prop_stateW[] =
251 {'S','t','a','t','e',0};
252 static const WCHAR prop_strvalueW[] =
253 {'S','t','r','i','n','g','V','a','l','u','e',0};
254 static const WCHAR prop_suitemaskW[] =
255 {'S','u','i','t','e','M','a','s','k',0};
256 static const WCHAR prop_systemdirectoryW[] =
257 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
258 static const WCHAR prop_systemnameW[] =
259 {'S','y','s','t','e','m','N','a','m','e',0};
260 static const WCHAR prop_tagW[] =
261 {'T','a','g',0};
262 static const WCHAR prop_threadcountW[] =
263 {'T','h','r','e','a','d','C','o','u','n','t',0};
264 static const WCHAR prop_totalphysicalmemoryW[] =
265 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
266 static const WCHAR prop_typeW[] =
267 {'T','y','p','e',0};
268 static const WCHAR prop_uniqueidW[] =
269 {'U','n','i','q','u','e','I','d',0};
270 static const WCHAR prop_varianttypeW[] =
271 {'V','a','r','i','a','n','t','T','y','p','e',0};
272 static const WCHAR prop_versionW[] =
273 {'V','e','r','s','i','o','n',0};
274 static const WCHAR prop_volumeserialnumberW[] =
275 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
277 /* column definitions must be kept in sync with record structures below */
278 static const struct column col_baseboard[] =
280 { prop_manufacturerW, CIM_STRING },
281 { prop_modelW, CIM_STRING },
282 { prop_nameW, CIM_STRING },
283 { prop_serialnumberW, CIM_STRING },
284 { prop_tagW, CIM_STRING|COL_FLAG_KEY }
286 static const struct column col_bios[] =
288 { prop_descriptionW, CIM_STRING },
289 { prop_identificationcodeW, CIM_STRING },
290 { prop_manufacturerW, CIM_STRING },
291 { prop_releasedateW, CIM_DATETIME },
292 { prop_serialnumberW, CIM_STRING },
293 { prop_smbiosbiosversionW, CIM_STRING },
294 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
296 static const struct column col_cdromdrive[] =
298 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
299 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
300 { prop_nameW, CIM_STRING },
301 { prop_pnpdeviceidW, CIM_STRING }
303 static const struct column col_compsys[] =
305 { prop_descriptionW, CIM_STRING },
306 { prop_domainW, CIM_STRING },
307 { prop_domainroleW, CIM_UINT16 },
308 { prop_manufacturerW, CIM_STRING },
309 { prop_modelW, CIM_STRING },
310 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
311 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
312 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
313 { prop_totalphysicalmemoryW, CIM_UINT64 }
315 static const struct column col_datafile[] =
317 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
318 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
320 static const struct column col_directory[] =
322 { prop_accessmaskW, CIM_UINT32 },
323 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
325 static const struct column col_diskdrive[] =
327 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
328 { prop_indexW, CIM_UINT32, VT_I4 },
329 { prop_manufacturerW, CIM_STRING },
330 { prop_mediatypeW, CIM_STRING },
331 { prop_modelW, CIM_STRING },
332 { prop_serialnumberW, CIM_STRING }
334 static const struct column col_diskpartition[] =
336 { prop_bootableW, CIM_BOOLEAN },
337 { prop_bootpartitionW, CIM_BOOLEAN },
338 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
339 { prop_diskindexW, CIM_UINT32, VT_I4 },
340 { prop_indexW, CIM_UINT32, VT_I4 },
341 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
342 { prop_sizeW, CIM_UINT64 },
343 { prop_startingoffsetW, CIM_UINT64 },
344 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
346 static const struct column col_logicaldisk[] =
348 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
349 { prop_drivetypeW, CIM_UINT32, VT_I4 },
350 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
351 { prop_freespaceW, CIM_UINT64 },
352 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
353 { prop_sizeW, CIM_UINT64 },
354 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
356 static const struct column col_networkadapter[] =
358 { prop_adaptertypeW, CIM_STRING },
359 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
360 { prop_indexW, CIM_UINT32, VT_I4 },
361 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
362 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
363 { prop_manufacturerW, CIM_STRING },
364 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
365 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
366 { prop_physicaladapterW, CIM_BOOLEAN },
367 { prop_pnpdeviceidW, CIM_STRING },
368 { prop_speedW, CIM_UINT64 }
370 static const struct column col_networkadapterconfig[] =
372 { prop_indexW, CIM_UINT32|COL_FLAG_KEY },
373 { prop_ipconnectionmetricW, CIM_UINT32 },
374 { prop_ipenabledW, CIM_BOOLEAN },
375 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }
377 static const struct column col_os[] =
379 { prop_buildnumberW, CIM_STRING },
380 { prop_captionW, CIM_STRING },
381 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
382 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
383 { prop_csdversionW, CIM_STRING },
384 { prop_installdateW, CIM_DATETIME },
385 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
386 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
387 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
388 { prop_nameW, CIM_STRING },
389 { prop_osarchitectureW, CIM_STRING },
390 { prop_oslanguageW, CIM_UINT32, VT_I4 },
391 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
392 { prop_ostypeW, CIM_UINT16, VT_I4 },
393 { prop_serialnumberW, CIM_STRING },
394 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
395 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
396 { prop_suitemaskW, CIM_UINT32, VT_I4 },
397 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
398 { prop_versionW, CIM_STRING }
400 static const struct column col_param[] =
402 { prop_classW, CIM_STRING },
403 { prop_methodW, CIM_STRING },
404 { prop_directionW, CIM_SINT32 },
405 { prop_parameterW, CIM_STRING },
406 { prop_typeW, CIM_UINT32 },
407 { prop_varianttypeW, CIM_UINT32 },
408 { prop_defaultvalueW, CIM_UINT32 }
410 static const struct column col_physicalmedia[] =
412 { prop_serialnumberW, CIM_STRING },
413 { prop_tagW, CIM_STRING }
415 static const struct column col_physicalmemory[] =
417 { prop_capacityW, CIM_UINT64 }
419 static const struct column col_process[] =
421 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
422 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
423 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
424 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
425 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
426 { prop_pprocessidW, CIM_UINT32, VT_I4 },
427 { prop_processidW, CIM_UINT32, VT_I4 },
428 { prop_threadcountW, CIM_UINT32, VT_I4 },
429 /* methods */
430 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
432 static const struct column col_processor[] =
434 { prop_addresswidthW, CIM_UINT16, VT_I4 },
435 { prop_cpustatusW, CIM_UINT16 },
436 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
437 { prop_familyW, CIM_UINT16, VT_I4 },
438 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
439 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
440 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
441 { prop_numcoresW, CIM_UINT32, VT_I4 },
442 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
443 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
444 { prop_uniqueidW, CIM_STRING }
446 static const struct column col_qualifier[] =
448 { prop_classW, CIM_STRING },
449 { prop_memberW, CIM_STRING },
450 { prop_typeW, CIM_UINT32 },
451 { prop_flavorW, CIM_SINT32 },
452 { prop_nameW, CIM_STRING },
453 { prop_intvalueW, CIM_SINT32 },
454 { prop_strvalueW, CIM_STRING }
456 static const struct column col_service[] =
458 { prop_acceptpauseW, CIM_BOOLEAN },
459 { prop_acceptstopW, CIM_BOOLEAN },
460 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
461 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
462 { prop_processidW, CIM_UINT32 },
463 { prop_servicetypeW, CIM_STRING },
464 { prop_startmodeW, CIM_STRING },
465 { prop_stateW, CIM_STRING },
466 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
467 /* methods */
468 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
469 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
470 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
471 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
473 static const struct column col_sounddevice[] =
475 { prop_nameW, CIM_STRING },
476 { prop_productnameW, CIM_STRING }
478 static const struct column col_stdregprov[] =
480 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
481 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
482 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
484 static const struct column col_videocontroller[] =
486 { prop_adapterdactypeW, CIM_STRING },
487 { prop_adapterramW, CIM_UINT32, VT_I4 },
488 { prop_currentbitsperpixelW, CIM_UINT32 },
489 { prop_currenthorizontalresW, CIM_UINT32 },
490 { prop_currentverticalresW, CIM_UINT32 },
491 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
492 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
493 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
494 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC }
497 static const WCHAR baseboard_manufacturerW[] =
498 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
499 static const WCHAR baseboard_serialnumberW[] =
500 {'N','o','n','e',0};
501 static const WCHAR baseboard_tagW[] =
502 {'B','a','s','e',' ','B','o','a','r','d',0};
503 static const WCHAR bios_descriptionW[] =
504 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
505 static const WCHAR bios_manufacturerW[] =
506 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
507 static const WCHAR bios_releasedateW[] =
508 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
509 static const WCHAR bios_serialnumberW[] =
510 {'0',0};
511 static const WCHAR bios_smbiosbiosversionW[] =
512 {'W','i','n','e',0};
513 static const WCHAR bios_versionW[] =
514 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
515 static const WCHAR cdromdrive_nameW[] =
516 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
517 static const WCHAR cdromdrive_pnpdeviceidW[]=
518 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
519 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
520 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
521 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
522 static const WCHAR compsys_descriptionW[] =
523 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
524 static const WCHAR compsys_domainW[] =
525 {'W','O','R','K','G','R','O','U','P',0};
526 static const WCHAR compsys_manufacturerW[] =
527 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
528 static const WCHAR compsys_modelW[] =
529 {'W','i','n','e',0};
530 static const WCHAR diskdrive_deviceidW[] =
531 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
532 static const WCHAR diskdrive_manufacturerW[] =
533 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
534 static const WCHAR diskdrive_mediatypeW[] =
535 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
536 static const WCHAR diskdrive_modelW[] =
537 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
538 static const WCHAR diskdrive_serialW[] =
539 {'W','I','N','E','H','D','I','S','K',0};
540 static const WCHAR networkadapter_pnpdeviceidW[]=
541 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
542 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
543 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
544 static const WCHAR os_32bitW[] =
545 {'3','2','-','b','i','t',0};
546 static const WCHAR os_64bitW[] =
547 {'6','4','-','b','i','t',0};
548 static const WCHAR os_buildnumberW[] =
549 {'2','6','0','0',0};
550 static const WCHAR os_captionW[] =
551 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
552 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
553 static const WCHAR os_csdversionW[] =
554 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
555 static const WCHAR os_installdateW[] =
556 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
557 static const WCHAR os_nameW[] =
558 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
559 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
560 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
561 '\\','P','a','r','t','i','t','i','o','n','1',0};
562 static const WCHAR os_serialnumberW[] =
563 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
564 static const WCHAR os_versionW[] =
565 {'5','.','1','.','2','6','0','0',0};
566 static const WCHAR physicalmedia_tagW[] =
567 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
568 static const WCHAR sounddevice_productnameW[] =
569 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
570 static const WCHAR videocontroller_dactypeW[] =
571 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
572 static const WCHAR videocontroller_deviceidW[] =
573 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
575 #include "pshpack1.h"
576 struct record_baseboard
578 const WCHAR *manufacturer;
579 const WCHAR *model;
580 const WCHAR *name;
581 const WCHAR *serialnumber;
582 const WCHAR *tag;
584 struct record_bios
586 const WCHAR *description;
587 const WCHAR *identificationcode;
588 const WCHAR *manufacturer;
589 const WCHAR *releasedate;
590 const WCHAR *serialnumber;
591 const WCHAR *smbiosbiosversion;
592 const WCHAR *version;
594 struct record_cdromdrive
596 const WCHAR *device_id;
597 const WCHAR *drive;
598 const WCHAR *name;
599 const WCHAR *pnpdevice_id;
601 struct record_computersystem
603 const WCHAR *description;
604 const WCHAR *domain;
605 UINT16 domainrole;
606 const WCHAR *manufacturer;
607 const WCHAR *model;
608 const WCHAR *name;
609 UINT32 num_logical_processors;
610 UINT32 num_processors;
611 UINT64 total_physical_memory;
613 struct record_datafile
615 const WCHAR *name;
616 const WCHAR *version;
618 struct record_directory
620 UINT32 accessmask;
621 const WCHAR *name;
623 struct record_diskdrive
625 const WCHAR *device_id;
626 UINT32 index;
627 const WCHAR *manufacturer;
628 const WCHAR *mediatype;
629 const WCHAR *name;
630 const WCHAR *serialnumber;
632 struct record_diskpartition
634 int bootable;
635 int bootpartition;
636 const WCHAR *device_id;
637 UINT32 diskindex;
638 UINT32 index;
639 const WCHAR *pnpdevice_id;
640 UINT64 size;
641 UINT64 startingoffset;
642 const WCHAR *type;
644 struct record_logicaldisk
646 const WCHAR *device_id;
647 UINT32 drivetype;
648 const WCHAR *filesystem;
649 UINT64 freespace;
650 const WCHAR *name;
651 UINT64 size;
652 const WCHAR *volumeserialnumber;
654 struct record_networkadapter
656 const WCHAR *adaptertype;
657 const WCHAR *device_id;
658 UINT32 index;
659 UINT32 interface_index;
660 const WCHAR *mac_address;
661 const WCHAR *manufacturer;
662 const WCHAR *name;
663 UINT16 netconnection_status;
664 int physicaladapter;
665 const WCHAR *pnpdevice_id;
666 UINT64 speed;
668 struct record_networkadapterconfig
670 UINT32 index;
671 UINT32 ipconnectionmetric;
672 int ipenabled;
673 const WCHAR *mac_address;
675 struct record_operatingsystem
677 const WCHAR *buildnumber;
678 const WCHAR *caption;
679 const WCHAR *codeset;
680 const WCHAR *countrycode;
681 const WCHAR *csdversion;
682 const WCHAR *installdate;
683 const WCHAR *lastbootuptime;
684 const WCHAR *localdatetime;
685 const WCHAR *locale;
686 const WCHAR *name;
687 const WCHAR *osarchitecture;
688 UINT32 oslanguage;
689 UINT32 osproductsuite;
690 UINT16 ostype;
691 const WCHAR *serialnumber;
692 UINT16 servicepackmajor;
693 UINT16 servicepackminor;
694 UINT32 suitemask;
695 const WCHAR *systemdirectory;
696 const WCHAR *version;
698 struct record_param
700 const WCHAR *class;
701 const WCHAR *method;
702 INT32 direction;
703 const WCHAR *parameter;
704 UINT32 type;
705 UINT32 varianttype;
706 UINT32 defaultvalue;
708 struct record_physicalmedia
710 const WCHAR *serialnumber;
711 const WCHAR *tag;
713 struct record_physicalmemory
715 UINT64 capacity;
717 struct record_process
719 const WCHAR *caption;
720 const WCHAR *commandline;
721 const WCHAR *description;
722 const WCHAR *handle;
723 const WCHAR *name;
724 UINT32 pprocess_id;
725 UINT32 process_id;
726 UINT32 thread_count;
727 /* methods */
728 class_method *get_owner;
730 struct record_processor
732 UINT16 addresswidth;
733 UINT16 cpu_status;
734 const WCHAR *device_id;
735 UINT16 family;
736 const WCHAR *manufacturer;
737 UINT32 maxclockspeed;
738 const WCHAR *name;
739 UINT32 num_cores;
740 UINT32 num_logical_processors;
741 const WCHAR *processor_id;
742 const WCHAR *unique_id;
744 struct record_qualifier
746 const WCHAR *class;
747 const WCHAR *member;
748 UINT32 type;
749 INT32 flavor;
750 const WCHAR *name;
751 INT32 intvalue;
752 const WCHAR *strvalue;
754 struct record_service
756 int accept_pause;
757 int accept_stop;
758 const WCHAR *displayname;
759 const WCHAR *name;
760 UINT32 process_id;
761 const WCHAR *servicetype;
762 const WCHAR *startmode;
763 const WCHAR *state;
764 const WCHAR *systemname;
765 /* methods */
766 class_method *pause_service;
767 class_method *resume_service;
768 class_method *start_service;
769 class_method *stop_service;
771 struct record_sounddevice
773 const WCHAR *name;
774 const WCHAR *productname;
776 struct record_stdregprov
778 class_method *enumkey;
779 class_method *enumvalues;
780 class_method *getstringvalue;
782 struct record_videocontroller
784 const WCHAR *adapter_dactype;
785 UINT32 adapter_ram;
786 UINT32 current_bitsperpixel;
787 UINT32 current_horizontalres;
788 UINT32 current_verticalres;
789 const WCHAR *description;
790 const WCHAR *device_id;
791 const WCHAR *name;
792 const WCHAR *pnpdevice_id;
794 #include "poppack.h"
796 static const struct record_baseboard data_baseboard[] =
798 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_tagW }
800 static const struct record_bios data_bios[] =
802 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW,
803 bios_smbiosbiosversionW, bios_versionW }
805 static const struct record_diskdrive data_diskdrive[] =
807 { diskdrive_deviceidW, 0, diskdrive_manufacturerW, diskdrive_mediatypeW, diskdrive_modelW,
808 diskdrive_serialW }
810 static const struct record_param data_param[] =
812 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
813 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
814 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
815 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
816 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
817 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
818 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
819 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
820 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
821 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
822 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
823 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
824 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
825 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
826 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
827 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
828 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
829 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
830 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
831 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
832 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING }
835 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
836 WBEM_FLAVOR_ORIGIN_PROPAGATED)
838 static const struct record_physicalmedia data_physicalmedia[] =
840 { diskdrive_serialW, physicalmedia_tagW }
842 static const struct record_qualifier data_qualifier[] =
844 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
845 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
847 static const struct record_sounddevice data_sounddevice[] =
849 { sounddevice_productnameW, sounddevice_productnameW }
851 static const struct record_stdregprov data_stdregprov[] =
853 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
856 /* check if row matches condition and update status */
857 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
859 LONGLONG val;
860 UINT type;
862 if (!cond)
864 *status = FILL_STATUS_UNFILTERED;
865 return TRUE;
867 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
869 *status = FILL_STATUS_FAILED;
870 return FALSE;
872 *status = FILL_STATUS_FILTERED;
873 return val != 0;
876 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
878 if (!table->num_rows_allocated)
880 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
881 table->num_rows_allocated = row_count;
882 return TRUE;
884 if (row_count >= table->num_rows_allocated)
886 BYTE *data;
887 UINT count = table->num_rows_allocated * 2;
888 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
889 table->data = data;
890 table->num_rows_allocated = count;
892 return TRUE;
895 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
897 static const WCHAR fmtW[] = {'%','c',':',0};
898 WCHAR drive[3], root[] = {'A',':','\\',0};
899 struct record_cdromdrive *rec;
900 UINT i, row = 0, offset = 0;
901 DWORD drives = GetLogicalDrives();
902 enum fill_status status = FILL_STATUS_UNFILTERED;
904 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
906 for (i = 0; i < sizeof(drives); i++)
908 if (drives & (1 << i))
910 root[0] = 'A' + i;
911 if (GetDriveTypeW( root ) != DRIVE_CDROM)
912 continue;
914 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
916 rec = (struct record_cdromdrive *)(table->data + offset);
917 rec->device_id = cdromdrive_pnpdeviceidW;
918 sprintfW( drive, fmtW, 'A' + i );
919 rec->drive = heap_strdupW( drive );
920 rec->name = cdromdrive_nameW;
921 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
922 if (!match_row( table, row, cond, &status ))
924 free_row_values( table, row );
925 continue;
927 offset += sizeof(*rec);
928 row++;
931 TRACE("created %u rows\n", row);
932 table->num_rows = row;
933 return status;
936 static UINT get_processor_count(void)
938 SYSTEM_BASIC_INFORMATION info;
940 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
941 return info.NumberOfProcessors;
944 static UINT get_logical_processor_count( UINT *num_cores )
946 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
947 UINT i, j, count = 0;
948 NTSTATUS status;
949 ULONG len;
951 if (num_cores) *num_cores = get_processor_count();
952 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
953 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
955 if (!(info = heap_alloc( len ))) return get_processor_count();
956 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
957 if (status != STATUS_SUCCESS)
959 heap_free( info );
960 return get_processor_count();
962 if (num_cores) *num_cores = 0;
963 for (i = 0; i < len / sizeof(*info); i++)
965 if (info[i].Relationship == RelationProcessorCore)
967 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
969 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
971 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
974 heap_free( info );
975 return count;
978 static UINT64 get_total_physical_memory(void)
980 MEMORYSTATUSEX status;
982 status.dwLength = sizeof(status);
983 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
984 return status.ullTotalPhys;
987 static WCHAR *get_computername(void)
989 WCHAR *ret;
990 DWORD size = MAX_COMPUTERNAME_LENGTH;
992 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
993 GetComputerNameW( ret, &size );
994 return ret;
997 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
999 struct record_computersystem *rec;
1000 enum fill_status status = FILL_STATUS_UNFILTERED;
1001 UINT row = 0;
1003 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1005 rec = (struct record_computersystem *)table->data;
1006 rec->description = compsys_descriptionW;
1007 rec->domain = compsys_domainW;
1008 rec->domainrole = 0; /* standalone workstation */
1009 rec->manufacturer = compsys_manufacturerW;
1010 rec->model = compsys_modelW;
1011 rec->name = get_computername();
1012 rec->num_logical_processors = get_logical_processor_count( NULL );
1013 rec->num_processors = get_processor_count();
1014 rec->total_physical_memory = get_total_physical_memory();
1015 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1016 else row++;
1018 TRACE("created %u rows\n", row);
1019 table->num_rows = row;
1020 return status;
1023 struct dirstack
1025 WCHAR **dirs;
1026 UINT *len_dirs;
1027 UINT num_dirs;
1028 UINT num_allocated;
1031 static struct dirstack *alloc_dirstack( UINT size )
1033 struct dirstack *dirstack;
1035 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1036 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1038 heap_free( dirstack );
1039 return NULL;
1041 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1043 heap_free( dirstack->dirs );
1044 heap_free( dirstack );
1045 return NULL;
1047 dirstack->num_dirs = 0;
1048 dirstack->num_allocated = size;
1049 return dirstack;
1052 static void clear_dirstack( struct dirstack *dirstack )
1054 UINT i;
1055 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1056 dirstack->num_dirs = 0;
1059 static void free_dirstack( struct dirstack *dirstack )
1061 clear_dirstack( dirstack );
1062 heap_free( dirstack->dirs );
1063 heap_free( dirstack->len_dirs );
1064 heap_free( dirstack );
1067 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1069 UINT size, i = dirstack->num_dirs;
1071 if (!dir) return FALSE;
1073 if (i == dirstack->num_allocated)
1075 WCHAR **tmp;
1076 UINT *len_tmp;
1078 size = dirstack->num_allocated * 2;
1079 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1080 dirstack->dirs = tmp;
1081 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1082 dirstack->len_dirs = len_tmp;
1083 dirstack->num_allocated = size;
1085 dirstack->dirs[i] = dir;
1086 dirstack->len_dirs[i] = len;
1087 dirstack->num_dirs++;
1088 return TRUE;
1091 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1093 if (!dirstack->num_dirs)
1095 *len = 0;
1096 return NULL;
1098 dirstack->num_dirs--;
1099 *len = dirstack->len_dirs[dirstack->num_dirs];
1100 return dirstack->dirs[dirstack->num_dirs];
1103 static const WCHAR *peek_dir( struct dirstack *dirstack )
1105 if (!dirstack->num_dirs) return NULL;
1106 return dirstack->dirs[dirstack->num_dirs - 1];
1109 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1111 UINT i = 0;
1112 WCHAR *ret;
1114 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1115 ret[i++] = drive;
1116 ret[i++] = ':';
1117 ret[i++] = '\\';
1118 if (path && len)
1120 memcpy( ret + i, path, len * sizeof(WCHAR) );
1121 i += len;
1122 ret[i++] = '\\';
1124 ret[i++] = '*';
1125 ret[i] = 0;
1126 return ret;
1129 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1131 UINT i = 0, len = 0;
1132 const WCHAR *p;
1133 WCHAR *ret;
1135 for (p = path; *p; p++)
1137 if (*p == '\\') len += 2;
1138 else len++;
1140 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1141 ret[i++] = drive;
1142 ret[i++] = ':';
1143 ret[i++] = '\\';
1144 ret[i++] = '\\';
1145 for (p = path; *p; p++)
1147 if (*p != '\\') ret[i++] = *p;
1148 else
1150 ret[i++] = '\\';
1151 ret[i++] = '\\';
1154 ret[i] = 0;
1155 return ret;
1158 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1160 const WCHAR *p = path, *start;
1161 UINT len, i;
1162 WCHAR *ret;
1164 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1165 start = path + 4;
1166 len = strlenW( start );
1167 p = start + len - 1;
1168 if (*p == '\\') return NULL;
1170 while (p >= start && *p != '\\') { len--; p--; };
1171 while (p >= start && *p == '\\') { len--; p--; };
1173 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1174 for (i = 0, p = start; p < start + len; p++)
1176 if (p[0] == '\\' && p[1] == '\\')
1178 ret[i++] = '\\';
1179 p++;
1181 else ret[i++] = *p;
1183 ret[i] = 0;
1184 *ret_len = i;
1185 return ret;
1188 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1190 UINT i;
1191 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1192 return FALSE;
1195 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1196 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1198 const struct expr *left, *right;
1200 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1202 left = cond->u.expr.left;
1203 right = cond->u.expr.right;
1204 if (cond->u.expr.op == OP_EQ)
1206 UINT len;
1207 WCHAR *path;
1208 const WCHAR *str = NULL;
1210 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1211 !strcmpW( left->u.propval->name, prop_nameW ) &&
1212 toupperW( right->u.sval[0] ) == toupperW( root ))
1214 str = right->u.sval;
1216 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1217 !strcmpW( right->u.propval->name, prop_nameW ) &&
1218 toupperW( left->u.sval[0] ) == toupperW( root ))
1220 str = left->u.sval;
1222 if (str && (path = build_dirname( str, &len )))
1224 if (seen_dir( dirstack, path ))
1226 heap_free( path );
1227 return ++*count;
1229 else if (push_dir( dirstack, path, len )) return ++*count;
1230 heap_free( path );
1231 return *count = 0;
1234 else if (cond->u.expr.op == OP_OR)
1236 UINT left_count = 0, right_count = 0;
1238 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1239 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1240 return *count += left_count + right_count;
1242 return *count = 0;
1245 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1247 UINT len_path = 0, len_segment = strlenW( segment );
1248 WCHAR *ret;
1250 *len = 0;
1251 if (path) len_path = strlenW( path );
1252 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1253 if (path && len_path)
1255 memcpy( ret, path, len_path * sizeof(WCHAR) );
1256 ret[len_path] = '\\';
1257 *len += len_path + 1;
1259 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1260 *len += len_segment;
1261 ret[*len] = 0;
1262 return ret;
1265 static WCHAR *get_file_version( const WCHAR *filename )
1267 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1268 VS_FIXEDFILEINFO *info;
1269 DWORD size;
1270 void *block;
1271 WCHAR *ret;
1273 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1274 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1276 heap_free( ret );
1277 return NULL;
1279 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1280 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1282 heap_free( block );
1283 heap_free( ret );
1284 return NULL;
1286 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1287 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1288 heap_free( block );
1289 return ret;
1292 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1294 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1295 struct record_datafile *rec;
1296 UINT i, len, row = 0, offset = 0, num_expected_rows;
1297 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1298 DWORD drives = GetLogicalDrives();
1299 WIN32_FIND_DATAW data;
1300 HANDLE handle;
1301 struct dirstack *dirstack;
1302 enum fill_status status = FILL_STATUS_UNFILTERED;
1304 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1306 dirstack = alloc_dirstack(2);
1308 for (i = 0; i < sizeof(drives); i++)
1310 if (!(drives & (1 << i))) continue;
1312 root[0] = 'A' + i;
1313 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1315 num_expected_rows = 0;
1316 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1318 for (;;)
1320 path = pop_dir( dirstack, &len );
1321 if (!(glob = build_glob( root[0], path, len )))
1323 status = FILL_STATUS_FAILED;
1324 goto done;
1326 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1330 if (!resize_table( table, row + 1, sizeof(*rec) ))
1332 status = FILL_STATUS_FAILED;
1333 FindClose( handle );
1334 goto done;
1336 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1337 new_path = append_path( path, data.cFileName, &len );
1339 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1341 if (push_dir( dirstack, new_path, len )) continue;
1342 heap_free( new_path );
1343 FindClose( handle );
1344 status = FILL_STATUS_FAILED;
1345 goto done;
1347 rec = (struct record_datafile *)(table->data + offset);
1348 rec->name = build_name( root[0], new_path );
1349 rec->version = get_file_version( rec->name );
1350 if (!match_row( table, row, cond, &status ))
1352 free_row_values( table, row );
1353 continue;
1355 else if (num_expected_rows && row == num_expected_rows - 1)
1357 row++;
1358 FindClose( handle );
1359 status = FILL_STATUS_FILTERED;
1360 goto done;
1362 offset += sizeof(*rec);
1363 row++;
1365 while (FindNextFileW( handle, &data ));
1366 FindClose( handle );
1368 if (!peek_dir( dirstack )) break;
1369 heap_free( glob );
1370 heap_free( path );
1374 done:
1375 free_dirstack( dirstack );
1376 heap_free( glob );
1377 heap_free( path );
1379 TRACE("created %u rows\n", row);
1380 table->num_rows = row;
1381 return status;
1384 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1386 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1387 struct record_directory *rec;
1388 UINT i, len, row = 0, offset = 0, num_expected_rows;
1389 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1390 DWORD drives = GetLogicalDrives();
1391 WIN32_FIND_DATAW data;
1392 HANDLE handle;
1393 struct dirstack *dirstack;
1394 enum fill_status status = FILL_STATUS_UNFILTERED;
1396 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1398 dirstack = alloc_dirstack(2);
1400 for (i = 0; i < sizeof(drives); i++)
1402 if (!(drives & (1 << i))) continue;
1404 root[0] = 'A' + i;
1405 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1407 num_expected_rows = 0;
1408 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1410 for (;;)
1412 path = pop_dir( dirstack, &len );
1413 if (!(glob = build_glob( root[0], path, len )))
1415 status = FILL_STATUS_FAILED;
1416 goto done;
1418 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1422 if (!resize_table( table, row + 1, sizeof(*rec) ))
1424 FindClose( handle );
1425 status = FILL_STATUS_FAILED;
1426 goto done;
1428 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1429 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1430 continue;
1432 new_path = append_path( path, data.cFileName, &len );
1433 if (!(push_dir( dirstack, new_path, len )))
1435 heap_free( new_path );
1436 FindClose( handle );
1437 status = FILL_STATUS_FAILED;
1438 goto done;
1440 rec = (struct record_directory *)(table->data + offset);
1441 rec->accessmask = FILE_ALL_ACCESS;
1442 rec->name = build_name( root[0], new_path );
1443 if (!match_row( table, row, cond, &status ))
1445 free_row_values( table, row );
1446 continue;
1448 else if (num_expected_rows && row == num_expected_rows - 1)
1450 row++;
1451 FindClose( handle );
1452 status = FILL_STATUS_FILTERED;
1453 goto done;
1455 offset += sizeof(*rec);
1456 row++;
1458 while (FindNextFileW( handle, &data ));
1459 FindClose( handle );
1461 if (!peek_dir( dirstack )) break;
1462 heap_free( glob );
1463 heap_free( path );
1467 done:
1468 free_dirstack( dirstack );
1469 heap_free( glob );
1470 heap_free( path );
1472 TRACE("created %u rows\n", row);
1473 table->num_rows = row;
1474 return status;
1477 static WCHAR *get_filesystem( const WCHAR *root )
1479 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1480 WCHAR buffer[MAX_PATH + 1];
1482 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1483 return heap_strdupW( buffer );
1484 return heap_strdupW( ntfsW );
1487 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1489 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1490 ULARGE_INTEGER free;
1491 DISK_GEOMETRY_EX info;
1492 HANDLE handle;
1494 free.QuadPart = 512 * 1024 * 1024;
1495 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1497 root[4] = dir[0];
1498 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1499 if (handle != INVALID_HANDLE_VALUE)
1501 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), NULL, NULL ))
1502 *disksize = info.DiskSize.QuadPart;
1503 CloseHandle( handle );
1505 return free.QuadPart;
1508 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1510 static const WCHAR fmtW[] =
1511 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1512 WCHAR device_id[32], root[] = {'A',':','\\',0};
1513 struct record_diskpartition *rec;
1514 UINT i, row = 0, offset = 0, type, index = 0;
1515 UINT64 size = 1024 * 1024 * 1024;
1516 DWORD drives = GetLogicalDrives();
1517 enum fill_status status = FILL_STATUS_UNFILTERED;
1519 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1521 for (i = 0; i < sizeof(drives); i++)
1523 if (drives & (1 << i))
1525 root[0] = 'A' + i;
1526 type = GetDriveTypeW( root );
1527 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1528 continue;
1530 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1532 rec = (struct record_diskpartition *)(table->data + offset);
1533 rec->bootable = (i == 2) ? -1 : 0;
1534 rec->bootpartition = (i == 2) ? -1 : 0;
1535 sprintfW( device_id, fmtW, index );
1536 rec->device_id = heap_strdupW( device_id );
1537 rec->diskindex = index;
1538 rec->index = 0;
1539 rec->pnpdevice_id = heap_strdupW( device_id );
1540 get_freespace( root, &size );
1541 rec->size = size;
1542 rec->startingoffset = 0;
1543 rec->type = get_filesystem( root );
1544 if (!match_row( table, row, cond, &status ))
1546 free_row_values( table, row );
1547 continue;
1549 offset += sizeof(*rec);
1550 row++;
1551 index++;
1554 TRACE("created %u rows\n", row);
1555 table->num_rows = row;
1556 return status;
1559 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1561 static const WCHAR fmtW[] = {'%','0','8','X',0};
1562 DWORD serial = 0;
1563 WCHAR buffer[9];
1565 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1566 sprintfW( buffer, fmtW, serial );
1567 return heap_strdupW( buffer );
1570 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1572 static const WCHAR fmtW[] = {'%','c',':',0};
1573 WCHAR device_id[3], root[] = {'A',':','\\',0};
1574 struct record_logicaldisk *rec;
1575 UINT i, row = 0, offset = 0, type;
1576 UINT64 size = 1024 * 1024 * 1024;
1577 DWORD drives = GetLogicalDrives();
1578 enum fill_status status = FILL_STATUS_UNFILTERED;
1580 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1582 for (i = 0; i < sizeof(drives); i++)
1584 if (drives & (1 << i))
1586 root[0] = 'A' + i;
1587 type = GetDriveTypeW( root );
1588 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1589 continue;
1591 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1593 rec = (struct record_logicaldisk *)(table->data + offset);
1594 sprintfW( device_id, fmtW, 'A' + i );
1595 rec->device_id = heap_strdupW( device_id );
1596 rec->drivetype = type;
1597 rec->filesystem = get_filesystem( root );
1598 rec->freespace = get_freespace( root, &size );
1599 rec->name = heap_strdupW( device_id );
1600 rec->size = size;
1601 rec->volumeserialnumber = get_volumeserialnumber( root );
1602 if (!match_row( table, row, cond, &status ))
1604 free_row_values( table, row );
1605 continue;
1607 offset += sizeof(*rec);
1608 row++;
1611 TRACE("created %u rows\n", row);
1612 table->num_rows = row;
1613 return status;
1616 static UINT16 get_connection_status( IF_OPER_STATUS status )
1618 switch (status)
1620 case IfOperStatusDown:
1621 return 0; /* Disconnected */
1622 case IfOperStatusUp:
1623 return 2; /* Connected */
1624 default:
1625 ERR("unhandled status %u\n", status);
1626 break;
1628 return 0;
1630 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
1632 static const WCHAR fmtW[] =
1633 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1634 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1635 WCHAR *ret;
1637 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
1638 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
1639 return ret;
1641 static const WCHAR *get_adaptertype( DWORD type, int *physical )
1643 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1644 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
1645 static const WCHAR firewireW[] = {'1','3','9','4',0};
1646 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
1648 switch (type)
1650 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
1651 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
1652 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
1653 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
1654 default: *physical = 0; return NULL;
1658 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
1660 static const WCHAR fmtW[] = {'%','u',0};
1661 WCHAR device_id[11];
1662 struct record_networkadapter *rec;
1663 IP_ADAPTER_ADDRESSES *aa, *buffer;
1664 UINT row = 0, offset = 0, count = 0;
1665 DWORD size = 0, ret;
1666 int physical;
1667 enum fill_status status = FILL_STATUS_UNFILTERED;
1669 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
1670 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
1672 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
1673 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
1675 heap_free( buffer );
1676 return FILL_STATUS_FAILED;
1678 for (aa = buffer; aa; aa = aa->Next)
1680 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
1682 if (!resize_table( table, count, sizeof(*rec) ))
1684 heap_free( buffer );
1685 return FILL_STATUS_FAILED;
1687 for (aa = buffer; aa; aa = aa->Next)
1689 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
1691 rec = (struct record_networkadapter *)(table->data + offset);
1692 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
1693 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
1694 rec->device_id = heap_strdupW( device_id );
1695 rec->index = aa->u.s.IfIndex;
1696 rec->interface_index = aa->u.s.IfIndex;
1697 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
1698 rec->manufacturer = compsys_manufacturerW;
1699 rec->name = heap_strdupW( aa->FriendlyName );
1700 rec->netconnection_status = get_connection_status( aa->OperStatus );
1701 rec->physicaladapter = physical;
1702 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
1703 rec->speed = 1000000;
1704 if (!match_row( table, row, cond, &status ))
1706 free_row_values( table, row );
1707 continue;
1709 offset += sizeof(*rec);
1710 row++;
1712 TRACE("created %u rows\n", row);
1713 table->num_rows = row;
1715 heap_free( buffer );
1716 return status;
1719 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
1721 struct record_networkadapterconfig *rec;
1722 IP_ADAPTER_ADDRESSES *aa, *buffer;
1723 UINT row = 0, offset = 0, count = 0;
1724 DWORD size = 0, ret;
1725 enum fill_status status = FILL_STATUS_UNFILTERED;
1727 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
1728 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
1730 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
1731 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
1733 heap_free( buffer );
1734 return FILL_STATUS_FAILED;
1736 for (aa = buffer; aa; aa = aa->Next)
1738 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
1740 if (!resize_table( table, count, sizeof(*rec) ))
1742 heap_free( buffer );
1743 return FILL_STATUS_FAILED;
1745 for (aa = buffer; aa; aa = aa->Next)
1747 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
1749 rec = (struct record_networkadapterconfig *)(table->data + offset);
1750 rec->index = aa->u.s.IfIndex;
1751 rec->ipconnectionmetric = 20;
1752 rec->ipenabled = -1;
1753 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
1754 if (!match_row( table, row, cond, &status ))
1756 free_row_values( table, row );
1757 continue;
1759 offset += sizeof(*rec);
1760 row++;
1762 TRACE("created %u rows\n", row);
1763 table->num_rows = row;
1765 heap_free( buffer );
1766 return status;
1769 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
1771 struct record_physicalmemory *rec;
1772 enum fill_status status = FILL_STATUS_UNFILTERED;
1773 UINT row = 0;
1775 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1777 rec = (struct record_physicalmemory *)table->data;
1778 rec->capacity = get_total_physical_memory();
1779 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1780 else row++;
1782 TRACE("created %u rows\n", row);
1783 table->num_rows = row;
1784 return status;
1787 static WCHAR *get_cmdline( DWORD process_id )
1789 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1790 return NULL; /* FIXME handle different process case */
1793 static enum fill_status fill_process( struct table *table, const struct expr *cond )
1795 static const WCHAR fmtW[] = {'%','u',0};
1796 WCHAR handle[11];
1797 struct record_process *rec;
1798 PROCESSENTRY32W entry;
1799 HANDLE snap;
1800 enum fill_status status = FILL_STATUS_FAILED;
1801 UINT row = 0, offset = 0;
1803 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
1804 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
1806 entry.dwSize = sizeof(entry);
1807 if (!Process32FirstW( snap, &entry )) goto done;
1808 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
1812 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
1814 rec = (struct record_process *)(table->data + offset);
1815 rec->caption = heap_strdupW( entry.szExeFile );
1816 rec->commandline = get_cmdline( entry.th32ProcessID );
1817 rec->description = heap_strdupW( entry.szExeFile );
1818 sprintfW( handle, fmtW, entry.th32ProcessID );
1819 rec->handle = heap_strdupW( handle );
1820 rec->name = heap_strdupW( entry.szExeFile );
1821 rec->process_id = entry.th32ProcessID;
1822 rec->pprocess_id = entry.th32ParentProcessID;
1823 rec->thread_count = entry.cntThreads;
1824 rec->get_owner = process_get_owner;
1825 if (!match_row( table, row, cond, &status ))
1827 free_row_values( table, row );
1828 continue;
1830 offset += sizeof(*rec);
1831 row++;
1832 } while (Process32NextW( snap, &entry ));
1834 TRACE("created %u rows\n", row);
1835 table->num_rows = row;
1836 status = FILL_STATUS_UNFILTERED;
1838 done:
1839 CloseHandle( snap );
1840 return status;
1843 static inline void do_cpuid( unsigned int ax, unsigned int *p )
1845 #ifdef __i386__
1846 __asm__("pushl %%ebx\n\t"
1847 "cpuid\n\t"
1848 "movl %%ebx, %%esi\n\t"
1849 "popl %%ebx"
1850 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
1851 : "0" (ax));
1852 #endif
1855 static void get_processor_id( WCHAR *processor_id )
1857 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
1858 unsigned int regs[4] = {0, 0, 0, 0};
1860 do_cpuid( 1, regs );
1861 sprintfW( processor_id, fmtW, regs[3], regs[0] );
1863 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
1865 unsigned int i;
1866 unsigned char *p = (unsigned char *)regs;
1868 for (i = 0; i < len; i++) { buffer[i] = *p++; }
1869 buffer[i] = 0;
1871 static void get_processor_manufacturer( WCHAR *manufacturer )
1873 unsigned int tmp, regs[4] = {0, 0, 0, 0};
1875 do_cpuid( 0, regs );
1876 tmp = regs[2]; /* swap edx and ecx */
1877 regs[2] = regs[3];
1878 regs[3] = tmp;
1880 regs_to_str( regs + 1, 12, manufacturer );
1882 static void get_processor_name( WCHAR *name )
1884 unsigned int regs[4] = {0, 0, 0, 0};
1886 do_cpuid( 0x80000000, regs );
1887 if (regs[0] >= 0x80000004)
1889 do_cpuid( 0x80000002, regs );
1890 regs_to_str( regs, 16, name );
1891 do_cpuid( 0x80000003, regs );
1892 regs_to_str( regs, 16, name + 16 );
1893 do_cpuid( 0x80000004, regs );
1894 regs_to_str( regs, 16, name + 32 );
1897 static UINT get_processor_maxclockspeed( void )
1899 PROCESSOR_POWER_INFORMATION *info;
1900 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
1901 NTSTATUS status;
1903 if ((info = heap_alloc( size )))
1905 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
1906 if (!status) ret = info[0].MaxMhz;
1907 heap_free( info );
1909 return ret;
1911 static const WCHAR *get_osarchitecture(void)
1913 SYSTEM_INFO info;
1914 GetNativeSystemInfo( &info );
1915 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
1916 return os_32bitW;
1919 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
1921 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
1922 WCHAR device_id[14], processor_id[17], manufacturer[13], name[49] = {0};
1923 struct record_processor *rec;
1924 UINT i, offset = 0, maxclockspeed, num_cores, num_logical_processors, count = get_processor_count();
1925 enum fill_status status = FILL_STATUS_UNFILTERED;
1927 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
1929 get_processor_id( processor_id );
1930 get_processor_manufacturer( manufacturer );
1931 get_processor_name( name );
1933 maxclockspeed = get_processor_maxclockspeed();
1934 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
1935 num_cores /= count;
1937 for (i = 0; i < count; i++)
1939 rec = (struct record_processor *)(table->data + offset);
1940 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
1941 rec->cpu_status = 1; /* CPU Enabled */
1942 sprintfW( device_id, fmtW, i );
1943 rec->device_id = heap_strdupW( device_id );
1944 rec->family = 2; /* Unknown */
1945 rec->manufacturer = heap_strdupW( manufacturer );
1946 rec->maxclockspeed = maxclockspeed;
1947 rec->name = heap_strdupW( name );
1948 rec->num_cores = num_cores;
1949 rec->num_logical_processors = num_logical_processors;
1950 rec->processor_id = heap_strdupW( processor_id );
1951 rec->unique_id = NULL;
1952 if (!match_row( table, i, cond, &status ))
1954 free_row_values( table, i );
1955 continue;
1957 offset += sizeof(*rec);
1960 TRACE("created %u rows\n", count);
1961 table->num_rows = count;
1962 return status;
1965 static WCHAR *get_lastbootuptime(void)
1967 static const WCHAR fmtW[] =
1968 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1969 '.','%','0','6','u','+','0','0','0',0};
1970 SYSTEM_TIMEOFDAY_INFORMATION ti;
1971 TIME_FIELDS tf;
1972 WCHAR *ret;
1974 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
1976 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
1977 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
1978 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
1979 return ret;
1981 static WCHAR *get_localdatetime(void)
1983 static const WCHAR fmtW[] =
1984 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1985 '.','%','0','6','u','%','+','0','3','d',0};
1986 TIME_ZONE_INFORMATION tzi;
1987 SYSTEMTIME st;
1988 WCHAR *ret;
1989 DWORD Status;
1990 LONG Bias;
1992 Status = GetTimeZoneInformation(&tzi);
1994 if(Status == TIME_ZONE_ID_INVALID) return NULL;
1995 Bias = tzi.Bias;
1996 if(Status == TIME_ZONE_ID_DAYLIGHT)
1997 Bias+= tzi.DaylightBias;
1998 else
1999 Bias+= tzi.StandardBias;
2000 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2002 GetLocalTime(&st);
2003 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2004 return ret;
2006 static WCHAR *get_systemdirectory(void)
2008 void *redir;
2009 WCHAR *ret;
2011 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2012 Wow64DisableWow64FsRedirection( &redir );
2013 GetSystemDirectoryW( ret, MAX_PATH );
2014 Wow64RevertWow64FsRedirection( redir );
2015 return ret;
2017 static WCHAR *get_codeset(void)
2019 static const WCHAR fmtW[] = {'%','u',0};
2020 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2021 if (ret) sprintfW( ret, fmtW, GetACP() );
2022 return ret;
2024 static WCHAR *get_countrycode(void)
2026 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2027 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2028 return ret;
2030 static WCHAR *get_locale(void)
2032 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2033 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2034 return ret;
2037 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2039 struct record_operatingsystem *rec;
2040 enum fill_status status = FILL_STATUS_UNFILTERED;
2041 UINT row = 0;
2043 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2045 rec = (struct record_operatingsystem *)table->data;
2046 rec->buildnumber = os_buildnumberW;
2047 rec->caption = os_captionW;
2048 rec->codeset = get_codeset();
2049 rec->countrycode = get_countrycode();
2050 rec->csdversion = os_csdversionW;
2051 rec->installdate = os_installdateW;
2052 rec->lastbootuptime = get_lastbootuptime();
2053 rec->localdatetime = get_localdatetime();
2054 rec->locale = get_locale();
2055 rec->name = os_nameW;
2056 rec->osarchitecture = get_osarchitecture();
2057 rec->oslanguage = GetSystemDefaultLangID();
2058 rec->osproductsuite = 2461140; /* Windows XP Professional */
2059 rec->ostype = 18; /* WINNT */
2060 rec->serialnumber = os_serialnumberW;
2061 rec->servicepackmajor = 3;
2062 rec->servicepackminor = 0;
2063 rec->suitemask = 272; /* Single User + Terminal */
2064 rec->systemdirectory = get_systemdirectory();
2065 rec->version = os_versionW;
2066 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2067 else row++;
2069 TRACE("created %u rows\n", row);
2070 table->num_rows = row;
2071 return status;
2074 static const WCHAR *get_service_type( DWORD type )
2076 static const WCHAR filesystem_driverW[] =
2077 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2078 static const WCHAR kernel_driverW[] =
2079 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2080 static const WCHAR own_processW[] =
2081 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2082 static const WCHAR share_processW[] =
2083 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2085 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2086 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2087 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2088 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2089 else ERR("unhandled type 0x%08x\n", type);
2090 return NULL;
2092 static const WCHAR *get_service_state( DWORD state )
2094 static const WCHAR runningW[] =
2095 {'R','u','n','n','i','n','g',0};
2096 static const WCHAR start_pendingW[] =
2097 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2098 static const WCHAR stop_pendingW[] =
2099 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2100 static const WCHAR stoppedW[] =
2101 {'S','t','o','p','p','e','d',0};
2102 static const WCHAR unknownW[] =
2103 {'U','n','k','n','o','w','n',0};
2105 switch (state)
2107 case SERVICE_STOPPED: return stoppedW;
2108 case SERVICE_START_PENDING: return start_pendingW;
2109 case SERVICE_STOP_PENDING: return stop_pendingW;
2110 case SERVICE_RUNNING: return runningW;
2111 default:
2112 ERR("unknown state %u\n", state);
2113 return unknownW;
2116 static const WCHAR *get_service_startmode( DWORD mode )
2118 static const WCHAR bootW[] = {'B','o','o','t',0};
2119 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2120 static const WCHAR autoW[] = {'A','u','t','o',0};
2121 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2122 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2123 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2125 switch (mode)
2127 case SERVICE_BOOT_START: return bootW;
2128 case SERVICE_SYSTEM_START: return systemW;
2129 case SERVICE_AUTO_START: return autoW;
2130 case SERVICE_DEMAND_START: return manualW;
2131 case SERVICE_DISABLED: return disabledW;
2132 default:
2133 ERR("unknown mode 0x%x\n", mode);
2134 return unknownW;
2137 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2139 QUERY_SERVICE_CONFIGW *config = NULL;
2140 SC_HANDLE service;
2141 DWORD size;
2143 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2144 QueryServiceConfigW( service, NULL, 0, &size );
2145 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2146 if (!(config = heap_alloc( size ))) goto done;
2147 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2148 heap_free( config );
2149 config = NULL;
2151 done:
2152 CloseServiceHandle( service );
2153 return config;
2156 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2158 struct record_service *rec;
2159 SC_HANDLE manager;
2160 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2161 SERVICE_STATUS_PROCESS *status;
2162 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2163 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2164 UINT i, row = 0, offset = 0, size = 256, needed, count;
2165 enum fill_status fill_status = FILL_STATUS_FAILED;
2166 BOOL ret;
2168 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2169 if (!(services = heap_alloc( size ))) goto done;
2171 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2172 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2173 &count, NULL, NULL );
2174 if (!ret)
2176 if (GetLastError() != ERROR_MORE_DATA) goto done;
2177 size = needed;
2178 if (!(tmp = heap_realloc( services, size ))) goto done;
2179 services = tmp;
2180 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2181 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2182 &count, NULL, NULL );
2183 if (!ret) goto done;
2185 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2187 GetComputerNameW( sysnameW, &len );
2188 fill_status = FILL_STATUS_UNFILTERED;
2190 for (i = 0; i < count; i++)
2192 QUERY_SERVICE_CONFIGW *config;
2194 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2196 status = &services[i].ServiceStatusProcess;
2197 rec = (struct record_service *)(table->data + offset);
2198 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2199 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2200 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2201 rec->name = heap_strdupW( services[i].lpServiceName );
2202 rec->process_id = status->dwProcessId;
2203 rec->servicetype = get_service_type( status->dwServiceType );
2204 rec->startmode = get_service_startmode( config->dwStartType );
2205 rec->state = get_service_state( status->dwCurrentState );
2206 rec->systemname = heap_strdupW( sysnameW );
2207 rec->pause_service = service_pause_service;
2208 rec->resume_service = service_resume_service;
2209 rec->start_service = service_start_service;
2210 rec->stop_service = service_stop_service;
2211 heap_free( config );
2212 if (!match_row( table, row, cond, &fill_status ))
2214 free_row_values( table, row );
2215 continue;
2217 offset += sizeof(*rec);
2218 row++;
2221 TRACE("created %u rows\n", row);
2222 table->num_rows = row;
2224 done:
2225 CloseServiceHandle( manager );
2226 heap_free( services );
2227 return fill_status;
2230 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2232 HDC hdc = GetDC( NULL );
2233 UINT32 ret;
2235 if (!hdc) return 32;
2236 ret = GetDeviceCaps( hdc, BITSPIXEL );
2237 *hres = GetDeviceCaps( hdc, HORZRES );
2238 *vres = GetDeviceCaps( hdc, VERTRES );
2239 ReleaseDC( NULL, hdc );
2240 return ret;
2242 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2244 static const WCHAR fmtW[] =
2245 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2246 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2247 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2248 WCHAR *ret;
2250 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2251 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2252 return ret;
2255 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2258 struct record_videocontroller *rec;
2259 HRESULT hr;
2260 IDXGIFactory *factory = NULL;
2261 IDXGIAdapter *adapter = NULL;
2262 DXGI_ADAPTER_DESC desc;
2263 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2264 const WCHAR *name = videocontroller_deviceidW;
2265 enum fill_status status = FILL_STATUS_UNFILTERED;
2266 UINT row = 0;
2268 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2270 memset (&desc, 0, sizeof(desc));
2271 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2272 if (FAILED(hr)) goto done;
2274 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2275 if (FAILED(hr)) goto done;
2277 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2278 if (SUCCEEDED(hr))
2280 vidmem = desc.DedicatedVideoMemory;
2281 name = desc.Description;
2284 done:
2285 rec = (struct record_videocontroller *)table->data;
2286 rec->adapter_dactype = videocontroller_dactypeW;
2287 rec->adapter_ram = vidmem;
2288 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2289 rec->current_horizontalres = hres;
2290 rec->current_verticalres = vres;
2291 rec->description = heap_strdupW( name );
2292 rec->device_id = videocontroller_deviceidW;
2293 rec->name = heap_strdupW( name );
2294 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2295 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2296 else row++;
2298 TRACE("created %u rows\n", row);
2299 table->num_rows = row;
2301 if (adapter) IDXGIAdapter_Release( adapter );
2302 if (factory) IDXGIFactory_Release( factory );
2303 return status;
2306 static struct table builtin_classes[] =
2308 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
2309 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
2310 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
2311 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
2312 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
2313 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
2314 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, SIZEOF(data_diskdrive), 0, (BYTE *)data_diskdrive },
2315 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
2316 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2317 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2318 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
2319 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL,
2320 fill_networkadapterconfig },
2321 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
2322 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
2323 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
2324 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
2325 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
2326 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2327 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
2328 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
2329 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
2330 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
2331 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
2334 void init_table_list( void )
2336 static struct list tables = LIST_INIT( tables );
2337 UINT i;
2339 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
2340 table_list = &tables;