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
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
26 #define WIN32_NO_STATUS
48 #include "wine/debug.h"
49 #include "wbemprox_private.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
53 static const WCHAR class_associatorsW
[] =
54 {'_','_','A','S','S','O','C','I','A','T','O','R','S',0};
55 static const WCHAR class_baseboardW
[] =
56 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
57 static const WCHAR class_biosW
[] =
58 {'W','i','n','3','2','_','B','I','O','S',0};
59 static const WCHAR class_cdromdriveW
[] =
60 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
61 static const WCHAR class_compsysW
[] =
62 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
63 static const WCHAR class_compsysproductW
[] =
64 {'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};
65 static const WCHAR class_datafileW
[] =
66 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
67 static const WCHAR class_desktopmonitorW
[] =
68 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
69 static const WCHAR class_directoryW
[] =
70 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
71 static const WCHAR class_diskdriveW
[] =
72 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
73 static const WCHAR class_diskdrivetodiskpartitionW
[] =
74 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e','T','o','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
75 static const WCHAR class_diskpartitionW
[] =
76 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
77 static const WCHAR class_displaycontrollerconfigW
[] =
78 {'W','i','n','3','2','_','D','i','s','p','l','a','y','C','o','n','t','r','o','l','l','e','r',
79 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
80 static const WCHAR class_ip4routetableW
[] =
81 {'W','i','n','3','2','_','I','P','4','R','o','u','t','e','T','a','b','l','e',0};
82 static const WCHAR class_logicaldiskW
[] =
83 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
84 static const WCHAR class_logicaldisk2W
[] =
85 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
86 static const WCHAR class_logicaldisktopartitionW
[] =
87 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','T','o','P','a','r','t','i','t','i','o','n',0};
88 static const WCHAR class_networkadapterW
[] =
89 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
90 static const WCHAR class_networkadapterconfigW
[] =
91 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
92 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
93 static const WCHAR class_operatingsystemW
[] =
94 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
95 static const WCHAR class_paramsW
[] =
96 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
97 static const WCHAR class_physicalmediaW
[] =
98 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
99 static const WCHAR class_physicalmemoryW
[] =
100 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
101 static const WCHAR class_pnpentityW
[] =
102 {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
103 static const WCHAR class_printerW
[] =
104 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
105 static const WCHAR class_process_getowner_outW
[] =
106 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
107 'N','E','R','_','O','U','T',0};
108 static const WCHAR class_processorW
[] =
109 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
110 static const WCHAR class_processor2W
[] =
111 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
112 static const WCHAR class_qualifiersW
[] =
113 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
114 static const WCHAR class_quickfixengineeringW
[] =
115 {'W','i','n','3','2','_','Q','u','i','c','k','F','i','x','E','n','g','i','n','e','e','r','i','n','g',0};
116 static const WCHAR class_sidW
[] =
117 {'W','i','n','3','2','_','S','I','D',0};
118 static const WCHAR class_sounddeviceW
[] =
119 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
120 static const WCHAR class_systemenclosureW
[] =
121 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
122 static const WCHAR class_videocontrollerW
[] =
123 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
124 static const WCHAR class_winsatW
[] =
125 {'W','i','n','3','2','_','W','i','n','S','A','T',0};
127 static const WCHAR prop_accountnameW
[] =
128 {'A','c','c','o','u','n','t','N','a','m','e',0};
129 static const WCHAR prop_acceptpauseW
[] =
130 {'A','c','c','e','p','t','P','a','u','s','e',0};
131 static const WCHAR prop_acceptstopW
[] =
132 {'A','c','c','e','p','t','S','t','o','p',0};
133 static const WCHAR prop_accessmaskW
[] =
134 {'A','c','c','e','s','s','M','a','s','k',0};
135 static const WCHAR prop_adapterdactypeW
[] =
136 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
137 static const WCHAR prop_adapterramW
[] =
138 {'A','d','a','p','t','e','r','R','A','M',0};
139 static const WCHAR prop_adaptertypeW
[] =
140 {'A','d','a','p','t','e','r','T','y','p','e',0};
141 static const WCHAR prop_adaptertypeidW
[] =
142 {'A','d','a','p','t','e','r','T','y','p','e','I','D',0};
143 static const WCHAR prop_addresswidthW
[] =
144 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
145 static const WCHAR prop_antecedentW
[] =
146 {'A','n','t','e','c','e','d','e','n','t',0};
147 static const WCHAR prop_architectureW
[] =
148 {'A','r','c','h','i','t','e','c','t','u','r','e',0};
149 static const WCHAR prop_assocclassW
[] =
150 {'A','s','s','o','c','C','l','a','s','s',0};
151 static const WCHAR prop_associatorW
[] =
152 {'A','s','s','o','c','i','a','t','o','r',0};
153 static const WCHAR prop_attributesW
[] =
154 {'A','t','t','r','i','b','u','t','e','s',0};
155 static const WCHAR prop_availabilityW
[] =
156 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
157 static const WCHAR prop_binaryrepresentationW
[] =
158 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
159 static const WCHAR prop_bitsperpixelW
[] =
160 {'B','i','t','s','P','e','r','P','i','x','e','l',0};
161 static const WCHAR prop_boolvalueW
[] =
162 {'B','o','o','l','V','a','l','u','e',0};
163 static const WCHAR prop_bootableW
[] =
164 {'B','o','o','t','a','b','l','e',0};
165 static const WCHAR prop_bootpartitionW
[] =
166 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
167 static const WCHAR prop_buildnumberW
[] =
168 {'B','u','i','l','d','N','u','m','b','e','r',0};
169 static const WCHAR prop_capacityW
[] =
170 {'C','a','p','a','c','i','t','y',0};
171 static const WCHAR prop_captionW
[] =
172 {'C','a','p','t','i','o','n',0};
173 static const WCHAR prop_chassistypesW
[] =
174 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
175 static const WCHAR prop_classW
[] =
176 {'C','l','a','s','s',0};
177 static const WCHAR prop_codesetW
[] =
178 {'C','o','d','e','S','e','t',0};
179 static const WCHAR prop_commandlineW
[] =
180 {'C','o','m','m','a','n','d','L','i','n','e',0};
181 static const WCHAR prop_configmanagererrorcodeW
[] =
182 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
183 static const WCHAR prop_configuredclockspeedW
[] =
184 {'C','o','n','f','i','g','u','r','e','d','C','l','o','c','k','S','p','e','e','d',0};
185 static const WCHAR prop_countrycodeW
[] =
186 {'C','o','u','n','t','r','y','C','o','d','e',0};
187 static const WCHAR prop_cpuscoreW
[] =
188 {'C','P','U','S','c','o','r','e',0};
189 static const WCHAR prop_cpustatusW
[] =
190 {'C','p','u','S','t','a','t','u','s',0};
191 static const WCHAR prop_csdversionW
[] =
192 {'C','S','D','V','e','r','s','i','o','n',0};
193 static const WCHAR prop_csnameW
[] =
194 {'C','S','N','a','m','e',0};
195 static const WCHAR prop_currentbitsperpixelW
[] =
196 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
197 static const WCHAR prop_currentclockspeedW
[] =
198 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
199 static const WCHAR prop_currenthorizontalresW
[] =
200 {'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};
201 static const WCHAR prop_currentlanguageW
[] =
202 {'C','u','r','r','e','n','t','L','a','n','g','u','a','g','e',0};
203 static const WCHAR prop_currentrefreshrateW
[] =
204 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
205 static const WCHAR prop_currentscanmodeW
[] =
206 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
207 static const WCHAR prop_currenttimezoneW
[] =
208 {'C','u','r','r','e','n','t','T','i','m','e','Z','o','n','e',0};
209 static const WCHAR prop_currentverticalresW
[] =
210 {'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};
211 static const WCHAR prop_d3dscoreW
[] =
212 {'D','3','D','S','c','o','r','e',0};
213 static const WCHAR prop_datawidthW
[] =
214 {'D','a','t','a','W','i','d','t','h',0};
215 static const WCHAR prop_defaultipgatewayW
[] =
216 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
217 static const WCHAR prop_defaultvalueW
[] =
218 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
219 static const WCHAR prop_dependentW
[] =
220 {'D','e','p','e','n','d','e','n','t',0};
221 static const WCHAR prop_descriptionW
[] =
222 {'D','e','s','c','r','i','p','t','i','o','n',0};
223 static const WCHAR prop_destinationW
[] =
224 {'D','e','s','t','i','n','a','t','i','o','n',0};
225 static const WCHAR prop_deviceidW
[] =
226 {'D','e','v','i','c','e','I','d',0};
227 static const WCHAR prop_devicelocatorW
[] =
228 {'D','e','v','i','c','e','L','o','c','a','t','o','r',0};
229 static const WCHAR prop_dhcpenabledW
[] =
230 {'D','H','C','P','E','n','a','b','l','e','d',0};
231 static const WCHAR prop_directionW
[] =
232 {'D','i','r','e','c','t','i','o','n',0};
233 static const WCHAR prop_diskscoreW
[] =
234 {'D','i','s','k','S','c','o','r','e',0};
235 static const WCHAR prop_displaynameW
[] =
236 {'D','i','s','p','l','a','y','N','a','m','e',0};
237 static const WCHAR prop_diskindexW
[] =
238 {'D','i','s','k','I','n','d','e','x',0};
239 static const WCHAR prop_dnshostnameW
[] =
240 {'D','N','S','H','o','s','t','N','a','m','e',0};
241 static const WCHAR prop_dnsserversearchorderW
[] =
242 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
243 static const WCHAR prop_domainW
[] =
244 {'D','o','m','a','i','n',0};
245 static const WCHAR prop_domainroleW
[] =
246 {'D','o','m','a','i','n','R','o','l','e',0};
247 static const WCHAR prop_driveW
[] =
248 {'D','r','i','v','e',0};
249 static const WCHAR prop_driverdateW
[] =
250 {'D','r','i','v','e','r','D','a','t','e',0};
251 static const WCHAR prop_drivernameW
[] =
252 {'D','r','i','v','e','r','N','a','m','e',0};
253 static const WCHAR prop_driverversionW
[] =
254 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
255 static const WCHAR prop_drivetypeW
[] =
256 {'D','r','i','v','e','T','y','p','e',0};
257 static const WCHAR prop_familyW
[] =
258 {'F','a','m','i','l','y',0};
259 static const WCHAR prop_filesystemW
[] =
260 {'F','i','l','e','S','y','s','t','e','m',0};
261 static const WCHAR prop_flavorW
[] =
262 {'F','l','a','v','o','r',0};
263 static const WCHAR prop_freespaceW
[] =
264 {'F','r','e','e','S','p','a','c','e',0};
265 static const WCHAR prop_freephysicalmemoryW
[] =
266 {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
267 static const WCHAR prop_handleW
[] =
268 {'H','a','n','d','l','e',0};
269 static const WCHAR prop_graphicsscoreW
[] =
270 {'G','r','a','p','h','i','c','s','S','c','o','r','e',0};
271 static const WCHAR prop_horizontalresolutionW
[] =
272 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
273 static const WCHAR prop_hotfixidW
[] =
274 {'H','o','t','F','i','x','I','D',0};
275 static const WCHAR prop_idW
[] =
277 static const WCHAR prop_identificationcodeW
[] =
278 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
279 static const WCHAR prop_identifyingnumberW
[] =
280 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
281 static const WCHAR prop_indexW
[] =
282 {'I','n','d','e','x',0};
283 static const WCHAR prop_installdateW
[] =
284 {'I','n','s','t','a','l','l','D','a','t','e',0};
285 static const WCHAR prop_installeddisplaydriversW
[]=
286 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
287 static const WCHAR prop_interfaceindexW
[] =
288 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
289 static const WCHAR prop_interfacetypeW
[] =
290 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
291 static const WCHAR prop_intvalueW
[] =
292 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
293 static const WCHAR prop_ipaddressW
[] =
294 {'I','P','A','d','d','r','e','s','s',0};
295 static const WCHAR prop_ipconnectionmetricW
[] =
296 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
297 static const WCHAR prop_ipenabledW
[] =
298 {'I','P','E','n','a','b','l','e','d',0};
299 static const WCHAR prop_ipsubnet
[] =
300 {'I','P','S','u','b','n','e','t',0};
301 static const WCHAR prop_lastbootuptimeW
[] =
302 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
303 static const WCHAR prop_levelW
[] =
304 {'L','e','v','e','l',0};
305 static const WCHAR prop_localW
[] =
306 {'L','o','c','a','l',0};
307 static const WCHAR prop_localdatetimeW
[] =
308 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
309 static const WCHAR prop_localeW
[] =
310 {'L','o','c','a','l','e',0};
311 static const WCHAR prop_locationW
[] =
312 {'L','o','c','a','t','i','o','n',0};
313 static const WCHAR prop_lockpresentW
[] =
314 {'L','o','c','k','P','r','e','s','e','n','t',0};
315 static const WCHAR prop_macaddressW
[] =
316 {'M','A','C','A','d','d','r','e','s','s',0};
317 static const WCHAR prop_manufacturerW
[] =
318 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
319 static const WCHAR prop_maxclockspeedW
[] =
320 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
321 static const WCHAR prop_mediatypeW
[] =
322 {'M','e','d','i','a','T','y','p','e',0};
323 static const WCHAR prop_memberW
[] =
324 {'M','e','m','b','e','r',0};
325 static const WCHAR prop_memoryscoreW
[] =
326 {'M','e','m','o','r','y','S','c','o','r','e',0};
327 static const WCHAR prop_memorytypeW
[] =
328 {'M','e','m','o','r','y','T','y','p','e',0};
329 static const WCHAR prop_methodW
[] =
330 {'M','e','t','h','o','d',0};
331 static const WCHAR prop_modelW
[] =
332 {'M','o','d','e','l',0};
333 static const WCHAR prop_netconnectionstatusW
[] =
334 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
335 static const WCHAR prop_networkW
[] =
336 {'N','e','t','w','o','r','k',0};
337 static const WCHAR prop_nexthopW
[] =
338 {'N','e','x','t','H','o','p',0};
339 static const WCHAR prop_numcoresW
[] =
340 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
341 static const WCHAR prop_numlogicalprocessorsW
[] =
342 {'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};
343 static const WCHAR prop_numprocessorsW
[] =
344 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
345 static const WCHAR prop_operatingsystemskuW
[] =
346 {'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m','S','K','U',0};
347 static const WCHAR prop_osarchitectureW
[] =
348 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
349 static const WCHAR prop_oslanguageW
[] =
350 {'O','S','L','a','n','g','u','a','g','e',0};
351 static const WCHAR prop_osproductsuiteW
[] =
352 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
353 static const WCHAR prop_ostypeW
[] =
354 {'O','S','T','y','p','e',0};
355 static const WCHAR prop_parameterW
[] =
356 {'P','a','r','a','m','e','t','e','r',0};
357 static const WCHAR prop_partnumberW
[] =
358 {'P','a','r','t','N','u','m','b','e','r',0};
359 static const WCHAR prop_physicaladapterW
[] =
360 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
361 static const WCHAR prop_pixelsperxlogicalinchW
[] =
362 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
363 static const WCHAR prop_pnpdeviceidW
[] =
364 {'P','N','P','D','e','v','i','c','e','I','D',0};
365 static const WCHAR prop_portnameW
[] =
366 {'P','o','r','t','N','a','m','e',0};
367 static const WCHAR prop_pprocessidW
[] =
368 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
369 static const WCHAR prop_primaryW
[] =
370 {'P','r','i','m','a','r','y',0};
371 static const WCHAR prop_processidW
[] =
372 {'P','r','o','c','e','s','s','I','D',0};
373 static const WCHAR prop_processoridW
[] =
374 {'P','r','o','c','e','s','s','o','r','I','d',0};
375 static const WCHAR prop_processortypeW
[] =
376 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
377 static const WCHAR prop_productW
[] =
378 {'P','r','o','d','u','c','t',0};
379 static const WCHAR prop_productnameW
[] =
380 {'P','r','o','d','u','c','t','N','a','m','e',0};
381 static const WCHAR prop_referenceddomainnameW
[] =
382 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
383 static const WCHAR prop_releasedateW
[] =
384 {'R','e','l','e','a','s','e','D','a','t','e',0};
385 static const WCHAR prop_revisionW
[] =
386 {'R','e','v','i','s','i','o','n',0};
387 static const WCHAR prop_serialnumberW
[] =
388 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
389 static const WCHAR prop_servicepackmajorW
[] =
390 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
391 static const WCHAR prop_servicepackminorW
[] =
392 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
393 static const WCHAR prop_servicetypeW
[] =
394 {'S','e','r','v','i','c','e','T','y','p','e',0};
395 static const WCHAR prop_settingidW
[] =
396 {'S','e','t','t','i','n','g','I','D',0};
397 static const WCHAR prop_skunumberW
[] =
398 {'S','K','U','N','u','m','b','e','r',0};
399 static const WCHAR prop_smbiosbiosversionW
[] =
400 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
401 static const WCHAR prop_smbiosmajorversionW
[] =
402 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
403 static const WCHAR prop_smbiosminorversionW
[] =
404 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
405 static const WCHAR prop_startmodeW
[] =
406 {'S','t','a','r','t','M','o','d','e',0};
407 static const WCHAR prop_sidW
[] =
409 static const WCHAR prop_sidlengthW
[] =
410 {'S','i','d','L','e','n','g','t','h',0};
411 static const WCHAR prop_sizeW
[] =
413 static const WCHAR prop_speedW
[] =
414 {'S','p','e','e','d',0};
415 static const WCHAR prop_startingoffsetW
[] =
416 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
417 static const WCHAR prop_stateW
[] =
418 {'S','t','a','t','e',0};
419 static const WCHAR prop_statusW
[] =
420 {'S','t','a','t','u','s',0};
421 static const WCHAR prop_statusinfoW
[] =
422 {'S','t','a','t','u','s','I','n','f','o',0};
423 static const WCHAR prop_strvalueW
[] =
424 {'S','t','r','i','n','g','V','a','l','u','e',0};
425 static const WCHAR prop_suitemaskW
[] =
426 {'S','u','i','t','e','M','a','s','k',0};
427 static const WCHAR prop_systemdirectoryW
[] =
428 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
429 static const WCHAR prop_systemdriveW
[] =
430 {'S','y','s','t','e','m','D','r','i','v','e',0};
431 static const WCHAR prop_systemnameW
[] =
432 {'S','y','s','t','e','m','N','a','m','e',0};
433 static const WCHAR prop_tagW
[] =
435 static const WCHAR prop_threadcountW
[] =
436 {'T','h','r','e','a','d','C','o','u','n','t',0};
437 static const WCHAR prop_timetakenW
[] =
438 {'T','i','m','e','T','a','k','e','n',0};
439 static const WCHAR prop_totalphysicalmemoryW
[] =
440 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
441 static const WCHAR prop_totalvirtualmemorysizeW
[] =
442 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
443 static const WCHAR prop_totalvisiblememorysizeW
[] =
444 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
445 static const WCHAR prop_typeW
[] =
447 static const WCHAR prop_uniqueidW
[] =
448 {'U','n','i','q','u','e','I','d',0};
449 static const WCHAR prop_usernameW
[] =
450 {'U','s','e','r','N','a','m','e',0};
451 static const WCHAR prop_uuidW
[] =
453 static const WCHAR prop_vendorW
[] =
454 {'V','e','n','d','o','r',0};
455 static const WCHAR prop_versionW
[] =
456 {'V','e','r','s','i','o','n',0};
457 static const WCHAR prop_verticalresolutionW
[] =
458 {'V','e','r','t','i','c','a','l','R','e','s','o','l','u','t','i','o','n',0};
459 static const WCHAR prop_videoarchitectureW
[] =
460 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
461 static const WCHAR prop_videomemorytypeW
[] =
462 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
463 static const WCHAR prop_videomodedescriptionW
[] =
464 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
465 static const WCHAR prop_videoprocessorW
[] =
466 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
467 static const WCHAR prop_volumenameW
[] =
468 {'V','o','l','u','m','e','N','a','m','e',0};
469 static const WCHAR prop_volumeserialnumberW
[] =
470 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
471 static const WCHAR prop_winsatassessmentstateW
[] =
472 {'W','i','n','S','A','T','A','s','s','e','s','s','m','e','n','t','S','t','a','t','e',0};
473 static const WCHAR prop_winsprlevelW
[] =
474 {'W','i','n','S','P','R','L','e','v','e','l',0};
475 static const WCHAR prop_workingsetsizeW
[] =
476 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
478 /* column definitions must be kept in sync with record structures below */
479 static const struct column col_associator
[] =
481 { prop_assocclassW
, CIM_STRING
},
482 { prop_classW
, CIM_STRING
},
483 { prop_associatorW
, CIM_STRING
}
485 static const struct column col_baseboard
[] =
487 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
488 { prop_modelW
, CIM_STRING
},
489 { prop_nameW
, CIM_STRING
},
490 { prop_productW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
491 { prop_serialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
492 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
493 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
495 static const struct column col_bios
[] =
497 { prop_currentlanguageW
, CIM_STRING
},
498 { prop_descriptionW
, CIM_STRING
},
499 { prop_identificationcodeW
, CIM_STRING
},
500 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
501 { prop_nameW
, CIM_STRING
},
502 { prop_releasedateW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
503 { prop_serialnumberW
, CIM_STRING
},
504 { prop_smbiosbiosversionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
505 { prop_smbiosmajorversionW
, CIM_UINT16
},
506 { prop_smbiosminorversionW
, CIM_UINT16
},
507 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
509 static const struct column col_cdromdrive
[] =
511 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
512 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
513 { prop_mediatypeW
, CIM_STRING
},
514 { prop_nameW
, CIM_STRING
},
515 { prop_pnpdeviceidW
, CIM_STRING
}
517 static const struct column col_compsys
[] =
519 { prop_descriptionW
, CIM_STRING
},
520 { prop_domainW
, CIM_STRING
},
521 { prop_domainroleW
, CIM_UINT16
},
522 { prop_manufacturerW
, CIM_STRING
},
523 { prop_modelW
, CIM_STRING
},
524 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
525 { prop_numlogicalprocessorsW
, CIM_UINT32
},
526 { prop_numprocessorsW
, CIM_UINT32
},
527 { prop_totalphysicalmemoryW
, CIM_UINT64
},
528 { prop_usernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
530 static const struct column col_compsysproduct
[] =
532 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
533 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
534 { prop_skunumberW
, CIM_STRING
},
535 { prop_uuidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
536 { prop_vendorW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
537 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
539 static const struct column col_datafile
[] =
541 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
542 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
544 static const struct column col_desktopmonitor
[] =
546 { prop_pixelsperxlogicalinchW
, CIM_UINT32
}
548 static const struct column col_directory
[] =
550 { prop_accessmaskW
, CIM_UINT32
},
551 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
553 static const struct column col_diskdrive
[] =
555 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
556 { prop_indexW
, CIM_UINT32
},
557 { prop_interfacetypeW
, CIM_STRING
},
558 { prop_manufacturerW
, CIM_STRING
},
559 { prop_mediatypeW
, CIM_STRING
},
560 { prop_modelW
, CIM_STRING
},
561 { prop_pnpdeviceidW
, CIM_STRING
},
562 { prop_serialnumberW
, CIM_STRING
},
563 { prop_sizeW
, CIM_UINT64
}
565 static const struct column col_diskdrivetodiskpartition
[] =
567 { prop_antecedentW
, CIM_REFERENCE
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
568 { prop_dependentW
, CIM_REFERENCE
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
570 static const struct column col_diskpartition
[] =
572 { prop_bootableW
, CIM_BOOLEAN
},
573 { prop_bootpartitionW
, CIM_BOOLEAN
},
574 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
575 { prop_diskindexW
, CIM_UINT32
},
576 { prop_indexW
, CIM_UINT32
},
577 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
578 { prop_sizeW
, CIM_UINT64
},
579 { prop_startingoffsetW
, CIM_UINT64
},
580 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
582 static const struct column col_displaycontrollerconfig
[] =
584 { prop_bitsperpixelW
, CIM_UINT32
},
585 { prop_captionW
, CIM_STRING
},
586 { prop_horizontalresolutionW
, CIM_UINT32
},
587 { prop_nameW
, CIM_STRING
|COL_FLAG_KEY
},
588 { prop_verticalresolutionW
, CIM_UINT32
}
590 static const struct column col_ip4routetable
[] =
592 { prop_destinationW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
593 { prop_interfaceindexW
, CIM_SINT32
|COL_FLAG_KEY
},
594 { prop_nexthopW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
596 static const struct column col_logicaldisk
[] =
598 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
599 { prop_drivetypeW
, CIM_UINT32
},
600 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
601 { prop_freespaceW
, CIM_UINT64
},
602 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
603 { prop_sizeW
, CIM_UINT64
},
604 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
605 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
607 static const struct column col_logicaldisktopartition
[] =
609 { prop_antecedentW
, CIM_REFERENCE
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
610 { prop_dependentW
, CIM_REFERENCE
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
612 static const struct column col_networkadapter
[] =
614 { prop_adaptertypeW
, CIM_STRING
},
615 { prop_adaptertypeidW
, CIM_UINT16
},
616 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
617 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
618 { prop_indexW
, CIM_UINT32
},
619 { prop_interfaceindexW
, CIM_UINT32
},
620 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
621 { prop_manufacturerW
, CIM_STRING
},
622 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
623 { prop_netconnectionstatusW
, CIM_UINT16
},
624 { prop_physicaladapterW
, CIM_BOOLEAN
},
625 { prop_pnpdeviceidW
, CIM_STRING
},
626 { prop_speedW
, CIM_UINT64
}
628 static const struct column col_networkadapterconfig
[] =
630 { prop_defaultipgatewayW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
631 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
632 { prop_dhcpenabledW
, CIM_BOOLEAN
},
633 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
634 { prop_dnsserversearchorderW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
635 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
},
636 { prop_ipaddressW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
637 { prop_ipconnectionmetricW
, CIM_UINT32
},
638 { prop_ipenabledW
, CIM_BOOLEAN
},
639 { prop_ipsubnet
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
640 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
641 { prop_settingidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
643 static const struct column col_operatingsystem
[] =
645 { prop_buildnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
646 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
647 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
648 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
649 { prop_csdversionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
650 { prop_csnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
651 { prop_currenttimezoneW
, CIM_SINT16
},
652 { prop_freephysicalmemoryW
, CIM_UINT64
},
653 { prop_installdateW
, CIM_DATETIME
},
654 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
655 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
656 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
657 { prop_manufacturerW
, CIM_STRING
},
658 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
659 { prop_operatingsystemskuW
, CIM_UINT32
},
660 { prop_osarchitectureW
, CIM_STRING
},
661 { prop_oslanguageW
, CIM_UINT32
},
662 { prop_osproductsuiteW
, CIM_UINT32
},
663 { prop_ostypeW
, CIM_UINT16
},
664 { prop_primaryW
, CIM_BOOLEAN
},
665 { prop_serialnumberW
, CIM_STRING
},
666 { prop_servicepackmajorW
, CIM_UINT16
},
667 { prop_servicepackminorW
, CIM_UINT16
},
668 { prop_suitemaskW
, CIM_UINT32
},
669 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
670 { prop_systemdriveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
671 { prop_totalvirtualmemorysizeW
, CIM_UINT64
},
672 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
673 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
675 static const struct column col_param
[] =
677 { prop_classW
, CIM_STRING
},
678 { prop_methodW
, CIM_STRING
},
679 { prop_directionW
, CIM_SINT32
},
680 { prop_parameterW
, CIM_STRING
},
681 { prop_typeW
, CIM_UINT32
},
682 { prop_defaultvalueW
, CIM_UINT32
}
684 static const struct column col_physicalmedia
[] =
686 { prop_serialnumberW
, CIM_STRING
},
687 { prop_tagW
, CIM_STRING
}
689 static const struct column col_physicalmemory
[] =
691 { prop_capacityW
, CIM_UINT64
},
692 { prop_configuredclockspeedW
, CIM_UINT32
},
693 { prop_devicelocatorW
, CIM_STRING
},
694 { prop_memorytypeW
, CIM_UINT16
},
695 { prop_partnumberW
, CIM_STRING
}
697 static const struct column col_pnpentity
[] =
699 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
701 static const struct column col_printer
[] =
703 { prop_attributesW
, CIM_UINT32
},
704 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
705 { prop_drivernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
706 { prop_horizontalresolutionW
, CIM_UINT32
},
707 { prop_localW
, CIM_BOOLEAN
},
708 { prop_locationW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
709 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
710 { prop_networkW
, CIM_BOOLEAN
},
711 { prop_portnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
713 static const struct column col_process
[] =
715 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
716 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
717 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
718 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
719 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
720 { prop_pprocessidW
, CIM_UINT32
},
721 { prop_processidW
, CIM_UINT32
},
722 { prop_threadcountW
, CIM_UINT32
},
723 { prop_workingsetsizeW
, CIM_UINT64
},
725 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
727 static const struct column col_processor
[] =
729 { prop_addresswidthW
, CIM_UINT16
},
730 { prop_architectureW
, CIM_UINT16
},
731 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
732 { prop_cpustatusW
, CIM_UINT16
},
733 { prop_currentclockspeedW
, CIM_UINT32
},
734 { prop_datawidthW
, CIM_UINT16
},
735 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
736 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
737 { prop_familyW
, CIM_UINT16
},
738 { prop_levelW
, CIM_UINT16
},
739 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
740 { prop_maxclockspeedW
, CIM_UINT32
},
741 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
742 { prop_numcoresW
, CIM_UINT32
},
743 { prop_numlogicalprocessorsW
, CIM_UINT32
},
744 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
745 { prop_processortypeW
, CIM_UINT16
},
746 { prop_revisionW
, CIM_UINT16
},
747 { prop_uniqueidW
, CIM_STRING
},
748 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
750 static const struct column col_qualifier
[] =
752 { prop_classW
, CIM_STRING
},
753 { prop_memberW
, CIM_STRING
},
754 { prop_typeW
, CIM_UINT32
},
755 { prop_flavorW
, CIM_SINT32
},
756 { prop_nameW
, CIM_STRING
},
757 { prop_intvalueW
, CIM_SINT32
},
758 { prop_strvalueW
, CIM_STRING
},
759 { prop_boolvalueW
, CIM_BOOLEAN
}
761 static const struct column col_quickfixengineering
[] =
763 { prop_captionW
, CIM_STRING
},
764 { prop_hotfixidW
, CIM_STRING
|COL_FLAG_KEY
}
766 static const struct column col_service
[] =
768 { prop_acceptpauseW
, CIM_BOOLEAN
},
769 { prop_acceptstopW
, CIM_BOOLEAN
},
770 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
771 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
772 { prop_processidW
, CIM_UINT32
},
773 { prop_servicetypeW
, CIM_STRING
},
774 { prop_startmodeW
, CIM_STRING
},
775 { prop_stateW
, CIM_STRING
},
776 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
778 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
779 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
780 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
781 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
783 static const struct column col_sid
[] =
785 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
786 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
787 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
788 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
789 { prop_sidlengthW
, CIM_UINT32
}
791 static const struct column col_sounddevice
[] =
793 { prop_nameW
, CIM_STRING
},
794 { prop_productnameW
, CIM_STRING
},
795 { prop_statusinfoW
, CIM_UINT16
}
797 static const struct column col_stdregprov
[] =
799 { method_createkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
800 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
801 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
802 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
804 static const struct column col_systemenclosure
[] =
806 { prop_captionW
, CIM_STRING
},
807 { prop_chassistypesW
, CIM_UINT16
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
808 { prop_descriptionW
, CIM_STRING
},
809 { prop_lockpresentW
, CIM_BOOLEAN
},
810 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
811 { prop_nameW
, CIM_STRING
},
812 { prop_tagW
, CIM_STRING
},
814 static const struct column col_systemsecurity
[] =
816 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
817 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
819 static const struct column col_videocontroller
[] =
821 { prop_adapterdactypeW
, CIM_STRING
},
822 { prop_adapterramW
, CIM_UINT32
},
823 { prop_availabilityW
, CIM_UINT16
},
824 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
825 { prop_configmanagererrorcodeW
, CIM_UINT32
},
826 { prop_currentbitsperpixelW
, CIM_UINT32
},
827 { prop_currenthorizontalresW
, CIM_UINT32
},
828 { prop_currentrefreshrateW
, CIM_UINT32
},
829 { prop_currentscanmodeW
, CIM_UINT16
},
830 { prop_currentverticalresW
, CIM_UINT32
},
831 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
832 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
833 { prop_driverdateW
, CIM_DATETIME
},
834 { prop_driverversionW
, CIM_STRING
},
835 { prop_installeddisplaydriversW
,CIM_STRING
},
836 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
837 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
838 { prop_statusW
, CIM_STRING
},
839 { prop_videoarchitectureW
, CIM_UINT16
},
840 { prop_videomemorytypeW
, CIM_UINT16
},
841 { prop_videomodedescriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
842 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
844 static const struct column col_winsat
[] =
846 { prop_cpuscoreW
, CIM_REAL32
},
847 { prop_d3dscoreW
, CIM_REAL32
},
848 { prop_diskscoreW
, CIM_REAL32
},
849 { prop_graphicsscoreW
, CIM_REAL32
},
850 { prop_memoryscoreW
, CIM_REAL32
},
851 { prop_timetakenW
, CIM_STRING
|COL_FLAG_KEY
},
852 { prop_winsatassessmentstateW
, CIM_UINT32
},
853 { prop_winsprlevelW
, CIM_REAL32
},
856 static const WCHAR baseboard_manufacturerW
[] =
857 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
858 static const WCHAR baseboard_serialnumberW
[] =
860 static const WCHAR baseboard_tagW
[] =
861 {'B','a','s','e',' ','B','o','a','r','d',0};
862 static const WCHAR baseboard_versionW
[] =
864 static const WCHAR bios_descriptionW
[] =
865 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
866 static const WCHAR bios_manufacturerW
[] =
867 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
868 static const WCHAR bios_releasedateW
[] =
869 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
870 static const WCHAR bios_serialnumberW
[] =
872 static const WCHAR bios_smbiosbiosversionW
[] =
874 static const WCHAR bios_versionW
[] =
875 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
876 static const WCHAR cdromdrive_mediatypeW
[] =
877 {'C','D','-','R','O','M',0};
878 static const WCHAR cdromdrive_nameW
[] =
879 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
880 static const WCHAR cdromdrive_pnpdeviceidW
[]=
881 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
882 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
883 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
884 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
885 static const WCHAR compsys_descriptionW
[] =
886 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
887 static const WCHAR compsys_domainW
[] =
888 {'W','O','R','K','G','R','O','U','P',0};
889 static const WCHAR compsys_manufacturerW
[] =
890 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
891 static const WCHAR compsys_modelW
[] =
893 static const WCHAR compsysproduct_identifyingnumberW
[] =
895 static const WCHAR compsysproduct_nameW
[] =
897 static const WCHAR compsysproduct_uuidW
[] =
898 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
899 'd','e','a','d','d','e','a','d','d','e','a','d',0};
900 static const WCHAR compsysproduct_vendorW
[] =
901 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
902 static const WCHAR compsysproduct_versionW
[] =
904 static const WCHAR diskdrive_interfacetypeW
[] =
906 static const WCHAR diskdrive_manufacturerW
[] =
907 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
908 static const WCHAR diskdrive_mediatype_fixedW
[] =
909 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
910 static const WCHAR diskdrive_mediatype_removableW
[] =
911 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
912 static const WCHAR diskdrive_modelW
[] =
913 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
914 static const WCHAR diskdrive_pnpdeviceidW
[] =
915 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
916 static const WCHAR diskdrive_serialW
[] =
917 {'W','I','N','E','H','D','I','S','K',0};
918 static const WCHAR networkadapter_pnpdeviceidW
[]=
919 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
920 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
921 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
922 static const WCHAR os_32bitW
[] =
923 {'3','2','-','b','i','t',0};
924 static const WCHAR os_64bitW
[] =
925 {'6','4','-','b','i','t',0};
926 static const WCHAR os_installdateW
[] =
927 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
928 static const WCHAR os_serialnumberW
[] =
929 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
930 static const WCHAR physicalmedia_tagW
[] =
931 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
932 static const WCHAR quickfixengineering_captionW
[] =
933 {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',0};
934 static const WCHAR quickfixengineering_hotfixidW
[] =
935 {'K','B','1','2','3','4','5','6','7',0};
936 static const WCHAR sounddevice_productnameW
[] =
937 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
938 static const WCHAR systemenclosure_systemenclosureW
[] =
939 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
940 static const WCHAR systemenclosure_tagW
[] =
941 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
942 static const WCHAR systemenclosure_manufacturerW
[] =
944 static const WCHAR videocontroller_dactypeW
[] =
945 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
946 static const WCHAR videocontroller_deviceidW
[] =
947 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
948 static const WCHAR videocontroller_driverdateW
[] =
949 {'2','0','1','7','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
950 static const WCHAR videocontroller_driverversionW
[] =
952 static const WCHAR videocontroller_statusW
[] =
954 static const WCHAR winsat_timetakenW
[] =
955 {'M','o','s','t','R','e','c','e','n','t','A','s','s','e','s','s','m','e','n','t',0};
957 #include "pshpack1.h"
958 struct record_associator
960 const WCHAR
*assocclass
;
962 const WCHAR
*associator
;
964 struct record_baseboard
966 const WCHAR
*manufacturer
;
969 const WCHAR
*product
;
970 const WCHAR
*serialnumber
;
972 const WCHAR
*version
;
976 const WCHAR
*currentlanguage
;
977 const WCHAR
*description
;
978 const WCHAR
*identificationcode
;
979 const WCHAR
*manufacturer
;
981 const WCHAR
*releasedate
;
982 const WCHAR
*serialnumber
;
983 const WCHAR
*smbiosbiosversion
;
984 UINT16 smbiosmajorversion
;
985 UINT16 smbiosminorversion
;
986 const WCHAR
*version
;
988 struct record_cdromdrive
990 const WCHAR
*device_id
;
992 const WCHAR
*mediatype
;
994 const WCHAR
*pnpdevice_id
;
996 struct record_computersystem
998 const WCHAR
*description
;
1001 const WCHAR
*manufacturer
;
1004 UINT32 num_logical_processors
;
1005 UINT32 num_processors
;
1006 UINT64 total_physical_memory
;
1007 const WCHAR
*username
;
1009 struct record_computersystemproduct
1011 const WCHAR
*identifyingnumber
;
1013 const WCHAR
*skunumber
;
1015 const WCHAR
*vendor
;
1016 const WCHAR
*version
;
1018 struct record_datafile
1021 const WCHAR
*version
;
1023 struct record_desktopmonitor
1025 UINT32 pixelsperxlogicalinch
;
1027 struct record_directory
1032 struct record_diskdrive
1034 const WCHAR
*device_id
;
1036 const WCHAR
*interfacetype
;
1037 const WCHAR
*manufacturer
;
1038 const WCHAR
*mediatype
;
1040 const WCHAR
*pnpdevice_id
;
1041 const WCHAR
*serialnumber
;
1044 struct record_diskdrivetodiskpartition
1046 const WCHAR
*antecedent
;
1047 const WCHAR
*dependent
;
1049 struct record_diskpartition
1053 const WCHAR
*device_id
;
1056 const WCHAR
*pnpdevice_id
;
1058 UINT64 startingoffset
;
1061 struct record_displaycontrollerconfig
1063 UINT32 bitsperpixel
;
1064 const WCHAR
*caption
;
1065 UINT32 horizontalresolution
;
1067 UINT32 verticalresolution
;
1069 struct record_ip4routetable
1071 const WCHAR
*destination
;
1072 INT32 interfaceindex
;
1073 const WCHAR
*nexthop
;
1075 struct record_logicaldisk
1077 const WCHAR
*device_id
;
1079 const WCHAR
*filesystem
;
1083 const WCHAR
*volumename
;
1084 const WCHAR
*volumeserialnumber
;
1086 struct record_logicaldisktopartition
1088 const WCHAR
*antecedent
;
1089 const WCHAR
*dependent
;
1091 struct record_networkadapter
1093 const WCHAR
*adaptertype
;
1094 UINT16 adaptertypeid
;
1095 const WCHAR
*description
;
1096 const WCHAR
*device_id
;
1098 UINT32 interface_index
;
1099 const WCHAR
*mac_address
;
1100 const WCHAR
*manufacturer
;
1102 UINT16 netconnection_status
;
1103 int physicaladapter
;
1104 const WCHAR
*pnpdevice_id
;
1107 struct record_networkadapterconfig
1109 const struct array
*defaultipgateway
;
1110 const WCHAR
*description
;
1112 const WCHAR
*dnshostname
;
1113 const struct array
*dnsserversearchorder
;
1115 const struct array
*ipaddress
;
1116 UINT32 ipconnectionmetric
;
1118 const struct array
*ipsubnet
;
1119 const WCHAR
*mac_address
;
1120 const WCHAR
*settingid
;
1122 struct record_operatingsystem
1124 const WCHAR
*buildnumber
;
1125 const WCHAR
*caption
;
1126 const WCHAR
*codeset
;
1127 const WCHAR
*countrycode
;
1128 const WCHAR
*csdversion
;
1129 const WCHAR
*csname
;
1130 INT16 currenttimezone
;
1131 UINT64 freephysicalmemory
;
1132 const WCHAR
*installdate
;
1133 const WCHAR
*lastbootuptime
;
1134 const WCHAR
*localdatetime
;
1135 const WCHAR
*locale
;
1136 const WCHAR
*manufacturer
;
1138 UINT32 operatingsystemsku
;
1139 const WCHAR
*osarchitecture
;
1141 UINT32 osproductsuite
;
1144 const WCHAR
*serialnumber
;
1145 UINT16 servicepackmajor
;
1146 UINT16 servicepackminor
;
1148 const WCHAR
*systemdirectory
;
1149 const WCHAR
*systemdrive
;
1150 UINT64 totalvirtualmemorysize
;
1151 UINT64 totalvisiblememorysize
;
1152 const WCHAR
*version
;
1157 const WCHAR
*method
;
1159 const WCHAR
*parameter
;
1161 UINT32 defaultvalue
;
1163 struct record_physicalmedia
1165 const WCHAR
*serialnumber
;
1168 struct record_physicalmemory
1171 UINT32 configuredclockspeed
;
1172 const WCHAR
*devicelocator
;
1174 const WCHAR
*partnumber
;
1176 struct record_pnpentity
1178 const WCHAR
*device_id
;
1180 struct record_printer
1183 const WCHAR
*device_id
;
1184 const WCHAR
*drivername
;
1185 UINT32 horizontalresolution
;
1187 const WCHAR
*location
;
1190 const WCHAR
*portname
;
1192 struct record_process
1194 const WCHAR
*caption
;
1195 const WCHAR
*commandline
;
1196 const WCHAR
*description
;
1197 const WCHAR
*handle
;
1201 UINT32 thread_count
;
1202 UINT64 workingsetsize
;
1204 class_method
*get_owner
;
1206 struct record_processor
1208 UINT16 addresswidth
;
1209 UINT16 architecture
;
1210 const WCHAR
*caption
;
1212 UINT32 currentclockspeed
;
1214 const WCHAR
*description
;
1215 const WCHAR
*device_id
;
1218 const WCHAR
*manufacturer
;
1219 UINT32 maxclockspeed
;
1222 UINT32 num_logical_processors
;
1223 const WCHAR
*processor_id
;
1224 UINT16 processortype
;
1226 const WCHAR
*unique_id
;
1227 const WCHAR
*version
;
1229 struct record_qualifier
1232 const WCHAR
*member
;
1237 const WCHAR
*strvalue
;
1240 struct record_quickfixengineering
1242 const WCHAR
*caption
;
1243 const WCHAR
*hotfixid
;
1245 struct record_service
1249 const WCHAR
*displayname
;
1252 const WCHAR
*servicetype
;
1253 const WCHAR
*startmode
;
1255 const WCHAR
*systemname
;
1257 class_method
*pause_service
;
1258 class_method
*resume_service
;
1259 class_method
*start_service
;
1260 class_method
*stop_service
;
1264 const WCHAR
*accountname
;
1265 const struct array
*binaryrepresentation
;
1266 const WCHAR
*referenceddomainname
;
1270 struct record_sounddevice
1273 const WCHAR
*productname
;
1276 struct record_stdregprov
1278 class_method
*createkey
;
1279 class_method
*enumkey
;
1280 class_method
*enumvalues
;
1281 class_method
*getstringvalue
;
1283 struct record_systemsecurity
1285 class_method
*getsd
;
1286 class_method
*setsd
;
1288 struct record_systemenclosure
1290 const WCHAR
*caption
;
1291 const struct array
*chassistypes
;
1292 const WCHAR
*description
;
1294 const WCHAR
*manufacturer
;
1298 struct record_videocontroller
1300 const WCHAR
*adapter_dactype
;
1302 UINT16 availability
;
1303 const WCHAR
*caption
;
1304 UINT32 config_errorcode
;
1305 UINT32 current_bitsperpixel
;
1306 UINT32 current_horizontalres
;
1307 UINT32 current_refreshrate
;
1308 UINT16 current_scanmode
;
1309 UINT32 current_verticalres
;
1310 const WCHAR
*description
;
1311 const WCHAR
*device_id
;
1312 const WCHAR
*driverdate
;
1313 const WCHAR
*driverversion
;
1314 const WCHAR
*installeddriver
;
1316 const WCHAR
*pnpdevice_id
;
1317 const WCHAR
*status
;
1318 UINT16 videoarchitecture
;
1319 UINT16 videomemorytype
;
1320 const WCHAR
*videomodedescription
;
1321 const WCHAR
*videoprocessor
;
1323 struct record_winsat
1328 FLOAT graphicsscore
;
1330 const WCHAR
*timetaken
;
1331 UINT32 winsatassessmentstate
;
1334 #include "poppack.h"
1336 static const struct record_associator data_associator
[] =
1338 { class_diskdrivetodiskpartitionW
, class_diskpartitionW
, class_diskdriveW
},
1339 { class_logicaldisktopartitionW
, class_logicaldiskW
, class_diskpartitionW
},
1341 static const struct record_param data_param
[] =
1343 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
},
1344 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
1345 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
1346 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
},
1347 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
},
1348 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
},
1349 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
},
1350 { class_stdregprovW
, method_createkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0x80000002 },
1351 { class_stdregprovW
, method_createkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1352 { class_stdregprovW
, method_createkeyW
, -1, param_returnvalueW
, CIM_UINT32
},
1353 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0x80000002 },
1354 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1355 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
},
1356 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1357 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0x80000002 },
1358 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
1359 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
},
1360 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1361 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
1362 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0x80000002 },
1363 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
1364 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
1365 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
},
1366 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
1367 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
},
1368 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1369 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1370 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
},
1373 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1374 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1376 static const struct record_physicalmedia data_physicalmedia
[] =
1378 { diskdrive_serialW
, physicalmedia_tagW
}
1380 static const struct record_qualifier data_qualifier
[] =
1382 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
1383 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
1385 static const struct record_quickfixengineering data_quickfixengineering
[] =
1387 { quickfixengineering_captionW
, quickfixengineering_hotfixidW
},
1389 static const struct record_sounddevice data_sounddevice
[] =
1391 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
1393 static const struct record_stdregprov data_stdregprov
[] =
1395 { reg_create_key
, reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
1397 static UINT16 systemenclosure_chassistypes
[] =
1401 static const struct array systemenclosure_chassistypes_array
=
1403 sizeof(*systemenclosure_chassistypes
),
1404 ARRAY_SIZE(systemenclosure_chassistypes
),
1405 &systemenclosure_chassistypes
1407 static const struct record_systemsecurity data_systemsecurity
[] =
1409 { security_get_sd
, security_set_sd
}
1411 static const struct record_winsat data_winsat
[] =
1413 { 8.0f
, 8.0f
, 8.0f
, 8.0f
, 8.0f
, winsat_timetakenW
, 1 /* Valid */, 8.0f
},
1416 /* check if row matches condition and update status */
1417 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1424 *status
= FILL_STATUS_UNFILTERED
;
1427 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1429 *status
= FILL_STATUS_FAILED
;
1432 *status
= FILL_STATUS_FILTERED
;
1436 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1438 if (!table
->num_rows_allocated
)
1440 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1441 table
->num_rows_allocated
= row_count
;
1444 if (row_count
> table
->num_rows_allocated
)
1447 UINT count
= max( row_count
, table
->num_rows_allocated
* 2 );
1448 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1450 table
->num_rows_allocated
= count
;
1455 #include "pshpack1.h"
1456 struct smbios_prologue
1458 BYTE calling_method
;
1469 SMBIOS_TYPE_BASEBOARD
,
1470 SMBIOS_TYPE_CHASSIS
,
1473 struct smbios_header
1480 struct smbios_baseboard
1482 struct smbios_header hdr
;
1491 struct smbios_header hdr
;
1497 UINT64 characteristics
;
1500 struct smbios_chassis
1502 struct smbios_header hdr
;
1510 struct smbios_system
1512 struct smbios_header hdr
;
1519 #include "poppack.h"
1521 #define RSMB (('R' << 24) | ('S' << 16) | ('M' << 8) | 'B')
1523 static const struct smbios_header
*find_smbios_entry( enum smbios_type type
, const char *buf
, UINT len
)
1525 const char *ptr
, *start
;
1526 const struct smbios_prologue
*prologue
;
1527 const struct smbios_header
*hdr
;
1529 if (len
< sizeof(struct smbios_prologue
)) return NULL
;
1530 prologue
= (const struct smbios_prologue
*)buf
;
1531 if (prologue
->length
> len
- sizeof(*prologue
) || prologue
->length
< sizeof(*hdr
)) return NULL
;
1533 start
= (const char *)(prologue
+ 1);
1534 hdr
= (const struct smbios_header
*)start
;
1538 if ((const char *)hdr
- start
>= prologue
->length
- sizeof(*hdr
)) return NULL
;
1542 WARN( "invalid entry\n" );
1546 if (hdr
->type
== type
)
1548 if ((const char *)hdr
- start
+ hdr
->length
> prologue
->length
) return NULL
;
1551 else /* skip other entries and their strings */
1553 for (ptr
= (const char *)hdr
+ hdr
->length
; ptr
- buf
< len
&& *ptr
; ptr
++)
1555 for (; ptr
- buf
< len
; ptr
++) if (!*ptr
) break;
1557 if (ptr
== (const char *)hdr
+ hdr
->length
) ptr
++;
1558 hdr
= (const struct smbios_header
*)(ptr
+ 1);
1565 static WCHAR
*get_smbios_string( BYTE id
, const char *buf
, UINT offset
, UINT buflen
)
1567 const char *ptr
= buf
+ offset
;
1570 if (!id
|| offset
>= buflen
) return NULL
;
1571 for (ptr
= buf
+ offset
; ptr
- buf
< buflen
&& *ptr
; ptr
++)
1573 if (++i
== id
) return heap_strdupAW( ptr
);
1574 for (; ptr
- buf
< buflen
; ptr
++) if (!*ptr
) break;
1579 static WCHAR
*get_baseboard_string( BYTE id
, const char *buf
, UINT len
)
1581 const struct smbios_header
*hdr
;
1582 const struct smbios_baseboard
*baseboard
;
1585 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_BASEBOARD
, buf
, len
))) return NULL
;
1587 baseboard
= (const struct smbios_baseboard
*)hdr
;
1588 offset
= (const char *)baseboard
- buf
+ baseboard
->hdr
.length
;
1589 return get_smbios_string( id
, buf
, offset
, len
);
1592 static WCHAR
*get_baseboard_manufacturer( const char *buf
, UINT len
)
1594 WCHAR
*ret
= get_baseboard_string( 1, buf
, len
);
1595 if (!ret
) return heap_strdupW( baseboard_manufacturerW
);
1599 static WCHAR
*get_baseboard_product( const char *buf
, UINT len
)
1601 WCHAR
*ret
= get_baseboard_string( 2, buf
, len
);
1602 if (!ret
) return heap_strdupW( baseboard_tagW
);
1606 static WCHAR
*get_baseboard_serialnumber( const char *buf
, UINT len
)
1608 WCHAR
*ret
= get_baseboard_string( 4, buf
, len
);
1609 if (!ret
) return heap_strdupW( baseboard_serialnumberW
);
1613 static WCHAR
*get_baseboard_version( const char *buf
, UINT len
)
1615 WCHAR
*ret
= get_baseboard_string( 3, buf
, len
);
1616 if (!ret
) return heap_strdupW( baseboard_versionW
);
1620 static enum fill_status
fill_baseboard( struct table
*table
, const struct expr
*cond
)
1622 struct record_baseboard
*rec
;
1623 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1627 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1629 len
= GetSystemFirmwareTable( RSMB
, 0, NULL
, 0 );
1630 if (!(buf
= heap_alloc( len
))) return FILL_STATUS_FAILED
;
1631 GetSystemFirmwareTable( RSMB
, 0, buf
, len
);
1633 rec
= (struct record_baseboard
*)table
->data
;
1634 rec
->manufacturer
= get_baseboard_manufacturer( buf
, len
);
1635 rec
->model
= baseboard_tagW
;
1636 rec
->name
= baseboard_tagW
;
1637 rec
->product
= get_baseboard_product( buf
, len
);
1638 rec
->serialnumber
= get_baseboard_serialnumber( buf
, len
);
1639 rec
->tag
= baseboard_tagW
;
1640 rec
->version
= get_baseboard_version( buf
, len
);
1641 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1646 TRACE("created %u rows\n", row
);
1647 table
->num_rows
= row
;
1651 static UINT16
get_bios_smbiosmajorversion( const char *buf
, UINT len
)
1653 const struct smbios_prologue
*prologue
= (const struct smbios_prologue
*)buf
;
1654 if (len
< sizeof(*prologue
)) return 2;
1655 return prologue
->major_version
;
1658 static UINT16
get_bios_smbiosminorversion( const char *buf
, UINT len
)
1660 const struct smbios_prologue
*prologue
= (const struct smbios_prologue
*)buf
;
1661 if (len
< sizeof(*prologue
)) return 0;
1662 return prologue
->minor_version
;
1665 static WCHAR
*get_bios_string( BYTE id
, const char *buf
, UINT len
)
1667 const struct smbios_header
*hdr
;
1668 const struct smbios_bios
*bios
;
1671 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_BIOS
, buf
, len
))) return NULL
;
1673 bios
= (const struct smbios_bios
*)hdr
;
1674 offset
= (const char *)bios
- buf
+ bios
->hdr
.length
;
1675 return get_smbios_string( id
, buf
, offset
, len
);
1678 static WCHAR
*get_bios_manufacturer( const char *buf
, UINT len
)
1680 WCHAR
*ret
= get_bios_string( 1, buf
, len
);
1681 if (!ret
) return heap_strdupW( bios_manufacturerW
);
1685 static WCHAR
*convert_bios_date( const WCHAR
*str
)
1687 static const WCHAR fmtW
[] =
1688 {'%','0','4','u','%','0','2','u','%','0','2','u','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
1689 UINT year
, month
, day
, len
= lstrlenW( str
);
1690 const WCHAR
*p
= str
, *q
;
1693 while (len
&& iswspace( *p
)) { p
++; len
--; }
1694 while (len
&& iswspace( p
[len
- 1] )) { len
--; }
1697 while (len
&& iswdigit( *q
)) { q
++; len
--; };
1698 if (q
- p
!= 2 || !len
|| *q
!= '/') return NULL
;
1699 month
= (p
[0] - '0') * 10 + p
[1] - '0';
1702 while (len
&& iswdigit( *q
)) { q
++; len
--; };
1703 if (q
- p
!= 2 || !len
|| *q
!= '/') return NULL
;
1704 day
= (p
[0] - '0') * 10 + p
[1] - '0';
1707 while (len
&& iswdigit( *q
)) { q
++; len
--; };
1708 if (q
- p
== 4) year
= (p
[0] - '0') * 1000 + (p
[1] - '0') * 100 + (p
[2] - '0') * 10 + p
[3] - '0';
1709 else if (q
- p
== 2) year
= 1900 + (p
[0] - '0') * 10 + p
[1] - '0';
1712 if (!(ret
= heap_alloc( sizeof(fmtW
) ))) return NULL
;
1713 swprintf( ret
, ARRAY_SIZE(fmtW
), fmtW
, year
, month
, day
);
1717 static WCHAR
*get_bios_releasedate( const char *buf
, UINT len
)
1719 WCHAR
*ret
, *date
= get_bios_string( 3, buf
, len
);
1720 if (!date
|| !(ret
= convert_bios_date( date
))) ret
= heap_strdupW( bios_releasedateW
);
1725 static WCHAR
*get_bios_smbiosbiosversion( const char *buf
, UINT len
)
1727 WCHAR
*ret
= get_bios_string( 2, buf
, len
);
1728 if (!ret
) return heap_strdupW( bios_smbiosbiosversionW
);
1732 static enum fill_status
fill_bios( struct table
*table
, const struct expr
*cond
)
1734 struct record_bios
*rec
;
1735 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1739 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1741 len
= GetSystemFirmwareTable( RSMB
, 0, NULL
, 0 );
1742 if (!(buf
= heap_alloc( len
))) return FILL_STATUS_FAILED
;
1743 GetSystemFirmwareTable( RSMB
, 0, buf
, len
);
1745 rec
= (struct record_bios
*)table
->data
;
1746 rec
->currentlanguage
= NULL
;
1747 rec
->description
= bios_descriptionW
;
1748 rec
->identificationcode
= NULL
;
1749 rec
->manufacturer
= get_bios_manufacturer( buf
, len
);
1750 rec
->name
= bios_descriptionW
;
1751 rec
->releasedate
= get_bios_releasedate( buf
, len
);
1752 rec
->serialnumber
= bios_serialnumberW
;
1753 rec
->smbiosbiosversion
= get_bios_smbiosbiosversion( buf
, len
);
1754 rec
->smbiosmajorversion
= get_bios_smbiosmajorversion( buf
, len
);
1755 rec
->smbiosminorversion
= get_bios_smbiosminorversion( buf
, len
);
1756 rec
->version
= bios_versionW
;
1757 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1762 TRACE("created %u rows\n", row
);
1763 table
->num_rows
= row
;
1767 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1769 static const WCHAR fmtW
[] = {'%','c',':',0};
1770 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1771 struct record_cdromdrive
*rec
;
1772 UINT i
, row
= 0, offset
= 0;
1773 DWORD drives
= GetLogicalDrives();
1774 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1776 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1778 for (i
= 0; i
< 26; i
++)
1780 if (drives
& (1 << i
))
1783 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1786 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1788 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1789 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1790 swprintf( drive
, ARRAY_SIZE( drive
), fmtW
, 'A' + i
);
1791 rec
->drive
= heap_strdupW( drive
);
1792 rec
->mediatype
= cdromdrive_mediatypeW
;
1793 rec
->name
= cdromdrive_nameW
;
1794 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1795 if (!match_row( table
, row
, cond
, &status
))
1797 free_row_values( table
, row
);
1800 offset
+= sizeof(*rec
);
1804 TRACE("created %u rows\n", row
);
1805 table
->num_rows
= row
;
1809 static UINT
get_processor_count(void)
1811 SYSTEM_BASIC_INFORMATION info
;
1813 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1814 return info
.NumberOfProcessors
;
1817 static UINT
get_logical_processor_count( UINT
*num_physical
, UINT
*num_packages
)
1819 SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
*buf
, *entry
;
1820 UINT core_relation_count
= 0, package_relation_count
= 0;
1822 ULONG len
, offset
= 0;
1823 BOOL smt_enabled
= FALSE
;
1824 DWORD all
= RelationAll
;
1826 if (num_packages
) *num_packages
= 1;
1827 status
= NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx
, &all
, sizeof(all
), NULL
, 0, &len
);
1828 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1830 if (!(buf
= heap_alloc( len
))) return get_processor_count();
1831 status
= NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx
, &all
, sizeof(all
), buf
, len
, NULL
);
1832 if (status
!= STATUS_SUCCESS
)
1835 return get_processor_count();
1838 while (offset
< len
)
1840 entry
= (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
*)((char *)buf
+ offset
);
1842 if (entry
->Relationship
== RelationProcessorCore
)
1844 core_relation_count
++;
1845 if (entry
->u
.Processor
.Flags
& LTP_PC_SMT
) smt_enabled
= TRUE
;
1847 else if (entry
->Relationship
== RelationProcessorPackage
)
1849 package_relation_count
++;
1851 offset
+= entry
->Size
;
1855 if (num_physical
) *num_physical
= core_relation_count
;
1856 if (num_packages
) *num_packages
= package_relation_count
;
1857 return smt_enabled
? core_relation_count
* 2 : core_relation_count
;
1860 static UINT64
get_total_physical_memory(void)
1862 MEMORYSTATUSEX status
;
1864 status
.dwLength
= sizeof(status
);
1865 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1866 return status
.ullTotalPhys
;
1869 static UINT64
get_available_physical_memory(void)
1871 MEMORYSTATUSEX status
;
1873 status
.dwLength
= sizeof(status
);
1874 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1875 return status
.ullAvailPhys
;
1878 static WCHAR
*get_computername(void)
1881 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1883 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1884 GetComputerNameW( ret
, &size
);
1888 static WCHAR
*get_username(void)
1891 DWORD compsize
, usersize
;
1895 GetComputerNameW( NULL
, &compsize
);
1897 GetUserNameW( NULL
, &usersize
);
1898 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1899 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1900 GetComputerNameW( ret
, &compsize
);
1901 ret
[compsize
] = '\\';
1902 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1906 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1908 struct record_computersystem
*rec
;
1909 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1912 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1914 rec
= (struct record_computersystem
*)table
->data
;
1915 rec
->description
= compsys_descriptionW
;
1916 rec
->domain
= compsys_domainW
;
1917 rec
->domainrole
= 0; /* standalone workstation */
1918 rec
->manufacturer
= compsys_manufacturerW
;
1919 rec
->model
= compsys_modelW
;
1920 rec
->name
= get_computername();
1921 rec
->num_logical_processors
= get_logical_processor_count( NULL
, &rec
->num_processors
);
1922 rec
->total_physical_memory
= get_total_physical_memory();
1923 rec
->username
= get_username();
1924 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1927 TRACE("created %u rows\n", row
);
1928 table
->num_rows
= row
;
1932 static WCHAR
*get_compsysproduct_string( BYTE id
, const char *buf
, UINT len
)
1934 const struct smbios_header
*hdr
;
1935 const struct smbios_system
*system
;
1938 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_SYSTEM
, buf
, len
))) return NULL
;
1940 system
= (const struct smbios_system
*)hdr
;
1941 offset
= (const char *)system
- buf
+ system
->hdr
.length
;
1942 return get_smbios_string( id
, buf
, offset
, len
);
1945 static WCHAR
*get_compsysproduct_identifyingnumber( const char *buf
, UINT len
)
1947 WCHAR
*ret
= get_compsysproduct_string( 4, buf
, len
);
1948 if (!ret
) return heap_strdupW( compsysproduct_identifyingnumberW
);
1952 static WCHAR
*get_compsysproduct_name( const char *buf
, UINT len
)
1954 WCHAR
*ret
= get_compsysproduct_string( 2, buf
, len
);
1955 if (!ret
) return heap_strdupW( compsysproduct_nameW
);
1959 static WCHAR
*get_compsysproduct_uuid( const char *buf
, UINT len
)
1961 static const WCHAR fmtW
[] =
1962 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1963 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1964 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1965 static const BYTE none
[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
1966 const struct smbios_header
*hdr
;
1967 const struct smbios_system
*system
;
1971 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_SYSTEM
, buf
, len
)) || hdr
->length
< sizeof(*system
)) goto done
;
1972 system
= (const struct smbios_system
*)hdr
;
1973 if (!memcmp( system
->uuid
, none
, sizeof(none
) ) || !(ret
= heap_alloc( 37 * sizeof(WCHAR
) ))) goto done
;
1976 swprintf( ret
, 37, fmtW
, ptr
[0], ptr
[1], ptr
[2], ptr
[3], ptr
[4], ptr
[5], ptr
[6], ptr
[7], ptr
[8], ptr
[9],
1977 ptr
[10], ptr
[11], ptr
[12], ptr
[13], ptr
[14], ptr
[15] );
1980 if (!ret
) ret
= heap_strdupW( compsysproduct_uuidW
);
1984 static WCHAR
*get_compsysproduct_vendor( const char *buf
, UINT len
)
1986 WCHAR
*ret
= get_compsysproduct_string( 1, buf
, len
);
1987 if (!ret
) return heap_strdupW( compsysproduct_vendorW
);
1991 static WCHAR
*get_compsysproduct_version( const char *buf
, UINT len
)
1993 WCHAR
*ret
= get_compsysproduct_string( 3, buf
, len
);
1994 if (!ret
) return heap_strdupW( compsysproduct_versionW
);
1998 static enum fill_status
fill_compsysproduct( struct table
*table
, const struct expr
*cond
)
2000 struct record_computersystemproduct
*rec
;
2001 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2005 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2007 len
= GetSystemFirmwareTable( RSMB
, 0, NULL
, 0 );
2008 if (!(buf
= heap_alloc( len
))) return FILL_STATUS_FAILED
;
2009 GetSystemFirmwareTable( RSMB
, 0, buf
, len
);
2011 rec
= (struct record_computersystemproduct
*)table
->data
;
2012 rec
->identifyingnumber
= get_compsysproduct_identifyingnumber( buf
, len
);
2013 rec
->name
= get_compsysproduct_name( buf
, len
);
2014 rec
->skunumber
= NULL
;
2015 rec
->uuid
= get_compsysproduct_uuid( buf
, len
);
2016 rec
->vendor
= get_compsysproduct_vendor( buf
, len
);
2017 rec
->version
= get_compsysproduct_version( buf
, len
);
2018 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2023 TRACE("created %u rows\n", row
);
2024 table
->num_rows
= row
;
2036 static struct dirstack
*alloc_dirstack( UINT size
)
2038 struct dirstack
*dirstack
;
2040 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
2041 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
2043 heap_free( dirstack
);
2046 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
2048 heap_free( dirstack
->dirs
);
2049 heap_free( dirstack
);
2052 dirstack
->num_dirs
= 0;
2053 dirstack
->num_allocated
= size
;
2057 static void clear_dirstack( struct dirstack
*dirstack
)
2060 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
2061 dirstack
->num_dirs
= 0;
2064 static void free_dirstack( struct dirstack
*dirstack
)
2066 clear_dirstack( dirstack
);
2067 heap_free( dirstack
->dirs
);
2068 heap_free( dirstack
->len_dirs
);
2069 heap_free( dirstack
);
2072 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
2074 UINT size
, i
= dirstack
->num_dirs
;
2076 if (!dir
) return FALSE
;
2078 if (i
== dirstack
->num_allocated
)
2083 size
= dirstack
->num_allocated
* 2;
2084 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
2085 dirstack
->dirs
= tmp
;
2086 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
2087 dirstack
->len_dirs
= len_tmp
;
2088 dirstack
->num_allocated
= size
;
2090 dirstack
->dirs
[i
] = dir
;
2091 dirstack
->len_dirs
[i
] = len
;
2092 dirstack
->num_dirs
++;
2096 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
2098 if (!dirstack
->num_dirs
)
2103 dirstack
->num_dirs
--;
2104 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
2105 return dirstack
->dirs
[dirstack
->num_dirs
];
2108 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
2110 if (!dirstack
->num_dirs
) return NULL
;
2111 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
2114 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
2119 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
2125 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
2134 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
2136 UINT i
= 0, len
= 0;
2140 for (p
= path
; *p
; p
++)
2142 if (*p
== '\\') len
+= 2;
2145 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
2150 for (p
= path
; *p
; p
++)
2152 if (*p
!= '\\') ret
[i
++] = *p
;
2163 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
2165 const WCHAR
*p
= path
, *start
;
2169 if (!iswalpha( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
2171 len
= lstrlenW( start
);
2172 p
= start
+ len
- 1;
2173 if (*p
== '\\') return NULL
;
2175 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
2176 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
2178 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
2179 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
2181 if (p
[0] == '\\' && p
[1] == '\\')
2193 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
2196 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!wcscmp( dirstack
->dirs
[i
], path
)) return TRUE
;
2200 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
2201 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
2203 const struct expr
*left
, *right
;
2205 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
2207 left
= cond
->u
.expr
.left
;
2208 right
= cond
->u
.expr
.right
;
2209 if (cond
->u
.expr
.op
== OP_EQ
)
2213 const WCHAR
*str
= NULL
;
2215 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
2216 !wcscmp( left
->u
.propval
->name
, prop_nameW
) &&
2217 towupper( right
->u
.sval
[0] ) == towupper( root
))
2219 str
= right
->u
.sval
;
2221 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
2222 !wcscmp( right
->u
.propval
->name
, prop_nameW
) &&
2223 towupper( left
->u
.sval
[0] ) == towupper( root
))
2227 if (str
&& (path
= build_dirname( str
, &len
)))
2229 if (seen_dir( dirstack
, path
))
2234 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
2239 else if (cond
->u
.expr
.op
== OP_OR
)
2241 UINT left_count
= 0, right_count
= 0;
2243 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
2244 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
2245 return *count
+= left_count
+ right_count
;
2250 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
2252 UINT len_path
= 0, len_segment
= lstrlenW( segment
);
2256 if (path
) len_path
= lstrlenW( path
);
2257 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
2258 if (path
&& len_path
)
2260 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
2261 ret
[len_path
] = '\\';
2262 *len
+= len_path
+ 1;
2264 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
2265 *len
+= len_segment
;
2270 static WCHAR
*get_file_version( const WCHAR
*filename
)
2272 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2273 VS_FIXEDFILEINFO
*info
;
2274 DWORD size
, len
= 4 * 5 + ARRAY_SIZE( fmtW
);
2278 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) ))) return NULL
;
2279 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
2284 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
2285 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
2291 swprintf( ret
, len
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
2292 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
2297 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
2299 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
2300 struct record_datafile
*rec
;
2301 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
2302 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
2303 DWORD drives
= GetLogicalDrives();
2304 WIN32_FIND_DATAW data
;
2306 struct dirstack
*dirstack
;
2307 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2309 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2311 dirstack
= alloc_dirstack(2);
2313 for (i
= 0; i
< 26; i
++)
2315 if (!(drives
& (1 << i
))) continue;
2318 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
2320 num_expected_rows
= 0;
2321 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
2327 path
= pop_dir( dirstack
, &len
);
2328 if (!(glob
= build_glob( root
[0], path
, len
)))
2330 status
= FILL_STATUS_FAILED
;
2333 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
2337 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
2339 status
= FILL_STATUS_FAILED
;
2340 FindClose( handle
);
2343 if (!wcscmp( data
.cFileName
, dotW
) || !wcscmp( data
.cFileName
, dotdotW
)) continue;
2345 if (!(new_path
= append_path( path
, data
.cFileName
, &len
)))
2347 status
= FILL_STATUS_FAILED
;
2348 FindClose( handle
);
2352 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
2354 if (push_dir( dirstack
, new_path
, len
)) continue;
2355 heap_free( new_path
);
2356 FindClose( handle
);
2357 status
= FILL_STATUS_FAILED
;
2360 rec
= (struct record_datafile
*)(table
->data
+ offset
);
2361 rec
->name
= build_name( root
[0], new_path
);
2362 rec
->version
= get_file_version( rec
->name
);
2363 heap_free( new_path
);
2364 if (!match_row( table
, row
, cond
, &status
))
2366 free_row_values( table
, row
);
2369 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
2372 FindClose( handle
);
2373 status
= FILL_STATUS_FILTERED
;
2376 offset
+= sizeof(*rec
);
2379 while (FindNextFileW( handle
, &data
));
2380 FindClose( handle
);
2382 if (!peek_dir( dirstack
)) break;
2387 free_dirstack( dirstack
);
2391 TRACE("created %u rows\n", row
);
2392 table
->num_rows
= row
;
2396 static UINT32
get_pixelsperxlogicalinch(void)
2398 HDC hdc
= GetDC( NULL
);
2401 if (!hdc
) return 96;
2402 ret
= GetDeviceCaps( hdc
, LOGPIXELSX
);
2403 ReleaseDC( NULL
, hdc
);
2407 static enum fill_status
fill_desktopmonitor( struct table
*table
, const struct expr
*cond
)
2409 struct record_desktopmonitor
*rec
;
2410 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2413 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2415 rec
= (struct record_desktopmonitor
*)table
->data
;
2416 rec
->pixelsperxlogicalinch
= get_pixelsperxlogicalinch();
2418 if (match_row( table
, row
, cond
, &status
)) row
++;
2420 TRACE("created %u rows\n", row
);
2421 table
->num_rows
= row
;
2425 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
2427 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
2428 struct record_directory
*rec
;
2429 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
2430 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
2431 DWORD drives
= GetLogicalDrives();
2432 WIN32_FIND_DATAW data
;
2434 struct dirstack
*dirstack
;
2435 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2437 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2439 dirstack
= alloc_dirstack(2);
2441 for (i
= 0; i
< 26; i
++)
2443 if (!(drives
& (1 << i
))) continue;
2446 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
2448 num_expected_rows
= 0;
2449 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
2455 path
= pop_dir( dirstack
, &len
);
2456 if (!(glob
= build_glob( root
[0], path
, len
)))
2458 status
= FILL_STATUS_FAILED
;
2461 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
2465 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
2467 FindClose( handle
);
2468 status
= FILL_STATUS_FAILED
;
2471 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
2472 !wcscmp( data
.cFileName
, dotW
) || !wcscmp( data
.cFileName
, dotdotW
))
2475 if (!(new_path
= append_path( path
, data
.cFileName
, &len
)))
2477 FindClose( handle
);
2478 status
= FILL_STATUS_FAILED
;
2482 if (!(push_dir( dirstack
, new_path
, len
)))
2484 heap_free( new_path
);
2485 FindClose( handle
);
2486 status
= FILL_STATUS_FAILED
;
2489 rec
= (struct record_directory
*)(table
->data
+ offset
);
2490 rec
->accessmask
= FILE_ALL_ACCESS
;
2491 rec
->name
= build_name( root
[0], new_path
);
2492 heap_free( new_path
);
2493 if (!match_row( table
, row
, cond
, &status
))
2495 free_row_values( table
, row
);
2498 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
2501 FindClose( handle
);
2502 status
= FILL_STATUS_FILTERED
;
2505 offset
+= sizeof(*rec
);
2508 while (FindNextFileW( handle
, &data
));
2509 FindClose( handle
);
2511 if (!peek_dir( dirstack
)) break;
2516 free_dirstack( dirstack
);
2520 TRACE("created %u rows\n", row
);
2521 table
->num_rows
= row
;
2525 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
2527 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
2528 ULARGE_INTEGER free
;
2529 DISK_GEOMETRY_EX info
;
2531 DWORD bytes_returned
;
2533 free
.QuadPart
= 512 * 1024 * 1024;
2534 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
2537 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
2538 if (handle
!= INVALID_HANDLE_VALUE
)
2540 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
2541 *disksize
= info
.DiskSize
.QuadPart
;
2542 CloseHandle( handle
);
2544 return free
.QuadPart
;
2547 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
2549 static const WCHAR fmtW
[] =
2550 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
2551 WCHAR device_id
[ARRAY_SIZE( fmtW
) + 10], root
[] = {'A',':','\\',0};
2552 struct record_diskdrive
*rec
;
2553 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
2554 UINT64 size
= 1024 * 1024 * 1024;
2555 DWORD drives
= GetLogicalDrives();
2556 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2558 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2560 for (i
= 0; i
< 26; i
++)
2562 if (drives
& (1 << i
))
2565 type
= GetDriveTypeW( root
);
2566 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
2569 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2571 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
2572 swprintf( device_id
, ARRAY_SIZE( device_id
), fmtW
, index
);
2573 rec
->device_id
= heap_strdupW( device_id
);
2574 rec
->index
= index
++;
2575 rec
->interfacetype
= diskdrive_interfacetypeW
;
2576 rec
->manufacturer
= diskdrive_manufacturerW
;
2577 rec
->mediatype
= (type
== DRIVE_FIXED
) ? diskdrive_mediatype_fixedW
: diskdrive_mediatype_removableW
;
2578 rec
->model
= diskdrive_modelW
;
2579 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
2580 rec
->serialnumber
= diskdrive_serialW
;
2581 get_freespace( root
, &size
);
2583 if (!match_row( table
, row
, cond
, &status
))
2585 free_row_values( table
, row
);
2588 offset
+= sizeof(*rec
);
2592 TRACE("created %u rows\n", row
);
2593 table
->num_rows
= row
;
2603 static void free_associations( struct association
*assoc
, UINT count
)
2607 for (i
= 0; i
< count
; i
++)
2609 heap_free( assoc
[i
].ref
);
2610 heap_free( assoc
[i
].ref2
);
2615 static struct association
*get_diskdrivetodiskpartition_pairs( UINT
*count
)
2617 static const WCHAR pathW
[] =
2618 {'_','_','P','A','T','H',0};
2619 static const WCHAR selectW
[] =
2620 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2621 'D','i','s','k','D','r','i','v','e',0};
2622 static const WCHAR select2W
[] =
2623 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2624 'D','i','s','k','P','a','r','t','i','t','i','o','n',0};
2625 struct association
*ret
= NULL
;
2626 struct query
*query
, *query2
= NULL
;
2631 if (!(query
= create_query())) return NULL
;
2632 if ((hr
= parse_query( selectW
, &query
->view
, &query
->mem
)) != S_OK
) goto done
;
2633 if ((hr
= execute_view( query
->view
)) != S_OK
) goto done
;
2635 if (!(query2
= create_query())) return FALSE
;
2636 if ((hr
= parse_query( select2W
, &query2
->view
, &query2
->mem
)) != S_OK
) goto done
;
2637 if ((hr
= execute_view( query2
->view
)) != S_OK
) goto done
;
2639 if (!(ret
= heap_alloc_zero( query
->view
->result_count
* sizeof(*ret
) ))) goto done
;
2641 for (i
= 0; i
< query
->view
->result_count
; i
++)
2643 if ((hr
= get_propval( query
->view
, i
, pathW
, &val
, NULL
, NULL
)) != S_OK
) goto done
;
2644 if (!(ret
[i
].ref
= heap_strdupW( V_BSTR(&val
) ))) goto done
;
2645 VariantClear( &val
);
2647 if ((hr
= get_propval( query2
->view
, i
, pathW
, &val
, NULL
, NULL
)) != S_OK
) goto done
;
2648 if (!(ret
[i
].ref2
= heap_strdupW( V_BSTR(&val
) ))) goto done
;
2649 VariantClear( &val
);
2652 *count
= query
->view
->result_count
;
2655 if (!ret
) free_associations( ret
, query
->view
->result_count
);
2656 free_query( query
);
2657 free_query( query2
);
2661 static enum fill_status
fill_diskdrivetodiskpartition( struct table
*table
, const struct expr
*cond
)
2663 struct record_diskdrivetodiskpartition
*rec
;
2664 UINT i
, row
= 0, offset
= 0, count
= 0;
2665 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2666 struct association
*assoc
;
2668 if (!(assoc
= get_diskdrivetodiskpartition_pairs( &count
))) return FILL_STATUS_FAILED
;
2671 free_associations( assoc
, count
);
2672 return FILL_STATUS_UNFILTERED
;
2674 if (!resize_table( table
, count
, sizeof(*rec
) ))
2676 free_associations( assoc
, count
);
2677 return FILL_STATUS_FAILED
;
2680 for (i
= 0; i
< count
; i
++)
2682 rec
= (struct record_diskdrivetodiskpartition
*)(table
->data
+ offset
);
2683 rec
->antecedent
= assoc
[i
].ref
;
2684 rec
->dependent
= assoc
[i
].ref2
;
2685 if (!match_row( table
, row
, cond
, &status
))
2687 free_row_values( table
, row
);
2690 offset
+= sizeof(*rec
);
2696 TRACE("created %u rows\n", row
);
2697 table
->num_rows
= row
;
2701 static WCHAR
*get_filesystem( const WCHAR
*root
)
2703 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
2704 WCHAR buffer
[MAX_PATH
+ 1];
2706 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
2707 return heap_strdupW( buffer
);
2708 return heap_strdupW( ntfsW
);
2711 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
2713 static const WCHAR fmtW
[] =
2714 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
2715 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
2716 struct record_diskpartition
*rec
;
2717 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
2718 UINT64 size
= 1024 * 1024 * 1024;
2719 DWORD drives
= GetLogicalDrives();
2720 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2722 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2724 for (i
= 0; i
< 26; i
++)
2726 if (drives
& (1 << i
))
2729 type
= GetDriveTypeW( root
);
2730 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
2733 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2735 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
2736 rec
->bootable
= (i
== 2) ? -1 : 0;
2737 rec
->bootpartition
= (i
== 2) ? -1 : 0;
2738 swprintf( device_id
, ARRAY_SIZE( device_id
), fmtW
, index
);
2739 rec
->device_id
= heap_strdupW( device_id
);
2740 rec
->diskindex
= index
++;
2742 rec
->pnpdevice_id
= heap_strdupW( device_id
);
2743 get_freespace( root
, &size
);
2745 rec
->startingoffset
= 0;
2746 rec
->type
= get_filesystem( root
);
2747 if (!match_row( table
, row
, cond
, &status
))
2749 free_row_values( table
, row
);
2752 offset
+= sizeof(*rec
);
2756 TRACE("created %u rows\n", row
);
2757 table
->num_rows
= row
;
2761 static UINT32
get_bitsperpixel( UINT
*hres
, UINT
*vres
)
2763 HDC hdc
= GetDC( NULL
);
2766 if (!hdc
) return 32;
2767 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2768 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2769 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2770 ReleaseDC( NULL
, hdc
);
2774 static enum fill_status
fill_displaycontrollerconfig( struct table
*table
, const struct expr
*cond
)
2776 struct record_displaycontrollerconfig
*rec
;
2777 UINT row
= 0, hres
= 1024, vres
= 768;
2778 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2780 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2782 rec
= (struct record_displaycontrollerconfig
*)table
->data
;
2783 rec
->bitsperpixel
= get_bitsperpixel( &hres
, &vres
);
2784 rec
->caption
= videocontroller_deviceidW
;
2785 rec
->horizontalresolution
= hres
;
2786 rec
->name
= videocontroller_deviceidW
;
2787 rec
->verticalresolution
= vres
;
2788 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2791 TRACE("created %u rows\n", row
);
2792 table
->num_rows
= row
;
2796 static WCHAR
*get_ip4_string( DWORD addr
)
2798 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2799 DWORD len
= sizeof("ddd.ddd.ddd.ddd");
2802 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) ))) return NULL
;
2803 swprintf( ret
, len
, fmtW
, (addr
>> 24) & 0xff, (addr
>> 16) & 0xff, (addr
>> 8) & 0xff, addr
& 0xff );
2807 static enum fill_status
fill_ip4routetable( struct table
*table
, const struct expr
*cond
)
2809 struct record_ip4routetable
*rec
;
2810 UINT i
, row
= 0, offset
= 0, size
= 0;
2811 MIB_IPFORWARDTABLE
*forwards
;
2812 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2814 if (GetIpForwardTable( NULL
, &size
, TRUE
) != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2815 if (!(forwards
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2816 if (GetIpForwardTable( forwards
, &size
, TRUE
))
2818 heap_free( forwards
);
2819 return FILL_STATUS_FAILED
;
2821 if (!resize_table( table
, max(forwards
->dwNumEntries
, 1), sizeof(*rec
) ))
2823 heap_free( forwards
);
2824 return FILL_STATUS_FAILED
;
2827 for (i
= 0; i
< forwards
->dwNumEntries
; i
++)
2829 rec
= (struct record_ip4routetable
*)(table
->data
+ offset
);
2831 rec
->destination
= get_ip4_string( ntohl(forwards
->table
[i
].dwForwardDest
) );
2832 rec
->interfaceindex
= forwards
->table
[i
].dwForwardIfIndex
;
2833 rec
->nexthop
= get_ip4_string( ntohl(forwards
->table
[i
].dwForwardNextHop
) );
2835 if (!match_row( table
, row
, cond
, &status
))
2837 free_row_values( table
, row
);
2840 offset
+= sizeof(*rec
);
2843 TRACE("created %u rows\n", row
);
2844 table
->num_rows
= row
;
2846 heap_free( forwards
);
2850 static WCHAR
*get_volumename( const WCHAR
*root
)
2852 WCHAR buf
[MAX_PATH
+ 1] = {0};
2853 GetVolumeInformationW( root
, buf
, ARRAY_SIZE( buf
), NULL
, NULL
, NULL
, NULL
, 0 );
2854 return heap_strdupW( buf
);
2856 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
2858 static const WCHAR fmtW
[] = {'%','0','8','X',0};
2862 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
2863 swprintf( buffer
, ARRAY_SIZE( buffer
), fmtW
, serial
);
2864 return heap_strdupW( buffer
);
2867 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
2869 static const WCHAR fmtW
[] = {'%','c',':',0};
2870 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
2871 struct record_logicaldisk
*rec
;
2872 UINT i
, row
= 0, offset
= 0, type
;
2873 UINT64 size
= 1024 * 1024 * 1024;
2874 DWORD drives
= GetLogicalDrives();
2875 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2877 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2879 for (i
= 0; i
< 26; i
++)
2881 if (drives
& (1 << i
))
2884 type
= GetDriveTypeW( root
);
2885 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
2888 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2890 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
2891 swprintf( device_id
, ARRAY_SIZE( device_id
), fmtW
, 'A' + i
);
2892 rec
->device_id
= heap_strdupW( device_id
);
2893 rec
->drivetype
= type
;
2894 rec
->filesystem
= get_filesystem( root
);
2895 rec
->freespace
= get_freespace( root
, &size
);
2896 rec
->name
= heap_strdupW( device_id
);
2898 rec
->volumename
= get_volumename( root
);
2899 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
2900 if (!match_row( table
, row
, cond
, &status
))
2902 free_row_values( table
, row
);
2905 offset
+= sizeof(*rec
);
2909 TRACE("created %u rows\n", row
);
2910 table
->num_rows
= row
;
2914 static struct association
*get_logicaldisktopartition_pairs( UINT
*count
)
2916 static const WCHAR pathW
[] =
2917 {'_','_','P','A','T','H',0};
2918 static const WCHAR selectW
[] =
2919 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2920 'D','i','s','k','P','a','r','t','i','t','i','o','n',0};
2921 static const WCHAR select2W
[] =
2922 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
2923 'L','o','g','i','c','a','l','D','i','s','k',' ','W','H','E','R','E',' ',
2924 'D','r','i','v','e','T','y','p','e','=','2',' ','O','R',' ','D','r','i','v','e','T','y','p','e','=','3',0};
2925 struct association
*ret
= NULL
;
2926 struct query
*query
, *query2
= NULL
;
2931 if (!(query
= create_query())) return NULL
;
2932 if ((hr
= parse_query( selectW
, &query
->view
, &query
->mem
)) != S_OK
) goto done
;
2933 if ((hr
= execute_view( query
->view
)) != S_OK
) goto done
;
2935 if (!(query2
= create_query())) return FALSE
;
2936 if ((hr
= parse_query( select2W
, &query2
->view
, &query2
->mem
)) != S_OK
) goto done
;
2937 if ((hr
= execute_view( query2
->view
)) != S_OK
) goto done
;
2939 if (!(ret
= heap_alloc_zero( query
->view
->result_count
* sizeof(*ret
) ))) goto done
;
2941 /* assume fixed and removable disks are enumerated in the same order as partitions */
2942 for (i
= 0; i
< query
->view
->result_count
; i
++)
2944 if ((hr
= get_propval( query
->view
, i
, pathW
, &val
, NULL
, NULL
)) != S_OK
) goto done
;
2945 if (!(ret
[i
].ref
= heap_strdupW( V_BSTR(&val
) ))) goto done
;
2946 VariantClear( &val
);
2948 if ((hr
= get_propval( query2
->view
, i
, pathW
, &val
, NULL
, NULL
)) != S_OK
) goto done
;
2949 if (!(ret
[i
].ref2
= heap_strdupW( V_BSTR(&val
) ))) goto done
;
2950 VariantClear( &val
);
2953 *count
= query
->view
->result_count
;
2956 if (!ret
) free_associations( ret
, query
->view
->result_count
);
2957 free_query( query
);
2958 free_query( query2
);
2962 static enum fill_status
fill_logicaldisktopartition( struct table
*table
, const struct expr
*cond
)
2964 struct record_logicaldisktopartition
*rec
;
2965 UINT i
, row
= 0, offset
= 0, count
= 0;
2966 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2967 struct association
*assoc
;
2969 if (!(assoc
= get_logicaldisktopartition_pairs( &count
))) return FILL_STATUS_FAILED
;
2972 free_associations( assoc
, count
);
2973 return FILL_STATUS_UNFILTERED
;
2975 if (!resize_table( table
, count
, sizeof(*rec
) ))
2977 free_associations( assoc
, count
);
2978 return FILL_STATUS_FAILED
;
2981 for (i
= 0; i
< count
; i
++)
2983 rec
= (struct record_logicaldisktopartition
*)(table
->data
+ offset
);
2984 rec
->antecedent
= assoc
[i
].ref
;
2985 rec
->dependent
= assoc
[i
].ref2
;
2986 if (!match_row( table
, row
, cond
, &status
))
2988 free_row_values( table
, row
);
2991 offset
+= sizeof(*rec
);
2997 TRACE("created %u rows\n", row
);
2998 table
->num_rows
= row
;
3002 static UINT16
get_connection_status( IF_OPER_STATUS status
)
3006 case IfOperStatusDown
:
3007 return 0; /* Disconnected */
3008 case IfOperStatusUp
:
3009 return 2; /* Connected */
3011 ERR("unhandled status %u\n", status
);
3016 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
3018 static const WCHAR fmtW
[] =
3019 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
3020 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
3023 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
3024 swprintf( ret
, 18, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
3027 static const WCHAR
*get_adaptertype( DWORD type
, int *id
, int *physical
)
3029 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
3030 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
3031 static const WCHAR firewireW
[] = {'1','3','9','4',0};
3032 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
3036 case IF_TYPE_ETHERNET_CSMACD
:
3040 case IF_TYPE_IEEE80211
:
3044 case IF_TYPE_IEEE1394
:
3048 case IF_TYPE_TUNNEL
:
3059 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
3061 static const WCHAR fmtW
[] = {'%','u',0};
3062 WCHAR device_id
[11];
3063 struct record_networkadapter
*rec
;
3064 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
3065 UINT row
= 0, offset
= 0, count
= 0;
3066 DWORD size
= 0, ret
;
3067 int adaptertypeid
, physical
;
3068 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3070 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
3071 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
3073 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
3074 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
3076 heap_free( buffer
);
3077 return FILL_STATUS_FAILED
;
3079 for (aa
= buffer
; aa
; aa
= aa
->Next
)
3081 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
3083 if (!resize_table( table
, count
, sizeof(*rec
) ))
3085 heap_free( buffer
);
3086 return FILL_STATUS_FAILED
;
3088 for (aa
= buffer
; aa
; aa
= aa
->Next
)
3090 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
3092 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
3093 swprintf( device_id
, ARRAY_SIZE( device_id
), fmtW
, aa
->u
.s
.IfIndex
);
3094 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &adaptertypeid
, &physical
);
3095 rec
->adaptertypeid
= adaptertypeid
;
3096 rec
->description
= heap_strdupW( aa
->Description
);
3097 rec
->device_id
= heap_strdupW( device_id
);
3098 rec
->index
= aa
->u
.s
.IfIndex
;
3099 rec
->interface_index
= aa
->u
.s
.IfIndex
;
3100 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
3101 rec
->manufacturer
= compsys_manufacturerW
;
3102 rec
->name
= heap_strdupW( aa
->FriendlyName
);
3103 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
3104 rec
->physicaladapter
= physical
;
3105 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
3106 rec
->speed
= 1000000;
3107 if (!match_row( table
, row
, cond
, &status
))
3109 free_row_values( table
, row
);
3112 offset
+= sizeof(*rec
);
3115 TRACE("created %u rows\n", row
);
3116 table
->num_rows
= row
;
3118 heap_free( buffer
);
3122 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
3124 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
3125 WCHAR buf
[NI_MAXHOST
];
3127 if (!addr
) return NULL
;
3128 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, ARRAY_SIZE( buf
), NULL
,
3129 0, NI_NAMEREQD
)) return NULL
;
3130 return heap_strdupW( buf
);
3132 static struct array
*get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS
*list
)
3134 IP_ADAPTER_GATEWAY_ADDRESS
*gateway
;
3136 ULONG buflen
, i
= 0, count
= 0;
3137 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
3139 if (!list
) return NULL
;
3140 for (gateway
= list
; gateway
; gateway
= gateway
->Next
) count
++;
3142 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
3143 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
3148 for (gateway
= list
; gateway
; gateway
= gateway
->Next
)
3150 buflen
= ARRAY_SIZE( buf
);
3151 if (WSAAddressToStringW( gateway
->Address
.lpSockaddr
, gateway
->Address
.iSockaddrLength
,
3152 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
3154 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
3160 ret
->elem_size
= sizeof(*ptr
);
3165 static struct array
*get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS
*list
)
3167 IP_ADAPTER_DNS_SERVER_ADDRESS
*server
;
3169 ULONG buflen
, i
= 0, count
= 0;
3170 WCHAR
**ptr
, *p
, buf
[54]; /* max IPv6 address length */
3172 if (!list
) return NULL
;
3173 for (server
= list
; server
; server
= server
->Next
) count
++;
3175 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
3176 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
3181 for (server
= list
; server
; server
= server
->Next
)
3183 buflen
= ARRAY_SIZE( buf
);
3184 if (WSAAddressToStringW( server
->Address
.lpSockaddr
, server
->Address
.iSockaddrLength
,
3185 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
3187 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
3192 if ((p
= wcsrchr( ptr
[i
- 1], ':' ))) *p
= 0;
3194 ret
->elem_size
= sizeof(*ptr
);
3199 static struct array
*get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH
*list
)
3201 IP_ADAPTER_UNICAST_ADDRESS_LH
*address
;
3203 ULONG buflen
, i
= 0, count
= 0;
3204 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
3206 if (!list
) return NULL
;
3207 for (address
= list
; address
; address
= address
->Next
) count
++;
3209 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
3210 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
3215 for (address
= list
; address
; address
= address
->Next
)
3217 buflen
= ARRAY_SIZE( buf
);
3218 if (WSAAddressToStringW( address
->Address
.lpSockaddr
, address
->Address
.iSockaddrLength
,
3219 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
3221 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
3227 ret
->elem_size
= sizeof(*ptr
);
3232 static struct array
*get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH
*list
)
3234 IP_ADAPTER_UNICAST_ADDRESS_LH
*address
;
3236 ULONG i
= 0, count
= 0;
3239 if (!list
) return NULL
;
3240 for (address
= list
; address
; address
= address
->Next
) count
++;
3242 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
3243 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
3248 for (address
= list
; address
; address
= address
->Next
)
3250 if (address
->Address
.lpSockaddr
->sa_family
== AF_INET
)
3252 WCHAR buf
[INET_ADDRSTRLEN
];
3254 ULONG buflen
= ARRAY_SIZE( buf
);
3256 memset( &addr
, 0, sizeof(addr
) );
3257 addr
.sin_family
= AF_INET
;
3258 if (ConvertLengthToIpv4Mask( address
->OnLinkPrefixLength
, &addr
.sin_addr
.S_un
.S_addr
) != NO_ERROR
3259 || WSAAddressToStringW( (SOCKADDR
*)&addr
, sizeof(addr
), NULL
, buf
, &buflen
))
3262 ptr
[i
] = heap_strdupW( buf
);
3266 static const WCHAR fmtW
[] = {'%','u',0};
3269 swprintf( buf
, ARRAY_SIZE( buf
), fmtW
, address
->OnLinkPrefixLength
);
3270 ptr
[i
] = heap_strdupW( buf
);
3274 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
3280 ret
->elem_size
= sizeof(*ptr
);
3285 static WCHAR
*get_settingid( UINT32 index
)
3289 memset( &guid
, 0, sizeof(guid
) );
3291 UuidToStringW( &guid
, &str
);
3292 ret
= heap_strdupW( str
);
3293 RpcStringFreeW( &str
);
3297 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
3299 struct record_networkadapterconfig
*rec
;
3300 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
3301 UINT row
= 0, offset
= 0, count
= 0;
3302 DWORD size
= 0, ret
;
3303 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3305 ret
= GetAdaptersAddresses( AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, NULL
, &size
);
3306 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
3308 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
3309 if (GetAdaptersAddresses( AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, buffer
, &size
))
3311 heap_free( buffer
);
3312 return FILL_STATUS_FAILED
;
3314 for (aa
= buffer
; aa
; aa
= aa
->Next
)
3316 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
3318 if (!resize_table( table
, count
, sizeof(*rec
) ))
3320 heap_free( buffer
);
3321 return FILL_STATUS_FAILED
;
3323 for (aa
= buffer
; aa
; aa
= aa
->Next
)
3325 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
3327 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
3328 rec
->defaultipgateway
= get_defaultipgateway( aa
->FirstGatewayAddress
);
3329 rec
->description
= heap_strdupW( aa
->Description
);
3330 rec
->dhcpenabled
= -1;
3331 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
3332 rec
->dnsserversearchorder
= get_dnsserversearchorder( aa
->FirstDnsServerAddress
);
3333 rec
->index
= aa
->u
.s
.IfIndex
;
3334 rec
->ipaddress
= get_ipaddress( aa
->FirstUnicastAddress
);
3335 rec
->ipconnectionmetric
= 20;
3336 rec
->ipenabled
= -1;
3337 rec
->ipsubnet
= get_ipsubnet( aa
->FirstUnicastAddress
);
3338 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
3339 rec
->settingid
= get_settingid( rec
->index
);
3340 if (!match_row( table
, row
, cond
, &status
))
3342 free_row_values( table
, row
);
3345 offset
+= sizeof(*rec
);
3348 TRACE("created %u rows\n", row
);
3349 table
->num_rows
= row
;
3351 heap_free( buffer
);
3355 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
3357 static const WCHAR dimm0W
[] = {'D','I','M','M',' ','0',0};
3358 struct record_physicalmemory
*rec
;
3359 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3362 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3364 rec
= (struct record_physicalmemory
*)table
->data
;
3365 rec
->capacity
= get_total_physical_memory();
3366 rec
->configuredclockspeed
= 0;
3367 rec
->devicelocator
= dimm0W
;
3368 rec
->memorytype
= 9; /* RAM */
3369 rec
->partnumber
= NULL
;
3370 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3373 TRACE("created %u rows\n", row
);
3374 table
->num_rows
= row
;
3378 static enum fill_status
fill_pnpentity( struct table
*table
, const struct expr
*cond
)
3380 struct record_pnpentity
*rec
;
3381 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3382 HDEVINFO device_info_set
;
3383 SP_DEVINFO_DATA devinfo
= {0};
3386 device_info_set
= SetupDiGetClassDevsW( NULL
, NULL
, NULL
, DIGCF_ALLCLASSES
|DIGCF_PRESENT
);
3388 devinfo
.cbSize
= sizeof(devinfo
);
3391 while (SetupDiEnumDeviceInfo( device_info_set
, idx
++, &devinfo
))
3396 resize_table( table
, idx
, sizeof(*rec
) );
3397 table
->num_rows
= 0;
3398 rec
= (struct record_pnpentity
*)table
->data
;
3401 while (SetupDiEnumDeviceInfo( device_info_set
, idx
++, &devinfo
))
3403 WCHAR device_id
[MAX_PATH
];
3404 if (SetupDiGetDeviceInstanceIdW( device_info_set
, &devinfo
, device_id
,
3405 ARRAY_SIZE(device_id
), NULL
))
3407 rec
->device_id
= heap_strdupW( device_id
);
3410 if (!match_row( table
, table
->num_rows
- 1, cond
, &status
))
3412 free_row_values( table
, table
->num_rows
- 1 );
3420 SetupDiDestroyDeviceInfoList( device_info_set
);
3425 static enum fill_status
fill_printer( struct table
*table
, const struct expr
*cond
)
3427 static const WCHAR fmtW
[] = {'P','r','i','n','t','e','r','%','d',0};
3428 struct record_printer
*rec
;
3429 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3430 PRINTER_INFO_2W
*info
;
3431 DWORD i
, offset
= 0, count
= 0, size
= 0, num_rows
= 0;
3434 EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &size
, &count
);
3435 if (!count
) return FILL_STATUS_UNFILTERED
;
3437 if (!(info
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
3438 if (!EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, (BYTE
*)info
, size
, &size
, &count
))
3441 return FILL_STATUS_FAILED
;
3443 if (!resize_table( table
, count
, sizeof(*rec
) ))
3446 return FILL_STATUS_FAILED
;
3449 for (i
= 0; i
< count
; i
++)
3451 rec
= (struct record_printer
*)(table
->data
+ offset
);
3452 rec
->attributes
= info
[i
].Attributes
;
3453 swprintf( id
, ARRAY_SIZE( id
), fmtW
, i
);
3454 rec
->device_id
= heap_strdupW( id
);
3455 rec
->drivername
= heap_strdupW( info
[i
].pDriverName
);
3456 rec
->horizontalresolution
= info
[i
].pDevMode
->u1
.s1
.dmPrintQuality
;
3458 rec
->location
= heap_strdupW( info
[i
].pLocation
);
3459 rec
->name
= heap_strdupW( info
[i
].pPrinterName
);
3461 rec
->portname
= heap_strdupW( info
[i
].pPortName
);
3462 if (!match_row( table
, i
, cond
, &status
))
3464 free_row_values( table
, i
);
3467 offset
+= sizeof(*rec
);
3470 TRACE("created %u rows\n", num_rows
);
3471 table
->num_rows
= num_rows
;
3477 static WCHAR
*get_cmdline( DWORD process_id
)
3479 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
3480 return NULL
; /* FIXME handle different process case */
3483 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
3485 static const WCHAR fmtW
[] = {'%','u',0};
3487 struct record_process
*rec
;
3488 PROCESSENTRY32W entry
;
3490 enum fill_status status
= FILL_STATUS_FAILED
;
3491 UINT row
= 0, offset
= 0;
3493 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
3494 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
3496 entry
.dwSize
= sizeof(entry
);
3497 if (!Process32FirstW( snap
, &entry
)) goto done
;
3498 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
3502 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
3504 status
= FILL_STATUS_FAILED
;
3508 rec
= (struct record_process
*)(table
->data
+ offset
);
3509 rec
->caption
= heap_strdupW( entry
.szExeFile
);
3510 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
3511 rec
->description
= heap_strdupW( entry
.szExeFile
);
3512 swprintf( handle
, ARRAY_SIZE( handle
), fmtW
, entry
.th32ProcessID
);
3513 rec
->handle
= heap_strdupW( handle
);
3514 rec
->name
= heap_strdupW( entry
.szExeFile
);
3515 rec
->process_id
= entry
.th32ProcessID
;
3516 rec
->pprocess_id
= entry
.th32ParentProcessID
;
3517 rec
->thread_count
= entry
.cntThreads
;
3518 rec
->workingsetsize
= 0;
3519 rec
->get_owner
= process_get_owner
;
3520 if (!match_row( table
, row
, cond
, &status
))
3522 free_row_values( table
, row
);
3525 offset
+= sizeof(*rec
);
3527 } while (Process32NextW( snap
, &entry
));
3529 TRACE("created %u rows\n", row
);
3530 table
->num_rows
= row
;
3533 CloseHandle( snap
);
3537 extern void do_cpuid( unsigned int ax
, unsigned int *p
);
3538 #if defined(_MSC_VER)
3539 void do_cpuid( unsigned int ax
, unsigned int *p
)
3543 #elif defined(__i386__)
3544 __ASM_GLOBAL_FUNC( do_cpuid
,
3547 "movl 12(%esp),%eax\n\t"
3548 "movl 16(%esp),%esi\n\t"
3550 "movl %eax,(%esi)\n\t"
3551 "movl %ebx,4(%esi)\n\t"
3552 "movl %ecx,8(%esi)\n\t"
3553 "movl %edx,12(%esi)\n\t"
3557 #elif defined(__x86_64__)
3558 __ASM_GLOBAL_FUNC( do_cpuid
,
3561 "movq %rcx,%rax\n\t"
3562 "movq %rdx,%rsi\n\t"
3564 "movl %eax,(%rsi)\n\t"
3565 "movl %ebx,4(%rsi)\n\t"
3566 "movl %ecx,8(%rsi)\n\t"
3567 "movl %edx,12(%rsi)\n\t"
3572 void do_cpuid( unsigned int ax
, unsigned int *p
)
3578 static unsigned int get_processor_model( unsigned int reg0
, unsigned int *stepping
, unsigned int *family
)
3580 unsigned int model
, family_id
= (reg0
& (0x0f << 8)) >> 8;
3582 model
= (reg0
& (0x0f << 4)) >> 4;
3583 if (family_id
== 6 || family_id
== 15) model
|= (reg0
& (0x0f << 16)) >> 12;
3586 *family
= family_id
;
3587 if (family_id
== 15) *family
+= (reg0
& (0xff << 20)) >> 20;
3589 *stepping
= reg0
& 0x0f;
3592 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
3595 unsigned char *p
= (unsigned char *)regs
;
3597 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
3600 static void get_processor_manufacturer( WCHAR
*manufacturer
, UINT len
)
3602 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
3604 do_cpuid( 0, regs
);
3605 tmp
= regs
[2]; /* swap edx and ecx */
3609 regs_to_str( regs
+ 1, min( 12, len
), manufacturer
);
3611 static const WCHAR
*get_osarchitecture(void)
3614 GetNativeSystemInfo( &info
);
3615 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
3618 static void get_processor_caption( WCHAR
*caption
, UINT len
)
3620 static const WCHAR fmtW
[] =
3621 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
3622 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
3623 static const WCHAR x86W
[] = {'x','8','6',0};
3624 static const WCHAR intel64W
[] = {'I','n','t','e','l','6','4',0};
3625 static const WCHAR amd64W
[] = {'A','M','D','6','4',0};
3626 static const WCHAR authenticamdW
[] = {'A','u','t','h','e','n','t','i','c','A','M','D',0};
3628 WCHAR manufacturer
[13];
3629 unsigned int regs
[4] = {0, 0, 0, 0}, family
, model
, stepping
;
3631 get_processor_manufacturer( manufacturer
, ARRAY_SIZE( manufacturer
) );
3632 if (get_osarchitecture() == os_32bitW
) arch
= x86W
;
3633 else if (!wcscmp( manufacturer
, authenticamdW
)) arch
= amd64W
;
3634 else arch
= intel64W
;
3636 do_cpuid( 1, regs
);
3638 model
= get_processor_model( regs
[0], &stepping
, &family
);
3639 swprintf( caption
, len
, fmtW
, arch
, family
, model
, stepping
);
3641 static void get_processor_version( WCHAR
*version
, UINT len
)
3643 static const WCHAR fmtW
[] =
3644 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
3645 unsigned int regs
[4] = {0, 0, 0, 0}, model
, stepping
;
3647 do_cpuid( 1, regs
);
3649 model
= get_processor_model( regs
[0], &stepping
, NULL
);
3650 swprintf( version
, len
, fmtW
, model
, stepping
);
3652 static UINT16
get_processor_revision(void)
3654 unsigned int regs
[4] = {0, 0, 0, 0};
3655 do_cpuid( 1, regs
);
3658 static void get_processor_id( WCHAR
*processor_id
, UINT len
)
3660 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
3661 unsigned int regs
[4] = {0, 0, 0, 0};
3663 do_cpuid( 1, regs
);
3664 swprintf( processor_id
, len
, fmtW
, regs
[3], regs
[0] );
3666 static void get_processor_name( WCHAR
*name
)
3668 unsigned int regs
[4] = {0, 0, 0, 0};
3671 do_cpuid( 0x80000000, regs
);
3672 if (regs
[0] >= 0x80000004)
3674 do_cpuid( 0x80000002, regs
);
3675 regs_to_str( regs
, 16, name
);
3676 do_cpuid( 0x80000003, regs
);
3677 regs_to_str( regs
, 16, name
+ 16 );
3678 do_cpuid( 0x80000004, regs
);
3679 regs_to_str( regs
, 16, name
+ 32 );
3681 for (i
= lstrlenW(name
) - 1; i
>= 0 && name
[i
] == ' '; i
--) name
[i
] = 0;
3683 static UINT
get_processor_currentclockspeed( UINT index
)
3685 PROCESSOR_POWER_INFORMATION
*info
;
3686 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
3689 if ((info
= heap_alloc( size
)))
3691 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
3692 if (!status
) ret
= info
[index
].CurrentMhz
;
3697 static UINT
get_processor_maxclockspeed( UINT index
)
3699 PROCESSOR_POWER_INFORMATION
*info
;
3700 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
3703 if ((info
= heap_alloc( size
)))
3705 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
3706 if (!status
) ret
= info
[index
].MaxMhz
;
3712 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
3714 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
3715 WCHAR caption
[100], device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0}, version
[50];
3716 struct record_processor
*rec
;
3717 UINT i
, offset
= 0, num_rows
= 0, num_logical
, num_physical
, num_packages
;
3718 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3720 num_logical
= get_logical_processor_count( &num_physical
, &num_packages
);
3722 if (!resize_table( table
, num_packages
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3724 get_processor_caption( caption
, ARRAY_SIZE( caption
) );
3725 get_processor_id( processor_id
, ARRAY_SIZE( processor_id
) );
3726 get_processor_manufacturer( manufacturer
, ARRAY_SIZE( manufacturer
) );
3727 get_processor_name( name
);
3728 get_processor_version( version
, ARRAY_SIZE( version
) );
3730 for (i
= 0; i
< num_packages
; i
++)
3732 rec
= (struct record_processor
*)(table
->data
+ offset
);
3733 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
3734 rec
->architecture
= get_osarchitecture() == os_32bitW
? 0 : 9;
3735 rec
->caption
= heap_strdupW( caption
);
3736 rec
->cpu_status
= 1; /* CPU Enabled */
3737 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
3738 rec
->datawidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
3739 rec
->description
= heap_strdupW( caption
);
3740 swprintf( device_id
, ARRAY_SIZE( device_id
), fmtW
, i
);
3741 rec
->device_id
= heap_strdupW( device_id
);
3742 rec
->family
= 2; /* Unknown */
3744 rec
->manufacturer
= heap_strdupW( manufacturer
);
3745 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
3746 rec
->name
= heap_strdupW( name
);
3747 rec
->num_cores
= num_physical
/ num_packages
;
3748 rec
->num_logical_processors
= num_logical
/ num_packages
;
3749 rec
->processor_id
= heap_strdupW( processor_id
);
3750 rec
->processortype
= 3; /* central processor */
3751 rec
->revision
= get_processor_revision();
3752 rec
->unique_id
= NULL
;
3753 rec
->version
= heap_strdupW( version
);
3754 if (!match_row( table
, i
, cond
, &status
))
3756 free_row_values( table
, i
);
3759 offset
+= sizeof(*rec
);
3763 TRACE("created %u rows\n", num_rows
);
3764 table
->num_rows
= num_rows
;
3768 static WCHAR
*get_lastbootuptime(void)
3770 static const WCHAR fmtW
[] =
3771 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
3772 '.','%','0','6','u','+','0','0','0',0};
3773 SYSTEM_TIMEOFDAY_INFORMATION ti
;
3777 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
3779 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
3780 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
3781 swprintf( ret
, 26, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
3784 static WCHAR
*get_localdatetime(void)
3786 static const WCHAR fmtW
[] =
3787 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
3788 '.','%','0','6','u','%','+','0','3','d',0};
3789 TIME_ZONE_INFORMATION tzi
;
3795 Status
= GetTimeZoneInformation(&tzi
);
3797 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
3799 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
3800 Bias
+= tzi
.DaylightBias
;
3802 Bias
+= tzi
.StandardBias
;
3803 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
3806 swprintf( ret
, 26, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
3809 static WCHAR
*get_systemdirectory(void)
3814 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
3815 Wow64DisableWow64FsRedirection( &redir
);
3816 GetSystemDirectoryW( ret
, MAX_PATH
);
3817 Wow64RevertWow64FsRedirection( redir
);
3820 static WCHAR
*get_systemdrive(void)
3822 WCHAR
*ret
= heap_alloc( 3 * sizeof(WCHAR
) ); /* "c:" */
3823 if (ret
&& GetEnvironmentVariableW( prop_systemdriveW
, ret
, 3 )) return ret
;
3827 static WCHAR
*get_codeset(void)
3829 static const WCHAR fmtW
[] = {'%','u',0};
3830 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
3831 if (ret
) swprintf( ret
, 11, fmtW
, GetACP() );
3834 static WCHAR
*get_countrycode(void)
3836 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
3837 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
3840 static WCHAR
*get_locale(void)
3842 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
3843 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
3846 static WCHAR
*get_osbuildnumber( OSVERSIONINFOEXW
*ver
)
3848 static const WCHAR fmtW
[] = {'%','u',0};
3849 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
3850 if (ret
) swprintf( ret
, 11, fmtW
, ver
->dwBuildNumber
);
3853 static WCHAR
*get_oscaption( OSVERSIONINFOEXW
*ver
)
3855 static const WCHAR windowsW
[] =
3856 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
3857 static const WCHAR win2000W
[] =
3858 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3859 static const WCHAR win2003W
[] =
3860 {'S','e','r','v','e','r',' ','2','0','0','3',' ','S','t','a','n','d','a','r','d',' ','E','d','i','t','i','o','n',0};
3861 static const WCHAR winxpW
[] =
3862 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3863 static const WCHAR winxp64W
[] =
3864 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',' ','x','6','4',' ','E','d','i','t','i','o','n',0};
3865 static const WCHAR vistaW
[] =
3866 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
3867 static const WCHAR win2008W
[] =
3868 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
3869 static const WCHAR win7W
[] =
3870 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3871 static const WCHAR win2008r2W
[] =
3872 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
3873 static const WCHAR win8W
[] =
3874 {'8',' ','P','r','o',0};
3875 static const WCHAR win81W
[] =
3876 {'8','.','1',' ','P','r','o',0};
3877 static const WCHAR win10W
[] =
3878 {'1','0',' ','P','r','o',0};
3879 int len
= ARRAY_SIZE( windowsW
);
3882 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(win2003W
) ))) return NULL
;
3883 memcpy( ret
, windowsW
, sizeof(windowsW
) );
3884 if (ver
->dwMajorVersion
== 10 && ver
->dwMinorVersion
== 0) memcpy( ret
+ len
, win10W
, sizeof(win10W
) );
3885 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 3) memcpy( ret
+ len
, win8W
, sizeof(win8W
) );
3886 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 2) memcpy( ret
+ len
, win81W
, sizeof(win81W
) );
3887 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 1)
3889 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, win7W
, sizeof(win7W
) );
3890 else memcpy( ret
+ len
, win2008r2W
, sizeof(win2008r2W
) );
3892 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 0)
3894 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, vistaW
, sizeof(vistaW
) );
3895 else memcpy( ret
+ len
, win2008W
, sizeof(win2008W
) );
3897 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 2)
3899 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, winxp64W
, sizeof(winxp64W
) );
3900 else memcpy( ret
+ len
, win2003W
, sizeof(win2003W
) );
3902 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 1) memcpy( ret
+ len
, winxpW
, sizeof(winxpW
) );
3903 else memcpy( ret
+ len
, win2000W
, sizeof(win2000W
) );
3906 static WCHAR
*get_osname( const WCHAR
*caption
)
3908 static const WCHAR partitionW
[] =
3909 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
3910 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
3911 int len
= lstrlenW( caption
);
3914 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(partitionW
) ))) return NULL
;
3915 memcpy( ret
, caption
, len
* sizeof(WCHAR
) );
3916 memcpy( ret
+ len
, partitionW
, sizeof(partitionW
) );
3919 static WCHAR
*get_osversion( OSVERSIONINFOEXW
*ver
)
3921 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u',0};
3922 WCHAR
*ret
= heap_alloc( 33 * sizeof(WCHAR
) );
3923 if (ret
) swprintf( ret
, 33, fmtW
, ver
->dwMajorVersion
, ver
->dwMinorVersion
, ver
->dwBuildNumber
);
3926 static DWORD
get_operatingsystemsku(void)
3928 DWORD ret
= PRODUCT_UNDEFINED
;
3929 GetProductInfo( 6, 0, 0, 0, &ret
);
3932 static INT16
get_currenttimezone(void)
3934 TIME_ZONE_INFORMATION info
;
3935 DWORD status
= GetTimeZoneInformation( &info
);
3936 if (status
== TIME_ZONE_ID_INVALID
) return 0;
3937 if (status
== TIME_ZONE_ID_DAYLIGHT
) return -(info
.Bias
+ info
.DaylightBias
);
3938 return -(info
.Bias
+ info
.StandardBias
);
3941 static enum fill_status
fill_operatingsystem( struct table
*table
, const struct expr
*cond
)
3943 static const WCHAR wineprojectW
[] = {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
3944 struct record_operatingsystem
*rec
;
3945 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3946 OSVERSIONINFOEXW ver
;
3949 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3951 ver
.dwOSVersionInfoSize
= sizeof(ver
);
3952 GetVersionExW( (OSVERSIONINFOW
*)&ver
);
3954 rec
= (struct record_operatingsystem
*)table
->data
;
3955 rec
->buildnumber
= get_osbuildnumber( &ver
);
3956 rec
->caption
= get_oscaption( &ver
);
3957 rec
->codeset
= get_codeset();
3958 rec
->countrycode
= get_countrycode();
3959 rec
->csdversion
= ver
.szCSDVersion
[0] ? heap_strdupW( ver
.szCSDVersion
) : NULL
;
3960 rec
->csname
= get_computername();
3961 rec
->currenttimezone
= get_currenttimezone();
3962 rec
->freephysicalmemory
= get_available_physical_memory() / 1024;
3963 rec
->installdate
= os_installdateW
;
3964 rec
->lastbootuptime
= get_lastbootuptime();
3965 rec
->localdatetime
= get_localdatetime();
3966 rec
->locale
= get_locale();
3967 rec
->manufacturer
= wineprojectW
;
3968 rec
->name
= get_osname( rec
->caption
);
3969 rec
->operatingsystemsku
= get_operatingsystemsku();
3970 rec
->osarchitecture
= get_osarchitecture();
3971 rec
->oslanguage
= GetSystemDefaultLangID();
3972 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
3973 rec
->ostype
= 18; /* WINNT */
3975 rec
->serialnumber
= os_serialnumberW
;
3976 rec
->servicepackmajor
= ver
.wServicePackMajor
;
3977 rec
->servicepackminor
= ver
.wServicePackMinor
;
3978 rec
->suitemask
= 272; /* Single User + Terminal */
3979 rec
->systemdirectory
= get_systemdirectory();
3980 rec
->systemdrive
= get_systemdrive();
3981 rec
->totalvirtualmemorysize
= get_total_physical_memory() / 1024;
3982 rec
->totalvisiblememorysize
= rec
->totalvirtualmemorysize
;
3983 rec
->version
= get_osversion( &ver
);
3984 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3987 TRACE("created %u rows\n", row
);
3988 table
->num_rows
= row
;
3992 static const WCHAR
*get_service_type( DWORD type
)
3994 static const WCHAR filesystem_driverW
[] =
3995 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
3996 static const WCHAR kernel_driverW
[] =
3997 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
3998 static const WCHAR own_processW
[] =
3999 {'O','w','n',' ','P','r','o','c','e','s','s',0};
4000 static const WCHAR share_processW
[] =
4001 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
4003 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
4004 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
4005 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
4006 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
4007 else ERR("unhandled type 0x%08x\n", type
);
4010 static const WCHAR
*get_service_state( DWORD state
)
4012 static const WCHAR runningW
[] =
4013 {'R','u','n','n','i','n','g',0};
4014 static const WCHAR start_pendingW
[] =
4015 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
4016 static const WCHAR stop_pendingW
[] =
4017 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
4018 static const WCHAR stoppedW
[] =
4019 {'S','t','o','p','p','e','d',0};
4020 static const WCHAR unknownW
[] =
4021 {'U','n','k','n','o','w','n',0};
4025 case SERVICE_STOPPED
: return stoppedW
;
4026 case SERVICE_START_PENDING
: return start_pendingW
;
4027 case SERVICE_STOP_PENDING
: return stop_pendingW
;
4028 case SERVICE_RUNNING
: return runningW
;
4030 ERR("unknown state %u\n", state
);
4034 static const WCHAR
*get_service_startmode( DWORD mode
)
4036 static const WCHAR bootW
[] = {'B','o','o','t',0};
4037 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
4038 static const WCHAR autoW
[] = {'A','u','t','o',0};
4039 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
4040 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
4041 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
4045 case SERVICE_BOOT_START
: return bootW
;
4046 case SERVICE_SYSTEM_START
: return systemW
;
4047 case SERVICE_AUTO_START
: return autoW
;
4048 case SERVICE_DEMAND_START
: return manualW
;
4049 case SERVICE_DISABLED
: return disabledW
;
4051 ERR("unknown mode 0x%x\n", mode
);
4055 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
4057 QUERY_SERVICE_CONFIGW
*config
= NULL
;
4061 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
4062 QueryServiceConfigW( service
, NULL
, 0, &size
);
4063 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
4064 if (!(config
= heap_alloc( size
))) goto done
;
4065 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
4066 heap_free( config
);
4070 CloseServiceHandle( service
);
4074 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
4076 struct record_service
*rec
;
4078 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
4079 SERVICE_STATUS_PROCESS
*status
;
4080 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
4081 DWORD len
= ARRAY_SIZE( sysnameW
);
4082 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
4083 enum fill_status fill_status
= FILL_STATUS_FAILED
;
4086 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
4087 if (!(services
= heap_alloc( size
))) goto done
;
4089 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
4090 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
4091 &count
, NULL
, NULL
);
4094 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
4096 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
4098 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
4099 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
4100 &count
, NULL
, NULL
);
4101 if (!ret
) goto done
;
4103 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
4105 GetComputerNameW( sysnameW
, &len
);
4106 fill_status
= FILL_STATUS_UNFILTERED
;
4108 for (i
= 0; i
< count
; i
++)
4110 QUERY_SERVICE_CONFIGW
*config
;
4112 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
4114 status
= &services
[i
].ServiceStatusProcess
;
4115 rec
= (struct record_service
*)(table
->data
+ offset
);
4116 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
4117 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
4118 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
4119 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
4120 rec
->process_id
= status
->dwProcessId
;
4121 rec
->servicetype
= get_service_type( status
->dwServiceType
);
4122 rec
->startmode
= get_service_startmode( config
->dwStartType
);
4123 rec
->state
= get_service_state( status
->dwCurrentState
);
4124 rec
->systemname
= heap_strdupW( sysnameW
);
4125 rec
->pause_service
= service_pause_service
;
4126 rec
->resume_service
= service_resume_service
;
4127 rec
->start_service
= service_start_service
;
4128 rec
->stop_service
= service_stop_service
;
4129 heap_free( config
);
4130 if (!match_row( table
, row
, cond
, &fill_status
))
4132 free_row_values( table
, row
);
4135 offset
+= sizeof(*rec
);
4139 TRACE("created %u rows\n", row
);
4140 table
->num_rows
= row
;
4143 CloseServiceHandle( manager
);
4144 heap_free( services
);
4148 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
4150 if (!name
|| !name
->Name
.Buffer
) return NULL
;
4151 return heap_strdupW( name
->Name
.Buffer
);
4153 static struct array
*get_binaryrepresentation( PSID sid
, UINT len
)
4158 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
4159 if (!(ptr
= heap_alloc( len
)))
4164 memcpy( ptr
, sid
, len
);
4165 ret
->elem_size
= sizeof(*ptr
);
4170 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
4172 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
4173 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
4175 static const WCHAR
*find_sid_str( const struct expr
*cond
)
4177 const struct expr
*left
, *right
;
4178 const WCHAR
*ret
= NULL
;
4180 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
4182 left
= cond
->u
.expr
.left
;
4183 right
= cond
->u
.expr
.right
;
4184 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !wcsicmp( left
->u
.propval
->name
, prop_sidW
))
4186 ret
= right
->u
.sval
;
4188 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !wcsicmp( right
->u
.propval
->name
, prop_sidW
))
4195 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
4198 LSA_REFERENCED_DOMAIN_LIST
*domain
;
4199 LSA_TRANSLATED_NAME
*name
;
4201 LSA_OBJECT_ATTRIBUTES attrs
;
4203 struct record_sid
*rec
;
4206 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
4207 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
4209 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
4210 len
= GetLengthSid( sid
);
4212 memset( &attrs
, 0, sizeof(attrs
) );
4213 attrs
.Length
= sizeof(attrs
);
4214 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
4217 return FILL_STATUS_FAILED
;
4219 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
4223 return FILL_STATUS_FAILED
;
4226 rec
= (struct record_sid
*)table
->data
;
4227 rec
->accountname
= get_accountname( name
);
4228 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
4229 rec
->referenceddomainname
= get_referenceddomainname( domain
);
4230 rec
->sid
= heap_strdupW( str
);
4231 rec
->sidlength
= len
;
4233 TRACE("created 1 row\n");
4234 table
->num_rows
= 1;
4236 LsaFreeMemory( domain
);
4237 LsaFreeMemory( name
);
4240 return FILL_STATUS_FILTERED
;
4243 static WCHAR
*get_systemenclosure_string( BYTE id
, const char *buf
, UINT len
)
4245 const struct smbios_header
*hdr
;
4246 const struct smbios_chassis
*chassis
;
4249 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_CHASSIS
, buf
, len
))) return NULL
;
4251 chassis
= (const struct smbios_chassis
*)hdr
;
4252 offset
= (const char *)chassis
- buf
+ chassis
->hdr
.length
;
4253 return get_smbios_string( id
, buf
, offset
, len
);
4256 static WCHAR
*get_systemenclosure_manufacturer( const char *buf
, UINT len
)
4258 WCHAR
*ret
= get_systemenclosure_string( 1, buf
, len
);
4259 if (!ret
) return heap_strdupW( systemenclosure_manufacturerW
);
4263 static int get_systemenclosure_lockpresent( const char *buf
, UINT len
)
4265 const struct smbios_header
*hdr
;
4266 const struct smbios_chassis
*chassis
;
4268 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_CHASSIS
, buf
, len
)) || hdr
->length
< sizeof(*chassis
)) return 0;
4270 chassis
= (const struct smbios_chassis
*)hdr
;
4271 return (chassis
->type
& 0x80) ? -1 : 0;
4274 static struct array
*dup_array( const struct array
*src
)
4277 if (!(dst
= heap_alloc( sizeof(*dst
) ))) return NULL
;
4278 if (!(dst
->ptr
= heap_alloc( src
->count
* src
->elem_size
)))
4283 memcpy( dst
->ptr
, src
->ptr
, src
->count
* src
->elem_size
);
4284 dst
->elem_size
= src
->elem_size
;
4285 dst
->count
= src
->count
;
4289 static struct array
*get_systemenclosure_chassistypes( const char *buf
, UINT len
)
4291 const struct smbios_header
*hdr
;
4292 const struct smbios_chassis
*chassis
;
4293 struct array
*ret
= NULL
;
4296 if (!(hdr
= find_smbios_entry( SMBIOS_TYPE_CHASSIS
, buf
, len
)) || hdr
->length
< sizeof(*chassis
)) goto done
;
4297 chassis
= (const struct smbios_chassis
*)hdr
;
4299 if (!(ret
= heap_alloc( sizeof(*ret
) ))) goto done
;
4300 if (!(types
= heap_alloc( sizeof(*types
) )))
4305 types
[0] = chassis
->type
& ~0x80;
4307 ret
->elem_size
= sizeof(*types
);
4312 if (!ret
) ret
= dup_array( &systemenclosure_chassistypes_array
);
4316 static enum fill_status
fill_systemenclosure( struct table
*table
, const struct expr
*cond
)
4318 struct record_systemenclosure
*rec
;
4319 enum fill_status status
= FILL_STATUS_UNFILTERED
;
4323 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
4325 len
= GetSystemFirmwareTable( RSMB
, 0, NULL
, 0 );
4326 if (!(buf
= heap_alloc( len
))) return FILL_STATUS_FAILED
;
4327 GetSystemFirmwareTable( RSMB
, 0, buf
, len
);
4329 rec
= (struct record_systemenclosure
*)table
->data
;
4330 rec
->caption
= systemenclosure_systemenclosureW
;
4331 rec
->chassistypes
= get_systemenclosure_chassistypes( buf
, len
);
4332 rec
->description
= systemenclosure_systemenclosureW
;
4333 rec
->lockpresent
= get_systemenclosure_lockpresent( buf
, len
);
4334 rec
->manufacturer
= get_systemenclosure_manufacturer( buf
, len
);
4335 rec
->name
= systemenclosure_systemenclosureW
;
4336 rec
->tag
= systemenclosure_tagW
;
4337 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
4342 TRACE("created %u rows\n", row
);
4343 table
->num_rows
= row
;
4347 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
4349 static const WCHAR fmtW
[] =
4350 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
4351 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
4352 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
4353 UINT len
= sizeof(fmtW
) + 2;
4356 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) ))) return NULL
;
4357 swprintf( ret
, len
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
4361 #define HW_VENDOR_AMD 0x1002
4362 #define HW_VENDOR_NVIDIA 0x10de
4363 #define HW_VENDOR_VMWARE 0x15ad
4364 #define HW_VENDOR_INTEL 0x8086
4366 static const WCHAR
*get_installeddriver( UINT vendorid
)
4368 static const WCHAR driver_amdW
[] = {'a','t','i','c','f','x','3','2','.','d','l','l',0};
4369 static const WCHAR driver_intelW
[] = {'i','g','d','u','m','d','i','m','3','2','.','d','l','l',0};
4370 static const WCHAR driver_nvidiaW
[] = {'n','v','d','3','d','u','m','.','d','l','l',0};
4371 static const WCHAR driver_wineW
[] = {'w','i','n','e','.','d','l','l',0};
4373 /* FIXME: wined3d has a better table, but we cannot access this information through dxgi */
4375 if (vendorid
== HW_VENDOR_AMD
)
4377 else if (vendorid
== HW_VENDOR_NVIDIA
)
4378 return driver_nvidiaW
;
4379 else if (vendorid
== HW_VENDOR_INTEL
)
4380 return driver_intelW
;
4381 return driver_wineW
;
4384 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
4386 static const WCHAR fmtW
[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
4387 struct record_videocontroller
*rec
;
4389 IDXGIFactory
*factory
= NULL
;
4390 IDXGIAdapter
*adapter
= NULL
;
4391 DXGI_ADAPTER_DESC desc
;
4392 UINT row
= 0, hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
4393 const WCHAR
*name
= videocontroller_deviceidW
;
4394 enum fill_status status
= FILL_STATUS_UNFILTERED
;
4397 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
4399 memset (&desc
, 0, sizeof(desc
));
4400 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
4401 if (FAILED(hr
)) goto done
;
4403 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
4404 if (FAILED(hr
)) goto done
;
4406 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
4409 vidmem
= desc
.DedicatedVideoMemory
;
4410 name
= desc
.Description
;
4414 rec
= (struct record_videocontroller
*)table
->data
;
4415 rec
->adapter_dactype
= videocontroller_dactypeW
;
4416 rec
->adapter_ram
= vidmem
;
4417 rec
->availability
= 3; /* Running or Full Power */
4418 rec
->config_errorcode
= 0; /* no error */
4419 rec
->caption
= heap_strdupW( name
);
4420 rec
->current_bitsperpixel
= get_bitsperpixel( &hres
, &vres
);
4421 rec
->current_horizontalres
= hres
;
4422 rec
->current_refreshrate
= 0; /* default refresh rate */
4423 rec
->current_scanmode
= 2; /* Unknown */
4424 rec
->current_verticalres
= vres
;
4425 rec
->description
= heap_strdupW( name
);
4426 rec
->device_id
= videocontroller_deviceidW
;
4427 rec
->driverdate
= videocontroller_driverdateW
;
4428 rec
->driverversion
= videocontroller_driverversionW
;
4429 rec
->installeddriver
= get_installeddriver( desc
.VendorId
);
4430 rec
->name
= heap_strdupW( name
);
4431 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
4432 rec
->status
= videocontroller_statusW
;
4433 rec
->videoarchitecture
= 2; /* Unknown */
4434 rec
->videomemorytype
= 2; /* Unknown */
4435 swprintf( mode
, ARRAY_SIZE( mode
), fmtW
, hres
, vres
, (UINT64
)1 << rec
->current_bitsperpixel
);
4436 rec
->videomodedescription
= heap_strdupW( mode
);
4437 rec
->videoprocessor
= heap_strdupW( name
);
4438 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
4441 TRACE("created %u rows\n", row
);
4442 table
->num_rows
= row
;
4444 if (adapter
) IDXGIAdapter_Release( adapter
);
4445 if (factory
) IDXGIFactory_Release( factory
);
4449 #define C(c) sizeof(c)/sizeof(c[0]), c
4450 #define D(d) sizeof(d)/sizeof(d[0]), 0, (BYTE *)d
4451 static struct table builtin_classes
[] =
4453 { class_associatorsW
, C(col_associator
), D(data_associator
) },
4454 { class_baseboardW
, C(col_baseboard
), 0, 0, NULL
, fill_baseboard
},
4455 { class_biosW
, C(col_bios
), 0, 0, NULL
, fill_bios
},
4456 { class_cdromdriveW
, C(col_cdromdrive
), 0, 0, NULL
, fill_cdromdrive
},
4457 { class_compsysW
, C(col_compsys
), 0, 0, NULL
, fill_compsys
},
4458 { class_compsysproductW
, C(col_compsysproduct
), 0, 0, NULL
, fill_compsysproduct
},
4459 { class_datafileW
, C(col_datafile
), 0, 0, NULL
, fill_datafile
},
4460 { class_desktopmonitorW
, C(col_desktopmonitor
), 0, 0, NULL
, fill_desktopmonitor
},
4461 { class_directoryW
, C(col_directory
), 0, 0, NULL
, fill_directory
},
4462 { class_diskdriveW
, C(col_diskdrive
), 0, 0, NULL
, fill_diskdrive
},
4463 { class_diskdrivetodiskpartitionW
, C(col_diskdrivetodiskpartition
), 0, 0, NULL
, fill_diskdrivetodiskpartition
},
4464 { class_diskpartitionW
, C(col_diskpartition
), 0, 0, NULL
, fill_diskpartition
},
4465 { class_displaycontrollerconfigW
, C(col_displaycontrollerconfig
), 0, 0, NULL
, fill_displaycontrollerconfig
},
4466 { class_ip4routetableW
, C(col_ip4routetable
), 0, 0, NULL
, fill_ip4routetable
},
4467 { class_logicaldiskW
, C(col_logicaldisk
), 0, 0, NULL
, fill_logicaldisk
},
4468 { class_logicaldisk2W
, C(col_logicaldisk
), 0, 0, NULL
, fill_logicaldisk
},
4469 { class_logicaldisktopartitionW
, C(col_logicaldisktopartition
), 0, 0, NULL
, fill_logicaldisktopartition
},
4470 { class_networkadapterW
, C(col_networkadapter
), 0, 0, NULL
, fill_networkadapter
},
4471 { class_networkadapterconfigW
, C(col_networkadapterconfig
), 0, 0, NULL
, fill_networkadapterconfig
},
4472 { class_operatingsystemW
, C(col_operatingsystem
), 0, 0, NULL
, fill_operatingsystem
},
4473 { class_paramsW
, C(col_param
), D(data_param
) },
4474 { class_physicalmediaW
, C(col_physicalmedia
), D(data_physicalmedia
) },
4475 { class_physicalmemoryW
, C(col_physicalmemory
), 0, 0, NULL
, fill_physicalmemory
},
4476 { class_pnpentityW
, C(col_pnpentity
), 0, 0, NULL
, fill_pnpentity
},
4477 { class_printerW
, C(col_printer
), 0, 0, NULL
, fill_printer
},
4478 { class_processW
, C(col_process
), 0, 0, NULL
, fill_process
},
4479 { class_processorW
, C(col_processor
), 0, 0, NULL
, fill_processor
},
4480 { class_processor2W
, C(col_processor
), 0, 0, NULL
, fill_processor
},
4481 { class_qualifiersW
, C(col_qualifier
), D(data_qualifier
) },
4482 { class_quickfixengineeringW
, C(col_quickfixengineering
), D(data_quickfixengineering
) },
4483 { class_serviceW
, C(col_service
), 0, 0, NULL
, fill_service
},
4484 { class_sidW
, C(col_sid
), 0, 0, NULL
, fill_sid
},
4485 { class_sounddeviceW
, C(col_sounddevice
), D(data_sounddevice
) },
4486 { class_stdregprovW
, C(col_stdregprov
), D(data_stdregprov
) },
4487 { class_systemsecurityW
, C(col_systemsecurity
), D(data_systemsecurity
) },
4488 { class_systemenclosureW
, C(col_systemenclosure
), 0, 0, NULL
, fill_systemenclosure
},
4489 { class_videocontrollerW
, C(col_videocontroller
), 0, 0, NULL
, fill_videocontroller
},
4490 { class_winsatW
, C(col_winsat
), D(data_winsat
) },
4495 void init_table_list( void )
4497 static struct list tables
= LIST_INIT( tables
);
4500 for (i
= 0; i
< ARRAY_SIZE(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
4501 table_list
= &tables
;