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