d3d11/tests: Add tests for D3D11CreateDeviceAndSwapChain().
[wine/multimedia.git] / dlls / wbemprox / builtin.c
blob1c960eb222cf4a4cbabfec6f9ad659f405681f82
1 /*
2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
23 #include "config.h"
24 #include <stdarg.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winsock2.h"
31 #include "ws2tcpip.h"
32 #include "initguid.h"
33 #include "wbemcli.h"
34 #include "wbemprov.h"
35 #include "iphlpapi.h"
36 #include "tlhelp32.h"
37 #include "d3d10.h"
38 #include "winternl.h"
39 #include "winioctl.h"
40 #include "winsvc.h"
41 #include "winver.h"
42 #include "sddl.h"
43 #include "ntsecapi.h"
44 #include "winspool.h"
46 #include "wine/debug.h"
47 #include "wbemprox_private.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
51 static const WCHAR class_baseboardW[] =
52 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
53 static const WCHAR class_biosW[] =
54 {'W','i','n','3','2','_','B','I','O','S',0};
55 static const WCHAR class_cdromdriveW[] =
56 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
57 static const WCHAR class_compsysW[] =
58 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
59 static const WCHAR class_compsysproductW[] =
60 {'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};
61 static const WCHAR class_datafileW[] =
62 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
63 static const WCHAR class_desktopmonitorW[] =
64 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
65 static const WCHAR class_directoryW[] =
66 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
67 static const WCHAR class_diskdriveW[] =
68 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
69 static const WCHAR class_diskpartitionW[] =
70 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
71 static const WCHAR class_logicaldiskW[] =
72 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
73 static const WCHAR class_logicaldisk2W[] =
74 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
75 static const WCHAR class_networkadapterW[] =
76 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
77 static const WCHAR class_networkadapterconfigW[] =
78 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
79 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
80 static const WCHAR class_osW[] =
81 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
82 static const WCHAR class_paramsW[] =
83 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
84 static const WCHAR class_physicalmediaW[] =
85 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
86 static const WCHAR class_physicalmemoryW[] =
87 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
88 static const WCHAR class_qualifiersW[] =
89 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
90 static const WCHAR class_printerW[] =
91 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
92 static const WCHAR class_process_getowner_outW[] =
93 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
94 'N','E','R','_','O','U','T',0};
95 static const WCHAR class_processorW[] =
96 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
97 static const WCHAR class_processor2W[] =
98 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
99 static const WCHAR class_sidW[] =
100 {'W','i','n','3','2','_','S','I','D',0};
101 static const WCHAR class_sounddeviceW[] =
102 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
103 static const WCHAR class_systemenclosureW[] =
104 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
105 static const WCHAR class_videocontrollerW[] =
106 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
108 static const WCHAR prop_accountnameW[] =
109 {'A','c','c','o','u','n','t','N','a','m','e',0};
110 static const WCHAR prop_acceptpauseW[] =
111 {'A','c','c','e','p','t','P','a','u','s','e',0};
112 static const WCHAR prop_acceptstopW[] =
113 {'A','c','c','e','p','t','S','t','o','p',0};
114 static const WCHAR prop_accessmaskW[] =
115 {'A','c','c','e','s','s','M','a','s','k',0};
116 static const WCHAR prop_adapterdactypeW[] =
117 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
118 static const WCHAR prop_adapterramW[] =
119 {'A','d','a','p','t','e','r','R','A','M',0};
120 static const WCHAR prop_adaptertypeW[] =
121 {'A','d','a','p','t','e','r','T','y','p','e',0};
122 static const WCHAR prop_addresswidthW[] =
123 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
124 static const WCHAR prop_attributesW[] =
125 {'A','t','t','r','i','b','u','t','e','s',0};
126 static const WCHAR prop_availabilityW[] =
127 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
128 static const WCHAR prop_binaryrepresentationW[] =
129 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
130 static const WCHAR prop_bootableW[] =
131 {'B','o','o','t','a','b','l','e',0};
132 static const WCHAR prop_bootpartitionW[] =
133 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
134 static const WCHAR prop_buildnumberW[] =
135 {'B','u','i','l','d','N','u','m','b','e','r',0};
136 static const WCHAR prop_capacityW[] =
137 {'C','a','p','a','c','i','t','y',0};
138 static const WCHAR prop_captionW[] =
139 {'C','a','p','t','i','o','n',0};
140 static const WCHAR prop_chassistypesW[] =
141 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
142 static const WCHAR prop_classW[] =
143 {'C','l','a','s','s',0};
144 static const WCHAR prop_codesetW[] =
145 {'C','o','d','e','S','e','t',0};
146 static const WCHAR prop_commandlineW[] =
147 {'C','o','m','m','a','n','d','L','i','n','e',0};
148 static const WCHAR prop_countrycodeW[] =
149 {'C','o','u','n','t','r','y','C','o','d','e',0};
150 static const WCHAR prop_cpustatusW[] =
151 {'C','p','u','S','t','a','t','u','s',0};
152 static const WCHAR prop_csdversionW[] =
153 {'C','S','D','V','e','r','s','i','o','n',0};
154 static const WCHAR prop_currentbitsperpixelW[] =
155 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
156 static const WCHAR prop_currentclockspeedW[] =
157 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
158 static const WCHAR prop_currenthorizontalresW[] =
159 {'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};
160 static const WCHAR prop_currentrefreshrateW[] =
161 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
162 static const WCHAR prop_currentscanmodeW[] =
163 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
164 static const WCHAR prop_currentverticalresW[] =
165 {'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};
166 static const WCHAR prop_datawidthW[] =
167 {'D','a','t','a','W','i','d','t','h',0};
168 static const WCHAR prop_defaultvalueW[] =
169 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
170 static const WCHAR prop_descriptionW[] =
171 {'D','e','s','c','r','i','p','t','i','o','n',0};
172 static const WCHAR prop_deviceidW[] =
173 {'D','e','v','i','c','e','I','d',0};
174 static const WCHAR prop_directionW[] =
175 {'D','i','r','e','c','t','i','o','n',0};
176 static const WCHAR prop_displaynameW[] =
177 {'D','i','s','p','l','a','y','N','a','m','e',0};
178 static const WCHAR prop_diskindexW[] =
179 {'D','i','s','k','I','n','d','e','x',0};
180 static const WCHAR prop_dnshostnameW[] =
181 {'D','N','S','H','o','s','t','N','a','m','e',0};
182 static const WCHAR prop_domainW[] =
183 {'D','o','m','a','i','n',0};
184 static const WCHAR prop_domainroleW[] =
185 {'D','o','m','a','i','n','R','o','l','e',0};
186 static const WCHAR prop_driveW[] =
187 {'D','r','i','v','e',0};
188 static const WCHAR prop_drivernameW[] =
189 {'D','r','i','v','e','r','N','a','m','e',0};
190 static const WCHAR prop_driverversionW[] =
191 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
192 static const WCHAR prop_drivetypeW[] =
193 {'D','r','i','v','e','T','y','p','e',0};
194 static const WCHAR prop_familyW[] =
195 {'F','a','m','i','l','y',0};
196 static const WCHAR prop_filesystemW[] =
197 {'F','i','l','e','S','y','s','t','e','m',0};
198 static const WCHAR prop_flavorW[] =
199 {'F','l','a','v','o','r',0};
200 static const WCHAR prop_freespaceW[] =
201 {'F','r','e','e','S','p','a','c','e',0};
202 static const WCHAR prop_handleW[] =
203 {'H','a','n','d','l','e',0};
204 static const WCHAR prop_horizontalresolutionW[] =
205 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
206 static const WCHAR prop_idW[] =
207 {'I','D',0};
208 static const WCHAR prop_identificationcodeW[] =
209 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
210 static const WCHAR prop_identifyingnumberW[] =
211 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
212 static const WCHAR prop_indexW[] =
213 {'I','n','d','e','x',0};
214 static const WCHAR prop_installdateW[] =
215 {'I','n','s','t','a','l','l','D','a','t','e',0};
216 static const WCHAR prop_interfaceindexW[] =
217 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
218 static const WCHAR prop_interfacetypeW[] =
219 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
220 static const WCHAR prop_intvalueW[] =
221 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
222 static const WCHAR prop_ipconnectionmetricW[] =
223 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
224 static const WCHAR prop_ipenabledW[] =
225 {'I','P','E','n','a','b','l','e','d',0};
226 static const WCHAR prop_lastbootuptimeW[] =
227 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
228 static const WCHAR prop_localW[] =
229 {'L','o','c','a','l',0};
230 static const WCHAR prop_localdatetimeW[] =
231 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
232 static const WCHAR prop_localeW[] =
233 {'L','o','c','a','l','e',0};
234 static const WCHAR prop_lockpresentW[] =
235 {'L','o','c','k','P','r','e','s','e','n','t',0};
236 static const WCHAR prop_macaddressW[] =
237 {'M','A','C','A','d','d','r','e','s','s',0};
238 static const WCHAR prop_manufacturerW[] =
239 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
240 static const WCHAR prop_maxclockspeedW[] =
241 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
242 static const WCHAR prop_mediatypeW[] =
243 {'M','e','d','i','a','T','y','p','e',0};
244 static const WCHAR prop_memberW[] =
245 {'M','e','m','b','e','r',0};
246 static const WCHAR prop_methodW[] =
247 {'M','e','t','h','o','d',0};
248 static const WCHAR prop_modelW[] =
249 {'M','o','d','e','l',0};
250 static const WCHAR prop_netconnectionstatusW[] =
251 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
252 static const WCHAR prop_networkW[] =
253 {'N','e','t','w','o','r','k',0};
254 static const WCHAR prop_numcoresW[] =
255 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
256 static const WCHAR prop_numlogicalprocessorsW[] =
257 {'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};
258 static const WCHAR prop_numprocessorsW[] =
259 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
260 static const WCHAR prop_osarchitectureW[] =
261 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
262 static const WCHAR prop_oslanguageW[] =
263 {'O','S','L','a','n','g','u','a','g','e',0};
264 static const WCHAR prop_osproductsuiteW[] =
265 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
266 static const WCHAR prop_ostypeW[] =
267 {'O','S','T','y','p','e',0};
268 static const WCHAR prop_parameterW[] =
269 {'P','a','r','a','m','e','t','e','r',0};
270 static const WCHAR prop_physicaladapterW[] =
271 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
272 static const WCHAR prop_pixelsperxlogicalinchW[] =
273 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
274 static const WCHAR prop_pnpdeviceidW[] =
275 {'P','N','P','D','e','v','i','c','e','I','D',0};
276 static const WCHAR prop_pprocessidW[] =
277 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
278 static const WCHAR prop_primaryW[] =
279 {'P','r','i','m','a','r','y',0};
280 static const WCHAR prop_processidW[] =
281 {'P','r','o','c','e','s','s','I','D',0};
282 static const WCHAR prop_processoridW[] =
283 {'P','r','o','c','e','s','s','o','r','I','d',0};
284 static const WCHAR prop_processortypeW[] =
285 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
286 static const WCHAR prop_productW[] =
287 {'P','r','o','d','u','c','t',0};
288 static const WCHAR prop_productnameW[] =
289 {'P','r','o','d','u','c','t','N','a','m','e',0};
290 static const WCHAR prop_referenceddomainnameW[] =
291 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
292 static const WCHAR prop_releasedateW[] =
293 {'R','e','l','e','a','s','e','D','a','t','e',0};
294 static const WCHAR prop_serialnumberW[] =
295 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
296 static const WCHAR prop_servicepackmajorW[] =
297 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
298 static const WCHAR prop_servicepackminorW[] =
299 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
300 static const WCHAR prop_servicetypeW[] =
301 {'S','e','r','v','i','c','e','T','y','p','e',0};
302 static const WCHAR prop_smbiosbiosversionW[] =
303 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
304 static const WCHAR prop_startmodeW[] =
305 {'S','t','a','r','t','M','o','d','e',0};
306 static const WCHAR prop_sidW[] =
307 {'S','I','D',0};
308 static const WCHAR prop_sidlengthW[] =
309 {'S','i','d','L','e','n','g','t','h',0};
310 static const WCHAR prop_sizeW[] =
311 {'S','i','z','e',0};
312 static const WCHAR prop_speedW[] =
313 {'S','p','e','e','d',0};
314 static const WCHAR prop_startingoffsetW[] =
315 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
316 static const WCHAR prop_stateW[] =
317 {'S','t','a','t','e',0};
318 static const WCHAR prop_statusinfoW[] =
319 {'S','t','a','t','u','s','I','n','f','o',0};
320 static const WCHAR prop_strvalueW[] =
321 {'S','t','r','i','n','g','V','a','l','u','e',0};
322 static const WCHAR prop_suitemaskW[] =
323 {'S','u','i','t','e','M','a','s','k',0};
324 static const WCHAR prop_systemdirectoryW[] =
325 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
326 static const WCHAR prop_systemnameW[] =
327 {'S','y','s','t','e','m','N','a','m','e',0};
328 static const WCHAR prop_tagW[] =
329 {'T','a','g',0};
330 static const WCHAR prop_threadcountW[] =
331 {'T','h','r','e','a','d','C','o','u','n','t',0};
332 static const WCHAR prop_totalphysicalmemoryW[] =
333 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
334 static const WCHAR prop_totalvisiblememorysizeW[] =
335 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
336 static const WCHAR prop_typeW[] =
337 {'T','y','p','e',0};
338 static const WCHAR prop_uniqueidW[] =
339 {'U','n','i','q','u','e','I','d',0};
340 static const WCHAR prop_usernameW[] =
341 {'U','s','e','r','N','a','m','e',0};
342 static const WCHAR prop_uuidW[] =
343 {'U','U','I','D',0};
344 static const WCHAR prop_varianttypeW[] =
345 {'V','a','r','i','a','n','t','T','y','p','e',0};
346 static const WCHAR prop_versionW[] =
347 {'V','e','r','s','i','o','n',0};
348 static const WCHAR prop_videoarchitectureW[] =
349 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
350 static const WCHAR prop_videomemorytypeW[] =
351 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
352 static const WCHAR prop_videoprocessorW[] =
353 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
354 static const WCHAR prop_volumenameW[] =
355 {'V','o','l','u','m','e','N','a','m','e',0};
356 static const WCHAR prop_volumeserialnumberW[] =
357 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
358 static const WCHAR prop_workingsetsizeW[] =
359 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
361 /* column definitions must be kept in sync with record structures below */
362 static const struct column col_baseboard[] =
364 { prop_manufacturerW, CIM_STRING },
365 { prop_modelW, CIM_STRING },
366 { prop_nameW, CIM_STRING },
367 { prop_productW, CIM_STRING },
368 { prop_serialnumberW, CIM_STRING },
369 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
370 { prop_versionW, CIM_STRING }
372 static const struct column col_bios[] =
374 { prop_descriptionW, CIM_STRING },
375 { prop_identificationcodeW, CIM_STRING },
376 { prop_manufacturerW, CIM_STRING },
377 { prop_releasedateW, CIM_DATETIME },
378 { prop_serialnumberW, CIM_STRING },
379 { prop_smbiosbiosversionW, CIM_STRING },
380 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
382 static const struct column col_cdromdrive[] =
384 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
385 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
386 { prop_mediatypeW, CIM_STRING },
387 { prop_nameW, CIM_STRING },
388 { prop_pnpdeviceidW, CIM_STRING }
390 static const struct column col_compsys[] =
392 { prop_descriptionW, CIM_STRING },
393 { prop_domainW, CIM_STRING },
394 { prop_domainroleW, CIM_UINT16, VT_I4 },
395 { prop_manufacturerW, CIM_STRING },
396 { prop_modelW, CIM_STRING },
397 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
398 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
399 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
400 { prop_totalphysicalmemoryW, CIM_UINT64 },
401 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
403 static const struct column col_compsysproduct[] =
405 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
406 { prop_uuidW, CIM_STRING }
408 static const struct column col_datafile[] =
410 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
411 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
413 static const struct column col_desktopmonitor[] =
415 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
417 static const struct column col_directory[] =
419 { prop_accessmaskW, CIM_UINT32 },
420 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
422 static const struct column col_diskdrive[] =
424 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
425 { prop_indexW, CIM_UINT32, VT_I4 },
426 { prop_interfacetypeW, CIM_STRING },
427 { prop_manufacturerW, CIM_STRING },
428 { prop_mediatypeW, CIM_STRING },
429 { prop_modelW, CIM_STRING },
430 { prop_pnpdeviceidW, CIM_STRING },
431 { prop_serialnumberW, CIM_STRING },
432 { prop_sizeW, CIM_UINT64 }
434 static const struct column col_diskpartition[] =
436 { prop_bootableW, CIM_BOOLEAN },
437 { prop_bootpartitionW, CIM_BOOLEAN },
438 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
439 { prop_diskindexW, CIM_UINT32, VT_I4 },
440 { prop_indexW, CIM_UINT32, VT_I4 },
441 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
442 { prop_sizeW, CIM_UINT64 },
443 { prop_startingoffsetW, CIM_UINT64 },
444 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
446 static const struct column col_logicaldisk[] =
448 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
449 { prop_drivetypeW, CIM_UINT32, VT_I4 },
450 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
451 { prop_freespaceW, CIM_UINT64 },
452 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
453 { prop_sizeW, CIM_UINT64 },
454 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
455 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
457 static const struct column col_networkadapter[] =
459 { prop_adaptertypeW, CIM_STRING },
460 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
461 { prop_indexW, CIM_UINT32, VT_I4 },
462 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
463 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
464 { prop_manufacturerW, CIM_STRING },
465 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
466 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
467 { prop_physicaladapterW, CIM_BOOLEAN },
468 { prop_pnpdeviceidW, CIM_STRING },
469 { prop_speedW, CIM_UINT64 }
471 static const struct column col_networkadapterconfig[] =
473 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
474 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
475 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
476 { prop_ipenabledW, CIM_BOOLEAN },
477 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }
479 static const struct column col_os[] =
481 { prop_buildnumberW, CIM_STRING },
482 { prop_captionW, CIM_STRING },
483 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
484 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
485 { prop_csdversionW, CIM_STRING },
486 { prop_installdateW, CIM_DATETIME },
487 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
488 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
489 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
490 { prop_nameW, CIM_STRING },
491 { prop_osarchitectureW, CIM_STRING },
492 { prop_oslanguageW, CIM_UINT32, VT_I4 },
493 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
494 { prop_ostypeW, CIM_UINT16, VT_I4 },
495 { prop_primaryW, CIM_BOOLEAN },
496 { prop_serialnumberW, CIM_STRING },
497 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
498 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
499 { prop_suitemaskW, CIM_UINT32, VT_I4 },
500 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
501 { prop_totalvisiblememorysizeW, CIM_UINT64 },
502 { prop_versionW, CIM_STRING }
504 static const struct column col_param[] =
506 { prop_classW, CIM_STRING },
507 { prop_methodW, CIM_STRING },
508 { prop_directionW, CIM_SINT32 },
509 { prop_parameterW, CIM_STRING },
510 { prop_typeW, CIM_UINT32 },
511 { prop_varianttypeW, CIM_UINT32 },
512 { prop_defaultvalueW, CIM_UINT32 }
514 static const struct column col_physicalmedia[] =
516 { prop_serialnumberW, CIM_STRING },
517 { prop_tagW, CIM_STRING }
519 static const struct column col_physicalmemory[] =
521 { prop_capacityW, CIM_UINT64 }
523 static const struct column col_printer[] =
525 { prop_attributesW, CIM_UINT32 },
526 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
527 { prop_horizontalresolutionW, CIM_UINT32 },
528 { prop_localW, CIM_BOOLEAN },
529 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
530 { prop_networkW, CIM_BOOLEAN }
532 static const struct column col_process[] =
534 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
535 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
536 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
537 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
538 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
539 { prop_pprocessidW, CIM_UINT32, VT_I4 },
540 { prop_processidW, CIM_UINT32, VT_I4 },
541 { prop_threadcountW, CIM_UINT32, VT_I4 },
542 { prop_workingsetsizeW, CIM_UINT64 },
543 /* methods */
544 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
546 static const struct column col_processor[] =
548 { prop_addresswidthW, CIM_UINT16, VT_I4 },
549 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
550 { prop_cpustatusW, CIM_UINT16 },
551 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
552 { prop_datawidthW, CIM_UINT16, VT_I4 },
553 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
554 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
555 { prop_familyW, CIM_UINT16, VT_I4 },
556 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
557 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
558 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
559 { prop_numcoresW, CIM_UINT32, VT_I4 },
560 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
561 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
562 { prop_processortypeW, CIM_UINT16, VT_I4 },
563 { prop_uniqueidW, CIM_STRING },
564 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
566 static const struct column col_qualifier[] =
568 { prop_classW, CIM_STRING },
569 { prop_memberW, CIM_STRING },
570 { prop_typeW, CIM_UINT32 },
571 { prop_flavorW, CIM_SINT32 },
572 { prop_nameW, CIM_STRING },
573 { prop_intvalueW, CIM_SINT32 },
574 { prop_strvalueW, CIM_STRING }
576 static const struct column col_service[] =
578 { prop_acceptpauseW, CIM_BOOLEAN },
579 { prop_acceptstopW, CIM_BOOLEAN },
580 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
581 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
582 { prop_processidW, CIM_UINT32 },
583 { prop_servicetypeW, CIM_STRING },
584 { prop_startmodeW, CIM_STRING },
585 { prop_stateW, CIM_STRING },
586 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
587 /* methods */
588 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
589 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
590 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
591 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
593 static const struct column col_sid[] =
595 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
596 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
597 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
598 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
599 { prop_sidlengthW, CIM_UINT32 }
601 static const struct column col_sounddevice[] =
603 { prop_nameW, CIM_STRING },
604 { prop_productnameW, CIM_STRING },
605 { prop_statusinfoW, CIM_UINT16, VT_I4 }
607 static const struct column col_stdregprov[] =
609 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
610 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
611 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
613 static const struct column col_systemenclosure[] =
615 { prop_captionW, CIM_STRING },
616 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY },
617 { prop_descriptionW, CIM_STRING },
618 { prop_lockpresentW, CIM_BOOLEAN },
619 { prop_manufacturerW, CIM_STRING },
620 { prop_nameW, CIM_STRING },
621 { prop_tagW, CIM_STRING },
623 static const struct column col_systemsecurity[] =
625 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
626 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
628 static const struct column col_videocontroller[] =
630 { prop_adapterdactypeW, CIM_STRING },
631 { prop_adapterramW, CIM_UINT32, VT_I4 },
632 { prop_availabilityW, CIM_UINT16 },
633 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
634 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
635 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
636 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
637 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
638 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
639 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
640 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
641 { prop_driverversionW, CIM_STRING },
642 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
643 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
644 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
645 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
646 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC }
649 static const WCHAR baseboard_manufacturerW[] =
650 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
651 static const WCHAR baseboard_serialnumberW[] =
652 {'N','o','n','e',0};
653 static const WCHAR baseboard_tagW[] =
654 {'B','a','s','e',' ','B','o','a','r','d',0};
655 static const WCHAR baseboard_versionW[] =
656 {'1','.','0',0};
657 static const WCHAR bios_descriptionW[] =
658 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
659 static const WCHAR bios_manufacturerW[] =
660 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
661 static const WCHAR bios_releasedateW[] =
662 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
663 static const WCHAR bios_serialnumberW[] =
664 {'0',0};
665 static const WCHAR bios_smbiosbiosversionW[] =
666 {'W','i','n','e',0};
667 static const WCHAR bios_versionW[] =
668 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
669 static const WCHAR cdromdrive_mediatypeW[] =
670 {'C','D','-','R','O','M',0};
671 static const WCHAR cdromdrive_nameW[] =
672 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
673 static const WCHAR cdromdrive_pnpdeviceidW[]=
674 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
675 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
676 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
677 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
678 static const WCHAR compsys_descriptionW[] =
679 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
680 static const WCHAR compsys_domainW[] =
681 {'W','O','R','K','G','R','O','U','P',0};
682 static const WCHAR compsys_manufacturerW[] =
683 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
684 static const WCHAR compsys_modelW[] =
685 {'W','i','n','e',0};
686 static const WCHAR compsysproduct_identifyingnumberW[] =
687 {'0',0};
688 static const WCHAR compsysproduct_uuidW[] =
689 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
690 '0','0','0','0','0','0','0','0','0','0','0','0',0};
691 static const WCHAR diskdrive_interfacetypeW[] =
692 {'I','D','E',0};
693 static const WCHAR diskdrive_manufacturerW[] =
694 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
695 static const WCHAR diskdrive_mediatype_fixedW[] =
696 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
697 static const WCHAR diskdrive_mediatype_removableW[] =
698 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
699 static const WCHAR diskdrive_modelW[] =
700 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
701 static const WCHAR diskdrive_pnpdeviceidW[] =
702 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
703 static const WCHAR diskdrive_serialW[] =
704 {'W','I','N','E','H','D','I','S','K',0};
705 static const WCHAR networkadapter_pnpdeviceidW[]=
706 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
707 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
708 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
709 static const WCHAR os_32bitW[] =
710 {'3','2','-','b','i','t',0};
711 static const WCHAR os_64bitW[] =
712 {'6','4','-','b','i','t',0};
713 static const WCHAR os_buildnumberW[] =
714 {'2','6','0','0',0};
715 static const WCHAR os_captionW[] =
716 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
717 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
718 static const WCHAR os_csdversionW[] =
719 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
720 static const WCHAR os_installdateW[] =
721 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
722 static const WCHAR os_nameW[] =
723 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
724 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
725 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
726 '\\','P','a','r','t','i','t','i','o','n','1',0};
727 static const WCHAR os_serialnumberW[] =
728 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
729 static const WCHAR os_versionW[] =
730 {'5','.','1','.','2','6','0','0',0};
731 static const WCHAR physicalmedia_tagW[] =
732 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
733 static const WCHAR sounddevice_productnameW[] =
734 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
735 static const WCHAR systemenclosure_systemenclosureW[] =
736 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
737 static const WCHAR systemenclosure_tagW[] =
738 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
739 static const WCHAR systemenclosure_manufacturerW[] =
740 {'W','i','n','e',0};
741 static const WCHAR videocontroller_dactypeW[] =
742 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
743 static const WCHAR videocontroller_deviceidW[] =
744 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
745 static const WCHAR videocontroller_driverversionW[] =
746 {'1','.','0',0};
748 #include "pshpack1.h"
749 struct record_baseboard
751 const WCHAR *manufacturer;
752 const WCHAR *model;
753 const WCHAR *name;
754 const WCHAR *product;
755 const WCHAR *serialnumber;
756 const WCHAR *tag;
757 const WCHAR *version;
759 struct record_bios
761 const WCHAR *description;
762 const WCHAR *identificationcode;
763 const WCHAR *manufacturer;
764 const WCHAR *releasedate;
765 const WCHAR *serialnumber;
766 const WCHAR *smbiosbiosversion;
767 const WCHAR *version;
769 struct record_cdromdrive
771 const WCHAR *device_id;
772 const WCHAR *drive;
773 const WCHAR *mediatype;
774 const WCHAR *name;
775 const WCHAR *pnpdevice_id;
777 struct record_computersystem
779 const WCHAR *description;
780 const WCHAR *domain;
781 UINT16 domainrole;
782 const WCHAR *manufacturer;
783 const WCHAR *model;
784 const WCHAR *name;
785 UINT32 num_logical_processors;
786 UINT32 num_processors;
787 UINT64 total_physical_memory;
788 const WCHAR *username;
790 struct record_computersystemproduct
792 const WCHAR *identifyingnumber;
793 const WCHAR *uuid;
795 struct record_datafile
797 const WCHAR *name;
798 const WCHAR *version;
800 struct record_desktopmonitor
802 UINT32 pixelsperxlogicalinch;
804 struct record_directory
806 UINT32 accessmask;
807 const WCHAR *name;
809 struct record_diskdrive
811 const WCHAR *device_id;
812 UINT32 index;
813 const WCHAR *interfacetype;
814 const WCHAR *manufacturer;
815 const WCHAR *mediatype;
816 const WCHAR *model;
817 const WCHAR *pnpdevice_id;
818 const WCHAR *serialnumber;
819 UINT64 size;
821 struct record_diskpartition
823 int bootable;
824 int bootpartition;
825 const WCHAR *device_id;
826 UINT32 diskindex;
827 UINT32 index;
828 const WCHAR *pnpdevice_id;
829 UINT64 size;
830 UINT64 startingoffset;
831 const WCHAR *type;
833 struct record_logicaldisk
835 const WCHAR *device_id;
836 UINT32 drivetype;
837 const WCHAR *filesystem;
838 UINT64 freespace;
839 const WCHAR *name;
840 UINT64 size;
841 const WCHAR *volumename;
842 const WCHAR *volumeserialnumber;
844 struct record_networkadapter
846 const WCHAR *adaptertype;
847 const WCHAR *device_id;
848 UINT32 index;
849 UINT32 interface_index;
850 const WCHAR *mac_address;
851 const WCHAR *manufacturer;
852 const WCHAR *name;
853 UINT16 netconnection_status;
854 int physicaladapter;
855 const WCHAR *pnpdevice_id;
856 UINT64 speed;
858 struct record_networkadapterconfig
860 const WCHAR *dnshostname;
861 UINT32 index;
862 UINT32 ipconnectionmetric;
863 int ipenabled;
864 const WCHAR *mac_address;
866 struct record_operatingsystem
868 const WCHAR *buildnumber;
869 const WCHAR *caption;
870 const WCHAR *codeset;
871 const WCHAR *countrycode;
872 const WCHAR *csdversion;
873 const WCHAR *installdate;
874 const WCHAR *lastbootuptime;
875 const WCHAR *localdatetime;
876 const WCHAR *locale;
877 const WCHAR *name;
878 const WCHAR *osarchitecture;
879 UINT32 oslanguage;
880 UINT32 osproductsuite;
881 UINT16 ostype;
882 int primary;
883 const WCHAR *serialnumber;
884 UINT16 servicepackmajor;
885 UINT16 servicepackminor;
886 UINT32 suitemask;
887 const WCHAR *systemdirectory;
888 UINT64 totalvisiblememorysize;
889 const WCHAR *version;
891 struct record_param
893 const WCHAR *class;
894 const WCHAR *method;
895 INT32 direction;
896 const WCHAR *parameter;
897 UINT32 type;
898 UINT32 varianttype;
899 UINT32 defaultvalue;
901 struct record_physicalmedia
903 const WCHAR *serialnumber;
904 const WCHAR *tag;
906 struct record_physicalmemory
908 UINT64 capacity;
910 struct record_printer
912 UINT32 attributes;
913 const WCHAR *drivername;
914 UINT32 horizontalresolution;
915 int local;
916 const WCHAR *name;
917 int network;
919 struct record_process
921 const WCHAR *caption;
922 const WCHAR *commandline;
923 const WCHAR *description;
924 const WCHAR *handle;
925 const WCHAR *name;
926 UINT32 pprocess_id;
927 UINT32 process_id;
928 UINT32 thread_count;
929 UINT64 workingsetsize;
930 /* methods */
931 class_method *get_owner;
933 struct record_processor
935 UINT16 addresswidth;
936 const WCHAR *caption;
937 UINT16 cpu_status;
938 UINT32 currentclockspeed;
939 UINT16 datawidth;
940 const WCHAR *description;
941 const WCHAR *device_id;
942 UINT16 family;
943 const WCHAR *manufacturer;
944 UINT32 maxclockspeed;
945 const WCHAR *name;
946 UINT32 num_cores;
947 UINT32 num_logical_processors;
948 const WCHAR *processor_id;
949 UINT16 processortype;
950 const WCHAR *unique_id;
951 const WCHAR *version;
953 struct record_qualifier
955 const WCHAR *class;
956 const WCHAR *member;
957 UINT32 type;
958 INT32 flavor;
959 const WCHAR *name;
960 INT32 intvalue;
961 const WCHAR *strvalue;
963 struct record_service
965 int accept_pause;
966 int accept_stop;
967 const WCHAR *displayname;
968 const WCHAR *name;
969 UINT32 process_id;
970 const WCHAR *servicetype;
971 const WCHAR *startmode;
972 const WCHAR *state;
973 const WCHAR *systemname;
974 /* methods */
975 class_method *pause_service;
976 class_method *resume_service;
977 class_method *start_service;
978 class_method *stop_service;
980 struct record_sid
982 const WCHAR *accountname;
983 const struct array *binaryrepresentation;
984 const WCHAR *referenceddomainname;
985 const WCHAR *sid;
986 UINT32 sidlength;
988 struct record_sounddevice
990 const WCHAR *name;
991 const WCHAR *productname;
992 UINT16 statusinfo;
994 struct record_stdregprov
996 class_method *enumkey;
997 class_method *enumvalues;
998 class_method *getstringvalue;
1000 struct record_systemsecurity
1002 class_method *getsd;
1003 class_method *setsd;
1005 struct record_systemenclosure
1007 const WCHAR *caption;
1008 const struct array *chassistypes;
1009 const WCHAR *description;
1010 int lockpresent;
1011 const WCHAR *manufacturer;
1012 const WCHAR *name;
1013 const WCHAR *tag;
1015 struct record_videocontroller
1017 const WCHAR *adapter_dactype;
1018 UINT32 adapter_ram;
1019 UINT16 availability;
1020 const WCHAR *caption;
1021 UINT32 current_bitsperpixel;
1022 UINT32 current_horizontalres;
1023 UINT32 current_refreshrate;
1024 UINT16 current_scanmode;
1025 UINT32 current_verticalres;
1026 const WCHAR *description;
1027 const WCHAR *device_id;
1028 const WCHAR *driverversion;
1029 const WCHAR *name;
1030 const WCHAR *pnpdevice_id;
1031 UINT16 videoarchitecture;
1032 UINT16 videomemorytype;
1033 const WCHAR *videoprocessor;
1035 #include "poppack.h"
1037 static const struct record_baseboard data_baseboard[] =
1039 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1041 static const struct record_bios data_bios[] =
1043 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW,
1044 bios_smbiosbiosversionW, bios_versionW }
1046 static const struct record_computersystemproduct data_compsysproduct[] =
1048 { compsysproduct_identifyingnumberW, compsysproduct_uuidW }
1050 static const struct record_param data_param[] =
1052 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1053 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1054 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1055 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1056 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1057 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1058 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1059 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1060 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1061 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1062 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1063 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1064 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1065 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1066 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1067 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1068 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1069 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1070 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1071 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1072 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1073 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1074 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1075 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1076 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1079 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1080 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1082 static const struct record_physicalmedia data_physicalmedia[] =
1084 { diskdrive_serialW, physicalmedia_tagW }
1086 static const struct record_qualifier data_qualifier[] =
1088 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1089 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1091 static const struct record_sounddevice data_sounddevice[] =
1093 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1095 static const struct record_stdregprov data_stdregprov[] =
1097 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1099 static UINT16 systemenclosure_chassistypes[] =
1103 static const struct array systemenclosure_chassistypes_array =
1105 SIZEOF(systemenclosure_chassistypes),
1106 &systemenclosure_chassistypes
1108 static const struct record_systemenclosure data_systemenclosure[] =
1111 systemenclosure_systemenclosureW,
1112 &systemenclosure_chassistypes_array,
1113 systemenclosure_systemenclosureW,
1114 FALSE,
1115 systemenclosure_manufacturerW,
1116 systemenclosure_systemenclosureW,
1117 systemenclosure_tagW,
1120 static const struct record_systemsecurity data_systemsecurity[] =
1122 { security_get_sd, security_set_sd }
1125 /* check if row matches condition and update status */
1126 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1128 LONGLONG val;
1129 UINT type;
1131 if (!cond)
1133 *status = FILL_STATUS_UNFILTERED;
1134 return TRUE;
1136 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1138 *status = FILL_STATUS_FAILED;
1139 return FALSE;
1141 *status = FILL_STATUS_FILTERED;
1142 return val != 0;
1145 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1147 if (!table->num_rows_allocated)
1149 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1150 table->num_rows_allocated = row_count;
1151 return TRUE;
1153 if (row_count > table->num_rows_allocated)
1155 BYTE *data;
1156 UINT count = max( row_count, table->num_rows_allocated * 2 );
1157 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1158 table->data = data;
1159 table->num_rows_allocated = count;
1161 return TRUE;
1164 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1166 static const WCHAR fmtW[] = {'%','c',':',0};
1167 WCHAR drive[3], root[] = {'A',':','\\',0};
1168 struct record_cdromdrive *rec;
1169 UINT i, row = 0, offset = 0;
1170 DWORD drives = GetLogicalDrives();
1171 enum fill_status status = FILL_STATUS_UNFILTERED;
1173 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1175 for (i = 0; i < sizeof(drives); i++)
1177 if (drives & (1 << i))
1179 root[0] = 'A' + i;
1180 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1181 continue;
1183 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1185 rec = (struct record_cdromdrive *)(table->data + offset);
1186 rec->device_id = cdromdrive_pnpdeviceidW;
1187 sprintfW( drive, fmtW, 'A' + i );
1188 rec->drive = heap_strdupW( drive );
1189 rec->mediatype = cdromdrive_mediatypeW;
1190 rec->name = cdromdrive_nameW;
1191 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1192 if (!match_row( table, row, cond, &status ))
1194 free_row_values( table, row );
1195 continue;
1197 offset += sizeof(*rec);
1198 row++;
1201 TRACE("created %u rows\n", row);
1202 table->num_rows = row;
1203 return status;
1206 static UINT get_processor_count(void)
1208 SYSTEM_BASIC_INFORMATION info;
1210 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1211 return info.NumberOfProcessors;
1214 static UINT get_logical_processor_count( UINT *num_cores )
1216 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1217 UINT i, j, count = 0;
1218 NTSTATUS status;
1219 ULONG len;
1221 if (num_cores) *num_cores = get_processor_count();
1222 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1223 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1225 if (!(info = heap_alloc( len ))) return get_processor_count();
1226 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1227 if (status != STATUS_SUCCESS)
1229 heap_free( info );
1230 return get_processor_count();
1232 if (num_cores) *num_cores = 0;
1233 for (i = 0; i < len / sizeof(*info); i++)
1235 if (info[i].Relationship == RelationProcessorCore)
1237 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1239 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1241 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1244 heap_free( info );
1245 return count;
1248 static UINT64 get_total_physical_memory(void)
1250 MEMORYSTATUSEX status;
1252 status.dwLength = sizeof(status);
1253 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1254 return status.ullTotalPhys;
1257 static WCHAR *get_computername(void)
1259 WCHAR *ret;
1260 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1262 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1263 GetComputerNameW( ret, &size );
1264 return ret;
1267 static WCHAR *get_username(void)
1269 WCHAR *ret;
1270 DWORD compsize, usersize;
1271 DWORD size;
1273 compsize = 0;
1274 GetComputerNameW( NULL, &compsize );
1275 usersize = 0;
1276 GetUserNameW( NULL, &usersize );
1277 size = compsize + usersize; /* two null terminators account for the \ */
1278 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1279 GetComputerNameW( ret, &compsize );
1280 ret[compsize] = '\\';
1281 GetUserNameW( ret + compsize + 1, &usersize );
1282 return ret;
1285 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1287 struct record_computersystem *rec;
1288 enum fill_status status = FILL_STATUS_UNFILTERED;
1289 UINT row = 0;
1291 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1293 rec = (struct record_computersystem *)table->data;
1294 rec->description = compsys_descriptionW;
1295 rec->domain = compsys_domainW;
1296 rec->domainrole = 0; /* standalone workstation */
1297 rec->manufacturer = compsys_manufacturerW;
1298 rec->model = compsys_modelW;
1299 rec->name = get_computername();
1300 rec->num_logical_processors = get_logical_processor_count( NULL );
1301 rec->num_processors = get_processor_count();
1302 rec->total_physical_memory = get_total_physical_memory();
1303 rec->username = get_username();
1304 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1305 else row++;
1307 TRACE("created %u rows\n", row);
1308 table->num_rows = row;
1309 return status;
1312 struct dirstack
1314 WCHAR **dirs;
1315 UINT *len_dirs;
1316 UINT num_dirs;
1317 UINT num_allocated;
1320 static struct dirstack *alloc_dirstack( UINT size )
1322 struct dirstack *dirstack;
1324 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1325 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1327 heap_free( dirstack );
1328 return NULL;
1330 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1332 heap_free( dirstack->dirs );
1333 heap_free( dirstack );
1334 return NULL;
1336 dirstack->num_dirs = 0;
1337 dirstack->num_allocated = size;
1338 return dirstack;
1341 static void clear_dirstack( struct dirstack *dirstack )
1343 UINT i;
1344 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1345 dirstack->num_dirs = 0;
1348 static void free_dirstack( struct dirstack *dirstack )
1350 clear_dirstack( dirstack );
1351 heap_free( dirstack->dirs );
1352 heap_free( dirstack->len_dirs );
1353 heap_free( dirstack );
1356 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1358 UINT size, i = dirstack->num_dirs;
1360 if (!dir) return FALSE;
1362 if (i == dirstack->num_allocated)
1364 WCHAR **tmp;
1365 UINT *len_tmp;
1367 size = dirstack->num_allocated * 2;
1368 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1369 dirstack->dirs = tmp;
1370 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1371 dirstack->len_dirs = len_tmp;
1372 dirstack->num_allocated = size;
1374 dirstack->dirs[i] = dir;
1375 dirstack->len_dirs[i] = len;
1376 dirstack->num_dirs++;
1377 return TRUE;
1380 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1382 if (!dirstack->num_dirs)
1384 *len = 0;
1385 return NULL;
1387 dirstack->num_dirs--;
1388 *len = dirstack->len_dirs[dirstack->num_dirs];
1389 return dirstack->dirs[dirstack->num_dirs];
1392 static const WCHAR *peek_dir( struct dirstack *dirstack )
1394 if (!dirstack->num_dirs) return NULL;
1395 return dirstack->dirs[dirstack->num_dirs - 1];
1398 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1400 UINT i = 0;
1401 WCHAR *ret;
1403 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1404 ret[i++] = drive;
1405 ret[i++] = ':';
1406 ret[i++] = '\\';
1407 if (path && len)
1409 memcpy( ret + i, path, len * sizeof(WCHAR) );
1410 i += len;
1411 ret[i++] = '\\';
1413 ret[i++] = '*';
1414 ret[i] = 0;
1415 return ret;
1418 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1420 UINT i = 0, len = 0;
1421 const WCHAR *p;
1422 WCHAR *ret;
1424 for (p = path; *p; p++)
1426 if (*p == '\\') len += 2;
1427 else len++;
1429 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1430 ret[i++] = drive;
1431 ret[i++] = ':';
1432 ret[i++] = '\\';
1433 ret[i++] = '\\';
1434 for (p = path; *p; p++)
1436 if (*p != '\\') ret[i++] = *p;
1437 else
1439 ret[i++] = '\\';
1440 ret[i++] = '\\';
1443 ret[i] = 0;
1444 return ret;
1447 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1449 const WCHAR *p = path, *start;
1450 UINT len, i;
1451 WCHAR *ret;
1453 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1454 start = path + 4;
1455 len = strlenW( start );
1456 p = start + len - 1;
1457 if (*p == '\\') return NULL;
1459 while (p >= start && *p != '\\') { len--; p--; };
1460 while (p >= start && *p == '\\') { len--; p--; };
1462 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1463 for (i = 0, p = start; p < start + len; p++)
1465 if (p[0] == '\\' && p[1] == '\\')
1467 ret[i++] = '\\';
1468 p++;
1470 else ret[i++] = *p;
1472 ret[i] = 0;
1473 *ret_len = i;
1474 return ret;
1477 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1479 UINT i;
1480 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1481 return FALSE;
1484 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1485 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1487 const struct expr *left, *right;
1489 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1491 left = cond->u.expr.left;
1492 right = cond->u.expr.right;
1493 if (cond->u.expr.op == OP_EQ)
1495 UINT len;
1496 WCHAR *path;
1497 const WCHAR *str = NULL;
1499 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1500 !strcmpW( left->u.propval->name, prop_nameW ) &&
1501 toupperW( right->u.sval[0] ) == toupperW( root ))
1503 str = right->u.sval;
1505 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1506 !strcmpW( right->u.propval->name, prop_nameW ) &&
1507 toupperW( left->u.sval[0] ) == toupperW( root ))
1509 str = left->u.sval;
1511 if (str && (path = build_dirname( str, &len )))
1513 if (seen_dir( dirstack, path ))
1515 heap_free( path );
1516 return ++*count;
1518 else if (push_dir( dirstack, path, len )) return ++*count;
1519 heap_free( path );
1520 return *count = 0;
1523 else if (cond->u.expr.op == OP_OR)
1525 UINT left_count = 0, right_count = 0;
1527 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1528 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1529 return *count += left_count + right_count;
1531 return *count = 0;
1534 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1536 UINT len_path = 0, len_segment = strlenW( segment );
1537 WCHAR *ret;
1539 *len = 0;
1540 if (path) len_path = strlenW( path );
1541 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1542 if (path && len_path)
1544 memcpy( ret, path, len_path * sizeof(WCHAR) );
1545 ret[len_path] = '\\';
1546 *len += len_path + 1;
1548 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1549 *len += len_segment;
1550 ret[*len] = 0;
1551 return ret;
1554 static WCHAR *get_file_version( const WCHAR *filename )
1556 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1557 VS_FIXEDFILEINFO *info;
1558 DWORD size;
1559 void *block;
1560 WCHAR *ret;
1562 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1563 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1565 heap_free( ret );
1566 return NULL;
1568 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1569 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1571 heap_free( block );
1572 heap_free( ret );
1573 return NULL;
1575 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1576 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1577 heap_free( block );
1578 return ret;
1581 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1583 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1584 struct record_datafile *rec;
1585 UINT i, len, row = 0, offset = 0, num_expected_rows;
1586 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1587 DWORD drives = GetLogicalDrives();
1588 WIN32_FIND_DATAW data;
1589 HANDLE handle;
1590 struct dirstack *dirstack;
1591 enum fill_status status = FILL_STATUS_UNFILTERED;
1593 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1595 dirstack = alloc_dirstack(2);
1597 for (i = 0; i < sizeof(drives); i++)
1599 if (!(drives & (1 << i))) continue;
1601 root[0] = 'A' + i;
1602 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1604 num_expected_rows = 0;
1605 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1607 for (;;)
1609 heap_free( glob );
1610 heap_free( path );
1611 path = pop_dir( dirstack, &len );
1612 if (!(glob = build_glob( root[0], path, len )))
1614 status = FILL_STATUS_FAILED;
1615 goto done;
1617 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1621 if (!resize_table( table, row + 1, sizeof(*rec) ))
1623 status = FILL_STATUS_FAILED;
1624 FindClose( handle );
1625 goto done;
1627 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1628 new_path = append_path( path, data.cFileName, &len );
1630 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1632 if (push_dir( dirstack, new_path, len )) continue;
1633 heap_free( new_path );
1634 FindClose( handle );
1635 status = FILL_STATUS_FAILED;
1636 goto done;
1638 rec = (struct record_datafile *)(table->data + offset);
1639 rec->name = build_name( root[0], new_path );
1640 rec->version = get_file_version( rec->name );
1641 if (!match_row( table, row, cond, &status ))
1643 free_row_values( table, row );
1644 continue;
1646 else if (num_expected_rows && row == num_expected_rows - 1)
1648 row++;
1649 FindClose( handle );
1650 status = FILL_STATUS_FILTERED;
1651 goto done;
1653 offset += sizeof(*rec);
1654 row++;
1656 while (FindNextFileW( handle, &data ));
1657 FindClose( handle );
1659 if (!peek_dir( dirstack )) break;
1663 done:
1664 free_dirstack( dirstack );
1665 heap_free( glob );
1666 heap_free( path );
1668 TRACE("created %u rows\n", row);
1669 table->num_rows = row;
1670 return status;
1673 static UINT32 get_pixelsperxlogicalinch(void)
1675 HDC hdc = GetDC( NULL );
1676 UINT32 ret;
1678 if (!hdc) return 96;
1679 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1680 ReleaseDC( NULL, hdc );
1681 return ret;
1684 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1686 struct record_desktopmonitor *rec;
1687 enum fill_status status = FILL_STATUS_UNFILTERED;
1688 UINT row = 0;
1690 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1692 rec = (struct record_desktopmonitor *)table->data;
1693 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1695 if (match_row( table, row, cond, &status )) row++;
1697 TRACE("created %u rows\n", row);
1698 table->num_rows = row;
1699 return status;
1702 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1704 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1705 struct record_directory *rec;
1706 UINT i, len, row = 0, offset = 0, num_expected_rows;
1707 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1708 DWORD drives = GetLogicalDrives();
1709 WIN32_FIND_DATAW data;
1710 HANDLE handle;
1711 struct dirstack *dirstack;
1712 enum fill_status status = FILL_STATUS_UNFILTERED;
1714 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1716 dirstack = alloc_dirstack(2);
1718 for (i = 0; i < sizeof(drives); i++)
1720 if (!(drives & (1 << i))) continue;
1722 root[0] = 'A' + i;
1723 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1725 num_expected_rows = 0;
1726 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1728 for (;;)
1730 heap_free( glob );
1731 heap_free( path );
1732 path = pop_dir( dirstack, &len );
1733 if (!(glob = build_glob( root[0], path, len )))
1735 status = FILL_STATUS_FAILED;
1736 goto done;
1738 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1742 if (!resize_table( table, row + 1, sizeof(*rec) ))
1744 FindClose( handle );
1745 status = FILL_STATUS_FAILED;
1746 goto done;
1748 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1749 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1750 continue;
1752 new_path = append_path( path, data.cFileName, &len );
1753 if (!(push_dir( dirstack, new_path, len )))
1755 heap_free( new_path );
1756 FindClose( handle );
1757 status = FILL_STATUS_FAILED;
1758 goto done;
1760 rec = (struct record_directory *)(table->data + offset);
1761 rec->accessmask = FILE_ALL_ACCESS;
1762 rec->name = build_name( root[0], new_path );
1763 if (!match_row( table, row, cond, &status ))
1765 free_row_values( table, row );
1766 continue;
1768 else if (num_expected_rows && row == num_expected_rows - 1)
1770 row++;
1771 FindClose( handle );
1772 status = FILL_STATUS_FILTERED;
1773 goto done;
1775 offset += sizeof(*rec);
1776 row++;
1778 while (FindNextFileW( handle, &data ));
1779 FindClose( handle );
1781 if (!peek_dir( dirstack )) break;
1785 done:
1786 free_dirstack( dirstack );
1787 heap_free( glob );
1788 heap_free( path );
1790 TRACE("created %u rows\n", row);
1791 table->num_rows = row;
1792 return status;
1795 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1797 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1798 ULARGE_INTEGER free;
1799 DISK_GEOMETRY_EX info;
1800 HANDLE handle;
1801 DWORD bytes_returned;
1803 free.QuadPart = 512 * 1024 * 1024;
1804 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1806 root[4] = dir[0];
1807 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1808 if (handle != INVALID_HANDLE_VALUE)
1810 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1811 *disksize = info.DiskSize.QuadPart;
1812 CloseHandle( handle );
1814 return free.QuadPart;
1817 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1819 static const WCHAR fmtW[] =
1820 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1821 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
1822 struct record_diskdrive *rec;
1823 UINT i, row = 0, offset = 0, index = 0, type;
1824 UINT64 size = 1024 * 1024 * 1024;
1825 DWORD drives = GetLogicalDrives();
1826 enum fill_status status = FILL_STATUS_UNFILTERED;
1828 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
1830 for (i = 0; i < sizeof(drives); i++)
1832 if (drives & (1 << i))
1834 root[0] = 'A' + i;
1835 type = GetDriveTypeW( root );
1836 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1837 continue;
1839 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1841 rec = (struct record_diskdrive *)(table->data + offset);
1842 sprintfW( device_id, fmtW, index );
1843 rec->device_id = heap_strdupW( device_id );
1844 rec->index = index;
1845 rec->interfacetype = diskdrive_interfacetypeW;
1846 rec->manufacturer = diskdrive_manufacturerW;
1847 if (type == DRIVE_FIXED)
1848 rec->mediatype = diskdrive_mediatype_fixedW;
1849 else
1850 rec->mediatype = diskdrive_mediatype_removableW;
1851 rec->model = diskdrive_modelW;
1852 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
1853 rec->serialnumber = diskdrive_serialW;
1854 get_freespace( root, &size );
1855 rec->size = size;
1856 if (!match_row( table, row, cond, &status ))
1858 free_row_values( table, row );
1859 continue;
1861 offset += sizeof(*rec);
1862 index++;
1863 row++;
1866 TRACE("created %u rows\n", row);
1867 table->num_rows = row;
1868 return status;
1871 static WCHAR *get_filesystem( const WCHAR *root )
1873 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1874 WCHAR buffer[MAX_PATH + 1];
1876 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1877 return heap_strdupW( buffer );
1878 return heap_strdupW( ntfsW );
1881 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1883 static const WCHAR fmtW[] =
1884 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1885 WCHAR device_id[32], root[] = {'A',':','\\',0};
1886 struct record_diskpartition *rec;
1887 UINT i, row = 0, offset = 0, type, index = 0;
1888 UINT64 size = 1024 * 1024 * 1024;
1889 DWORD drives = GetLogicalDrives();
1890 enum fill_status status = FILL_STATUS_UNFILTERED;
1892 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1894 for (i = 0; i < sizeof(drives); i++)
1896 if (drives & (1 << i))
1898 root[0] = 'A' + i;
1899 type = GetDriveTypeW( root );
1900 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1901 continue;
1903 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1905 rec = (struct record_diskpartition *)(table->data + offset);
1906 rec->bootable = (i == 2) ? -1 : 0;
1907 rec->bootpartition = (i == 2) ? -1 : 0;
1908 sprintfW( device_id, fmtW, index );
1909 rec->device_id = heap_strdupW( device_id );
1910 rec->diskindex = index;
1911 rec->index = 0;
1912 rec->pnpdevice_id = heap_strdupW( device_id );
1913 get_freespace( root, &size );
1914 rec->size = size;
1915 rec->startingoffset = 0;
1916 rec->type = get_filesystem( root );
1917 if (!match_row( table, row, cond, &status ))
1919 free_row_values( table, row );
1920 continue;
1922 offset += sizeof(*rec);
1923 row++;
1924 index++;
1927 TRACE("created %u rows\n", row);
1928 table->num_rows = row;
1929 return status;
1932 static WCHAR *get_volumename( const WCHAR *root )
1934 WCHAR buf[MAX_PATH + 1] = {0};
1935 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
1936 return heap_strdupW( buf );
1938 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1940 static const WCHAR fmtW[] = {'%','0','8','X',0};
1941 DWORD serial = 0;
1942 WCHAR buffer[9];
1944 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1945 sprintfW( buffer, fmtW, serial );
1946 return heap_strdupW( buffer );
1949 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1951 static const WCHAR fmtW[] = {'%','c',':',0};
1952 WCHAR device_id[3], root[] = {'A',':','\\',0};
1953 struct record_logicaldisk *rec;
1954 UINT i, row = 0, offset = 0, type;
1955 UINT64 size = 1024 * 1024 * 1024;
1956 DWORD drives = GetLogicalDrives();
1957 enum fill_status status = FILL_STATUS_UNFILTERED;
1959 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1961 for (i = 0; i < sizeof(drives); i++)
1963 if (drives & (1 << i))
1965 root[0] = 'A' + i;
1966 type = GetDriveTypeW( root );
1967 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1968 continue;
1970 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1972 rec = (struct record_logicaldisk *)(table->data + offset);
1973 sprintfW( device_id, fmtW, 'A' + i );
1974 rec->device_id = heap_strdupW( device_id );
1975 rec->drivetype = type;
1976 rec->filesystem = get_filesystem( root );
1977 rec->freespace = get_freespace( root, &size );
1978 rec->name = heap_strdupW( device_id );
1979 rec->size = size;
1980 rec->volumename = get_volumename( root );
1981 rec->volumeserialnumber = get_volumeserialnumber( root );
1982 if (!match_row( table, row, cond, &status ))
1984 free_row_values( table, row );
1985 continue;
1987 offset += sizeof(*rec);
1988 row++;
1991 TRACE("created %u rows\n", row);
1992 table->num_rows = row;
1993 return status;
1996 static UINT16 get_connection_status( IF_OPER_STATUS status )
1998 switch (status)
2000 case IfOperStatusDown:
2001 return 0; /* Disconnected */
2002 case IfOperStatusUp:
2003 return 2; /* Connected */
2004 default:
2005 ERR("unhandled status %u\n", status);
2006 break;
2008 return 0;
2010 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2012 static const WCHAR fmtW[] =
2013 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2014 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2015 WCHAR *ret;
2017 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2018 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2019 return ret;
2021 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2023 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2024 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2025 static const WCHAR firewireW[] = {'1','3','9','4',0};
2026 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2028 switch (type)
2030 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2031 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2032 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2033 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2034 default: *physical = 0; return NULL;
2038 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2040 static const WCHAR fmtW[] = {'%','u',0};
2041 WCHAR device_id[11];
2042 struct record_networkadapter *rec;
2043 IP_ADAPTER_ADDRESSES *aa, *buffer;
2044 UINT row = 0, offset = 0, count = 0;
2045 DWORD size = 0, ret;
2046 int physical;
2047 enum fill_status status = FILL_STATUS_UNFILTERED;
2049 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2050 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2052 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2053 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2055 heap_free( buffer );
2056 return FILL_STATUS_FAILED;
2058 for (aa = buffer; aa; aa = aa->Next)
2060 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2062 if (!resize_table( table, count, sizeof(*rec) ))
2064 heap_free( buffer );
2065 return FILL_STATUS_FAILED;
2067 for (aa = buffer; aa; aa = aa->Next)
2069 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2071 rec = (struct record_networkadapter *)(table->data + offset);
2072 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2073 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2074 rec->device_id = heap_strdupW( device_id );
2075 rec->index = aa->u.s.IfIndex;
2076 rec->interface_index = aa->u.s.IfIndex;
2077 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2078 rec->manufacturer = compsys_manufacturerW;
2079 rec->name = heap_strdupW( aa->FriendlyName );
2080 rec->netconnection_status = get_connection_status( aa->OperStatus );
2081 rec->physicaladapter = physical;
2082 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2083 rec->speed = 1000000;
2084 if (!match_row( table, row, cond, &status ))
2086 free_row_values( table, row );
2087 continue;
2089 offset += sizeof(*rec);
2090 row++;
2092 TRACE("created %u rows\n", row);
2093 table->num_rows = row;
2095 heap_free( buffer );
2096 return status;
2099 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2101 const SOCKET_ADDRESS *sa = &addr->Address;
2102 WCHAR buf[NI_MAXHOST];
2104 if (!addr) return NULL;
2105 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2106 0, NI_NAMEREQD )) return NULL;
2107 return heap_strdupW( buf );
2110 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2112 struct record_networkadapterconfig *rec;
2113 IP_ADAPTER_ADDRESSES *aa, *buffer;
2114 UINT row = 0, offset = 0, count = 0;
2115 DWORD size = 0, ret;
2116 enum fill_status status = FILL_STATUS_UNFILTERED;
2118 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2119 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2121 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2122 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2124 heap_free( buffer );
2125 return FILL_STATUS_FAILED;
2127 for (aa = buffer; aa; aa = aa->Next)
2129 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2131 if (!resize_table( table, count, sizeof(*rec) ))
2133 heap_free( buffer );
2134 return FILL_STATUS_FAILED;
2136 for (aa = buffer; aa; aa = aa->Next)
2138 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2140 rec = (struct record_networkadapterconfig *)(table->data + offset);
2141 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2142 rec->index = aa->u.s.IfIndex;
2143 rec->ipconnectionmetric = 20;
2144 rec->ipenabled = -1;
2145 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2146 if (!match_row( table, row, cond, &status ))
2148 free_row_values( table, row );
2149 continue;
2151 offset += sizeof(*rec);
2152 row++;
2154 TRACE("created %u rows\n", row);
2155 table->num_rows = row;
2157 heap_free( buffer );
2158 return status;
2161 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2163 struct record_physicalmemory *rec;
2164 enum fill_status status = FILL_STATUS_UNFILTERED;
2165 UINT row = 0;
2167 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2169 rec = (struct record_physicalmemory *)table->data;
2170 rec->capacity = get_total_physical_memory();
2171 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2172 else row++;
2174 TRACE("created %u rows\n", row);
2175 table->num_rows = row;
2176 return status;
2179 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2181 struct record_printer *rec;
2182 enum fill_status status = FILL_STATUS_UNFILTERED;
2183 PRINTER_INFO_2W *info;
2184 DWORD i, offset = 0, count = 0, size = 0;
2186 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2187 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2189 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2190 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2192 heap_free( info );
2193 return FILL_STATUS_FAILED;
2195 if (!resize_table( table, count, sizeof(*rec) ))
2197 heap_free( info );
2198 return FILL_STATUS_FAILED;
2201 for (i = 0; i < count; i++)
2203 rec = (struct record_printer *)(table->data + offset);
2204 rec->attributes = info[i].Attributes;
2205 rec->drivername = heap_strdupW( info[i].pDriverName );
2206 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2207 rec->local = -1;
2208 rec->name = heap_strdupW( info[i].pPrinterName );
2209 rec->network = 0;
2210 if (!match_row( table, i, cond, &status ))
2212 free_row_values( table, i );
2213 continue;
2215 offset += sizeof(*rec);
2217 TRACE("created %u rows\n", count);
2218 table->num_rows = count;
2220 heap_free( info );
2221 return status;
2224 static WCHAR *get_cmdline( DWORD process_id )
2226 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2227 return NULL; /* FIXME handle different process case */
2230 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2232 static const WCHAR fmtW[] = {'%','u',0};
2233 WCHAR handle[11];
2234 struct record_process *rec;
2235 PROCESSENTRY32W entry;
2236 HANDLE snap;
2237 enum fill_status status = FILL_STATUS_FAILED;
2238 UINT row = 0, offset = 0;
2240 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2241 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2243 entry.dwSize = sizeof(entry);
2244 if (!Process32FirstW( snap, &entry )) goto done;
2245 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2249 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2251 rec = (struct record_process *)(table->data + offset);
2252 rec->caption = heap_strdupW( entry.szExeFile );
2253 rec->commandline = get_cmdline( entry.th32ProcessID );
2254 rec->description = heap_strdupW( entry.szExeFile );
2255 sprintfW( handle, fmtW, entry.th32ProcessID );
2256 rec->handle = heap_strdupW( handle );
2257 rec->name = heap_strdupW( entry.szExeFile );
2258 rec->process_id = entry.th32ProcessID;
2259 rec->pprocess_id = entry.th32ParentProcessID;
2260 rec->thread_count = entry.cntThreads;
2261 rec->workingsetsize = 0;
2262 rec->get_owner = process_get_owner;
2263 if (!match_row( table, row, cond, &status ))
2265 free_row_values( table, row );
2266 continue;
2268 offset += sizeof(*rec);
2269 row++;
2270 } while (Process32NextW( snap, &entry ));
2272 TRACE("created %u rows\n", row);
2273 table->num_rows = row;
2274 status = FILL_STATUS_UNFILTERED;
2276 done:
2277 CloseHandle( snap );
2278 return status;
2281 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2283 #ifdef __i386__
2284 #ifdef _MSC_VER
2285 __cpuid(p, ax);
2286 #else
2287 __asm__("pushl %%ebx\n\t"
2288 "cpuid\n\t"
2289 "movl %%ebx, %%esi\n\t"
2290 "popl %%ebx"
2291 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2292 : "0" (ax));
2293 #endif
2294 #endif
2296 static const WCHAR *get_osarchitecture(void)
2298 SYSTEM_INFO info;
2299 GetNativeSystemInfo( &info );
2300 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2301 return os_32bitW;
2303 static void get_processor_caption( WCHAR *caption )
2305 static const WCHAR fmtW[] =
2306 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2307 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2308 static const WCHAR x86W[] = {'x','8','6',0};
2309 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2310 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2311 unsigned int regs[4] = {0, 0, 0, 0};
2313 do_cpuid( 1, regs );
2314 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2316 static void get_processor_version( WCHAR *version )
2318 static const WCHAR fmtW[] =
2319 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2320 unsigned int regs[4] = {0, 0, 0, 0};
2322 do_cpuid( 1, regs );
2323 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2325 static void get_processor_id( WCHAR *processor_id )
2327 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2328 unsigned int regs[4] = {0, 0, 0, 0};
2330 do_cpuid( 1, regs );
2331 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2333 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2335 unsigned int i;
2336 unsigned char *p = (unsigned char *)regs;
2338 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2339 buffer[i] = 0;
2341 static void get_processor_manufacturer( WCHAR *manufacturer )
2343 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2345 do_cpuid( 0, regs );
2346 tmp = regs[2]; /* swap edx and ecx */
2347 regs[2] = regs[3];
2348 regs[3] = tmp;
2350 regs_to_str( regs + 1, 12, manufacturer );
2352 static void get_processor_name( WCHAR *name )
2354 unsigned int regs[4] = {0, 0, 0, 0};
2356 do_cpuid( 0x80000000, regs );
2357 if (regs[0] >= 0x80000004)
2359 do_cpuid( 0x80000002, regs );
2360 regs_to_str( regs, 16, name );
2361 do_cpuid( 0x80000003, regs );
2362 regs_to_str( regs, 16, name + 16 );
2363 do_cpuid( 0x80000004, regs );
2364 regs_to_str( regs, 16, name + 32 );
2367 static UINT get_processor_currentclockspeed( UINT index )
2369 PROCESSOR_POWER_INFORMATION *info;
2370 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2371 NTSTATUS status;
2373 if ((info = heap_alloc( size )))
2375 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2376 if (!status) ret = info[index].CurrentMhz;
2377 heap_free( info );
2379 return ret;
2381 static UINT get_processor_maxclockspeed( UINT index )
2383 PROCESSOR_POWER_INFORMATION *info;
2384 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2385 NTSTATUS status;
2387 if ((info = heap_alloc( size )))
2389 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2390 if (!status) ret = info[index].MaxMhz;
2391 heap_free( info );
2393 return ret;
2396 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2398 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2399 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2400 struct record_processor *rec;
2401 UINT i, offset = 0, num_cores, num_logical_processors, count = get_processor_count();
2402 enum fill_status status = FILL_STATUS_UNFILTERED;
2404 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2406 get_processor_caption( caption );
2407 get_processor_id( processor_id );
2408 get_processor_manufacturer( manufacturer );
2409 get_processor_name( name );
2410 get_processor_version( version );
2412 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2413 num_cores /= count;
2415 for (i = 0; i < count; i++)
2417 rec = (struct record_processor *)(table->data + offset);
2418 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2419 rec->caption = heap_strdupW( caption );
2420 rec->cpu_status = 1; /* CPU Enabled */
2421 rec->currentclockspeed = get_processor_currentclockspeed( i );
2422 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2423 rec->description = heap_strdupW( caption );
2424 sprintfW( device_id, fmtW, i );
2425 rec->device_id = heap_strdupW( device_id );
2426 rec->family = 2; /* Unknown */
2427 rec->manufacturer = heap_strdupW( manufacturer );
2428 rec->maxclockspeed = get_processor_maxclockspeed( i );
2429 rec->name = heap_strdupW( name );
2430 rec->num_cores = num_cores;
2431 rec->num_logical_processors = num_logical_processors;
2432 rec->processor_id = heap_strdupW( processor_id );
2433 rec->processortype = 3; /* central processor */
2434 rec->unique_id = NULL;
2435 rec->version = heap_strdupW( version );
2436 if (!match_row( table, i, cond, &status ))
2438 free_row_values( table, i );
2439 continue;
2441 offset += sizeof(*rec);
2444 TRACE("created %u rows\n", count);
2445 table->num_rows = count;
2446 return status;
2449 static WCHAR *get_lastbootuptime(void)
2451 static const WCHAR fmtW[] =
2452 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2453 '.','%','0','6','u','+','0','0','0',0};
2454 SYSTEM_TIMEOFDAY_INFORMATION ti;
2455 TIME_FIELDS tf;
2456 WCHAR *ret;
2458 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2460 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2461 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2462 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2463 return ret;
2465 static WCHAR *get_localdatetime(void)
2467 static const WCHAR fmtW[] =
2468 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2469 '.','%','0','6','u','%','+','0','3','d',0};
2470 TIME_ZONE_INFORMATION tzi;
2471 SYSTEMTIME st;
2472 WCHAR *ret;
2473 DWORD Status;
2474 LONG Bias;
2476 Status = GetTimeZoneInformation(&tzi);
2478 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2479 Bias = tzi.Bias;
2480 if(Status == TIME_ZONE_ID_DAYLIGHT)
2481 Bias+= tzi.DaylightBias;
2482 else
2483 Bias+= tzi.StandardBias;
2484 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2486 GetLocalTime(&st);
2487 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2488 return ret;
2490 static WCHAR *get_systemdirectory(void)
2492 void *redir;
2493 WCHAR *ret;
2495 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2496 Wow64DisableWow64FsRedirection( &redir );
2497 GetSystemDirectoryW( ret, MAX_PATH );
2498 Wow64RevertWow64FsRedirection( redir );
2499 return ret;
2501 static WCHAR *get_codeset(void)
2503 static const WCHAR fmtW[] = {'%','u',0};
2504 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2505 if (ret) sprintfW( ret, fmtW, GetACP() );
2506 return ret;
2508 static WCHAR *get_countrycode(void)
2510 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2511 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2512 return ret;
2514 static WCHAR *get_locale(void)
2516 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2517 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2518 return ret;
2521 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2523 struct record_operatingsystem *rec;
2524 enum fill_status status = FILL_STATUS_UNFILTERED;
2525 UINT row = 0;
2527 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2529 rec = (struct record_operatingsystem *)table->data;
2530 rec->buildnumber = os_buildnumberW;
2531 rec->caption = os_captionW;
2532 rec->codeset = get_codeset();
2533 rec->countrycode = get_countrycode();
2534 rec->csdversion = os_csdversionW;
2535 rec->installdate = os_installdateW;
2536 rec->lastbootuptime = get_lastbootuptime();
2537 rec->localdatetime = get_localdatetime();
2538 rec->locale = get_locale();
2539 rec->name = os_nameW;
2540 rec->osarchitecture = get_osarchitecture();
2541 rec->oslanguage = GetSystemDefaultLangID();
2542 rec->osproductsuite = 2461140; /* Windows XP Professional */
2543 rec->ostype = 18; /* WINNT */
2544 rec->primary = -1;
2545 rec->serialnumber = os_serialnumberW;
2546 rec->servicepackmajor = 3;
2547 rec->servicepackminor = 0;
2548 rec->suitemask = 272; /* Single User + Terminal */
2549 rec->systemdirectory = get_systemdirectory();
2550 rec->totalvisiblememorysize = get_total_physical_memory() / 1024;
2551 rec->version = os_versionW;
2552 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2553 else row++;
2555 TRACE("created %u rows\n", row);
2556 table->num_rows = row;
2557 return status;
2560 static const WCHAR *get_service_type( DWORD type )
2562 static const WCHAR filesystem_driverW[] =
2563 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2564 static const WCHAR kernel_driverW[] =
2565 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2566 static const WCHAR own_processW[] =
2567 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2568 static const WCHAR share_processW[] =
2569 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2571 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2572 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2573 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2574 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2575 else ERR("unhandled type 0x%08x\n", type);
2576 return NULL;
2578 static const WCHAR *get_service_state( DWORD state )
2580 static const WCHAR runningW[] =
2581 {'R','u','n','n','i','n','g',0};
2582 static const WCHAR start_pendingW[] =
2583 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2584 static const WCHAR stop_pendingW[] =
2585 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2586 static const WCHAR stoppedW[] =
2587 {'S','t','o','p','p','e','d',0};
2588 static const WCHAR unknownW[] =
2589 {'U','n','k','n','o','w','n',0};
2591 switch (state)
2593 case SERVICE_STOPPED: return stoppedW;
2594 case SERVICE_START_PENDING: return start_pendingW;
2595 case SERVICE_STOP_PENDING: return stop_pendingW;
2596 case SERVICE_RUNNING: return runningW;
2597 default:
2598 ERR("unknown state %u\n", state);
2599 return unknownW;
2602 static const WCHAR *get_service_startmode( DWORD mode )
2604 static const WCHAR bootW[] = {'B','o','o','t',0};
2605 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2606 static const WCHAR autoW[] = {'A','u','t','o',0};
2607 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2608 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2609 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2611 switch (mode)
2613 case SERVICE_BOOT_START: return bootW;
2614 case SERVICE_SYSTEM_START: return systemW;
2615 case SERVICE_AUTO_START: return autoW;
2616 case SERVICE_DEMAND_START: return manualW;
2617 case SERVICE_DISABLED: return disabledW;
2618 default:
2619 ERR("unknown mode 0x%x\n", mode);
2620 return unknownW;
2623 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2625 QUERY_SERVICE_CONFIGW *config = NULL;
2626 SC_HANDLE service;
2627 DWORD size;
2629 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2630 QueryServiceConfigW( service, NULL, 0, &size );
2631 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2632 if (!(config = heap_alloc( size ))) goto done;
2633 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2634 heap_free( config );
2635 config = NULL;
2637 done:
2638 CloseServiceHandle( service );
2639 return config;
2642 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2644 struct record_service *rec;
2645 SC_HANDLE manager;
2646 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2647 SERVICE_STATUS_PROCESS *status;
2648 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2649 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2650 UINT i, row = 0, offset = 0, size = 256, needed, count;
2651 enum fill_status fill_status = FILL_STATUS_FAILED;
2652 BOOL ret;
2654 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2655 if (!(services = heap_alloc( size ))) goto done;
2657 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2658 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2659 &count, NULL, NULL );
2660 if (!ret)
2662 if (GetLastError() != ERROR_MORE_DATA) goto done;
2663 size = needed;
2664 if (!(tmp = heap_realloc( services, size ))) goto done;
2665 services = tmp;
2666 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2667 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2668 &count, NULL, NULL );
2669 if (!ret) goto done;
2671 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2673 GetComputerNameW( sysnameW, &len );
2674 fill_status = FILL_STATUS_UNFILTERED;
2676 for (i = 0; i < count; i++)
2678 QUERY_SERVICE_CONFIGW *config;
2680 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2682 status = &services[i].ServiceStatusProcess;
2683 rec = (struct record_service *)(table->data + offset);
2684 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2685 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2686 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2687 rec->name = heap_strdupW( services[i].lpServiceName );
2688 rec->process_id = status->dwProcessId;
2689 rec->servicetype = get_service_type( status->dwServiceType );
2690 rec->startmode = get_service_startmode( config->dwStartType );
2691 rec->state = get_service_state( status->dwCurrentState );
2692 rec->systemname = heap_strdupW( sysnameW );
2693 rec->pause_service = service_pause_service;
2694 rec->resume_service = service_resume_service;
2695 rec->start_service = service_start_service;
2696 rec->stop_service = service_stop_service;
2697 heap_free( config );
2698 if (!match_row( table, row, cond, &fill_status ))
2700 free_row_values( table, row );
2701 continue;
2703 offset += sizeof(*rec);
2704 row++;
2707 TRACE("created %u rows\n", row);
2708 table->num_rows = row;
2710 done:
2711 CloseServiceHandle( manager );
2712 heap_free( services );
2713 return fill_status;
2716 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
2718 if (!name || !name->Name.Buffer) return NULL;
2719 return heap_strdupW( name->Name.Buffer );
2721 static struct array *get_binaryrepresentation( PSID sid, UINT len )
2723 struct array *array = heap_alloc( sizeof(struct array) );
2724 if (array)
2726 UINT8 *ret = heap_alloc( len );
2727 if (ret)
2729 memcpy( ret, sid, len );
2730 array->count = len;
2731 array->ptr = ret;
2732 return array;
2734 heap_free( array );
2736 return NULL;
2738 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
2740 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
2741 return heap_strdupW( domain->Domains->Name.Buffer );
2743 static const WCHAR *find_sid_str( const struct expr *cond )
2745 const struct expr *left, *right;
2746 const WCHAR *ret = NULL;
2748 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
2750 left = cond->u.expr.left;
2751 right = cond->u.expr.right;
2752 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
2754 ret = right->u.sval;
2756 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
2758 ret = left->u.sval;
2760 return ret;
2763 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
2765 PSID sid;
2766 LSA_REFERENCED_DOMAIN_LIST *domain;
2767 LSA_TRANSLATED_NAME *name;
2768 LSA_HANDLE handle;
2769 LSA_OBJECT_ATTRIBUTES attrs;
2770 const WCHAR *str;
2771 struct record_sid *rec;
2772 UINT len;
2774 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
2775 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2777 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
2778 len = GetLengthSid( sid );
2780 memset( &attrs, 0, sizeof(attrs) );
2781 attrs.Length = sizeof(attrs);
2782 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
2784 LocalFree( sid );
2785 return FILL_STATUS_FAILED;
2787 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
2789 LocalFree( sid );
2790 LsaClose( handle );
2791 return FILL_STATUS_FAILED;
2794 rec = (struct record_sid *)table->data;
2795 rec->accountname = get_accountname( name );
2796 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
2797 rec->referenceddomainname = get_referenceddomainname( domain );
2798 rec->sid = heap_strdupW( str );
2799 rec->sidlength = len;
2801 TRACE("created 1 row\n");
2802 table->num_rows = 1;
2804 LsaFreeMemory( domain );
2805 LsaFreeMemory( name );
2806 LocalFree( sid );
2807 LsaClose( handle );
2808 return FILL_STATUS_FILTERED;
2811 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2813 HDC hdc = GetDC( NULL );
2814 UINT32 ret;
2816 if (!hdc) return 32;
2817 ret = GetDeviceCaps( hdc, BITSPIXEL );
2818 *hres = GetDeviceCaps( hdc, HORZRES );
2819 *vres = GetDeviceCaps( hdc, VERTRES );
2820 ReleaseDC( NULL, hdc );
2821 return ret;
2823 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2825 static const WCHAR fmtW[] =
2826 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2827 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2828 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2829 WCHAR *ret;
2831 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2832 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2833 return ret;
2836 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2839 struct record_videocontroller *rec;
2840 HRESULT hr;
2841 IDXGIFactory *factory = NULL;
2842 IDXGIAdapter *adapter = NULL;
2843 DXGI_ADAPTER_DESC desc;
2844 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2845 const WCHAR *name = videocontroller_deviceidW;
2846 enum fill_status status = FILL_STATUS_UNFILTERED;
2847 UINT row = 0;
2849 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2851 memset (&desc, 0, sizeof(desc));
2852 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2853 if (FAILED(hr)) goto done;
2855 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2856 if (FAILED(hr)) goto done;
2858 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2859 if (SUCCEEDED(hr))
2861 vidmem = desc.DedicatedVideoMemory;
2862 name = desc.Description;
2865 done:
2866 rec = (struct record_videocontroller *)table->data;
2867 rec->adapter_dactype = videocontroller_dactypeW;
2868 rec->adapter_ram = vidmem;
2869 rec->availability = 3; /* Running or Full Power */
2870 rec->caption = heap_strdupW( name );
2871 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2872 rec->current_horizontalres = hres;
2873 rec->current_refreshrate = 0; /* default refresh rate */
2874 rec->current_scanmode = 2; /* Unknown */
2875 rec->current_verticalres = vres;
2876 rec->description = heap_strdupW( name );
2877 rec->device_id = videocontroller_deviceidW;
2878 rec->driverversion = videocontroller_driverversionW;
2879 rec->name = heap_strdupW( name );
2880 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2881 rec->videoarchitecture = 2; /* Unknown */
2882 rec->videomemorytype = 2; /* Unknown */
2883 rec->videoprocessor = heap_strdupW( name );
2884 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2885 else row++;
2887 TRACE("created %u rows\n", row);
2888 table->num_rows = row;
2890 if (adapter) IDXGIAdapter_Release( adapter );
2891 if (factory) IDXGIFactory_Release( factory );
2892 return status;
2895 static struct table builtin_classes[] =
2897 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
2898 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
2899 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
2900 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
2901 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, SIZEOF(data_compsysproduct), 0, (BYTE *)data_compsysproduct },
2902 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
2903 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
2904 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
2905 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
2906 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
2907 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2908 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2909 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
2910 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
2911 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
2912 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
2913 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
2914 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
2915 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
2916 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
2917 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2918 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2919 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
2920 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
2921 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
2922 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
2923 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
2924 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
2925 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
2926 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
2929 void init_table_list( void )
2931 static struct list tables = LIST_INIT( tables );
2932 UINT i;
2934 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
2935 table_list = &tables;