[WBEMPROX]
[reactos.git] / reactos / dll / win32 / wbemprox / builtin.c
1 /*
2 * Copyright 2012 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 #include "wbemprox_private.h"
20
21 #include <wingdi.h>
22 #include <winsock2.h>
23 #include <ws2tcpip.h>
24 #include <iphlpapi.h>
25 #include <tlhelp32.h>
26 #include <winternl.h>
27 #include <winioctl.h>
28 #include <winver.h>
29 #include <ntsecapi.h>
30 #include <sddl.h>
31
32 #include <initguid.h>
33 #include <d3d10.h>
34
35 static const WCHAR class_baseboardW[] =
36 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
37 static const WCHAR class_biosW[] =
38 {'W','i','n','3','2','_','B','I','O','S',0};
39 static const WCHAR class_cdromdriveW[] =
40 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
41 static const WCHAR class_compsysW[] =
42 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
43 static const WCHAR class_compsysproductW[] =
44 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
45 static const WCHAR class_datafileW[] =
46 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
47 static const WCHAR class_directoryW[] =
48 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
49 static const WCHAR class_diskdriveW[] =
50 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
51 static const WCHAR class_diskpartitionW[] =
52 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
53 static const WCHAR class_logicaldiskW[] =
54 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
55 static const WCHAR class_logicaldisk2W[] =
56 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
57 static const WCHAR class_networkadapterW[] =
58 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
59 static const WCHAR class_networkadapterconfigW[] =
60 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
61 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
62 static const WCHAR class_osW[] =
63 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
64 static const WCHAR class_paramsW[] =
65 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
66 static const WCHAR class_physicalmediaW[] =
67 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
68 static const WCHAR class_physicalmemoryW[] =
69 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
70 static const WCHAR class_qualifiersW[] =
71 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
72 static const WCHAR class_process_getowner_outW[] =
73 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
74 'N','E','R','_','O','U','T',0};
75 static const WCHAR class_processorW[] =
76 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
77 static const WCHAR class_processor2W[] =
78 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
79 static const WCHAR class_sidW[] =
80 {'W','i','n','3','2','_','S','I','D',0};
81 static const WCHAR class_sounddeviceW[] =
82 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
83 static const WCHAR class_videocontrollerW[] =
84 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
85
86 static const WCHAR prop_accountnameW[] =
87 {'A','c','c','o','u','n','t','N','a','m','e',0};
88 static const WCHAR prop_acceptpauseW[] =
89 {'A','c','c','e','p','t','P','a','u','s','e',0};
90 static const WCHAR prop_acceptstopW[] =
91 {'A','c','c','e','p','t','S','t','o','p',0};
92 static const WCHAR prop_accessmaskW[] =
93 {'A','c','c','e','s','s','M','a','s','k',0};
94 static const WCHAR prop_adapterdactypeW[] =
95 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
96 static const WCHAR prop_adapterramW[] =
97 {'A','d','a','p','t','e','r','R','A','M',0};
98 static const WCHAR prop_adaptertypeW[] =
99 {'A','d','a','p','t','e','r','T','y','p','e',0};
100 static const WCHAR prop_addresswidthW[] =
101 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
102 static const WCHAR prop_availabilityW[] =
103 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
104 static const WCHAR prop_binaryrepresentationW[] =
105 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',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_currentclockspeedW[] =
131 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
132 static const WCHAR prop_currenthorizontalresW[] =
133 {'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};
134 static const WCHAR prop_currentverticalresW[] =
135 {'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};
136 static const WCHAR prop_defaultvalueW[] =
137 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
138 static const WCHAR prop_descriptionW[] =
139 {'D','e','s','c','r','i','p','t','i','o','n',0};
140 static const WCHAR prop_deviceidW[] =
141 {'D','e','v','i','c','e','I','d',0};
142 static const WCHAR prop_directionW[] =
143 {'D','i','r','e','c','t','i','o','n',0};
144 static const WCHAR prop_displaynameW[] =
145 {'D','i','s','p','l','a','y','N','a','m','e',0};
146 static const WCHAR prop_diskindexW[] =
147 {'D','i','s','k','I','n','d','e','x',0};
148 static const WCHAR prop_dnshostnameW[] =
149 {'D','N','S','H','o','s','t','N','a','m','e',0};
150 static const WCHAR prop_domainW[] =
151 {'D','o','m','a','i','n',0};
152 static const WCHAR prop_domainroleW[] =
153 {'D','o','m','a','i','n','R','o','l','e',0};
154 static const WCHAR prop_driveW[] =
155 {'D','r','i','v','e',0};
156 static const WCHAR prop_driverversionW[] =
157 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
158 static const WCHAR prop_drivetypeW[] =
159 {'D','r','i','v','e','T','y','p','e',0};
160 static const WCHAR prop_familyW[] =
161 {'F','a','m','i','l','y',0};
162 static const WCHAR prop_filesystemW[] =
163 {'F','i','l','e','S','y','s','t','e','m',0};
164 static const WCHAR prop_flavorW[] =
165 {'F','l','a','v','o','r',0};
166 static const WCHAR prop_freespaceW[] =
167 {'F','r','e','e','S','p','a','c','e',0};
168 static const WCHAR prop_handleW[] =
169 {'H','a','n','d','l','e',0};
170 static const WCHAR prop_idW[] =
171 {'I','D',0};
172 static const WCHAR prop_identificationcodeW[] =
173 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
174 static const WCHAR prop_identifyingnumberW[] =
175 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
176 static const WCHAR prop_indexW[] =
177 {'I','n','d','e','x',0};
178 static const WCHAR prop_installdateW[] =
179 {'I','n','s','t','a','l','l','D','a','t','e',0};
180 static const WCHAR prop_interfaceindexW[] =
181 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
182 static const WCHAR prop_interfacetypeW[] =
183 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
184 static const WCHAR prop_intvalueW[] =
185 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
186 static const WCHAR prop_ipconnectionmetricW[] =
187 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
188 static const WCHAR prop_ipenabledW[] =
189 {'I','P','E','n','a','b','l','e','d',0};
190 static const WCHAR prop_lastbootuptimeW[] =
191 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
192 static const WCHAR prop_localdatetimeW[] =
193 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
194 static const WCHAR prop_localeW[] =
195 {'L','o','c','a','l','e',0};
196 static const WCHAR prop_macaddressW[] =
197 {'M','A','C','A','d','d','r','e','s','s',0};
198 static const WCHAR prop_manufacturerW[] =
199 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
200 static const WCHAR prop_maxclockspeedW[] =
201 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
202 static const WCHAR prop_mediatypeW[] =
203 {'M','e','d','i','a','T','y','p','e',0};
204 static const WCHAR prop_memberW[] =
205 {'M','e','m','b','e','r',0};
206 static const WCHAR prop_methodW[] =
207 {'M','e','t','h','o','d',0};
208 static const WCHAR prop_modelW[] =
209 {'M','o','d','e','l',0};
210 static const WCHAR prop_netconnectionstatusW[] =
211 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
212 static const WCHAR prop_numcoresW[] =
213 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
214 static const WCHAR prop_numlogicalprocessorsW[] =
215 {'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};
216 static const WCHAR prop_numprocessorsW[] =
217 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
218 static const WCHAR prop_osarchitectureW[] =
219 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
220 static const WCHAR prop_oslanguageW[] =
221 {'O','S','L','a','n','g','u','a','g','e',0};
222 static const WCHAR prop_osproductsuiteW[] =
223 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
224 static const WCHAR prop_ostypeW[] =
225 {'O','S','T','y','p','e',0};
226 static const WCHAR prop_parameterW[] =
227 {'P','a','r','a','m','e','t','e','r',0};
228 static const WCHAR prop_physicaladapterW[] =
229 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
230 static const WCHAR prop_pnpdeviceidW[] =
231 {'P','N','P','D','e','v','i','c','e','I','D',0};
232 static const WCHAR prop_pprocessidW[] =
233 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
234 static const WCHAR prop_processidW[] =
235 {'P','r','o','c','e','s','s','I','D',0};
236 static const WCHAR prop_processoridW[] =
237 {'P','r','o','c','e','s','s','o','r','I','d',0};
238 static const WCHAR prop_processortypeW[] =
239 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
240 static const WCHAR prop_productW[] =
241 {'P','r','o','d','u','c','t',0};
242 static const WCHAR prop_productnameW[] =
243 {'P','r','o','d','u','c','t','N','a','m','e',0};
244 static const WCHAR prop_referenceddomainnameW[] =
245 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
246 static const WCHAR prop_releasedateW[] =
247 {'R','e','l','e','a','s','e','D','a','t','e',0};
248 static const WCHAR prop_serialnumberW[] =
249 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
250 static const WCHAR prop_servicepackmajorW[] =
251 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
252 static const WCHAR prop_servicepackminorW[] =
253 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
254 static const WCHAR prop_servicetypeW[] =
255 {'S','e','r','v','i','c','e','T','y','p','e',0};
256 static const WCHAR prop_smbiosbiosversionW[] =
257 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
258 static const WCHAR prop_startmodeW[] =
259 {'S','t','a','r','t','M','o','d','e',0};
260 static const WCHAR prop_sidW[] =
261 {'S','I','D',0};
262 static const WCHAR prop_sidlengthW[] =
263 {'S','i','d','L','e','n','g','t','h',0};
264 static const WCHAR prop_sizeW[] =
265 {'S','i','z','e',0};
266 static const WCHAR prop_speedW[] =
267 {'S','p','e','e','d',0};
268 static const WCHAR prop_startingoffsetW[] =
269 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
270 static const WCHAR prop_stateW[] =
271 {'S','t','a','t','e',0};
272 static const WCHAR prop_statusinfoW[] =
273 {'S','t','a','t','u','s','I','n','f','o',0};
274 static const WCHAR prop_strvalueW[] =
275 {'S','t','r','i','n','g','V','a','l','u','e',0};
276 static const WCHAR prop_suitemaskW[] =
277 {'S','u','i','t','e','M','a','s','k',0};
278 static const WCHAR prop_systemdirectoryW[] =
279 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
280 static const WCHAR prop_systemnameW[] =
281 {'S','y','s','t','e','m','N','a','m','e',0};
282 static const WCHAR prop_tagW[] =
283 {'T','a','g',0};
284 static const WCHAR prop_threadcountW[] =
285 {'T','h','r','e','a','d','C','o','u','n','t',0};
286 static const WCHAR prop_totalphysicalmemoryW[] =
287 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
288 static const WCHAR prop_totalvisiblememorysizeW[] =
289 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
290 static const WCHAR prop_typeW[] =
291 {'T','y','p','e',0};
292 static const WCHAR prop_uniqueidW[] =
293 {'U','n','i','q','u','e','I','d',0};
294 static const WCHAR prop_usernameW[] =
295 {'U','s','e','r','N','a','m','e',0};
296 static const WCHAR prop_uuidW[] =
297 {'U','U','I','D',0};
298 static const WCHAR prop_varianttypeW[] =
299 {'V','a','r','i','a','n','t','T','y','p','e',0};
300 static const WCHAR prop_versionW[] =
301 {'V','e','r','s','i','o','n',0};
302 static const WCHAR prop_videoprocessorW[] =
303 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
304 static const WCHAR prop_volumenameW[] =
305 {'V','o','l','u','m','e','N','a','m','e',0};
306 static const WCHAR prop_volumeserialnumberW[] =
307 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
308
309 /* column definitions must be kept in sync with record structures below */
310 static const struct column col_baseboard[] =
311 {
312 { prop_manufacturerW, CIM_STRING },
313 { prop_modelW, CIM_STRING },
314 { prop_nameW, CIM_STRING },
315 { prop_productW, CIM_STRING },
316 { prop_serialnumberW, CIM_STRING },
317 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
318 { prop_versionW, CIM_STRING }
319 };
320 static const struct column col_bios[] =
321 {
322 { prop_descriptionW, CIM_STRING },
323 { prop_identificationcodeW, CIM_STRING },
324 { prop_manufacturerW, CIM_STRING },
325 { prop_releasedateW, CIM_DATETIME },
326 { prop_serialnumberW, CIM_STRING },
327 { prop_smbiosbiosversionW, CIM_STRING },
328 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
329 };
330 static const struct column col_cdromdrive[] =
331 {
332 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
333 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
334 { prop_mediatypeW, CIM_STRING },
335 { prop_nameW, CIM_STRING },
336 { prop_pnpdeviceidW, CIM_STRING }
337 };
338 static const struct column col_compsys[] =
339 {
340 { prop_descriptionW, CIM_STRING },
341 { prop_domainW, CIM_STRING },
342 { prop_domainroleW, CIM_UINT16, VT_I4 },
343 { prop_manufacturerW, CIM_STRING },
344 { prop_modelW, CIM_STRING },
345 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
346 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
347 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
348 { prop_totalphysicalmemoryW, CIM_UINT64 },
349 { prop_usernameW, CIM_STRING }
350 };
351 static const struct column col_compsysproduct[] =
352 {
353 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
354 { prop_uuidW, CIM_STRING }
355 };
356 static const struct column col_datafile[] =
357 {
358 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
359 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
360 };
361 static const struct column col_directory[] =
362 {
363 { prop_accessmaskW, CIM_UINT32 },
364 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
365 };
366 static const struct column col_diskdrive[] =
367 {
368 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
369 { prop_indexW, CIM_UINT32, VT_I4 },
370 { prop_interfacetypeW, CIM_STRING },
371 { prop_manufacturerW, CIM_STRING },
372 { prop_mediatypeW, CIM_STRING },
373 { prop_modelW, CIM_STRING },
374 { prop_pnpdeviceidW, CIM_STRING },
375 { prop_serialnumberW, CIM_STRING },
376 { prop_sizeW, CIM_UINT64 }
377 };
378 static const struct column col_diskpartition[] =
379 {
380 { prop_bootableW, CIM_BOOLEAN },
381 { prop_bootpartitionW, CIM_BOOLEAN },
382 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
383 { prop_diskindexW, CIM_UINT32, VT_I4 },
384 { prop_indexW, CIM_UINT32, VT_I4 },
385 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
386 { prop_sizeW, CIM_UINT64 },
387 { prop_startingoffsetW, CIM_UINT64 },
388 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
389 };
390 static const struct column col_logicaldisk[] =
391 {
392 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
393 { prop_drivetypeW, CIM_UINT32, VT_I4 },
394 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
395 { prop_freespaceW, CIM_UINT64 },
396 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
397 { prop_sizeW, CIM_UINT64 },
398 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
399 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
400 };
401 static const struct column col_networkadapter[] =
402 {
403 { prop_adaptertypeW, CIM_STRING },
404 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
405 { prop_indexW, CIM_UINT32, VT_I4 },
406 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
407 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
408 { prop_manufacturerW, CIM_STRING },
409 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
410 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
411 { prop_physicaladapterW, CIM_BOOLEAN },
412 { prop_pnpdeviceidW, CIM_STRING },
413 { prop_speedW, CIM_UINT64 }
414 };
415 static const struct column col_networkadapterconfig[] =
416 {
417 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
418 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
419 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
420 { prop_ipenabledW, CIM_BOOLEAN },
421 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }
422 };
423 static const struct column col_os[] =
424 {
425 { prop_buildnumberW, CIM_STRING },
426 { prop_captionW, CIM_STRING },
427 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
428 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
429 { prop_csdversionW, CIM_STRING },
430 { prop_installdateW, CIM_DATETIME },
431 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
432 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
433 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
434 { prop_nameW, CIM_STRING },
435 { prop_osarchitectureW, CIM_STRING },
436 { prop_oslanguageW, CIM_UINT32, VT_I4 },
437 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
438 { prop_ostypeW, CIM_UINT16, VT_I4 },
439 { prop_serialnumberW, CIM_STRING },
440 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
441 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
442 { prop_suitemaskW, CIM_UINT32, VT_I4 },
443 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
444 { prop_totalvisiblememorysizeW, CIM_UINT64 },
445 { prop_versionW, CIM_STRING }
446 };
447 static const struct column col_param[] =
448 {
449 { prop_classW, CIM_STRING },
450 { prop_methodW, CIM_STRING },
451 { prop_directionW, CIM_SINT32 },
452 { prop_parameterW, CIM_STRING },
453 { prop_typeW, CIM_UINT32 },
454 { prop_varianttypeW, CIM_UINT32 },
455 { prop_defaultvalueW, CIM_UINT32 }
456 };
457 static const struct column col_physicalmedia[] =
458 {
459 { prop_serialnumberW, CIM_STRING },
460 { prop_tagW, CIM_STRING }
461 };
462 static const struct column col_physicalmemory[] =
463 {
464 { prop_capacityW, CIM_UINT64 }
465 };
466 static const struct column col_process[] =
467 {
468 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
469 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
470 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
471 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
472 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
473 { prop_pprocessidW, CIM_UINT32, VT_I4 },
474 { prop_processidW, CIM_UINT32, VT_I4 },
475 { prop_threadcountW, CIM_UINT32, VT_I4 },
476 /* methods */
477 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
478 };
479 static const struct column col_processor[] =
480 {
481 { prop_addresswidthW, CIM_UINT16, VT_I4 },
482 { prop_cpustatusW, CIM_UINT16 },
483 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
484 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
485 { prop_familyW, CIM_UINT16, VT_I4 },
486 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
487 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
488 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
489 { prop_numcoresW, CIM_UINT32, VT_I4 },
490 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
491 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
492 { prop_processortypeW, CIM_UINT16, VT_I4 },
493 { prop_uniqueidW, CIM_STRING }
494 };
495 static const struct column col_qualifier[] =
496 {
497 { prop_classW, CIM_STRING },
498 { prop_memberW, CIM_STRING },
499 { prop_typeW, CIM_UINT32 },
500 { prop_flavorW, CIM_SINT32 },
501 { prop_nameW, CIM_STRING },
502 { prop_intvalueW, CIM_SINT32 },
503 { prop_strvalueW, CIM_STRING }
504 };
505 static const struct column col_service[] =
506 {
507 { prop_acceptpauseW, CIM_BOOLEAN },
508 { prop_acceptstopW, CIM_BOOLEAN },
509 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
510 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
511 { prop_processidW, CIM_UINT32 },
512 { prop_servicetypeW, CIM_STRING },
513 { prop_startmodeW, CIM_STRING },
514 { prop_stateW, CIM_STRING },
515 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
516 /* methods */
517 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
518 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
519 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
520 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
521 };
522 static const struct column col_sid[] =
523 {
524 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
525 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
526 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
527 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
528 { prop_sidlengthW, CIM_UINT32 }
529 };
530 static const struct column col_sounddevice[] =
531 {
532 { prop_nameW, CIM_STRING },
533 { prop_productnameW, CIM_STRING },
534 { prop_statusinfoW, CIM_UINT16, VT_I4 }
535 };
536 static const struct column col_stdregprov[] =
537 {
538 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
539 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
540 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
541 };
542 static const struct column col_systemsecurity[] =
543 {
544 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
545 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
546 };
547 static const struct column col_videocontroller[] =
548 {
549 { prop_adapterdactypeW, CIM_STRING },
550 { prop_adapterramW, CIM_UINT32, VT_I4 },
551 { prop_availabilityW, CIM_UINT16 },
552 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
553 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
554 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
555 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
556 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
557 { prop_driverversionW, CIM_STRING },
558 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
559 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
560 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC }
561 };
562
563 static const WCHAR baseboard_manufacturerW[] =
564 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
565 static const WCHAR baseboard_serialnumberW[] =
566 {'N','o','n','e',0};
567 static const WCHAR baseboard_tagW[] =
568 {'B','a','s','e',' ','B','o','a','r','d',0};
569 static const WCHAR baseboard_versionW[] =
570 {'1','.','0',0};
571 static const WCHAR bios_descriptionW[] =
572 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
573 static const WCHAR bios_manufacturerW[] =
574 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
575 static const WCHAR bios_releasedateW[] =
576 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
577 static const WCHAR bios_serialnumberW[] =
578 {'0',0};
579 static const WCHAR bios_smbiosbiosversionW[] =
580 {'W','i','n','e',0};
581 static const WCHAR bios_versionW[] =
582 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
583 static const WCHAR cdromdrive_mediatypeW[] =
584 {'C','D','-','R','O','M',0};
585 static const WCHAR cdromdrive_nameW[] =
586 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
587 static const WCHAR cdromdrive_pnpdeviceidW[]=
588 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
589 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
590 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
591 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
592 static const WCHAR compsys_descriptionW[] =
593 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
594 static const WCHAR compsys_domainW[] =
595 {'W','O','R','K','G','R','O','U','P',0};
596 static const WCHAR compsys_manufacturerW[] =
597 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
598 static const WCHAR compsys_modelW[] =
599 {'W','i','n','e',0};
600 static const WCHAR compsysproduct_identifyingnumberW[] =
601 {'0',0};
602 static const WCHAR compsysproduct_uuidW[] =
603 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
604 '0','0','0','0','0','0','0','0','0','0','0','0',0};
605 static const WCHAR diskdrive_interfacetypeW[] =
606 {'I','D','E',0};
607 static const WCHAR diskdrive_manufacturerW[] =
608 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
609 static const WCHAR diskdrive_mediatype_fixedW[] =
610 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
611 static const WCHAR diskdrive_mediatype_removableW[] =
612 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
613 static const WCHAR diskdrive_modelW[] =
614 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
615 static const WCHAR diskdrive_pnpdeviceidW[] =
616 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
617 static const WCHAR diskdrive_serialW[] =
618 {'W','I','N','E','H','D','I','S','K',0};
619 static const WCHAR networkadapter_pnpdeviceidW[]=
620 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
621 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
622 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
623 static const WCHAR os_32bitW[] =
624 {'3','2','-','b','i','t',0};
625 static const WCHAR os_64bitW[] =
626 {'6','4','-','b','i','t',0};
627 static const WCHAR os_buildnumberW[] =
628 {'2','6','0','0',0};
629 static const WCHAR os_captionW[] =
630 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
631 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
632 static const WCHAR os_csdversionW[] =
633 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
634 static const WCHAR os_installdateW[] =
635 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
636 static const WCHAR os_nameW[] =
637 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
638 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
639 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
640 '\\','P','a','r','t','i','t','i','o','n','1',0};
641 static const WCHAR os_serialnumberW[] =
642 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
643 static const WCHAR os_versionW[] =
644 {'5','.','1','.','2','6','0','0',0};
645 static const WCHAR physicalmedia_tagW[] =
646 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
647 static const WCHAR sounddevice_productnameW[] =
648 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
649 static const WCHAR videocontroller_dactypeW[] =
650 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
651 static const WCHAR videocontroller_deviceidW[] =
652 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
653 static const WCHAR videocontroller_driverversionW[] =
654 {'1','.','0',0};
655
656 #include "pshpack1.h"
657 struct record_baseboard
658 {
659 const WCHAR *manufacturer;
660 const WCHAR *model;
661 const WCHAR *name;
662 const WCHAR *product;
663 const WCHAR *serialnumber;
664 const WCHAR *tag;
665 const WCHAR *version;
666 };
667 struct record_bios
668 {
669 const WCHAR *description;
670 const WCHAR *identificationcode;
671 const WCHAR *manufacturer;
672 const WCHAR *releasedate;
673 const WCHAR *serialnumber;
674 const WCHAR *smbiosbiosversion;
675 const WCHAR *version;
676 };
677 struct record_cdromdrive
678 {
679 const WCHAR *device_id;
680 const WCHAR *drive;
681 const WCHAR *mediatype;
682 const WCHAR *name;
683 const WCHAR *pnpdevice_id;
684 };
685 struct record_computersystem
686 {
687 const WCHAR *description;
688 const WCHAR *domain;
689 UINT16 domainrole;
690 const WCHAR *manufacturer;
691 const WCHAR *model;
692 const WCHAR *name;
693 UINT32 num_logical_processors;
694 UINT32 num_processors;
695 UINT64 total_physical_memory;
696 const WCHAR *username;
697 };
698 struct record_computersystemproduct
699 {
700 const WCHAR *identifyingnumber;
701 const WCHAR *uuid;
702 };
703 struct record_datafile
704 {
705 const WCHAR *name;
706 const WCHAR *version;
707 };
708 struct record_directory
709 {
710 UINT32 accessmask;
711 const WCHAR *name;
712 };
713 struct record_diskdrive
714 {
715 const WCHAR *device_id;
716 UINT32 index;
717 const WCHAR *interfacetype;
718 const WCHAR *manufacturer;
719 const WCHAR *mediatype;
720 const WCHAR *model;
721 const WCHAR *pnpdevice_id;
722 const WCHAR *serialnumber;
723 UINT64 size;
724 };
725 struct record_diskpartition
726 {
727 int bootable;
728 int bootpartition;
729 const WCHAR *device_id;
730 UINT32 diskindex;
731 UINT32 index;
732 const WCHAR *pnpdevice_id;
733 UINT64 size;
734 UINT64 startingoffset;
735 const WCHAR *type;
736 };
737 struct record_logicaldisk
738 {
739 const WCHAR *device_id;
740 UINT32 drivetype;
741 const WCHAR *filesystem;
742 UINT64 freespace;
743 const WCHAR *name;
744 UINT64 size;
745 const WCHAR *volumename;
746 const WCHAR *volumeserialnumber;
747 };
748 struct record_networkadapter
749 {
750 const WCHAR *adaptertype;
751 const WCHAR *device_id;
752 UINT32 index;
753 UINT32 interface_index;
754 const WCHAR *mac_address;
755 const WCHAR *manufacturer;
756 const WCHAR *name;
757 UINT16 netconnection_status;
758 int physicaladapter;
759 const WCHAR *pnpdevice_id;
760 UINT64 speed;
761 };
762 struct record_networkadapterconfig
763 {
764 const WCHAR *dnshostname;
765 UINT32 index;
766 UINT32 ipconnectionmetric;
767 int ipenabled;
768 const WCHAR *mac_address;
769 };
770 struct record_operatingsystem
771 {
772 const WCHAR *buildnumber;
773 const WCHAR *caption;
774 const WCHAR *codeset;
775 const WCHAR *countrycode;
776 const WCHAR *csdversion;
777 const WCHAR *installdate;
778 const WCHAR *lastbootuptime;
779 const WCHAR *localdatetime;
780 const WCHAR *locale;
781 const WCHAR *name;
782 const WCHAR *osarchitecture;
783 UINT32 oslanguage;
784 UINT32 osproductsuite;
785 UINT16 ostype;
786 const WCHAR *serialnumber;
787 UINT16 servicepackmajor;
788 UINT16 servicepackminor;
789 UINT32 suitemask;
790 const WCHAR *systemdirectory;
791 UINT64 totalvisiblememorysize;
792 const WCHAR *version;
793 };
794 struct record_param
795 {
796 const WCHAR *class;
797 const WCHAR *method;
798 INT32 direction;
799 const WCHAR *parameter;
800 UINT32 type;
801 UINT32 varianttype;
802 UINT32 defaultvalue;
803 };
804 struct record_physicalmedia
805 {
806 const WCHAR *serialnumber;
807 const WCHAR *tag;
808 };
809 struct record_physicalmemory
810 {
811 UINT64 capacity;
812 };
813 struct record_process
814 {
815 const WCHAR *caption;
816 const WCHAR *commandline;
817 const WCHAR *description;
818 const WCHAR *handle;
819 const WCHAR *name;
820 UINT32 pprocess_id;
821 UINT32 process_id;
822 UINT32 thread_count;
823 /* methods */
824 class_method *get_owner;
825 };
826 struct record_processor
827 {
828 UINT16 addresswidth;
829 UINT16 cpu_status;
830 UINT32 currentclockspeed;
831 const WCHAR *device_id;
832 UINT16 family;
833 const WCHAR *manufacturer;
834 UINT32 maxclockspeed;
835 const WCHAR *name;
836 UINT32 num_cores;
837 UINT32 num_logical_processors;
838 const WCHAR *processor_id;
839 UINT16 processortype;
840 const WCHAR *unique_id;
841 };
842 struct record_qualifier
843 {
844 const WCHAR *class;
845 const WCHAR *member;
846 UINT32 type;
847 INT32 flavor;
848 const WCHAR *name;
849 INT32 intvalue;
850 const WCHAR *strvalue;
851 };
852 struct record_service
853 {
854 int accept_pause;
855 int accept_stop;
856 const WCHAR *displayname;
857 const WCHAR *name;
858 UINT32 process_id;
859 const WCHAR *servicetype;
860 const WCHAR *startmode;
861 const WCHAR *state;
862 const WCHAR *systemname;
863 /* methods */
864 class_method *pause_service;
865 class_method *resume_service;
866 class_method *start_service;
867 class_method *stop_service;
868 };
869 struct record_sid
870 {
871 const WCHAR *accountname;
872 const UINT8 *binaryrepresentation;
873 const WCHAR *referenceddomainname;
874 const WCHAR *sid;
875 UINT32 sidlength;
876 };
877 struct record_sounddevice
878 {
879 const WCHAR *name;
880 const WCHAR *productname;
881 UINT16 statusinfo;
882 };
883 struct record_stdregprov
884 {
885 class_method *enumkey;
886 class_method *enumvalues;
887 class_method *getstringvalue;
888 };
889 struct record_systemsecurity
890 {
891 class_method *getsd;
892 class_method *setsd;
893 };
894 struct record_videocontroller
895 {
896 const WCHAR *adapter_dactype;
897 UINT32 adapter_ram;
898 UINT16 availability;
899 UINT32 current_bitsperpixel;
900 UINT32 current_horizontalres;
901 UINT32 current_verticalres;
902 const WCHAR *description;
903 const WCHAR *device_id;
904 const WCHAR *driverversion;
905 const WCHAR *name;
906 const WCHAR *pnpdevice_id;
907 const WCHAR *videoprocessor;
908 };
909 #include "poppack.h"
910
911 static const struct record_baseboard data_baseboard[] =
912 {
913 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
914 };
915 static const struct record_bios data_bios[] =
916 {
917 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW,
918 bios_smbiosbiosversionW, bios_versionW }
919 };
920 static const struct record_computersystemproduct data_compsysproduct[] =
921 {
922 { compsysproduct_identifyingnumberW, compsysproduct_uuidW }
923 };
924 static const struct record_param data_param[] =
925 {
926 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
927 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
928 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
929 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
930 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
931 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
932 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
933 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
934 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
935 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
936 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
937 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
938 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
939 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
940 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
941 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
942 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
943 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
944 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
945 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
946 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
947 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
948 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
949 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
950 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
951 };
952
953 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
954 WBEM_FLAVOR_ORIGIN_PROPAGATED)
955
956 static const struct record_physicalmedia data_physicalmedia[] =
957 {
958 { diskdrive_serialW, physicalmedia_tagW }
959 };
960 static const struct record_qualifier data_qualifier[] =
961 {
962 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
963 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
964 };
965 static const struct record_sounddevice data_sounddevice[] =
966 {
967 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
968 };
969 static const struct record_stdregprov data_stdregprov[] =
970 {
971 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
972 };
973 static const struct record_systemsecurity data_systemsecurity[] =
974 {
975 { security_get_sd, security_set_sd }
976 };
977
978 /* check if row matches condition and update status */
979 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
980 {
981 LONGLONG val;
982 UINT type;
983
984 if (!cond)
985 {
986 *status = FILL_STATUS_UNFILTERED;
987 return TRUE;
988 }
989 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
990 {
991 *status = FILL_STATUS_FAILED;
992 return FALSE;
993 }
994 *status = FILL_STATUS_FILTERED;
995 return val != 0;
996 }
997
998 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
999 {
1000 if (!table->num_rows_allocated)
1001 {
1002 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1003 table->num_rows_allocated = row_count;
1004 return TRUE;
1005 }
1006 if (row_count >= table->num_rows_allocated)
1007 {
1008 BYTE *data;
1009 UINT count = table->num_rows_allocated * 2;
1010 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1011 table->data = data;
1012 table->num_rows_allocated = count;
1013 }
1014 return TRUE;
1015 }
1016
1017 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1018 {
1019 static const WCHAR fmtW[] = {'%','c',':',0};
1020 WCHAR drive[3], root[] = {'A',':','\\',0};
1021 struct record_cdromdrive *rec;
1022 UINT i, row = 0, offset = 0;
1023 DWORD drives = GetLogicalDrives();
1024 enum fill_status status = FILL_STATUS_UNFILTERED;
1025
1026 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1027
1028 for (i = 0; i < sizeof(drives); i++)
1029 {
1030 if (drives & (1 << i))
1031 {
1032 root[0] = 'A' + i;
1033 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1034 continue;
1035
1036 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1037
1038 rec = (struct record_cdromdrive *)(table->data + offset);
1039 rec->device_id = cdromdrive_pnpdeviceidW;
1040 sprintfW( drive, fmtW, 'A' + i );
1041 rec->drive = heap_strdupW( drive );
1042 rec->mediatype = cdromdrive_mediatypeW;
1043 rec->name = cdromdrive_nameW;
1044 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1045 if (!match_row( table, row, cond, &status ))
1046 {
1047 free_row_values( table, row );
1048 continue;
1049 }
1050 offset += sizeof(*rec);
1051 row++;
1052 }
1053 }
1054 TRACE("created %u rows\n", row);
1055 table->num_rows = row;
1056 return status;
1057 }
1058
1059 static UINT get_processor_count(void)
1060 {
1061 SYSTEM_BASIC_INFORMATION info;
1062
1063 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1064 return info.NumberOfProcessors;
1065 }
1066
1067 static UINT get_logical_processor_count( UINT *num_cores )
1068 {
1069 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1070 UINT i, j, count = 0;
1071 NTSTATUS status;
1072 ULONG len;
1073
1074 if (num_cores) *num_cores = get_processor_count();
1075 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1076 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1077
1078 if (!(info = heap_alloc( len ))) return get_processor_count();
1079 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1080 if (status != STATUS_SUCCESS)
1081 {
1082 heap_free( info );
1083 return get_processor_count();
1084 }
1085 if (num_cores) *num_cores = 0;
1086 for (i = 0; i < len / sizeof(*info); i++)
1087 {
1088 if (info[i].Relationship == RelationProcessorCore)
1089 {
1090 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1091 }
1092 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1093 {
1094 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1095 }
1096 }
1097 heap_free( info );
1098 return count;
1099 }
1100
1101 static UINT64 get_total_physical_memory(void)
1102 {
1103 MEMORYSTATUSEX status;
1104
1105 status.dwLength = sizeof(status);
1106 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1107 return status.ullTotalPhys;
1108 }
1109
1110 static WCHAR *get_computername(void)
1111 {
1112 WCHAR *ret;
1113 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1114
1115 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1116 GetComputerNameW( ret, &size );
1117 return ret;
1118 }
1119
1120 static WCHAR *get_username(void)
1121 {
1122 WCHAR *ret;
1123 DWORD compsize, usersize;
1124 DWORD size;
1125
1126 compsize = 0;
1127 GetComputerNameW( NULL, &compsize );
1128 usersize = 0;
1129 GetUserNameW( NULL, &usersize );
1130 size = compsize + usersize; /* two null terminators account for the \ */
1131 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1132 GetComputerNameW( ret, &compsize );
1133 ret[compsize] = '\\';
1134 GetUserNameW( ret + compsize + 1, &usersize );
1135 return ret;
1136 }
1137
1138 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1139 {
1140 struct record_computersystem *rec;
1141 enum fill_status status = FILL_STATUS_UNFILTERED;
1142 UINT row = 0;
1143
1144 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1145
1146 rec = (struct record_computersystem *)table->data;
1147 rec->description = compsys_descriptionW;
1148 rec->domain = compsys_domainW;
1149 rec->domainrole = 0; /* standalone workstation */
1150 rec->manufacturer = compsys_manufacturerW;
1151 rec->model = compsys_modelW;
1152 rec->name = get_computername();
1153 rec->num_logical_processors = get_logical_processor_count( NULL );
1154 rec->num_processors = get_processor_count();
1155 rec->total_physical_memory = get_total_physical_memory();
1156 rec->username = get_username();
1157 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1158 else row++;
1159
1160 TRACE("created %u rows\n", row);
1161 table->num_rows = row;
1162 return status;
1163 }
1164
1165 struct dirstack
1166 {
1167 WCHAR **dirs;
1168 UINT *len_dirs;
1169 UINT num_dirs;
1170 UINT num_allocated;
1171 };
1172
1173 static struct dirstack *alloc_dirstack( UINT size )
1174 {
1175 struct dirstack *dirstack;
1176
1177 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1178 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1179 {
1180 heap_free( dirstack );
1181 return NULL;
1182 }
1183 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1184 {
1185 heap_free( dirstack->dirs );
1186 heap_free( dirstack );
1187 return NULL;
1188 }
1189 dirstack->num_dirs = 0;
1190 dirstack->num_allocated = size;
1191 return dirstack;
1192 }
1193
1194 static void clear_dirstack( struct dirstack *dirstack )
1195 {
1196 UINT i;
1197 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1198 dirstack->num_dirs = 0;
1199 }
1200
1201 static void free_dirstack( struct dirstack *dirstack )
1202 {
1203 clear_dirstack( dirstack );
1204 heap_free( dirstack->dirs );
1205 heap_free( dirstack->len_dirs );
1206 heap_free( dirstack );
1207 }
1208
1209 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1210 {
1211 UINT size, i = dirstack->num_dirs;
1212
1213 if (!dir) return FALSE;
1214
1215 if (i == dirstack->num_allocated)
1216 {
1217 WCHAR **tmp;
1218 UINT *len_tmp;
1219
1220 size = dirstack->num_allocated * 2;
1221 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1222 dirstack->dirs = tmp;
1223 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1224 dirstack->len_dirs = len_tmp;
1225 dirstack->num_allocated = size;
1226 }
1227 dirstack->dirs[i] = dir;
1228 dirstack->len_dirs[i] = len;
1229 dirstack->num_dirs++;
1230 return TRUE;
1231 }
1232
1233 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1234 {
1235 if (!dirstack->num_dirs)
1236 {
1237 *len = 0;
1238 return NULL;
1239 }
1240 dirstack->num_dirs--;
1241 *len = dirstack->len_dirs[dirstack->num_dirs];
1242 return dirstack->dirs[dirstack->num_dirs];
1243 }
1244
1245 static const WCHAR *peek_dir( struct dirstack *dirstack )
1246 {
1247 if (!dirstack->num_dirs) return NULL;
1248 return dirstack->dirs[dirstack->num_dirs - 1];
1249 }
1250
1251 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1252 {
1253 UINT i = 0;
1254 WCHAR *ret;
1255
1256 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1257 ret[i++] = drive;
1258 ret[i++] = ':';
1259 ret[i++] = '\\';
1260 if (path && len)
1261 {
1262 memcpy( ret + i, path, len * sizeof(WCHAR) );
1263 i += len;
1264 ret[i++] = '\\';
1265 }
1266 ret[i++] = '*';
1267 ret[i] = 0;
1268 return ret;
1269 }
1270
1271 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1272 {
1273 UINT i = 0, len = 0;
1274 const WCHAR *p;
1275 WCHAR *ret;
1276
1277 for (p = path; *p; p++)
1278 {
1279 if (*p == '\\') len += 2;
1280 else len++;
1281 };
1282 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1283 ret[i++] = drive;
1284 ret[i++] = ':';
1285 ret[i++] = '\\';
1286 ret[i++] = '\\';
1287 for (p = path; *p; p++)
1288 {
1289 if (*p != '\\') ret[i++] = *p;
1290 else
1291 {
1292 ret[i++] = '\\';
1293 ret[i++] = '\\';
1294 }
1295 }
1296 ret[i] = 0;
1297 return ret;
1298 }
1299
1300 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1301 {
1302 const WCHAR *p = path, *start;
1303 UINT len, i;
1304 WCHAR *ret;
1305
1306 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1307 start = path + 4;
1308 len = strlenW( start );
1309 p = start + len - 1;
1310 if (*p == '\\') return NULL;
1311
1312 while (p >= start && *p != '\\') { len--; p--; };
1313 while (p >= start && *p == '\\') { len--; p--; };
1314
1315 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1316 for (i = 0, p = start; p < start + len; p++)
1317 {
1318 if (p[0] == '\\' && p[1] == '\\')
1319 {
1320 ret[i++] = '\\';
1321 p++;
1322 }
1323 else ret[i++] = *p;
1324 }
1325 ret[i] = 0;
1326 *ret_len = i;
1327 return ret;
1328 }
1329
1330 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1331 {
1332 UINT i;
1333 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1334 return FALSE;
1335 }
1336
1337 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1338 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1339 {
1340 const struct expr *left, *right;
1341
1342 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1343
1344 left = cond->u.expr.left;
1345 right = cond->u.expr.right;
1346 if (cond->u.expr.op == OP_EQ)
1347 {
1348 UINT len;
1349 WCHAR *path;
1350 const WCHAR *str = NULL;
1351
1352 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1353 !strcmpW( left->u.propval->name, prop_nameW ) &&
1354 toupperW( right->u.sval[0] ) == toupperW( root ))
1355 {
1356 str = right->u.sval;
1357 }
1358 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1359 !strcmpW( right->u.propval->name, prop_nameW ) &&
1360 toupperW( left->u.sval[0] ) == toupperW( root ))
1361 {
1362 str = left->u.sval;
1363 }
1364 if (str && (path = build_dirname( str, &len )))
1365 {
1366 if (seen_dir( dirstack, path ))
1367 {
1368 heap_free( path );
1369 return ++*count;
1370 }
1371 else if (push_dir( dirstack, path, len )) return ++*count;
1372 heap_free( path );
1373 return *count = 0;
1374 }
1375 }
1376 else if (cond->u.expr.op == OP_OR)
1377 {
1378 UINT left_count = 0, right_count = 0;
1379
1380 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1381 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1382 return *count += left_count + right_count;
1383 }
1384 return *count = 0;
1385 }
1386
1387 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1388 {
1389 UINT len_path = 0, len_segment = strlenW( segment );
1390 WCHAR *ret;
1391
1392 *len = 0;
1393 if (path) len_path = strlenW( path );
1394 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1395 if (path && len_path)
1396 {
1397 memcpy( ret, path, len_path * sizeof(WCHAR) );
1398 ret[len_path] = '\\';
1399 *len += len_path + 1;
1400 }
1401 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1402 *len += len_segment;
1403 ret[*len] = 0;
1404 return ret;
1405 }
1406
1407 static WCHAR *get_file_version( const WCHAR *filename )
1408 {
1409 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1410 VS_FIXEDFILEINFO *info;
1411 DWORD size;
1412 void *block;
1413 WCHAR *ret;
1414
1415 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1416 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1417 {
1418 heap_free( ret );
1419 return NULL;
1420 }
1421 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1422 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1423 {
1424 heap_free( block );
1425 heap_free( ret );
1426 return NULL;
1427 }
1428 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1429 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1430 heap_free( block );
1431 return ret;
1432 }
1433
1434 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1435 {
1436 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1437 struct record_datafile *rec;
1438 UINT i, len, row = 0, offset = 0, num_expected_rows;
1439 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1440 DWORD drives = GetLogicalDrives();
1441 WIN32_FIND_DATAW data;
1442 HANDLE handle;
1443 struct dirstack *dirstack;
1444 enum fill_status status = FILL_STATUS_UNFILTERED;
1445
1446 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1447
1448 dirstack = alloc_dirstack(2);
1449
1450 for (i = 0; i < sizeof(drives); i++)
1451 {
1452 if (!(drives & (1 << i))) continue;
1453
1454 root[0] = 'A' + i;
1455 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1456
1457 num_expected_rows = 0;
1458 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1459
1460 for (;;)
1461 {
1462 path = pop_dir( dirstack, &len );
1463 if (!(glob = build_glob( root[0], path, len )))
1464 {
1465 status = FILL_STATUS_FAILED;
1466 goto done;
1467 }
1468 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1469 {
1470 do
1471 {
1472 if (!resize_table( table, row + 1, sizeof(*rec) ))
1473 {
1474 status = FILL_STATUS_FAILED;
1475 FindClose( handle );
1476 goto done;
1477 }
1478 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1479 new_path = append_path( path, data.cFileName, &len );
1480
1481 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1482 {
1483 if (push_dir( dirstack, new_path, len )) continue;
1484 heap_free( new_path );
1485 FindClose( handle );
1486 status = FILL_STATUS_FAILED;
1487 goto done;
1488 }
1489 rec = (struct record_datafile *)(table->data + offset);
1490 rec->name = build_name( root[0], new_path );
1491 rec->version = get_file_version( rec->name );
1492 if (!match_row( table, row, cond, &status ))
1493 {
1494 free_row_values( table, row );
1495 continue;
1496 }
1497 else if (num_expected_rows && row == num_expected_rows - 1)
1498 {
1499 row++;
1500 FindClose( handle );
1501 status = FILL_STATUS_FILTERED;
1502 goto done;
1503 }
1504 offset += sizeof(*rec);
1505 row++;
1506 }
1507 while (FindNextFileW( handle, &data ));
1508 FindClose( handle );
1509 }
1510 if (!peek_dir( dirstack )) break;
1511 heap_free( glob );
1512 heap_free( path );
1513 }
1514 }
1515
1516 done:
1517 free_dirstack( dirstack );
1518 heap_free( glob );
1519 heap_free( path );
1520
1521 TRACE("created %u rows\n", row);
1522 table->num_rows = row;
1523 return status;
1524 }
1525
1526 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1527 {
1528 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1529 struct record_directory *rec;
1530 UINT i, len, row = 0, offset = 0, num_expected_rows;
1531 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1532 DWORD drives = GetLogicalDrives();
1533 WIN32_FIND_DATAW data;
1534 HANDLE handle;
1535 struct dirstack *dirstack;
1536 enum fill_status status = FILL_STATUS_UNFILTERED;
1537
1538 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1539
1540 dirstack = alloc_dirstack(2);
1541
1542 for (i = 0; i < sizeof(drives); i++)
1543 {
1544 if (!(drives & (1 << i))) continue;
1545
1546 root[0] = 'A' + i;
1547 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1548
1549 num_expected_rows = 0;
1550 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1551
1552 for (;;)
1553 {
1554 path = pop_dir( dirstack, &len );
1555 if (!(glob = build_glob( root[0], path, len )))
1556 {
1557 status = FILL_STATUS_FAILED;
1558 goto done;
1559 }
1560 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1561 {
1562 do
1563 {
1564 if (!resize_table( table, row + 1, sizeof(*rec) ))
1565 {
1566 FindClose( handle );
1567 status = FILL_STATUS_FAILED;
1568 goto done;
1569 }
1570 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1571 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1572 continue;
1573
1574 new_path = append_path( path, data.cFileName, &len );
1575 if (!(push_dir( dirstack, new_path, len )))
1576 {
1577 heap_free( new_path );
1578 FindClose( handle );
1579 status = FILL_STATUS_FAILED;
1580 goto done;
1581 }
1582 rec = (struct record_directory *)(table->data + offset);
1583 rec->accessmask = FILE_ALL_ACCESS;
1584 rec->name = build_name( root[0], new_path );
1585 if (!match_row( table, row, cond, &status ))
1586 {
1587 free_row_values( table, row );
1588 continue;
1589 }
1590 else if (num_expected_rows && row == num_expected_rows - 1)
1591 {
1592 row++;
1593 FindClose( handle );
1594 status = FILL_STATUS_FILTERED;
1595 goto done;
1596 }
1597 offset += sizeof(*rec);
1598 row++;
1599 }
1600 while (FindNextFileW( handle, &data ));
1601 FindClose( handle );
1602 }
1603 if (!peek_dir( dirstack )) break;
1604 heap_free( glob );
1605 heap_free( path );
1606 }
1607 }
1608
1609 done:
1610 free_dirstack( dirstack );
1611 heap_free( glob );
1612 heap_free( path );
1613
1614 TRACE("created %u rows\n", row);
1615 table->num_rows = row;
1616 return status;
1617 }
1618
1619 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1620 {
1621 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1622 ULARGE_INTEGER free;
1623 DISK_GEOMETRY_EX info;
1624 HANDLE handle;
1625 DWORD bytes_returned;
1626
1627 free.QuadPart = 512 * 1024 * 1024;
1628 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1629
1630 root[4] = dir[0];
1631 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1632 if (handle != INVALID_HANDLE_VALUE)
1633 {
1634 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1635 *disksize = info.DiskSize.QuadPart;
1636 CloseHandle( handle );
1637 }
1638 return free.QuadPart;
1639 }
1640
1641 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1642 {
1643 static const WCHAR fmtW[] =
1644 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1645 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
1646 struct record_diskdrive *rec;
1647 UINT i, row = 0, offset = 0, index = 0, type;
1648 UINT64 size = 1024 * 1024 * 1024;
1649 DWORD drives = GetLogicalDrives();
1650 enum fill_status status = FILL_STATUS_UNFILTERED;
1651
1652 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
1653
1654 for (i = 0; i < sizeof(drives); i++)
1655 {
1656 if (drives & (1 << i))
1657 {
1658 root[0] = 'A' + i;
1659 type = GetDriveTypeW( root );
1660 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1661 continue;
1662
1663 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1664
1665 rec = (struct record_diskdrive *)(table->data + offset);
1666 sprintfW( device_id, fmtW, index );
1667 rec->device_id = heap_strdupW( device_id );
1668 rec->index = index;
1669 rec->interfacetype = diskdrive_interfacetypeW;
1670 rec->manufacturer = diskdrive_manufacturerW;
1671 if (type == DRIVE_FIXED)
1672 rec->mediatype = diskdrive_mediatype_fixedW;
1673 else
1674 rec->mediatype = diskdrive_mediatype_removableW;
1675 rec->model = diskdrive_modelW;
1676 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
1677 rec->serialnumber = diskdrive_serialW;
1678 get_freespace( root, &size );
1679 rec->size = size;
1680 if (!match_row( table, row, cond, &status ))
1681 {
1682 free_row_values( table, row );
1683 continue;
1684 }
1685 offset += sizeof(*rec);
1686 index++;
1687 row++;
1688 }
1689 }
1690 TRACE("created %u rows\n", row);
1691 table->num_rows = row;
1692 return status;
1693 }
1694
1695 static WCHAR *get_filesystem( const WCHAR *root )
1696 {
1697 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1698 WCHAR buffer[MAX_PATH + 1];
1699
1700 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1701 return heap_strdupW( buffer );
1702 return heap_strdupW( ntfsW );
1703 }
1704
1705 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1706 {
1707 static const WCHAR fmtW[] =
1708 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1709 WCHAR device_id[32], root[] = {'A',':','\\',0};
1710 struct record_diskpartition *rec;
1711 UINT i, row = 0, offset = 0, type, index = 0;
1712 UINT64 size = 1024 * 1024 * 1024;
1713 DWORD drives = GetLogicalDrives();
1714 enum fill_status status = FILL_STATUS_UNFILTERED;
1715
1716 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1717
1718 for (i = 0; i < sizeof(drives); i++)
1719 {
1720 if (drives & (1 << i))
1721 {
1722 root[0] = 'A' + i;
1723 type = GetDriveTypeW( root );
1724 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1725 continue;
1726
1727 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1728
1729 rec = (struct record_diskpartition *)(table->data + offset);
1730 rec->bootable = (i == 2) ? -1 : 0;
1731 rec->bootpartition = (i == 2) ? -1 : 0;
1732 sprintfW( device_id, fmtW, index );
1733 rec->device_id = heap_strdupW( device_id );
1734 rec->diskindex = index;
1735 rec->index = 0;
1736 rec->pnpdevice_id = heap_strdupW( device_id );
1737 get_freespace( root, &size );
1738 rec->size = size;
1739 rec->startingoffset = 0;
1740 rec->type = get_filesystem( root );
1741 if (!match_row( table, row, cond, &status ))
1742 {
1743 free_row_values( table, row );
1744 continue;
1745 }
1746 offset += sizeof(*rec);
1747 row++;
1748 index++;
1749 }
1750 }
1751 TRACE("created %u rows\n", row);
1752 table->num_rows = row;
1753 return status;
1754 }
1755
1756 static WCHAR *get_volumename( const WCHAR *root )
1757 {
1758 WCHAR buf[MAX_PATH + 1] = {0};
1759 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
1760 return heap_strdupW( buf );
1761 }
1762 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1763 {
1764 static const WCHAR fmtW[] = {'%','0','8','X',0};
1765 DWORD serial = 0;
1766 WCHAR buffer[9];
1767
1768 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1769 sprintfW( buffer, fmtW, serial );
1770 return heap_strdupW( buffer );
1771 }
1772
1773 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1774 {
1775 static const WCHAR fmtW[] = {'%','c',':',0};
1776 WCHAR device_id[3], root[] = {'A',':','\\',0};
1777 struct record_logicaldisk *rec;
1778 UINT i, row = 0, offset = 0, type;
1779 UINT64 size = 1024 * 1024 * 1024;
1780 DWORD drives = GetLogicalDrives();
1781 enum fill_status status = FILL_STATUS_UNFILTERED;
1782
1783 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1784
1785 for (i = 0; i < sizeof(drives); i++)
1786 {
1787 if (drives & (1 << i))
1788 {
1789 root[0] = 'A' + i;
1790 type = GetDriveTypeW( root );
1791 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1792 continue;
1793
1794 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1795
1796 rec = (struct record_logicaldisk *)(table->data + offset);
1797 sprintfW( device_id, fmtW, 'A' + i );
1798 rec->device_id = heap_strdupW( device_id );
1799 rec->drivetype = type;
1800 rec->filesystem = get_filesystem( root );
1801 rec->freespace = get_freespace( root, &size );
1802 rec->name = heap_strdupW( device_id );
1803 rec->size = size;
1804 rec->volumename = get_volumename( root );
1805 rec->volumeserialnumber = get_volumeserialnumber( root );
1806 if (!match_row( table, row, cond, &status ))
1807 {
1808 free_row_values( table, row );
1809 continue;
1810 }
1811 offset += sizeof(*rec);
1812 row++;
1813 }
1814 }
1815 TRACE("created %u rows\n", row);
1816 table->num_rows = row;
1817 return status;
1818 }
1819
1820 static UINT16 get_connection_status( IF_OPER_STATUS status )
1821 {
1822 switch (status)
1823 {
1824 case IfOperStatusDown:
1825 return 0; /* Disconnected */
1826 case IfOperStatusUp:
1827 return 2; /* Connected */
1828 default:
1829 ERR("unhandled status %u\n", status);
1830 break;
1831 }
1832 return 0;
1833 }
1834 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
1835 {
1836 static const WCHAR fmtW[] =
1837 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1838 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1839 WCHAR *ret;
1840
1841 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
1842 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
1843 return ret;
1844 }
1845 static const WCHAR *get_adaptertype( DWORD type, int *physical )
1846 {
1847 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1848 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
1849 static const WCHAR firewireW[] = {'1','3','9','4',0};
1850 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
1851
1852 switch (type)
1853 {
1854 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
1855 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
1856 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
1857 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
1858 default: *physical = 0; return NULL;
1859 }
1860 }
1861
1862 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
1863 {
1864 static const WCHAR fmtW[] = {'%','u',0};
1865 WCHAR device_id[11];
1866 struct record_networkadapter *rec;
1867 IP_ADAPTER_ADDRESSES *aa, *buffer;
1868 UINT row = 0, offset = 0, count = 0;
1869 DWORD size = 0, ret;
1870 int physical;
1871 enum fill_status status = FILL_STATUS_UNFILTERED;
1872
1873 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
1874 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
1875
1876 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
1877 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
1878 {
1879 heap_free( buffer );
1880 return FILL_STATUS_FAILED;
1881 }
1882 for (aa = buffer; aa; aa = aa->Next)
1883 {
1884 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
1885 }
1886 if (!resize_table( table, count, sizeof(*rec) ))
1887 {
1888 heap_free( buffer );
1889 return FILL_STATUS_FAILED;
1890 }
1891 for (aa = buffer; aa; aa = aa->Next)
1892 {
1893 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
1894
1895 rec = (struct record_networkadapter *)(table->data + offset);
1896 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
1897 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
1898 rec->device_id = heap_strdupW( device_id );
1899 rec->index = aa->u.s.IfIndex;
1900 rec->interface_index = aa->u.s.IfIndex;
1901 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
1902 rec->manufacturer = compsys_manufacturerW;
1903 rec->name = heap_strdupW( aa->FriendlyName );
1904 rec->netconnection_status = get_connection_status( aa->OperStatus );
1905 rec->physicaladapter = physical;
1906 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
1907 rec->speed = 1000000;
1908 if (!match_row( table, row, cond, &status ))
1909 {
1910 free_row_values( table, row );
1911 continue;
1912 }
1913 offset += sizeof(*rec);
1914 row++;
1915 }
1916 TRACE("created %u rows\n", row);
1917 table->num_rows = row;
1918
1919 heap_free( buffer );
1920 return status;
1921 }
1922
1923 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
1924 {
1925 const SOCKET_ADDRESS *sa = &addr->Address;
1926 WCHAR buf[NI_MAXHOST];
1927
1928 if (!addr) return NULL;
1929 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
1930 0, NI_NAMEREQD )) return NULL;
1931 return heap_strdupW( buf );
1932 }
1933
1934 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
1935 {
1936 struct record_networkadapterconfig *rec;
1937 IP_ADAPTER_ADDRESSES *aa, *buffer;
1938 UINT row = 0, offset = 0, count = 0;
1939 DWORD size = 0, ret;
1940 enum fill_status status = FILL_STATUS_UNFILTERED;
1941
1942 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
1943 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
1944
1945 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
1946 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
1947 {
1948 heap_free( buffer );
1949 return FILL_STATUS_FAILED;
1950 }
1951 for (aa = buffer; aa; aa = aa->Next)
1952 {
1953 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
1954 }
1955 if (!resize_table( table, count, sizeof(*rec) ))
1956 {
1957 heap_free( buffer );
1958 return FILL_STATUS_FAILED;
1959 }
1960 for (aa = buffer; aa; aa = aa->Next)
1961 {
1962 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
1963
1964 rec = (struct record_networkadapterconfig *)(table->data + offset);
1965 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
1966 rec->index = aa->u.s.IfIndex;
1967 rec->ipconnectionmetric = 20;
1968 rec->ipenabled = -1;
1969 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
1970 if (!match_row( table, row, cond, &status ))
1971 {
1972 free_row_values( table, row );
1973 continue;
1974 }
1975 offset += sizeof(*rec);
1976 row++;
1977 }
1978 TRACE("created %u rows\n", row);
1979 table->num_rows = row;
1980
1981 heap_free( buffer );
1982 return status;
1983 }
1984
1985 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
1986 {
1987 struct record_physicalmemory *rec;
1988 enum fill_status status = FILL_STATUS_UNFILTERED;
1989 UINT row = 0;
1990
1991 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1992
1993 rec = (struct record_physicalmemory *)table->data;
1994 rec->capacity = get_total_physical_memory();
1995 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1996 else row++;
1997
1998 TRACE("created %u rows\n", row);
1999 table->num_rows = row;
2000 return status;
2001 }
2002
2003 static WCHAR *get_cmdline( DWORD process_id )
2004 {
2005 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2006 return NULL; /* FIXME handle different process case */
2007 }
2008
2009 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2010 {
2011 static const WCHAR fmtW[] = {'%','u',0};
2012 WCHAR handle[11];
2013 struct record_process *rec;
2014 PROCESSENTRY32W entry;
2015 HANDLE snap;
2016 enum fill_status status = FILL_STATUS_FAILED;
2017 UINT row = 0, offset = 0;
2018
2019 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2020 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2021
2022 entry.dwSize = sizeof(entry);
2023 if (!Process32FirstW( snap, &entry )) goto done;
2024 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2025
2026 do
2027 {
2028 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2029
2030 rec = (struct record_process *)(table->data + offset);
2031 rec->caption = heap_strdupW( entry.szExeFile );
2032 rec->commandline = get_cmdline( entry.th32ProcessID );
2033 rec->description = heap_strdupW( entry.szExeFile );
2034 sprintfW( handle, fmtW, entry.th32ProcessID );
2035 rec->handle = heap_strdupW( handle );
2036 rec->name = heap_strdupW( entry.szExeFile );
2037 rec->process_id = entry.th32ProcessID;
2038 rec->pprocess_id = entry.th32ParentProcessID;
2039 rec->thread_count = entry.cntThreads;
2040 rec->get_owner = process_get_owner;
2041 if (!match_row( table, row, cond, &status ))
2042 {
2043 free_row_values( table, row );
2044 continue;
2045 }
2046 offset += sizeof(*rec);
2047 row++;
2048 } while (Process32NextW( snap, &entry ));
2049
2050 TRACE("created %u rows\n", row);
2051 table->num_rows = row;
2052 status = FILL_STATUS_UNFILTERED;
2053
2054 done:
2055 CloseHandle( snap );
2056 return status;
2057 }
2058
2059 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2060 {
2061 #ifdef __i386__
2062 #ifdef _MSC_VER
2063 __cpuid(p, ax);
2064 #else
2065 __asm__("pushl %%ebx\n\t"
2066 "cpuid\n\t"
2067 "movl %%ebx, %%esi\n\t"
2068 "popl %%ebx"
2069 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2070 : "0" (ax));
2071 #endif
2072 #endif
2073 }
2074
2075 static void get_processor_id( WCHAR *processor_id )
2076 {
2077 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2078 unsigned int regs[4] = {0, 0, 0, 0};
2079
2080 do_cpuid( 1, regs );
2081 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2082 }
2083 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2084 {
2085 unsigned int i;
2086 unsigned char *p = (unsigned char *)regs;
2087
2088 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2089 buffer[i] = 0;
2090 }
2091 static void get_processor_manufacturer( WCHAR *manufacturer )
2092 {
2093 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2094
2095 do_cpuid( 0, regs );
2096 tmp = regs[2]; /* swap edx and ecx */
2097 regs[2] = regs[3];
2098 regs[3] = tmp;
2099
2100 regs_to_str( regs + 1, 12, manufacturer );
2101 }
2102 static void get_processor_name( WCHAR *name )
2103 {
2104 unsigned int regs[4] = {0, 0, 0, 0};
2105
2106 do_cpuid( 0x80000000, regs );
2107 if (regs[0] >= 0x80000004)
2108 {
2109 do_cpuid( 0x80000002, regs );
2110 regs_to_str( regs, 16, name );
2111 do_cpuid( 0x80000003, regs );
2112 regs_to_str( regs, 16, name + 16 );
2113 do_cpuid( 0x80000004, regs );
2114 regs_to_str( regs, 16, name + 32 );
2115 }
2116 }
2117 static UINT get_processor_currentclockspeed( UINT index )
2118 {
2119 PROCESSOR_POWER_INFORMATION *info;
2120 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2121 NTSTATUS status;
2122
2123 if ((info = heap_alloc( size )))
2124 {
2125 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2126 if (!status) ret = info[index].CurrentMhz;
2127 heap_free( info );
2128 }
2129 return ret;
2130 }
2131 static UINT get_processor_maxclockspeed( UINT index )
2132 {
2133 PROCESSOR_POWER_INFORMATION *info;
2134 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2135 NTSTATUS status;
2136
2137 if ((info = heap_alloc( size )))
2138 {
2139 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2140 if (!status) ret = info[index].MaxMhz;
2141 heap_free( info );
2142 }
2143 return ret;
2144 }
2145 static const WCHAR *get_osarchitecture(void)
2146 {
2147 SYSTEM_INFO info;
2148 GetNativeSystemInfo( &info );
2149 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2150 return os_32bitW;
2151 }
2152
2153 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2154 {
2155 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2156 WCHAR device_id[14], processor_id[17], manufacturer[13], name[49] = {0};
2157 struct record_processor *rec;
2158 UINT i, offset = 0, num_cores, num_logical_processors, count = get_processor_count();
2159 enum fill_status status = FILL_STATUS_UNFILTERED;
2160
2161 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2162
2163 get_processor_id( processor_id );
2164 get_processor_manufacturer( manufacturer );
2165 get_processor_name( name );
2166
2167 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2168 num_cores /= count;
2169
2170 for (i = 0; i < count; i++)
2171 {
2172 rec = (struct record_processor *)(table->data + offset);
2173 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2174 rec->cpu_status = 1; /* CPU Enabled */
2175 rec->currentclockspeed = get_processor_currentclockspeed( i );
2176 sprintfW( device_id, fmtW, i );
2177 rec->device_id = heap_strdupW( device_id );
2178 rec->family = 2; /* Unknown */
2179 rec->manufacturer = heap_strdupW( manufacturer );
2180 rec->maxclockspeed = get_processor_maxclockspeed( i );
2181 rec->name = heap_strdupW( name );
2182 rec->num_cores = num_cores;
2183 rec->num_logical_processors = num_logical_processors;
2184 rec->processor_id = heap_strdupW( processor_id );
2185 rec->processortype = 3; /* central processor */
2186 rec->unique_id = NULL;
2187 if (!match_row( table, i, cond, &status ))
2188 {
2189 free_row_values( table, i );
2190 continue;
2191 }
2192 offset += sizeof(*rec);
2193 }
2194
2195 TRACE("created %u rows\n", count);
2196 table->num_rows = count;
2197 return status;
2198 }
2199
2200 static WCHAR *get_lastbootuptime(void)
2201 {
2202 static const WCHAR fmtW[] =
2203 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2204 '.','%','0','6','u','+','0','0','0',0};
2205 SYSTEM_TIMEOFDAY_INFORMATION ti;
2206 TIME_FIELDS tf;
2207 WCHAR *ret;
2208
2209 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2210
2211 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2212 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2213 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2214 return ret;
2215 }
2216 static WCHAR *get_localdatetime(void)
2217 {
2218 static const WCHAR fmtW[] =
2219 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2220 '.','%','0','6','u','%','+','0','3','d',0};
2221 TIME_ZONE_INFORMATION tzi;
2222 SYSTEMTIME st;
2223 WCHAR *ret;
2224 DWORD Status;
2225 LONG Bias;
2226
2227 Status = GetTimeZoneInformation(&tzi);
2228
2229 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2230 Bias = tzi.Bias;
2231 if(Status == TIME_ZONE_ID_DAYLIGHT)
2232 Bias+= tzi.DaylightBias;
2233 else
2234 Bias+= tzi.StandardBias;
2235 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2236
2237 GetLocalTime(&st);
2238 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2239 return ret;
2240 }
2241 static WCHAR *get_systemdirectory(void)
2242 {
2243 void *redir;
2244 WCHAR *ret;
2245
2246 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2247 Wow64DisableWow64FsRedirection( &redir );
2248 GetSystemDirectoryW( ret, MAX_PATH );
2249 Wow64RevertWow64FsRedirection( redir );
2250 return ret;
2251 }
2252 static WCHAR *get_codeset(void)
2253 {
2254 static const WCHAR fmtW[] = {'%','u',0};
2255 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2256 if (ret) sprintfW( ret, fmtW, GetACP() );
2257 return ret;
2258 }
2259 static WCHAR *get_countrycode(void)
2260 {
2261 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2262 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2263 return ret;
2264 }
2265 static WCHAR *get_locale(void)
2266 {
2267 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2268 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2269 return ret;
2270 }
2271
2272 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2273 {
2274 struct record_operatingsystem *rec;
2275 enum fill_status status = FILL_STATUS_UNFILTERED;
2276 UINT row = 0;
2277
2278 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2279
2280 rec = (struct record_operatingsystem *)table->data;
2281 rec->buildnumber = os_buildnumberW;
2282 rec->caption = os_captionW;
2283 rec->codeset = get_codeset();
2284 rec->countrycode = get_countrycode();
2285 rec->csdversion = os_csdversionW;
2286 rec->installdate = os_installdateW;
2287 rec->lastbootuptime = get_lastbootuptime();
2288 rec->localdatetime = get_localdatetime();
2289 rec->locale = get_locale();
2290 rec->name = os_nameW;
2291 rec->osarchitecture = get_osarchitecture();
2292 rec->oslanguage = GetSystemDefaultLangID();
2293 rec->osproductsuite = 2461140; /* Windows XP Professional */
2294 rec->ostype = 18; /* WINNT */
2295 rec->serialnumber = os_serialnumberW;
2296 rec->servicepackmajor = 3;
2297 rec->servicepackminor = 0;
2298 rec->suitemask = 272; /* Single User + Terminal */
2299 rec->systemdirectory = get_systemdirectory();
2300 rec->totalvisiblememorysize = get_total_physical_memory() / 1024;
2301 rec->version = os_versionW;
2302 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2303 else row++;
2304
2305 TRACE("created %u rows\n", row);
2306 table->num_rows = row;
2307 return status;
2308 }
2309
2310 static const WCHAR *get_service_type( DWORD type )
2311 {
2312 static const WCHAR filesystem_driverW[] =
2313 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2314 static const WCHAR kernel_driverW[] =
2315 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2316 static const WCHAR own_processW[] =
2317 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2318 static const WCHAR share_processW[] =
2319 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2320
2321 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2322 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2323 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2324 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2325 else ERR("unhandled type 0x%08x\n", type);
2326 return NULL;
2327 }
2328 static const WCHAR *get_service_state( DWORD state )
2329 {
2330 static const WCHAR runningW[] =
2331 {'R','u','n','n','i','n','g',0};
2332 static const WCHAR start_pendingW[] =
2333 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2334 static const WCHAR stop_pendingW[] =
2335 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2336 static const WCHAR stoppedW[] =
2337 {'S','t','o','p','p','e','d',0};
2338 static const WCHAR unknownW[] =
2339 {'U','n','k','n','o','w','n',0};
2340
2341 switch (state)
2342 {
2343 case SERVICE_STOPPED: return stoppedW;
2344 case SERVICE_START_PENDING: return start_pendingW;
2345 case SERVICE_STOP_PENDING: return stop_pendingW;
2346 case SERVICE_RUNNING: return runningW;
2347 default:
2348 ERR("unknown state %u\n", state);
2349 return unknownW;
2350 }
2351 }
2352 static const WCHAR *get_service_startmode( DWORD mode )
2353 {
2354 static const WCHAR bootW[] = {'B','o','o','t',0};
2355 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2356 static const WCHAR autoW[] = {'A','u','t','o',0};
2357 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2358 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2359 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2360
2361 switch (mode)
2362 {
2363 case SERVICE_BOOT_START: return bootW;
2364 case SERVICE_SYSTEM_START: return systemW;
2365 case SERVICE_AUTO_START: return autoW;
2366 case SERVICE_DEMAND_START: return manualW;
2367 case SERVICE_DISABLED: return disabledW;
2368 default:
2369 ERR("unknown mode 0x%x\n", mode);
2370 return unknownW;
2371 }
2372 }
2373 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2374 {
2375 QUERY_SERVICE_CONFIGW *config = NULL;
2376 SC_HANDLE service;
2377 DWORD size;
2378
2379 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2380 QueryServiceConfigW( service, NULL, 0, &size );
2381 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2382 if (!(config = heap_alloc( size ))) goto done;
2383 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2384 heap_free( config );
2385 config = NULL;
2386
2387 done:
2388 CloseServiceHandle( service );
2389 return config;
2390 }
2391
2392 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2393 {
2394 struct record_service *rec;
2395 SC_HANDLE manager;
2396 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2397 SERVICE_STATUS_PROCESS *status;
2398 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2399 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2400 UINT i, row = 0, offset = 0, size = 256, needed, count;
2401 enum fill_status fill_status = FILL_STATUS_FAILED;
2402 BOOL ret;
2403
2404 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2405 if (!(services = heap_alloc( size ))) goto done;
2406
2407 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2408 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2409 &count, NULL, NULL );
2410 if (!ret)
2411 {
2412 if (GetLastError() != ERROR_MORE_DATA) goto done;
2413 size = needed;
2414 if (!(tmp = heap_realloc( services, size ))) goto done;
2415 services = tmp;
2416 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2417 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2418 &count, NULL, NULL );
2419 if (!ret) goto done;
2420 }
2421 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2422
2423 GetComputerNameW( sysnameW, &len );
2424 fill_status = FILL_STATUS_UNFILTERED;
2425
2426 for (i = 0; i < count; i++)
2427 {
2428 QUERY_SERVICE_CONFIGW *config;
2429
2430 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2431
2432 status = &services[i].ServiceStatusProcess;
2433 rec = (struct record_service *)(table->data + offset);
2434 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2435 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2436 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2437 rec->name = heap_strdupW( services[i].lpServiceName );
2438 rec->process_id = status->dwProcessId;
2439 rec->servicetype = get_service_type( status->dwServiceType );
2440 rec->startmode = get_service_startmode( config->dwStartType );
2441 rec->state = get_service_state( status->dwCurrentState );
2442 rec->systemname = heap_strdupW( sysnameW );
2443 rec->pause_service = service_pause_service;
2444 rec->resume_service = service_resume_service;
2445 rec->start_service = service_start_service;
2446 rec->stop_service = service_stop_service;
2447 heap_free( config );
2448 if (!match_row( table, row, cond, &fill_status ))
2449 {
2450 free_row_values( table, row );
2451 continue;
2452 }
2453 offset += sizeof(*rec);
2454 row++;
2455 }
2456
2457 TRACE("created %u rows\n", row);
2458 table->num_rows = row;
2459
2460 done:
2461 CloseServiceHandle( manager );
2462 heap_free( services );
2463 return fill_status;
2464 }
2465
2466 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
2467 {
2468 if (!name || !name->Name.Buffer) return NULL;
2469 return heap_strdupW( name->Name.Buffer );
2470 }
2471 static UINT8 *get_binaryrepresentation( PSID sid, UINT len )
2472 {
2473 UINT8 *ret = heap_alloc( len );
2474 if (!ret) return NULL;
2475 memcpy( ret, sid, len );
2476 return ret;
2477 }
2478 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
2479 {
2480 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
2481 return heap_strdupW( domain->Domains->Name.Buffer );
2482 }
2483 static const WCHAR *find_sid_str( const struct expr *cond )
2484 {
2485 const struct expr *left, *right;
2486 const WCHAR *ret = NULL;
2487
2488 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
2489
2490 left = cond->u.expr.left;
2491 right = cond->u.expr.right;
2492 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
2493 {
2494 ret = right->u.sval;
2495 }
2496 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
2497 {
2498 ret = left->u.sval;
2499 }
2500 return ret;
2501 }
2502
2503 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
2504 {
2505 PSID sid;
2506 LSA_REFERENCED_DOMAIN_LIST *domain;
2507 LSA_TRANSLATED_NAME *name;
2508 LSA_HANDLE handle;
2509 LSA_OBJECT_ATTRIBUTES attrs;
2510 const WCHAR *str;
2511 struct record_sid *rec;
2512 UINT len;
2513
2514 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
2515 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2516
2517 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
2518 len = GetLengthSid( sid );
2519
2520 memset( &attrs, 0, sizeof(attrs) );
2521 attrs.Length = sizeof(attrs);
2522 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
2523 {
2524 LocalFree( sid );
2525 return FILL_STATUS_FAILED;
2526 }
2527 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
2528 {
2529 LocalFree( sid );
2530 LsaClose( handle );
2531 return FILL_STATUS_FAILED;
2532 }
2533
2534 rec = (struct record_sid *)table->data;
2535 rec->accountname = get_accountname( name );
2536 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
2537 rec->referenceddomainname = get_referenceddomainname( domain );
2538 rec->sid = heap_strdupW( str );
2539 rec->sidlength = len;
2540
2541 TRACE("created 1 row\n");
2542 table->num_rows = 1;
2543
2544 LsaFreeMemory( domain );
2545 LsaFreeMemory( name );
2546 LocalFree( sid );
2547 LsaClose( handle );
2548 return FILL_STATUS_FILTERED;
2549 }
2550
2551 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2552 {
2553 HDC hdc = GetDC( NULL );
2554 UINT32 ret;
2555
2556 if (!hdc) return 32;
2557 ret = GetDeviceCaps( hdc, BITSPIXEL );
2558 *hres = GetDeviceCaps( hdc, HORZRES );
2559 *vres = GetDeviceCaps( hdc, VERTRES );
2560 ReleaseDC( NULL, hdc );
2561 return ret;
2562 }
2563 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2564 {
2565 static const WCHAR fmtW[] =
2566 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2567 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2568 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2569 WCHAR *ret;
2570
2571 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2572 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2573 return ret;
2574 }
2575
2576 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2577 {
2578
2579 struct record_videocontroller *rec;
2580 HRESULT hr;
2581 IDXGIFactory *factory = NULL;
2582 IDXGIAdapter *adapter = NULL;
2583 DXGI_ADAPTER_DESC desc;
2584 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2585 const WCHAR *name = videocontroller_deviceidW;
2586 enum fill_status status = FILL_STATUS_UNFILTERED;
2587 UINT row = 0;
2588
2589 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2590
2591 memset (&desc, 0, sizeof(desc));
2592 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2593 if (FAILED(hr)) goto done;
2594
2595 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2596 if (FAILED(hr)) goto done;
2597
2598 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2599 if (SUCCEEDED(hr))
2600 {
2601 vidmem = desc.DedicatedVideoMemory;
2602 name = desc.Description;
2603 }
2604
2605 done:
2606 rec = (struct record_videocontroller *)table->data;
2607 rec->adapter_dactype = videocontroller_dactypeW;
2608 rec->adapter_ram = vidmem;
2609 rec->availability = 3; /* Running or Full Power */
2610 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2611 rec->current_horizontalres = hres;
2612 rec->current_verticalres = vres;
2613 rec->description = heap_strdupW( name );
2614 rec->device_id = videocontroller_deviceidW;
2615 rec->driverversion = videocontroller_driverversionW;
2616 rec->name = heap_strdupW( name );
2617 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2618 rec->videoprocessor = heap_strdupW( name );
2619 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2620 else row++;
2621
2622 TRACE("created %u rows\n", row);
2623 table->num_rows = row;
2624
2625 if (adapter) IDXGIAdapter_Release( adapter );
2626 if (factory) IDXGIFactory_Release( factory );
2627 return status;
2628 }
2629
2630 static struct table builtin_classes[] =
2631 {
2632 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
2633 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
2634 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
2635 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
2636 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, SIZEOF(data_compsysproduct), 0, (BYTE *)data_compsysproduct },
2637 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
2638 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
2639 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
2640 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
2641 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2642 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2643 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
2644 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
2645 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
2646 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
2647 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
2648 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
2649 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
2650 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2651 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2652 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
2653 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
2654 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
2655 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
2656 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
2657 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
2658 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
2659 };
2660
2661 void init_table_list( void )
2662 {
2663 static struct list tables = LIST_INIT( tables );
2664 UINT i;
2665
2666 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
2667 table_list = &tables;
2668 }