wbemprox: Add bios name column in Win32_BIOS.
[wine.git] / dlls / wbemprox / builtin.c
blob2ff3f5031a951545734f7edea720cbbb3d57487b
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_nameW, CIM_STRING },
378 { prop_releasedateW, CIM_DATETIME },
379 { prop_serialnumberW, CIM_STRING },
380 { prop_smbiosbiosversionW, CIM_STRING },
381 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
383 static const struct column col_cdromdrive[] =
385 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
386 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
387 { prop_mediatypeW, CIM_STRING },
388 { prop_nameW, CIM_STRING },
389 { prop_pnpdeviceidW, CIM_STRING }
391 static const struct column col_compsys[] =
393 { prop_descriptionW, CIM_STRING },
394 { prop_domainW, CIM_STRING },
395 { prop_domainroleW, CIM_UINT16, VT_I4 },
396 { prop_manufacturerW, CIM_STRING },
397 { prop_modelW, CIM_STRING },
398 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
399 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
400 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
401 { prop_totalphysicalmemoryW, CIM_UINT64 },
402 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
404 static const struct column col_compsysproduct[] =
406 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
407 { prop_uuidW, CIM_STRING }
409 static const struct column col_datafile[] =
411 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
412 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
414 static const struct column col_desktopmonitor[] =
416 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
418 static const struct column col_directory[] =
420 { prop_accessmaskW, CIM_UINT32 },
421 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
423 static const struct column col_diskdrive[] =
425 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
426 { prop_indexW, CIM_UINT32, VT_I4 },
427 { prop_interfacetypeW, CIM_STRING },
428 { prop_manufacturerW, CIM_STRING },
429 { prop_mediatypeW, CIM_STRING },
430 { prop_modelW, CIM_STRING },
431 { prop_pnpdeviceidW, CIM_STRING },
432 { prop_serialnumberW, CIM_STRING },
433 { prop_sizeW, CIM_UINT64 }
435 static const struct column col_diskpartition[] =
437 { prop_bootableW, CIM_BOOLEAN },
438 { prop_bootpartitionW, CIM_BOOLEAN },
439 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
440 { prop_diskindexW, CIM_UINT32, VT_I4 },
441 { prop_indexW, CIM_UINT32, VT_I4 },
442 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
443 { prop_sizeW, CIM_UINT64 },
444 { prop_startingoffsetW, CIM_UINT64 },
445 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
447 static const struct column col_logicaldisk[] =
449 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
450 { prop_drivetypeW, CIM_UINT32, VT_I4 },
451 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
452 { prop_freespaceW, CIM_UINT64 },
453 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
454 { prop_sizeW, CIM_UINT64 },
455 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
456 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
458 static const struct column col_networkadapter[] =
460 { prop_adaptertypeW, CIM_STRING },
461 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
462 { prop_indexW, CIM_UINT32, VT_I4 },
463 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
464 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
465 { prop_manufacturerW, CIM_STRING },
466 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
467 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
468 { prop_physicaladapterW, CIM_BOOLEAN },
469 { prop_pnpdeviceidW, CIM_STRING },
470 { prop_speedW, CIM_UINT64 }
472 static const struct column col_networkadapterconfig[] =
474 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
475 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
476 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
477 { prop_ipenabledW, CIM_BOOLEAN },
478 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }
480 static const struct column col_os[] =
482 { prop_buildnumberW, CIM_STRING },
483 { prop_captionW, CIM_STRING },
484 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
485 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
486 { prop_csdversionW, CIM_STRING },
487 { prop_installdateW, CIM_DATETIME },
488 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
489 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
490 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
491 { prop_nameW, CIM_STRING },
492 { prop_osarchitectureW, CIM_STRING },
493 { prop_oslanguageW, CIM_UINT32, VT_I4 },
494 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
495 { prop_ostypeW, CIM_UINT16, VT_I4 },
496 { prop_primaryW, CIM_BOOLEAN },
497 { prop_serialnumberW, CIM_STRING },
498 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
499 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
500 { prop_suitemaskW, CIM_UINT32, VT_I4 },
501 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
502 { prop_totalvisiblememorysizeW, CIM_UINT64 },
503 { prop_versionW, CIM_STRING }
505 static const struct column col_param[] =
507 { prop_classW, CIM_STRING },
508 { prop_methodW, CIM_STRING },
509 { prop_directionW, CIM_SINT32 },
510 { prop_parameterW, CIM_STRING },
511 { prop_typeW, CIM_UINT32 },
512 { prop_varianttypeW, CIM_UINT32 },
513 { prop_defaultvalueW, CIM_UINT32 }
515 static const struct column col_physicalmedia[] =
517 { prop_serialnumberW, CIM_STRING },
518 { prop_tagW, CIM_STRING }
520 static const struct column col_physicalmemory[] =
522 { prop_capacityW, CIM_UINT64 }
524 static const struct column col_printer[] =
526 { prop_attributesW, CIM_UINT32 },
527 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
528 { prop_horizontalresolutionW, CIM_UINT32 },
529 { prop_localW, CIM_BOOLEAN },
530 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
531 { prop_networkW, CIM_BOOLEAN }
533 static const struct column col_process[] =
535 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
536 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
537 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
538 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
539 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
540 { prop_pprocessidW, CIM_UINT32, VT_I4 },
541 { prop_processidW, CIM_UINT32, VT_I4 },
542 { prop_threadcountW, CIM_UINT32, VT_I4 },
543 { prop_workingsetsizeW, CIM_UINT64 },
544 /* methods */
545 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
547 static const struct column col_processor[] =
549 { prop_addresswidthW, CIM_UINT16, VT_I4 },
550 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
551 { prop_cpustatusW, CIM_UINT16 },
552 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
553 { prop_datawidthW, CIM_UINT16, VT_I4 },
554 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
555 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
556 { prop_familyW, CIM_UINT16, VT_I4 },
557 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
558 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
559 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
560 { prop_numcoresW, CIM_UINT32, VT_I4 },
561 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
562 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
563 { prop_processortypeW, CIM_UINT16, VT_I4 },
564 { prop_uniqueidW, CIM_STRING },
565 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
567 static const struct column col_qualifier[] =
569 { prop_classW, CIM_STRING },
570 { prop_memberW, CIM_STRING },
571 { prop_typeW, CIM_UINT32 },
572 { prop_flavorW, CIM_SINT32 },
573 { prop_nameW, CIM_STRING },
574 { prop_intvalueW, CIM_SINT32 },
575 { prop_strvalueW, CIM_STRING }
577 static const struct column col_service[] =
579 { prop_acceptpauseW, CIM_BOOLEAN },
580 { prop_acceptstopW, CIM_BOOLEAN },
581 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
582 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
583 { prop_processidW, CIM_UINT32 },
584 { prop_servicetypeW, CIM_STRING },
585 { prop_startmodeW, CIM_STRING },
586 { prop_stateW, CIM_STRING },
587 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
588 /* methods */
589 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
590 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
591 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
592 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
594 static const struct column col_sid[] =
596 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
597 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
598 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
599 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
600 { prop_sidlengthW, CIM_UINT32 }
602 static const struct column col_sounddevice[] =
604 { prop_nameW, CIM_STRING },
605 { prop_productnameW, CIM_STRING },
606 { prop_statusinfoW, CIM_UINT16, VT_I4 }
608 static const struct column col_stdregprov[] =
610 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
611 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
612 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
614 static const struct column col_systemenclosure[] =
616 { prop_captionW, CIM_STRING },
617 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY },
618 { prop_descriptionW, CIM_STRING },
619 { prop_lockpresentW, CIM_BOOLEAN },
620 { prop_manufacturerW, CIM_STRING },
621 { prop_nameW, CIM_STRING },
622 { prop_tagW, CIM_STRING },
624 static const struct column col_systemsecurity[] =
626 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
627 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
629 static const struct column col_videocontroller[] =
631 { prop_adapterdactypeW, CIM_STRING },
632 { prop_adapterramW, CIM_UINT32, VT_I4 },
633 { prop_availabilityW, CIM_UINT16 },
634 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
635 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
636 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
637 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
638 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
639 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
640 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
641 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
642 { prop_driverversionW, CIM_STRING },
643 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
644 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
645 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
646 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
647 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC }
650 static const WCHAR baseboard_manufacturerW[] =
651 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
652 static const WCHAR baseboard_serialnumberW[] =
653 {'N','o','n','e',0};
654 static const WCHAR baseboard_tagW[] =
655 {'B','a','s','e',' ','B','o','a','r','d',0};
656 static const WCHAR baseboard_versionW[] =
657 {'1','.','0',0};
658 static const WCHAR bios_descriptionW[] =
659 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
660 static const WCHAR bios_manufacturerW[] =
661 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
662 static const WCHAR bios_nameW[] =
663 {'W','I','N','E',' ','B','I','O','S',0};
664 static const WCHAR bios_releasedateW[] =
665 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
666 static const WCHAR bios_serialnumberW[] =
667 {'0',0};
668 static const WCHAR bios_smbiosbiosversionW[] =
669 {'W','i','n','e',0};
670 static const WCHAR bios_versionW[] =
671 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
672 static const WCHAR cdromdrive_mediatypeW[] =
673 {'C','D','-','R','O','M',0};
674 static const WCHAR cdromdrive_nameW[] =
675 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
676 static const WCHAR cdromdrive_pnpdeviceidW[]=
677 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
678 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
679 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
680 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
681 static const WCHAR compsys_descriptionW[] =
682 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
683 static const WCHAR compsys_domainW[] =
684 {'W','O','R','K','G','R','O','U','P',0};
685 static const WCHAR compsys_manufacturerW[] =
686 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
687 static const WCHAR compsys_modelW[] =
688 {'W','i','n','e',0};
689 static const WCHAR compsysproduct_identifyingnumberW[] =
690 {'0',0};
691 static const WCHAR compsysproduct_uuidW[] =
692 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
693 '0','0','0','0','0','0','0','0','0','0','0','0',0};
694 static const WCHAR diskdrive_interfacetypeW[] =
695 {'I','D','E',0};
696 static const WCHAR diskdrive_manufacturerW[] =
697 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
698 static const WCHAR diskdrive_mediatype_fixedW[] =
699 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
700 static const WCHAR diskdrive_mediatype_removableW[] =
701 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
702 static const WCHAR diskdrive_modelW[] =
703 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
704 static const WCHAR diskdrive_pnpdeviceidW[] =
705 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
706 static const WCHAR diskdrive_serialW[] =
707 {'W','I','N','E','H','D','I','S','K',0};
708 static const WCHAR networkadapter_pnpdeviceidW[]=
709 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
710 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
711 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
712 static const WCHAR os_32bitW[] =
713 {'3','2','-','b','i','t',0};
714 static const WCHAR os_64bitW[] =
715 {'6','4','-','b','i','t',0};
716 static const WCHAR os_buildnumberW[] =
717 {'2','6','0','0',0};
718 static const WCHAR os_captionW[] =
719 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
720 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
721 static const WCHAR os_csdversionW[] =
722 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
723 static const WCHAR os_installdateW[] =
724 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
725 static const WCHAR os_nameW[] =
726 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
727 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
728 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
729 '\\','P','a','r','t','i','t','i','o','n','1',0};
730 static const WCHAR os_serialnumberW[] =
731 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
732 static const WCHAR os_versionW[] =
733 {'5','.','1','.','2','6','0','0',0};
734 static const WCHAR physicalmedia_tagW[] =
735 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
736 static const WCHAR sounddevice_productnameW[] =
737 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
738 static const WCHAR systemenclosure_systemenclosureW[] =
739 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
740 static const WCHAR systemenclosure_tagW[] =
741 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
742 static const WCHAR systemenclosure_manufacturerW[] =
743 {'W','i','n','e',0};
744 static const WCHAR videocontroller_dactypeW[] =
745 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
746 static const WCHAR videocontroller_deviceidW[] =
747 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
748 static const WCHAR videocontroller_driverversionW[] =
749 {'1','.','0',0};
751 #include "pshpack1.h"
752 struct record_baseboard
754 const WCHAR *manufacturer;
755 const WCHAR *model;
756 const WCHAR *name;
757 const WCHAR *product;
758 const WCHAR *serialnumber;
759 const WCHAR *tag;
760 const WCHAR *version;
762 struct record_bios
764 const WCHAR *description;
765 const WCHAR *identificationcode;
766 const WCHAR *manufacturer;
767 const WCHAR *name;
768 const WCHAR *releasedate;
769 const WCHAR *serialnumber;
770 const WCHAR *smbiosbiosversion;
771 const WCHAR *version;
773 struct record_cdromdrive
775 const WCHAR *device_id;
776 const WCHAR *drive;
777 const WCHAR *mediatype;
778 const WCHAR *name;
779 const WCHAR *pnpdevice_id;
781 struct record_computersystem
783 const WCHAR *description;
784 const WCHAR *domain;
785 UINT16 domainrole;
786 const WCHAR *manufacturer;
787 const WCHAR *model;
788 const WCHAR *name;
789 UINT32 num_logical_processors;
790 UINT32 num_processors;
791 UINT64 total_physical_memory;
792 const WCHAR *username;
794 struct record_computersystemproduct
796 const WCHAR *identifyingnumber;
797 const WCHAR *uuid;
799 struct record_datafile
801 const WCHAR *name;
802 const WCHAR *version;
804 struct record_desktopmonitor
806 UINT32 pixelsperxlogicalinch;
808 struct record_directory
810 UINT32 accessmask;
811 const WCHAR *name;
813 struct record_diskdrive
815 const WCHAR *device_id;
816 UINT32 index;
817 const WCHAR *interfacetype;
818 const WCHAR *manufacturer;
819 const WCHAR *mediatype;
820 const WCHAR *model;
821 const WCHAR *pnpdevice_id;
822 const WCHAR *serialnumber;
823 UINT64 size;
825 struct record_diskpartition
827 int bootable;
828 int bootpartition;
829 const WCHAR *device_id;
830 UINT32 diskindex;
831 UINT32 index;
832 const WCHAR *pnpdevice_id;
833 UINT64 size;
834 UINT64 startingoffset;
835 const WCHAR *type;
837 struct record_logicaldisk
839 const WCHAR *device_id;
840 UINT32 drivetype;
841 const WCHAR *filesystem;
842 UINT64 freespace;
843 const WCHAR *name;
844 UINT64 size;
845 const WCHAR *volumename;
846 const WCHAR *volumeserialnumber;
848 struct record_networkadapter
850 const WCHAR *adaptertype;
851 const WCHAR *device_id;
852 UINT32 index;
853 UINT32 interface_index;
854 const WCHAR *mac_address;
855 const WCHAR *manufacturer;
856 const WCHAR *name;
857 UINT16 netconnection_status;
858 int physicaladapter;
859 const WCHAR *pnpdevice_id;
860 UINT64 speed;
862 struct record_networkadapterconfig
864 const WCHAR *dnshostname;
865 UINT32 index;
866 UINT32 ipconnectionmetric;
867 int ipenabled;
868 const WCHAR *mac_address;
870 struct record_operatingsystem
872 const WCHAR *buildnumber;
873 const WCHAR *caption;
874 const WCHAR *codeset;
875 const WCHAR *countrycode;
876 const WCHAR *csdversion;
877 const WCHAR *installdate;
878 const WCHAR *lastbootuptime;
879 const WCHAR *localdatetime;
880 const WCHAR *locale;
881 const WCHAR *name;
882 const WCHAR *osarchitecture;
883 UINT32 oslanguage;
884 UINT32 osproductsuite;
885 UINT16 ostype;
886 int primary;
887 const WCHAR *serialnumber;
888 UINT16 servicepackmajor;
889 UINT16 servicepackminor;
890 UINT32 suitemask;
891 const WCHAR *systemdirectory;
892 UINT64 totalvisiblememorysize;
893 const WCHAR *version;
895 struct record_param
897 const WCHAR *class;
898 const WCHAR *method;
899 INT32 direction;
900 const WCHAR *parameter;
901 UINT32 type;
902 UINT32 varianttype;
903 UINT32 defaultvalue;
905 struct record_physicalmedia
907 const WCHAR *serialnumber;
908 const WCHAR *tag;
910 struct record_physicalmemory
912 UINT64 capacity;
914 struct record_printer
916 UINT32 attributes;
917 const WCHAR *drivername;
918 UINT32 horizontalresolution;
919 int local;
920 const WCHAR *name;
921 int network;
923 struct record_process
925 const WCHAR *caption;
926 const WCHAR *commandline;
927 const WCHAR *description;
928 const WCHAR *handle;
929 const WCHAR *name;
930 UINT32 pprocess_id;
931 UINT32 process_id;
932 UINT32 thread_count;
933 UINT64 workingsetsize;
934 /* methods */
935 class_method *get_owner;
937 struct record_processor
939 UINT16 addresswidth;
940 const WCHAR *caption;
941 UINT16 cpu_status;
942 UINT32 currentclockspeed;
943 UINT16 datawidth;
944 const WCHAR *description;
945 const WCHAR *device_id;
946 UINT16 family;
947 const WCHAR *manufacturer;
948 UINT32 maxclockspeed;
949 const WCHAR *name;
950 UINT32 num_cores;
951 UINT32 num_logical_processors;
952 const WCHAR *processor_id;
953 UINT16 processortype;
954 const WCHAR *unique_id;
955 const WCHAR *version;
957 struct record_qualifier
959 const WCHAR *class;
960 const WCHAR *member;
961 UINT32 type;
962 INT32 flavor;
963 const WCHAR *name;
964 INT32 intvalue;
965 const WCHAR *strvalue;
967 struct record_service
969 int accept_pause;
970 int accept_stop;
971 const WCHAR *displayname;
972 const WCHAR *name;
973 UINT32 process_id;
974 const WCHAR *servicetype;
975 const WCHAR *startmode;
976 const WCHAR *state;
977 const WCHAR *systemname;
978 /* methods */
979 class_method *pause_service;
980 class_method *resume_service;
981 class_method *start_service;
982 class_method *stop_service;
984 struct record_sid
986 const WCHAR *accountname;
987 const struct array *binaryrepresentation;
988 const WCHAR *referenceddomainname;
989 const WCHAR *sid;
990 UINT32 sidlength;
992 struct record_sounddevice
994 const WCHAR *name;
995 const WCHAR *productname;
996 UINT16 statusinfo;
998 struct record_stdregprov
1000 class_method *enumkey;
1001 class_method *enumvalues;
1002 class_method *getstringvalue;
1004 struct record_systemsecurity
1006 class_method *getsd;
1007 class_method *setsd;
1009 struct record_systemenclosure
1011 const WCHAR *caption;
1012 const struct array *chassistypes;
1013 const WCHAR *description;
1014 int lockpresent;
1015 const WCHAR *manufacturer;
1016 const WCHAR *name;
1017 const WCHAR *tag;
1019 struct record_videocontroller
1021 const WCHAR *adapter_dactype;
1022 UINT32 adapter_ram;
1023 UINT16 availability;
1024 const WCHAR *caption;
1025 UINT32 current_bitsperpixel;
1026 UINT32 current_horizontalres;
1027 UINT32 current_refreshrate;
1028 UINT16 current_scanmode;
1029 UINT32 current_verticalres;
1030 const WCHAR *description;
1031 const WCHAR *device_id;
1032 const WCHAR *driverversion;
1033 const WCHAR *name;
1034 const WCHAR *pnpdevice_id;
1035 UINT16 videoarchitecture;
1036 UINT16 videomemorytype;
1037 const WCHAR *videoprocessor;
1039 #include "poppack.h"
1041 static const struct record_baseboard data_baseboard[] =
1043 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1045 static const struct record_bios data_bios[] =
1047 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_nameW, bios_releasedateW, bios_serialnumberW,
1048 bios_smbiosbiosversionW, bios_versionW }
1050 static const struct record_computersystemproduct data_compsysproduct[] =
1052 { compsysproduct_identifyingnumberW, compsysproduct_uuidW }
1054 static const struct record_param data_param[] =
1056 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1057 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1058 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1059 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1060 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1061 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1062 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1063 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1064 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1065 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1066 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1067 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1068 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1069 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1070 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1071 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1072 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1073 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1074 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1075 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1076 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1077 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1078 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1079 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1080 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1083 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1084 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1086 static const struct record_physicalmedia data_physicalmedia[] =
1088 { diskdrive_serialW, physicalmedia_tagW }
1090 static const struct record_qualifier data_qualifier[] =
1092 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1093 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1095 static const struct record_sounddevice data_sounddevice[] =
1097 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1099 static const struct record_stdregprov data_stdregprov[] =
1101 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1103 static UINT16 systemenclosure_chassistypes[] =
1107 static const struct array systemenclosure_chassistypes_array =
1109 SIZEOF(systemenclosure_chassistypes),
1110 &systemenclosure_chassistypes
1112 static const struct record_systemenclosure data_systemenclosure[] =
1115 systemenclosure_systemenclosureW,
1116 &systemenclosure_chassistypes_array,
1117 systemenclosure_systemenclosureW,
1118 FALSE,
1119 systemenclosure_manufacturerW,
1120 systemenclosure_systemenclosureW,
1121 systemenclosure_tagW,
1124 static const struct record_systemsecurity data_systemsecurity[] =
1126 { security_get_sd, security_set_sd }
1129 /* check if row matches condition and update status */
1130 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1132 LONGLONG val;
1133 UINT type;
1135 if (!cond)
1137 *status = FILL_STATUS_UNFILTERED;
1138 return TRUE;
1140 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1142 *status = FILL_STATUS_FAILED;
1143 return FALSE;
1145 *status = FILL_STATUS_FILTERED;
1146 return val != 0;
1149 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1151 if (!table->num_rows_allocated)
1153 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1154 table->num_rows_allocated = row_count;
1155 return TRUE;
1157 if (row_count > table->num_rows_allocated)
1159 BYTE *data;
1160 UINT count = max( row_count, table->num_rows_allocated * 2 );
1161 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1162 table->data = data;
1163 table->num_rows_allocated = count;
1165 return TRUE;
1168 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1170 static const WCHAR fmtW[] = {'%','c',':',0};
1171 WCHAR drive[3], root[] = {'A',':','\\',0};
1172 struct record_cdromdrive *rec;
1173 UINT i, row = 0, offset = 0;
1174 DWORD drives = GetLogicalDrives();
1175 enum fill_status status = FILL_STATUS_UNFILTERED;
1177 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1179 for (i = 0; i < sizeof(drives); i++)
1181 if (drives & (1 << i))
1183 root[0] = 'A' + i;
1184 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1185 continue;
1187 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1189 rec = (struct record_cdromdrive *)(table->data + offset);
1190 rec->device_id = cdromdrive_pnpdeviceidW;
1191 sprintfW( drive, fmtW, 'A' + i );
1192 rec->drive = heap_strdupW( drive );
1193 rec->mediatype = cdromdrive_mediatypeW;
1194 rec->name = cdromdrive_nameW;
1195 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1196 if (!match_row( table, row, cond, &status ))
1198 free_row_values( table, row );
1199 continue;
1201 offset += sizeof(*rec);
1202 row++;
1205 TRACE("created %u rows\n", row);
1206 table->num_rows = row;
1207 return status;
1210 static UINT get_processor_count(void)
1212 SYSTEM_BASIC_INFORMATION info;
1214 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1215 return info.NumberOfProcessors;
1218 static UINT get_logical_processor_count( UINT *num_cores )
1220 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1221 UINT i, j, count = 0;
1222 NTSTATUS status;
1223 ULONG len;
1225 if (num_cores) *num_cores = get_processor_count();
1226 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1227 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1229 if (!(info = heap_alloc( len ))) return get_processor_count();
1230 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1231 if (status != STATUS_SUCCESS)
1233 heap_free( info );
1234 return get_processor_count();
1236 if (num_cores) *num_cores = 0;
1237 for (i = 0; i < len / sizeof(*info); i++)
1239 if (info[i].Relationship == RelationProcessorCore)
1241 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1243 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1245 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1248 heap_free( info );
1249 return count;
1252 static UINT64 get_total_physical_memory(void)
1254 MEMORYSTATUSEX status;
1256 status.dwLength = sizeof(status);
1257 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1258 return status.ullTotalPhys;
1261 static WCHAR *get_computername(void)
1263 WCHAR *ret;
1264 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1266 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1267 GetComputerNameW( ret, &size );
1268 return ret;
1271 static WCHAR *get_username(void)
1273 WCHAR *ret;
1274 DWORD compsize, usersize;
1275 DWORD size;
1277 compsize = 0;
1278 GetComputerNameW( NULL, &compsize );
1279 usersize = 0;
1280 GetUserNameW( NULL, &usersize );
1281 size = compsize + usersize; /* two null terminators account for the \ */
1282 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1283 GetComputerNameW( ret, &compsize );
1284 ret[compsize] = '\\';
1285 GetUserNameW( ret + compsize + 1, &usersize );
1286 return ret;
1289 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1291 struct record_computersystem *rec;
1292 enum fill_status status = FILL_STATUS_UNFILTERED;
1293 UINT row = 0;
1295 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1297 rec = (struct record_computersystem *)table->data;
1298 rec->description = compsys_descriptionW;
1299 rec->domain = compsys_domainW;
1300 rec->domainrole = 0; /* standalone workstation */
1301 rec->manufacturer = compsys_manufacturerW;
1302 rec->model = compsys_modelW;
1303 rec->name = get_computername();
1304 rec->num_logical_processors = get_logical_processor_count( NULL );
1305 rec->num_processors = get_processor_count();
1306 rec->total_physical_memory = get_total_physical_memory();
1307 rec->username = get_username();
1308 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1309 else row++;
1311 TRACE("created %u rows\n", row);
1312 table->num_rows = row;
1313 return status;
1316 struct dirstack
1318 WCHAR **dirs;
1319 UINT *len_dirs;
1320 UINT num_dirs;
1321 UINT num_allocated;
1324 static struct dirstack *alloc_dirstack( UINT size )
1326 struct dirstack *dirstack;
1328 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1329 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1331 heap_free( dirstack );
1332 return NULL;
1334 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1336 heap_free( dirstack->dirs );
1337 heap_free( dirstack );
1338 return NULL;
1340 dirstack->num_dirs = 0;
1341 dirstack->num_allocated = size;
1342 return dirstack;
1345 static void clear_dirstack( struct dirstack *dirstack )
1347 UINT i;
1348 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1349 dirstack->num_dirs = 0;
1352 static void free_dirstack( struct dirstack *dirstack )
1354 clear_dirstack( dirstack );
1355 heap_free( dirstack->dirs );
1356 heap_free( dirstack->len_dirs );
1357 heap_free( dirstack );
1360 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1362 UINT size, i = dirstack->num_dirs;
1364 if (!dir) return FALSE;
1366 if (i == dirstack->num_allocated)
1368 WCHAR **tmp;
1369 UINT *len_tmp;
1371 size = dirstack->num_allocated * 2;
1372 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1373 dirstack->dirs = tmp;
1374 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1375 dirstack->len_dirs = len_tmp;
1376 dirstack->num_allocated = size;
1378 dirstack->dirs[i] = dir;
1379 dirstack->len_dirs[i] = len;
1380 dirstack->num_dirs++;
1381 return TRUE;
1384 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1386 if (!dirstack->num_dirs)
1388 *len = 0;
1389 return NULL;
1391 dirstack->num_dirs--;
1392 *len = dirstack->len_dirs[dirstack->num_dirs];
1393 return dirstack->dirs[dirstack->num_dirs];
1396 static const WCHAR *peek_dir( struct dirstack *dirstack )
1398 if (!dirstack->num_dirs) return NULL;
1399 return dirstack->dirs[dirstack->num_dirs - 1];
1402 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1404 UINT i = 0;
1405 WCHAR *ret;
1407 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1408 ret[i++] = drive;
1409 ret[i++] = ':';
1410 ret[i++] = '\\';
1411 if (path && len)
1413 memcpy( ret + i, path, len * sizeof(WCHAR) );
1414 i += len;
1415 ret[i++] = '\\';
1417 ret[i++] = '*';
1418 ret[i] = 0;
1419 return ret;
1422 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1424 UINT i = 0, len = 0;
1425 const WCHAR *p;
1426 WCHAR *ret;
1428 for (p = path; *p; p++)
1430 if (*p == '\\') len += 2;
1431 else len++;
1433 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1434 ret[i++] = drive;
1435 ret[i++] = ':';
1436 ret[i++] = '\\';
1437 ret[i++] = '\\';
1438 for (p = path; *p; p++)
1440 if (*p != '\\') ret[i++] = *p;
1441 else
1443 ret[i++] = '\\';
1444 ret[i++] = '\\';
1447 ret[i] = 0;
1448 return ret;
1451 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1453 const WCHAR *p = path, *start;
1454 UINT len, i;
1455 WCHAR *ret;
1457 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1458 start = path + 4;
1459 len = strlenW( start );
1460 p = start + len - 1;
1461 if (*p == '\\') return NULL;
1463 while (p >= start && *p != '\\') { len--; p--; };
1464 while (p >= start && *p == '\\') { len--; p--; };
1466 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1467 for (i = 0, p = start; p < start + len; p++)
1469 if (p[0] == '\\' && p[1] == '\\')
1471 ret[i++] = '\\';
1472 p++;
1474 else ret[i++] = *p;
1476 ret[i] = 0;
1477 *ret_len = i;
1478 return ret;
1481 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1483 UINT i;
1484 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1485 return FALSE;
1488 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1489 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1491 const struct expr *left, *right;
1493 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1495 left = cond->u.expr.left;
1496 right = cond->u.expr.right;
1497 if (cond->u.expr.op == OP_EQ)
1499 UINT len;
1500 WCHAR *path;
1501 const WCHAR *str = NULL;
1503 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1504 !strcmpW( left->u.propval->name, prop_nameW ) &&
1505 toupperW( right->u.sval[0] ) == toupperW( root ))
1507 str = right->u.sval;
1509 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1510 !strcmpW( right->u.propval->name, prop_nameW ) &&
1511 toupperW( left->u.sval[0] ) == toupperW( root ))
1513 str = left->u.sval;
1515 if (str && (path = build_dirname( str, &len )))
1517 if (seen_dir( dirstack, path ))
1519 heap_free( path );
1520 return ++*count;
1522 else if (push_dir( dirstack, path, len )) return ++*count;
1523 heap_free( path );
1524 return *count = 0;
1527 else if (cond->u.expr.op == OP_OR)
1529 UINT left_count = 0, right_count = 0;
1531 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1532 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1533 return *count += left_count + right_count;
1535 return *count = 0;
1538 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1540 UINT len_path = 0, len_segment = strlenW( segment );
1541 WCHAR *ret;
1543 *len = 0;
1544 if (path) len_path = strlenW( path );
1545 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1546 if (path && len_path)
1548 memcpy( ret, path, len_path * sizeof(WCHAR) );
1549 ret[len_path] = '\\';
1550 *len += len_path + 1;
1552 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1553 *len += len_segment;
1554 ret[*len] = 0;
1555 return ret;
1558 static WCHAR *get_file_version( const WCHAR *filename )
1560 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1561 VS_FIXEDFILEINFO *info;
1562 DWORD size;
1563 void *block;
1564 WCHAR *ret;
1566 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1567 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1569 heap_free( ret );
1570 return NULL;
1572 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1573 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1575 heap_free( block );
1576 heap_free( ret );
1577 return NULL;
1579 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1580 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1581 heap_free( block );
1582 return ret;
1585 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1587 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1588 struct record_datafile *rec;
1589 UINT i, len, row = 0, offset = 0, num_expected_rows;
1590 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1591 DWORD drives = GetLogicalDrives();
1592 WIN32_FIND_DATAW data;
1593 HANDLE handle;
1594 struct dirstack *dirstack;
1595 enum fill_status status = FILL_STATUS_UNFILTERED;
1597 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1599 dirstack = alloc_dirstack(2);
1601 for (i = 0; i < sizeof(drives); i++)
1603 if (!(drives & (1 << i))) continue;
1605 root[0] = 'A' + i;
1606 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1608 num_expected_rows = 0;
1609 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1611 for (;;)
1613 heap_free( glob );
1614 heap_free( path );
1615 path = pop_dir( dirstack, &len );
1616 if (!(glob = build_glob( root[0], path, len )))
1618 status = FILL_STATUS_FAILED;
1619 goto done;
1621 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1625 if (!resize_table( table, row + 1, sizeof(*rec) ))
1627 status = FILL_STATUS_FAILED;
1628 FindClose( handle );
1629 goto done;
1631 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1632 new_path = append_path( path, data.cFileName, &len );
1634 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1636 if (push_dir( dirstack, new_path, len )) continue;
1637 heap_free( new_path );
1638 FindClose( handle );
1639 status = FILL_STATUS_FAILED;
1640 goto done;
1642 rec = (struct record_datafile *)(table->data + offset);
1643 rec->name = build_name( root[0], new_path );
1644 rec->version = get_file_version( rec->name );
1645 if (!match_row( table, row, cond, &status ))
1647 free_row_values( table, row );
1648 continue;
1650 else if (num_expected_rows && row == num_expected_rows - 1)
1652 row++;
1653 FindClose( handle );
1654 status = FILL_STATUS_FILTERED;
1655 goto done;
1657 offset += sizeof(*rec);
1658 row++;
1660 while (FindNextFileW( handle, &data ));
1661 FindClose( handle );
1663 if (!peek_dir( dirstack )) break;
1667 done:
1668 free_dirstack( dirstack );
1669 heap_free( glob );
1670 heap_free( path );
1672 TRACE("created %u rows\n", row);
1673 table->num_rows = row;
1674 return status;
1677 static UINT32 get_pixelsperxlogicalinch(void)
1679 HDC hdc = GetDC( NULL );
1680 UINT32 ret;
1682 if (!hdc) return 96;
1683 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1684 ReleaseDC( NULL, hdc );
1685 return ret;
1688 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1690 struct record_desktopmonitor *rec;
1691 enum fill_status status = FILL_STATUS_UNFILTERED;
1692 UINT row = 0;
1694 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1696 rec = (struct record_desktopmonitor *)table->data;
1697 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1699 if (match_row( table, row, cond, &status )) row++;
1701 TRACE("created %u rows\n", row);
1702 table->num_rows = row;
1703 return status;
1706 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1708 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1709 struct record_directory *rec;
1710 UINT i, len, row = 0, offset = 0, num_expected_rows;
1711 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1712 DWORD drives = GetLogicalDrives();
1713 WIN32_FIND_DATAW data;
1714 HANDLE handle;
1715 struct dirstack *dirstack;
1716 enum fill_status status = FILL_STATUS_UNFILTERED;
1718 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1720 dirstack = alloc_dirstack(2);
1722 for (i = 0; i < sizeof(drives); i++)
1724 if (!(drives & (1 << i))) continue;
1726 root[0] = 'A' + i;
1727 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1729 num_expected_rows = 0;
1730 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1732 for (;;)
1734 heap_free( glob );
1735 heap_free( path );
1736 path = pop_dir( dirstack, &len );
1737 if (!(glob = build_glob( root[0], path, len )))
1739 status = FILL_STATUS_FAILED;
1740 goto done;
1742 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1746 if (!resize_table( table, row + 1, sizeof(*rec) ))
1748 FindClose( handle );
1749 status = FILL_STATUS_FAILED;
1750 goto done;
1752 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1753 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1754 continue;
1756 new_path = append_path( path, data.cFileName, &len );
1757 if (!(push_dir( dirstack, new_path, len )))
1759 heap_free( new_path );
1760 FindClose( handle );
1761 status = FILL_STATUS_FAILED;
1762 goto done;
1764 rec = (struct record_directory *)(table->data + offset);
1765 rec->accessmask = FILE_ALL_ACCESS;
1766 rec->name = build_name( root[0], new_path );
1767 if (!match_row( table, row, cond, &status ))
1769 free_row_values( table, row );
1770 continue;
1772 else if (num_expected_rows && row == num_expected_rows - 1)
1774 row++;
1775 FindClose( handle );
1776 status = FILL_STATUS_FILTERED;
1777 goto done;
1779 offset += sizeof(*rec);
1780 row++;
1782 while (FindNextFileW( handle, &data ));
1783 FindClose( handle );
1785 if (!peek_dir( dirstack )) break;
1789 done:
1790 free_dirstack( dirstack );
1791 heap_free( glob );
1792 heap_free( path );
1794 TRACE("created %u rows\n", row);
1795 table->num_rows = row;
1796 return status;
1799 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1801 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1802 ULARGE_INTEGER free;
1803 DISK_GEOMETRY_EX info;
1804 HANDLE handle;
1805 DWORD bytes_returned;
1807 free.QuadPart = 512 * 1024 * 1024;
1808 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1810 root[4] = dir[0];
1811 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1812 if (handle != INVALID_HANDLE_VALUE)
1814 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1815 *disksize = info.DiskSize.QuadPart;
1816 CloseHandle( handle );
1818 return free.QuadPart;
1821 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1823 static const WCHAR fmtW[] =
1824 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1825 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
1826 struct record_diskdrive *rec;
1827 UINT i, row = 0, offset = 0, index = 0, type;
1828 UINT64 size = 1024 * 1024 * 1024;
1829 DWORD drives = GetLogicalDrives();
1830 enum fill_status status = FILL_STATUS_UNFILTERED;
1832 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
1834 for (i = 0; i < sizeof(drives); i++)
1836 if (drives & (1 << i))
1838 root[0] = 'A' + i;
1839 type = GetDriveTypeW( root );
1840 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1841 continue;
1843 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1845 rec = (struct record_diskdrive *)(table->data + offset);
1846 sprintfW( device_id, fmtW, index );
1847 rec->device_id = heap_strdupW( device_id );
1848 rec->index = index;
1849 rec->interfacetype = diskdrive_interfacetypeW;
1850 rec->manufacturer = diskdrive_manufacturerW;
1851 if (type == DRIVE_FIXED)
1852 rec->mediatype = diskdrive_mediatype_fixedW;
1853 else
1854 rec->mediatype = diskdrive_mediatype_removableW;
1855 rec->model = diskdrive_modelW;
1856 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
1857 rec->serialnumber = diskdrive_serialW;
1858 get_freespace( root, &size );
1859 rec->size = size;
1860 if (!match_row( table, row, cond, &status ))
1862 free_row_values( table, row );
1863 continue;
1865 offset += sizeof(*rec);
1866 index++;
1867 row++;
1870 TRACE("created %u rows\n", row);
1871 table->num_rows = row;
1872 return status;
1875 static WCHAR *get_filesystem( const WCHAR *root )
1877 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1878 WCHAR buffer[MAX_PATH + 1];
1880 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1881 return heap_strdupW( buffer );
1882 return heap_strdupW( ntfsW );
1885 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1887 static const WCHAR fmtW[] =
1888 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1889 WCHAR device_id[32], root[] = {'A',':','\\',0};
1890 struct record_diskpartition *rec;
1891 UINT i, row = 0, offset = 0, type, index = 0;
1892 UINT64 size = 1024 * 1024 * 1024;
1893 DWORD drives = GetLogicalDrives();
1894 enum fill_status status = FILL_STATUS_UNFILTERED;
1896 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1898 for (i = 0; i < sizeof(drives); i++)
1900 if (drives & (1 << i))
1902 root[0] = 'A' + i;
1903 type = GetDriveTypeW( root );
1904 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1905 continue;
1907 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1909 rec = (struct record_diskpartition *)(table->data + offset);
1910 rec->bootable = (i == 2) ? -1 : 0;
1911 rec->bootpartition = (i == 2) ? -1 : 0;
1912 sprintfW( device_id, fmtW, index );
1913 rec->device_id = heap_strdupW( device_id );
1914 rec->diskindex = index;
1915 rec->index = 0;
1916 rec->pnpdevice_id = heap_strdupW( device_id );
1917 get_freespace( root, &size );
1918 rec->size = size;
1919 rec->startingoffset = 0;
1920 rec->type = get_filesystem( root );
1921 if (!match_row( table, row, cond, &status ))
1923 free_row_values( table, row );
1924 continue;
1926 offset += sizeof(*rec);
1927 row++;
1928 index++;
1931 TRACE("created %u rows\n", row);
1932 table->num_rows = row;
1933 return status;
1936 static WCHAR *get_volumename( const WCHAR *root )
1938 WCHAR buf[MAX_PATH + 1] = {0};
1939 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
1940 return heap_strdupW( buf );
1942 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1944 static const WCHAR fmtW[] = {'%','0','8','X',0};
1945 DWORD serial = 0;
1946 WCHAR buffer[9];
1948 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1949 sprintfW( buffer, fmtW, serial );
1950 return heap_strdupW( buffer );
1953 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1955 static const WCHAR fmtW[] = {'%','c',':',0};
1956 WCHAR device_id[3], root[] = {'A',':','\\',0};
1957 struct record_logicaldisk *rec;
1958 UINT i, row = 0, offset = 0, type;
1959 UINT64 size = 1024 * 1024 * 1024;
1960 DWORD drives = GetLogicalDrives();
1961 enum fill_status status = FILL_STATUS_UNFILTERED;
1963 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1965 for (i = 0; i < sizeof(drives); i++)
1967 if (drives & (1 << i))
1969 root[0] = 'A' + i;
1970 type = GetDriveTypeW( root );
1971 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1972 continue;
1974 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1976 rec = (struct record_logicaldisk *)(table->data + offset);
1977 sprintfW( device_id, fmtW, 'A' + i );
1978 rec->device_id = heap_strdupW( device_id );
1979 rec->drivetype = type;
1980 rec->filesystem = get_filesystem( root );
1981 rec->freespace = get_freespace( root, &size );
1982 rec->name = heap_strdupW( device_id );
1983 rec->size = size;
1984 rec->volumename = get_volumename( root );
1985 rec->volumeserialnumber = get_volumeserialnumber( root );
1986 if (!match_row( table, row, cond, &status ))
1988 free_row_values( table, row );
1989 continue;
1991 offset += sizeof(*rec);
1992 row++;
1995 TRACE("created %u rows\n", row);
1996 table->num_rows = row;
1997 return status;
2000 static UINT16 get_connection_status( IF_OPER_STATUS status )
2002 switch (status)
2004 case IfOperStatusDown:
2005 return 0; /* Disconnected */
2006 case IfOperStatusUp:
2007 return 2; /* Connected */
2008 default:
2009 ERR("unhandled status %u\n", status);
2010 break;
2012 return 0;
2014 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2016 static const WCHAR fmtW[] =
2017 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2018 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2019 WCHAR *ret;
2021 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2022 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2023 return ret;
2025 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2027 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2028 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2029 static const WCHAR firewireW[] = {'1','3','9','4',0};
2030 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2032 switch (type)
2034 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2035 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2036 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2037 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2038 default: *physical = 0; return NULL;
2042 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2044 static const WCHAR fmtW[] = {'%','u',0};
2045 WCHAR device_id[11];
2046 struct record_networkadapter *rec;
2047 IP_ADAPTER_ADDRESSES *aa, *buffer;
2048 UINT row = 0, offset = 0, count = 0;
2049 DWORD size = 0, ret;
2050 int physical;
2051 enum fill_status status = FILL_STATUS_UNFILTERED;
2053 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2054 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2056 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2057 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2059 heap_free( buffer );
2060 return FILL_STATUS_FAILED;
2062 for (aa = buffer; aa; aa = aa->Next)
2064 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2066 if (!resize_table( table, count, sizeof(*rec) ))
2068 heap_free( buffer );
2069 return FILL_STATUS_FAILED;
2071 for (aa = buffer; aa; aa = aa->Next)
2073 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2075 rec = (struct record_networkadapter *)(table->data + offset);
2076 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2077 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2078 rec->device_id = heap_strdupW( device_id );
2079 rec->index = aa->u.s.IfIndex;
2080 rec->interface_index = aa->u.s.IfIndex;
2081 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2082 rec->manufacturer = compsys_manufacturerW;
2083 rec->name = heap_strdupW( aa->FriendlyName );
2084 rec->netconnection_status = get_connection_status( aa->OperStatus );
2085 rec->physicaladapter = physical;
2086 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2087 rec->speed = 1000000;
2088 if (!match_row( table, row, cond, &status ))
2090 free_row_values( table, row );
2091 continue;
2093 offset += sizeof(*rec);
2094 row++;
2096 TRACE("created %u rows\n", row);
2097 table->num_rows = row;
2099 heap_free( buffer );
2100 return status;
2103 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2105 const SOCKET_ADDRESS *sa = &addr->Address;
2106 WCHAR buf[NI_MAXHOST];
2108 if (!addr) return NULL;
2109 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2110 0, NI_NAMEREQD )) return NULL;
2111 return heap_strdupW( buf );
2114 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2116 struct record_networkadapterconfig *rec;
2117 IP_ADAPTER_ADDRESSES *aa, *buffer;
2118 UINT row = 0, offset = 0, count = 0;
2119 DWORD size = 0, ret;
2120 enum fill_status status = FILL_STATUS_UNFILTERED;
2122 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2123 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2125 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2126 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2128 heap_free( buffer );
2129 return FILL_STATUS_FAILED;
2131 for (aa = buffer; aa; aa = aa->Next)
2133 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2135 if (!resize_table( table, count, sizeof(*rec) ))
2137 heap_free( buffer );
2138 return FILL_STATUS_FAILED;
2140 for (aa = buffer; aa; aa = aa->Next)
2142 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2144 rec = (struct record_networkadapterconfig *)(table->data + offset);
2145 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2146 rec->index = aa->u.s.IfIndex;
2147 rec->ipconnectionmetric = 20;
2148 rec->ipenabled = -1;
2149 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2150 if (!match_row( table, row, cond, &status ))
2152 free_row_values( table, row );
2153 continue;
2155 offset += sizeof(*rec);
2156 row++;
2158 TRACE("created %u rows\n", row);
2159 table->num_rows = row;
2161 heap_free( buffer );
2162 return status;
2165 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2167 struct record_physicalmemory *rec;
2168 enum fill_status status = FILL_STATUS_UNFILTERED;
2169 UINT row = 0;
2171 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2173 rec = (struct record_physicalmemory *)table->data;
2174 rec->capacity = get_total_physical_memory();
2175 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2176 else row++;
2178 TRACE("created %u rows\n", row);
2179 table->num_rows = row;
2180 return status;
2183 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2185 struct record_printer *rec;
2186 enum fill_status status = FILL_STATUS_UNFILTERED;
2187 PRINTER_INFO_2W *info;
2188 DWORD i, offset = 0, count = 0, size = 0;
2190 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2191 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2193 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2194 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2196 heap_free( info );
2197 return FILL_STATUS_FAILED;
2199 if (!resize_table( table, count, sizeof(*rec) ))
2201 heap_free( info );
2202 return FILL_STATUS_FAILED;
2205 for (i = 0; i < count; i++)
2207 rec = (struct record_printer *)(table->data + offset);
2208 rec->attributes = info[i].Attributes;
2209 rec->drivername = heap_strdupW( info[i].pDriverName );
2210 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2211 rec->local = -1;
2212 rec->name = heap_strdupW( info[i].pPrinterName );
2213 rec->network = 0;
2214 if (!match_row( table, i, cond, &status ))
2216 free_row_values( table, i );
2217 continue;
2219 offset += sizeof(*rec);
2221 TRACE("created %u rows\n", count);
2222 table->num_rows = count;
2224 heap_free( info );
2225 return status;
2228 static WCHAR *get_cmdline( DWORD process_id )
2230 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2231 return NULL; /* FIXME handle different process case */
2234 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2236 static const WCHAR fmtW[] = {'%','u',0};
2237 WCHAR handle[11];
2238 struct record_process *rec;
2239 PROCESSENTRY32W entry;
2240 HANDLE snap;
2241 enum fill_status status = FILL_STATUS_FAILED;
2242 UINT row = 0, offset = 0;
2244 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2245 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2247 entry.dwSize = sizeof(entry);
2248 if (!Process32FirstW( snap, &entry )) goto done;
2249 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2253 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2255 rec = (struct record_process *)(table->data + offset);
2256 rec->caption = heap_strdupW( entry.szExeFile );
2257 rec->commandline = get_cmdline( entry.th32ProcessID );
2258 rec->description = heap_strdupW( entry.szExeFile );
2259 sprintfW( handle, fmtW, entry.th32ProcessID );
2260 rec->handle = heap_strdupW( handle );
2261 rec->name = heap_strdupW( entry.szExeFile );
2262 rec->process_id = entry.th32ProcessID;
2263 rec->pprocess_id = entry.th32ParentProcessID;
2264 rec->thread_count = entry.cntThreads;
2265 rec->workingsetsize = 0;
2266 rec->get_owner = process_get_owner;
2267 if (!match_row( table, row, cond, &status ))
2269 free_row_values( table, row );
2270 continue;
2272 offset += sizeof(*rec);
2273 row++;
2274 } while (Process32NextW( snap, &entry ));
2276 TRACE("created %u rows\n", row);
2277 table->num_rows = row;
2278 status = FILL_STATUS_UNFILTERED;
2280 done:
2281 CloseHandle( snap );
2282 return status;
2285 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2287 #ifdef __i386__
2288 #ifdef _MSC_VER
2289 __cpuid(p, ax);
2290 #else
2291 __asm__("pushl %%ebx\n\t"
2292 "cpuid\n\t"
2293 "movl %%ebx, %%esi\n\t"
2294 "popl %%ebx"
2295 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2296 : "0" (ax));
2297 #endif
2298 #endif
2300 static const WCHAR *get_osarchitecture(void)
2302 SYSTEM_INFO info;
2303 GetNativeSystemInfo( &info );
2304 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2305 return os_32bitW;
2307 static void get_processor_caption( WCHAR *caption )
2309 static const WCHAR fmtW[] =
2310 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2311 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2312 static const WCHAR x86W[] = {'x','8','6',0};
2313 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2314 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2315 unsigned int regs[4] = {0, 0, 0, 0};
2317 do_cpuid( 1, regs );
2318 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2320 static void get_processor_version( WCHAR *version )
2322 static const WCHAR fmtW[] =
2323 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2324 unsigned int regs[4] = {0, 0, 0, 0};
2326 do_cpuid( 1, regs );
2327 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2329 static void get_processor_id( WCHAR *processor_id )
2331 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2332 unsigned int regs[4] = {0, 0, 0, 0};
2334 do_cpuid( 1, regs );
2335 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2337 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2339 unsigned int i;
2340 unsigned char *p = (unsigned char *)regs;
2342 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2343 buffer[i] = 0;
2345 static void get_processor_manufacturer( WCHAR *manufacturer )
2347 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2349 do_cpuid( 0, regs );
2350 tmp = regs[2]; /* swap edx and ecx */
2351 regs[2] = regs[3];
2352 regs[3] = tmp;
2354 regs_to_str( regs + 1, 12, manufacturer );
2356 static void get_processor_name( WCHAR *name )
2358 unsigned int regs[4] = {0, 0, 0, 0};
2360 do_cpuid( 0x80000000, regs );
2361 if (regs[0] >= 0x80000004)
2363 do_cpuid( 0x80000002, regs );
2364 regs_to_str( regs, 16, name );
2365 do_cpuid( 0x80000003, regs );
2366 regs_to_str( regs, 16, name + 16 );
2367 do_cpuid( 0x80000004, regs );
2368 regs_to_str( regs, 16, name + 32 );
2371 static UINT get_processor_currentclockspeed( UINT index )
2373 PROCESSOR_POWER_INFORMATION *info;
2374 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2375 NTSTATUS status;
2377 if ((info = heap_alloc( size )))
2379 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2380 if (!status) ret = info[index].CurrentMhz;
2381 heap_free( info );
2383 return ret;
2385 static UINT get_processor_maxclockspeed( UINT index )
2387 PROCESSOR_POWER_INFORMATION *info;
2388 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2389 NTSTATUS status;
2391 if ((info = heap_alloc( size )))
2393 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2394 if (!status) ret = info[index].MaxMhz;
2395 heap_free( info );
2397 return ret;
2400 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2402 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2403 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2404 struct record_processor *rec;
2405 UINT i, offset = 0, num_cores, num_logical_processors, count = get_processor_count();
2406 enum fill_status status = FILL_STATUS_UNFILTERED;
2408 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2410 get_processor_caption( caption );
2411 get_processor_id( processor_id );
2412 get_processor_manufacturer( manufacturer );
2413 get_processor_name( name );
2414 get_processor_version( version );
2416 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2417 num_cores /= count;
2419 for (i = 0; i < count; i++)
2421 rec = (struct record_processor *)(table->data + offset);
2422 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2423 rec->caption = heap_strdupW( caption );
2424 rec->cpu_status = 1; /* CPU Enabled */
2425 rec->currentclockspeed = get_processor_currentclockspeed( i );
2426 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2427 rec->description = heap_strdupW( caption );
2428 sprintfW( device_id, fmtW, i );
2429 rec->device_id = heap_strdupW( device_id );
2430 rec->family = 2; /* Unknown */
2431 rec->manufacturer = heap_strdupW( manufacturer );
2432 rec->maxclockspeed = get_processor_maxclockspeed( i );
2433 rec->name = heap_strdupW( name );
2434 rec->num_cores = num_cores;
2435 rec->num_logical_processors = num_logical_processors;
2436 rec->processor_id = heap_strdupW( processor_id );
2437 rec->processortype = 3; /* central processor */
2438 rec->unique_id = NULL;
2439 rec->version = heap_strdupW( version );
2440 if (!match_row( table, i, cond, &status ))
2442 free_row_values( table, i );
2443 continue;
2445 offset += sizeof(*rec);
2448 TRACE("created %u rows\n", count);
2449 table->num_rows = count;
2450 return status;
2453 static WCHAR *get_lastbootuptime(void)
2455 static const WCHAR fmtW[] =
2456 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2457 '.','%','0','6','u','+','0','0','0',0};
2458 SYSTEM_TIMEOFDAY_INFORMATION ti;
2459 TIME_FIELDS tf;
2460 WCHAR *ret;
2462 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2464 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2465 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2466 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2467 return ret;
2469 static WCHAR *get_localdatetime(void)
2471 static const WCHAR fmtW[] =
2472 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2473 '.','%','0','6','u','%','+','0','3','d',0};
2474 TIME_ZONE_INFORMATION tzi;
2475 SYSTEMTIME st;
2476 WCHAR *ret;
2477 DWORD Status;
2478 LONG Bias;
2480 Status = GetTimeZoneInformation(&tzi);
2482 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2483 Bias = tzi.Bias;
2484 if(Status == TIME_ZONE_ID_DAYLIGHT)
2485 Bias+= tzi.DaylightBias;
2486 else
2487 Bias+= tzi.StandardBias;
2488 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2490 GetLocalTime(&st);
2491 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2492 return ret;
2494 static WCHAR *get_systemdirectory(void)
2496 void *redir;
2497 WCHAR *ret;
2499 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2500 Wow64DisableWow64FsRedirection( &redir );
2501 GetSystemDirectoryW( ret, MAX_PATH );
2502 Wow64RevertWow64FsRedirection( redir );
2503 return ret;
2505 static WCHAR *get_codeset(void)
2507 static const WCHAR fmtW[] = {'%','u',0};
2508 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2509 if (ret) sprintfW( ret, fmtW, GetACP() );
2510 return ret;
2512 static WCHAR *get_countrycode(void)
2514 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2515 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2516 return ret;
2518 static WCHAR *get_locale(void)
2520 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2521 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2522 return ret;
2525 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2527 struct record_operatingsystem *rec;
2528 enum fill_status status = FILL_STATUS_UNFILTERED;
2529 UINT row = 0;
2531 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2533 rec = (struct record_operatingsystem *)table->data;
2534 rec->buildnumber = os_buildnumberW;
2535 rec->caption = os_captionW;
2536 rec->codeset = get_codeset();
2537 rec->countrycode = get_countrycode();
2538 rec->csdversion = os_csdversionW;
2539 rec->installdate = os_installdateW;
2540 rec->lastbootuptime = get_lastbootuptime();
2541 rec->localdatetime = get_localdatetime();
2542 rec->locale = get_locale();
2543 rec->name = os_nameW;
2544 rec->osarchitecture = get_osarchitecture();
2545 rec->oslanguage = GetSystemDefaultLangID();
2546 rec->osproductsuite = 2461140; /* Windows XP Professional */
2547 rec->ostype = 18; /* WINNT */
2548 rec->primary = -1;
2549 rec->serialnumber = os_serialnumberW;
2550 rec->servicepackmajor = 3;
2551 rec->servicepackminor = 0;
2552 rec->suitemask = 272; /* Single User + Terminal */
2553 rec->systemdirectory = get_systemdirectory();
2554 rec->totalvisiblememorysize = get_total_physical_memory() / 1024;
2555 rec->version = os_versionW;
2556 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2557 else row++;
2559 TRACE("created %u rows\n", row);
2560 table->num_rows = row;
2561 return status;
2564 static const WCHAR *get_service_type( DWORD type )
2566 static const WCHAR filesystem_driverW[] =
2567 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2568 static const WCHAR kernel_driverW[] =
2569 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2570 static const WCHAR own_processW[] =
2571 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2572 static const WCHAR share_processW[] =
2573 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2575 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2576 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2577 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2578 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2579 else ERR("unhandled type 0x%08x\n", type);
2580 return NULL;
2582 static const WCHAR *get_service_state( DWORD state )
2584 static const WCHAR runningW[] =
2585 {'R','u','n','n','i','n','g',0};
2586 static const WCHAR start_pendingW[] =
2587 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2588 static const WCHAR stop_pendingW[] =
2589 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2590 static const WCHAR stoppedW[] =
2591 {'S','t','o','p','p','e','d',0};
2592 static const WCHAR unknownW[] =
2593 {'U','n','k','n','o','w','n',0};
2595 switch (state)
2597 case SERVICE_STOPPED: return stoppedW;
2598 case SERVICE_START_PENDING: return start_pendingW;
2599 case SERVICE_STOP_PENDING: return stop_pendingW;
2600 case SERVICE_RUNNING: return runningW;
2601 default:
2602 ERR("unknown state %u\n", state);
2603 return unknownW;
2606 static const WCHAR *get_service_startmode( DWORD mode )
2608 static const WCHAR bootW[] = {'B','o','o','t',0};
2609 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2610 static const WCHAR autoW[] = {'A','u','t','o',0};
2611 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2612 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2613 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2615 switch (mode)
2617 case SERVICE_BOOT_START: return bootW;
2618 case SERVICE_SYSTEM_START: return systemW;
2619 case SERVICE_AUTO_START: return autoW;
2620 case SERVICE_DEMAND_START: return manualW;
2621 case SERVICE_DISABLED: return disabledW;
2622 default:
2623 ERR("unknown mode 0x%x\n", mode);
2624 return unknownW;
2627 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2629 QUERY_SERVICE_CONFIGW *config = NULL;
2630 SC_HANDLE service;
2631 DWORD size;
2633 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2634 QueryServiceConfigW( service, NULL, 0, &size );
2635 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2636 if (!(config = heap_alloc( size ))) goto done;
2637 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2638 heap_free( config );
2639 config = NULL;
2641 done:
2642 CloseServiceHandle( service );
2643 return config;
2646 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2648 struct record_service *rec;
2649 SC_HANDLE manager;
2650 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2651 SERVICE_STATUS_PROCESS *status;
2652 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2653 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2654 UINT i, row = 0, offset = 0, size = 256, needed, count;
2655 enum fill_status fill_status = FILL_STATUS_FAILED;
2656 BOOL ret;
2658 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2659 if (!(services = heap_alloc( size ))) goto done;
2661 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2662 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2663 &count, NULL, NULL );
2664 if (!ret)
2666 if (GetLastError() != ERROR_MORE_DATA) goto done;
2667 size = needed;
2668 if (!(tmp = heap_realloc( services, size ))) goto done;
2669 services = tmp;
2670 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2671 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2672 &count, NULL, NULL );
2673 if (!ret) goto done;
2675 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2677 GetComputerNameW( sysnameW, &len );
2678 fill_status = FILL_STATUS_UNFILTERED;
2680 for (i = 0; i < count; i++)
2682 QUERY_SERVICE_CONFIGW *config;
2684 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2686 status = &services[i].ServiceStatusProcess;
2687 rec = (struct record_service *)(table->data + offset);
2688 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2689 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2690 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2691 rec->name = heap_strdupW( services[i].lpServiceName );
2692 rec->process_id = status->dwProcessId;
2693 rec->servicetype = get_service_type( status->dwServiceType );
2694 rec->startmode = get_service_startmode( config->dwStartType );
2695 rec->state = get_service_state( status->dwCurrentState );
2696 rec->systemname = heap_strdupW( sysnameW );
2697 rec->pause_service = service_pause_service;
2698 rec->resume_service = service_resume_service;
2699 rec->start_service = service_start_service;
2700 rec->stop_service = service_stop_service;
2701 heap_free( config );
2702 if (!match_row( table, row, cond, &fill_status ))
2704 free_row_values( table, row );
2705 continue;
2707 offset += sizeof(*rec);
2708 row++;
2711 TRACE("created %u rows\n", row);
2712 table->num_rows = row;
2714 done:
2715 CloseServiceHandle( manager );
2716 heap_free( services );
2717 return fill_status;
2720 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
2722 if (!name || !name->Name.Buffer) return NULL;
2723 return heap_strdupW( name->Name.Buffer );
2725 static struct array *get_binaryrepresentation( PSID sid, UINT len )
2727 struct array *array = heap_alloc( sizeof(struct array) );
2728 if (array)
2730 UINT8 *ret = heap_alloc( len );
2731 if (ret)
2733 memcpy( ret, sid, len );
2734 array->count = len;
2735 array->ptr = ret;
2736 return array;
2738 heap_free( array );
2740 return NULL;
2742 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
2744 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
2745 return heap_strdupW( domain->Domains->Name.Buffer );
2747 static const WCHAR *find_sid_str( const struct expr *cond )
2749 const struct expr *left, *right;
2750 const WCHAR *ret = NULL;
2752 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
2754 left = cond->u.expr.left;
2755 right = cond->u.expr.right;
2756 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
2758 ret = right->u.sval;
2760 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
2762 ret = left->u.sval;
2764 return ret;
2767 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
2769 PSID sid;
2770 LSA_REFERENCED_DOMAIN_LIST *domain;
2771 LSA_TRANSLATED_NAME *name;
2772 LSA_HANDLE handle;
2773 LSA_OBJECT_ATTRIBUTES attrs;
2774 const WCHAR *str;
2775 struct record_sid *rec;
2776 UINT len;
2778 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
2779 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2781 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
2782 len = GetLengthSid( sid );
2784 memset( &attrs, 0, sizeof(attrs) );
2785 attrs.Length = sizeof(attrs);
2786 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
2788 LocalFree( sid );
2789 return FILL_STATUS_FAILED;
2791 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
2793 LocalFree( sid );
2794 LsaClose( handle );
2795 return FILL_STATUS_FAILED;
2798 rec = (struct record_sid *)table->data;
2799 rec->accountname = get_accountname( name );
2800 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
2801 rec->referenceddomainname = get_referenceddomainname( domain );
2802 rec->sid = heap_strdupW( str );
2803 rec->sidlength = len;
2805 TRACE("created 1 row\n");
2806 table->num_rows = 1;
2808 LsaFreeMemory( domain );
2809 LsaFreeMemory( name );
2810 LocalFree( sid );
2811 LsaClose( handle );
2812 return FILL_STATUS_FILTERED;
2815 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2817 HDC hdc = GetDC( NULL );
2818 UINT32 ret;
2820 if (!hdc) return 32;
2821 ret = GetDeviceCaps( hdc, BITSPIXEL );
2822 *hres = GetDeviceCaps( hdc, HORZRES );
2823 *vres = GetDeviceCaps( hdc, VERTRES );
2824 ReleaseDC( NULL, hdc );
2825 return ret;
2827 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2829 static const WCHAR fmtW[] =
2830 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2831 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2832 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2833 WCHAR *ret;
2835 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2836 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2837 return ret;
2840 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2843 struct record_videocontroller *rec;
2844 HRESULT hr;
2845 IDXGIFactory *factory = NULL;
2846 IDXGIAdapter *adapter = NULL;
2847 DXGI_ADAPTER_DESC desc;
2848 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2849 const WCHAR *name = videocontroller_deviceidW;
2850 enum fill_status status = FILL_STATUS_UNFILTERED;
2851 UINT row = 0;
2853 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2855 memset (&desc, 0, sizeof(desc));
2856 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2857 if (FAILED(hr)) goto done;
2859 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2860 if (FAILED(hr)) goto done;
2862 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2863 if (SUCCEEDED(hr))
2865 vidmem = desc.DedicatedVideoMemory;
2866 name = desc.Description;
2869 done:
2870 rec = (struct record_videocontroller *)table->data;
2871 rec->adapter_dactype = videocontroller_dactypeW;
2872 rec->adapter_ram = vidmem;
2873 rec->availability = 3; /* Running or Full Power */
2874 rec->caption = heap_strdupW( name );
2875 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2876 rec->current_horizontalres = hres;
2877 rec->current_refreshrate = 0; /* default refresh rate */
2878 rec->current_scanmode = 2; /* Unknown */
2879 rec->current_verticalres = vres;
2880 rec->description = heap_strdupW( name );
2881 rec->device_id = videocontroller_deviceidW;
2882 rec->driverversion = videocontroller_driverversionW;
2883 rec->name = heap_strdupW( name );
2884 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2885 rec->videoarchitecture = 2; /* Unknown */
2886 rec->videomemorytype = 2; /* Unknown */
2887 rec->videoprocessor = heap_strdupW( name );
2888 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2889 else row++;
2891 TRACE("created %u rows\n", row);
2892 table->num_rows = row;
2894 if (adapter) IDXGIAdapter_Release( adapter );
2895 if (factory) IDXGIFactory_Release( factory );
2896 return status;
2899 static struct table builtin_classes[] =
2901 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
2902 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
2903 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
2904 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
2905 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, SIZEOF(data_compsysproduct), 0, (BYTE *)data_compsysproduct },
2906 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
2907 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
2908 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
2909 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
2910 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
2911 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2912 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2913 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
2914 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
2915 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
2916 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
2917 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
2918 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
2919 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
2920 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
2921 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2922 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
2923 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
2924 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
2925 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
2926 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
2927 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
2928 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
2929 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
2930 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
2933 void init_table_list( void )
2935 static struct list tables = LIST_INIT( tables );
2936 UINT i;
2938 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
2939 table_list = &tables;