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
29 #ifdef HAVE_ARPA_INET_H
30 # include <arpa/inet.h>
34 #define WIN32_NO_STATUS
38 # include "winsock2.h"
39 # include "ws2tcpip.h"
40 # define WS_AF_INET AF_INET
41 # define WS_AF_UNSPEC AF_UNSPEC
42 # define WS_NI_MAXHOST NI_MAXHOST
43 # define WS_NI_NAMEREQD NI_NAMEREQD
45 # define USE_WS_PREFIX
46 # include "winsock2.h"
47 # include "ws2tcpip.h"
65 #include "wine/debug.h"
66 #include "wbemprox_private.h"
68 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
70 static const WCHAR class_baseboardW
[] =
71 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
72 static const WCHAR class_biosW
[] =
73 {'W','i','n','3','2','_','B','I','O','S',0};
74 static const WCHAR class_cdromdriveW
[] =
75 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
76 static const WCHAR class_compsysW
[] =
77 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
78 static const WCHAR class_compsysproductW
[] =
79 {'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};
80 static const WCHAR class_datafileW
[] =
81 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
82 static const WCHAR class_desktopmonitorW
[] =
83 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
84 static const WCHAR class_directoryW
[] =
85 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
86 static const WCHAR class_diskdriveW
[] =
87 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
88 static const WCHAR class_diskpartitionW
[] =
89 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
90 static const WCHAR class_ip4routetableW
[] =
91 {'W','i','n','3','2','_','I','P','4','R','o','u','t','e','T','a','b','l','e',0};
92 static const WCHAR class_logicaldiskW
[] =
93 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
94 static const WCHAR class_logicaldisk2W
[] =
95 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
96 static const WCHAR class_networkadapterW
[] =
97 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
98 static const WCHAR class_networkadapterconfigW
[] =
99 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
100 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
101 static const WCHAR class_osW
[] =
102 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
103 static const WCHAR class_paramsW
[] =
104 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
105 static const WCHAR class_physicalmediaW
[] =
106 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
107 static const WCHAR class_physicalmemoryW
[] =
108 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
109 static const WCHAR class_pnpentityW
[] =
110 {'W','i','n','3','2','_','P','n','P','E','n','t','i','t','y',0};
111 static const WCHAR class_printerW
[] =
112 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
113 static const WCHAR class_process_getowner_outW
[] =
114 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
115 'N','E','R','_','O','U','T',0};
116 static const WCHAR class_processorW
[] =
117 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
118 static const WCHAR class_processor2W
[] =
119 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
120 static const WCHAR class_qualifiersW
[] =
121 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
122 static const WCHAR class_sidW
[] =
123 {'W','i','n','3','2','_','S','I','D',0};
124 static const WCHAR class_sounddeviceW
[] =
125 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
126 static const WCHAR class_systemenclosureW
[] =
127 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
128 static const WCHAR class_videocontrollerW
[] =
129 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
131 static const WCHAR prop_accountnameW
[] =
132 {'A','c','c','o','u','n','t','N','a','m','e',0};
133 static const WCHAR prop_acceptpauseW
[] =
134 {'A','c','c','e','p','t','P','a','u','s','e',0};
135 static const WCHAR prop_acceptstopW
[] =
136 {'A','c','c','e','p','t','S','t','o','p',0};
137 static const WCHAR prop_accessmaskW
[] =
138 {'A','c','c','e','s','s','M','a','s','k',0};
139 static const WCHAR prop_adapterdactypeW
[] =
140 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
141 static const WCHAR prop_adapterramW
[] =
142 {'A','d','a','p','t','e','r','R','A','M',0};
143 static const WCHAR prop_adaptertypeW
[] =
144 {'A','d','a','p','t','e','r','T','y','p','e',0};
145 static const WCHAR prop_addresswidthW
[] =
146 {'A','d','d','r','e','s','s','W','i','d','t','h',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_attributesW
[] =
150 {'A','t','t','r','i','b','u','t','e','s',0};
151 static const WCHAR prop_availabilityW
[] =
152 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
153 static const WCHAR prop_binaryrepresentationW
[] =
154 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
155 static const WCHAR prop_bootableW
[] =
156 {'B','o','o','t','a','b','l','e',0};
157 static const WCHAR prop_bootpartitionW
[] =
158 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
159 static const WCHAR prop_buildnumberW
[] =
160 {'B','u','i','l','d','N','u','m','b','e','r',0};
161 static const WCHAR prop_capacityW
[] =
162 {'C','a','p','a','c','i','t','y',0};
163 static const WCHAR prop_captionW
[] =
164 {'C','a','p','t','i','o','n',0};
165 static const WCHAR prop_chassistypesW
[] =
166 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
167 static const WCHAR prop_classW
[] =
168 {'C','l','a','s','s',0};
169 static const WCHAR prop_codesetW
[] =
170 {'C','o','d','e','S','e','t',0};
171 static const WCHAR prop_commandlineW
[] =
172 {'C','o','m','m','a','n','d','L','i','n','e',0};
173 static const WCHAR prop_configmanagererrorcodeW
[] =
174 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
175 static const WCHAR prop_countrycodeW
[] =
176 {'C','o','u','n','t','r','y','C','o','d','e',0};
177 static const WCHAR prop_cpustatusW
[] =
178 {'C','p','u','S','t','a','t','u','s',0};
179 static const WCHAR prop_csdversionW
[] =
180 {'C','S','D','V','e','r','s','i','o','n',0};
181 static const WCHAR prop_currentbitsperpixelW
[] =
182 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
183 static const WCHAR prop_currentclockspeedW
[] =
184 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
185 static const WCHAR prop_currenthorizontalresW
[] =
186 {'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};
187 static const WCHAR prop_currentrefreshrateW
[] =
188 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
189 static const WCHAR prop_currentscanmodeW
[] =
190 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
191 static const WCHAR prop_currentverticalresW
[] =
192 {'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};
193 static const WCHAR prop_datawidthW
[] =
194 {'D','a','t','a','W','i','d','t','h',0};
195 static const WCHAR prop_defaultipgatewayW
[] =
196 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
197 static const WCHAR prop_defaultvalueW
[] =
198 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
199 static const WCHAR prop_descriptionW
[] =
200 {'D','e','s','c','r','i','p','t','i','o','n',0};
201 static const WCHAR prop_destinationW
[] =
202 {'D','e','s','t','i','n','a','t','i','o','n',0};
203 static const WCHAR prop_deviceidW
[] =
204 {'D','e','v','i','c','e','I','d',0};
205 static const WCHAR prop_dhcpenabledW
[] =
206 {'D','H','C','P','E','n','a','b','l','e','d',0};
207 static const WCHAR prop_directionW
[] =
208 {'D','i','r','e','c','t','i','o','n',0};
209 static const WCHAR prop_displaynameW
[] =
210 {'D','i','s','p','l','a','y','N','a','m','e',0};
211 static const WCHAR prop_diskindexW
[] =
212 {'D','i','s','k','I','n','d','e','x',0};
213 static const WCHAR prop_dnshostnameW
[] =
214 {'D','N','S','H','o','s','t','N','a','m','e',0};
215 static const WCHAR prop_dnsserversearchorderW
[] =
216 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
217 static const WCHAR prop_domainW
[] =
218 {'D','o','m','a','i','n',0};
219 static const WCHAR prop_domainroleW
[] =
220 {'D','o','m','a','i','n','R','o','l','e',0};
221 static const WCHAR prop_driveW
[] =
222 {'D','r','i','v','e',0};
223 static const WCHAR prop_driverdateW
[] =
224 {'D','r','i','v','e','r','D','a','t','e',0};
225 static const WCHAR prop_drivernameW
[] =
226 {'D','r','i','v','e','r','N','a','m','e',0};
227 static const WCHAR prop_driverversionW
[] =
228 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
229 static const WCHAR prop_drivetypeW
[] =
230 {'D','r','i','v','e','T','y','p','e',0};
231 static const WCHAR prop_familyW
[] =
232 {'F','a','m','i','l','y',0};
233 static const WCHAR prop_filesystemW
[] =
234 {'F','i','l','e','S','y','s','t','e','m',0};
235 static const WCHAR prop_flavorW
[] =
236 {'F','l','a','v','o','r',0};
237 static const WCHAR prop_freespaceW
[] =
238 {'F','r','e','e','S','p','a','c','e',0};
239 static const WCHAR prop_freephysicalmemoryW
[] =
240 {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
241 static const WCHAR prop_handleW
[] =
242 {'H','a','n','d','l','e',0};
243 static const WCHAR prop_horizontalresolutionW
[] =
244 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
245 static const WCHAR prop_idW
[] =
247 static const WCHAR prop_identificationcodeW
[] =
248 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
249 static const WCHAR prop_identifyingnumberW
[] =
250 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
251 static const WCHAR prop_indexW
[] =
252 {'I','n','d','e','x',0};
253 static const WCHAR prop_installdateW
[] =
254 {'I','n','s','t','a','l','l','D','a','t','e',0};
255 static const WCHAR prop_installeddisplaydriversW
[]=
256 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
257 static const WCHAR prop_interfaceindexW
[] =
258 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
259 static const WCHAR prop_interfacetypeW
[] =
260 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
261 static const WCHAR prop_intvalueW
[] =
262 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
263 static const WCHAR prop_ipaddressW
[] =
264 {'I','P','A','d','d','r','e','s','s',0};
265 static const WCHAR prop_ipconnectionmetricW
[] =
266 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
267 static const WCHAR prop_ipenabledW
[] =
268 {'I','P','E','n','a','b','l','e','d',0};
269 static const WCHAR prop_ipsubnet
[] =
270 {'I','P','S','u','b','n','e','t',0};
271 static const WCHAR prop_lastbootuptimeW
[] =
272 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
273 static const WCHAR prop_levelW
[] =
274 {'L','e','v','e','l',0};
275 static const WCHAR prop_localW
[] =
276 {'L','o','c','a','l',0};
277 static const WCHAR prop_localdatetimeW
[] =
278 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
279 static const WCHAR prop_localeW
[] =
280 {'L','o','c','a','l','e',0};
281 static const WCHAR prop_locationW
[] =
282 {'L','o','c','a','t','i','o','n',0};
283 static const WCHAR prop_lockpresentW
[] =
284 {'L','o','c','k','P','r','e','s','e','n','t',0};
285 static const WCHAR prop_macaddressW
[] =
286 {'M','A','C','A','d','d','r','e','s','s',0};
287 static const WCHAR prop_manufacturerW
[] =
288 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
289 static const WCHAR prop_maxclockspeedW
[] =
290 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
291 static const WCHAR prop_mediatypeW
[] =
292 {'M','e','d','i','a','T','y','p','e',0};
293 static const WCHAR prop_memberW
[] =
294 {'M','e','m','b','e','r',0};
295 static const WCHAR prop_memorytypeW
[] =
296 {'M','e','m','o','r','y','T','y','p','e',0};
297 static const WCHAR prop_methodW
[] =
298 {'M','e','t','h','o','d',0};
299 static const WCHAR prop_modelW
[] =
300 {'M','o','d','e','l',0};
301 static const WCHAR prop_netconnectionstatusW
[] =
302 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
303 static const WCHAR prop_networkW
[] =
304 {'N','e','t','w','o','r','k',0};
305 static const WCHAR prop_nexthopW
[] =
306 {'N','e','x','t','H','o','p',0};
307 static const WCHAR prop_numcoresW
[] =
308 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
309 static const WCHAR prop_numlogicalprocessorsW
[] =
310 {'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};
311 static const WCHAR prop_numprocessorsW
[] =
312 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
313 static const WCHAR prop_osarchitectureW
[] =
314 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
315 static const WCHAR prop_oslanguageW
[] =
316 {'O','S','L','a','n','g','u','a','g','e',0};
317 static const WCHAR prop_osproductsuiteW
[] =
318 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
319 static const WCHAR prop_ostypeW
[] =
320 {'O','S','T','y','p','e',0};
321 static const WCHAR prop_parameterW
[] =
322 {'P','a','r','a','m','e','t','e','r',0};
323 static const WCHAR prop_physicaladapterW
[] =
324 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
325 static const WCHAR prop_pixelsperxlogicalinchW
[] =
326 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
327 static const WCHAR prop_pnpdeviceidW
[] =
328 {'P','N','P','D','e','v','i','c','e','I','D',0};
329 static const WCHAR prop_portnameW
[] =
330 {'P','o','r','t','N','a','m','e',0};
331 static const WCHAR prop_pprocessidW
[] =
332 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
333 static const WCHAR prop_primaryW
[] =
334 {'P','r','i','m','a','r','y',0};
335 static const WCHAR prop_processidW
[] =
336 {'P','r','o','c','e','s','s','I','D',0};
337 static const WCHAR prop_processoridW
[] =
338 {'P','r','o','c','e','s','s','o','r','I','d',0};
339 static const WCHAR prop_processortypeW
[] =
340 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
341 static const WCHAR prop_productW
[] =
342 {'P','r','o','d','u','c','t',0};
343 static const WCHAR prop_productnameW
[] =
344 {'P','r','o','d','u','c','t','N','a','m','e',0};
345 static const WCHAR prop_referenceddomainnameW
[] =
346 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
347 static const WCHAR prop_releasedateW
[] =
348 {'R','e','l','e','a','s','e','D','a','t','e',0};
349 static const WCHAR prop_revisionW
[] =
350 {'R','e','v','i','s','i','o','n',0};
351 static const WCHAR prop_serialnumberW
[] =
352 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
353 static const WCHAR prop_servicepackmajorW
[] =
354 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
355 static const WCHAR prop_servicepackminorW
[] =
356 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
357 static const WCHAR prop_servicetypeW
[] =
358 {'S','e','r','v','i','c','e','T','y','p','e',0};
359 static const WCHAR prop_settingidW
[] =
360 {'S','e','t','t','i','n','g','I','D',0};
361 static const WCHAR prop_skunumberW
[] =
362 {'S','K','U','N','u','m','b','e','r',0};
363 static const WCHAR prop_smbiosbiosversionW
[] =
364 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
365 static const WCHAR prop_smbiosmajorversionW
[] =
366 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
367 static const WCHAR prop_smbiosminorversionW
[] =
368 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
369 static const WCHAR prop_startmodeW
[] =
370 {'S','t','a','r','t','M','o','d','e',0};
371 static const WCHAR prop_sidW
[] =
373 static const WCHAR prop_sidlengthW
[] =
374 {'S','i','d','L','e','n','g','t','h',0};
375 static const WCHAR prop_sizeW
[] =
377 static const WCHAR prop_speedW
[] =
378 {'S','p','e','e','d',0};
379 static const WCHAR prop_startingoffsetW
[] =
380 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
381 static const WCHAR prop_stateW
[] =
382 {'S','t','a','t','e',0};
383 static const WCHAR prop_statusW
[] =
384 {'S','t','a','t','u','s',0};
385 static const WCHAR prop_statusinfoW
[] =
386 {'S','t','a','t','u','s','I','n','f','o',0};
387 static const WCHAR prop_strvalueW
[] =
388 {'S','t','r','i','n','g','V','a','l','u','e',0};
389 static const WCHAR prop_suitemaskW
[] =
390 {'S','u','i','t','e','M','a','s','k',0};
391 static const WCHAR prop_systemdirectoryW
[] =
392 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
393 static const WCHAR prop_systemnameW
[] =
394 {'S','y','s','t','e','m','N','a','m','e',0};
395 static const WCHAR prop_tagW
[] =
397 static const WCHAR prop_threadcountW
[] =
398 {'T','h','r','e','a','d','C','o','u','n','t',0};
399 static const WCHAR prop_totalphysicalmemoryW
[] =
400 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
401 static const WCHAR prop_totalvirtualmemorysizeW
[] =
402 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
403 static const WCHAR prop_totalvisiblememorysizeW
[] =
404 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
405 static const WCHAR prop_typeW
[] =
407 static const WCHAR prop_uniqueidW
[] =
408 {'U','n','i','q','u','e','I','d',0};
409 static const WCHAR prop_usernameW
[] =
410 {'U','s','e','r','N','a','m','e',0};
411 static const WCHAR prop_uuidW
[] =
413 static const WCHAR prop_varianttypeW
[] =
414 {'V','a','r','i','a','n','t','T','y','p','e',0};
415 static const WCHAR prop_vendorW
[] =
416 {'V','e','n','d','o','r',0};
417 static const WCHAR prop_versionW
[] =
418 {'V','e','r','s','i','o','n',0};
419 static const WCHAR prop_videoarchitectureW
[] =
420 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
421 static const WCHAR prop_videomemorytypeW
[] =
422 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
423 static const WCHAR prop_videomodedescriptionW
[] =
424 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
425 static const WCHAR prop_videoprocessorW
[] =
426 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
427 static const WCHAR prop_volumenameW
[] =
428 {'V','o','l','u','m','e','N','a','m','e',0};
429 static const WCHAR prop_volumeserialnumberW
[] =
430 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
431 static const WCHAR prop_workingsetsizeW
[] =
432 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
434 /* column definitions must be kept in sync with record structures below */
435 static const struct column col_baseboard
[] =
437 { prop_manufacturerW
, CIM_STRING
},
438 { prop_modelW
, CIM_STRING
},
439 { prop_nameW
, CIM_STRING
},
440 { prop_productW
, CIM_STRING
},
441 { prop_serialnumberW
, CIM_STRING
},
442 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
443 { prop_versionW
, CIM_STRING
}
445 static const struct column col_bios
[] =
447 { prop_descriptionW
, CIM_STRING
},
448 { prop_identificationcodeW
, CIM_STRING
},
449 { prop_manufacturerW
, CIM_STRING
},
450 { prop_nameW
, CIM_STRING
},
451 { prop_releasedateW
, CIM_DATETIME
},
452 { prop_serialnumberW
, CIM_STRING
},
453 { prop_smbiosbiosversionW
, CIM_STRING
},
454 { prop_smbiosmajorversionW
, CIM_UINT16
, VT_I4
},
455 { prop_smbiosminorversionW
, CIM_UINT16
, VT_I4
},
456 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
458 static const struct column col_cdromdrive
[] =
460 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
461 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
462 { prop_mediatypeW
, CIM_STRING
},
463 { prop_nameW
, CIM_STRING
},
464 { prop_pnpdeviceidW
, CIM_STRING
}
466 static const struct column col_compsys
[] =
468 { prop_descriptionW
, CIM_STRING
},
469 { prop_domainW
, CIM_STRING
},
470 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
471 { prop_manufacturerW
, CIM_STRING
},
472 { prop_modelW
, CIM_STRING
},
473 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
474 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
475 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
476 { prop_totalphysicalmemoryW
, CIM_UINT64
},
477 { prop_usernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
479 static const struct column col_compsysproduct
[] =
481 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
482 { prop_nameW
, CIM_STRING
|COL_FLAG_KEY
},
483 { prop_skunumberW
, CIM_STRING
},
484 { prop_uuidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
485 { prop_vendorW
, CIM_STRING
},
486 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
488 static const struct column col_datafile
[] =
490 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
491 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
493 static const struct column col_desktopmonitor
[] =
495 { prop_pixelsperxlogicalinchW
, CIM_UINT32
}
497 static const struct column col_directory
[] =
499 { prop_accessmaskW
, CIM_UINT32
},
500 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
502 static const struct column col_diskdrive
[] =
504 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
505 { prop_indexW
, CIM_UINT32
, VT_I4
},
506 { prop_interfacetypeW
, CIM_STRING
},
507 { prop_manufacturerW
, CIM_STRING
},
508 { prop_mediatypeW
, CIM_STRING
},
509 { prop_modelW
, CIM_STRING
},
510 { prop_pnpdeviceidW
, CIM_STRING
},
511 { prop_serialnumberW
, CIM_STRING
},
512 { prop_sizeW
, CIM_UINT64
}
514 static const struct column col_diskpartition
[] =
516 { prop_bootableW
, CIM_BOOLEAN
},
517 { prop_bootpartitionW
, CIM_BOOLEAN
},
518 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
519 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
520 { prop_indexW
, CIM_UINT32
, VT_I4
},
521 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
522 { prop_sizeW
, CIM_UINT64
},
523 { prop_startingoffsetW
, CIM_UINT64
},
524 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
526 static const struct column col_ip4routetable
[] =
528 { prop_destinationW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
529 { prop_interfaceindexW
, CIM_SINT32
|COL_FLAG_KEY
},
530 { prop_nexthopW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
532 static const struct column col_logicaldisk
[] =
534 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
535 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
536 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
537 { prop_freespaceW
, CIM_UINT64
},
538 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
539 { prop_sizeW
, CIM_UINT64
},
540 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
541 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
543 static const struct column col_networkadapter
[] =
545 { prop_adaptertypeW
, CIM_STRING
},
546 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
547 { prop_indexW
, CIM_UINT32
, VT_I4
},
548 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
549 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
550 { prop_manufacturerW
, CIM_STRING
},
551 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
552 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
553 { prop_physicaladapterW
, CIM_BOOLEAN
},
554 { prop_pnpdeviceidW
, CIM_STRING
},
555 { prop_speedW
, CIM_UINT64
}
557 static const struct column col_networkadapterconfig
[] =
559 { prop_defaultipgatewayW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
560 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
561 { prop_dhcpenabledW
, CIM_BOOLEAN
},
562 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
563 { prop_dnsserversearchorderW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
564 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
565 { prop_ipaddressW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
566 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
567 { prop_ipenabledW
, CIM_BOOLEAN
},
568 { prop_ipsubnet
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
569 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
570 { prop_settingidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
572 static const struct column col_os
[] =
574 { prop_buildnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
575 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
576 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
577 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
578 { prop_csdversionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
579 { prop_freephysicalmemoryW
, CIM_UINT64
},
580 { prop_installdateW
, CIM_DATETIME
},
581 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
582 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
583 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
584 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
585 { prop_osarchitectureW
, CIM_STRING
},
586 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
587 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
588 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
589 { prop_primaryW
, CIM_BOOLEAN
},
590 { prop_serialnumberW
, CIM_STRING
},
591 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
592 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
593 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
594 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
595 { prop_totalvirtualmemorysizeW
, CIM_UINT64
},
596 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
597 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
599 static const struct column col_param
[] =
601 { prop_classW
, CIM_STRING
},
602 { prop_methodW
, CIM_STRING
},
603 { prop_directionW
, CIM_SINT32
},
604 { prop_parameterW
, CIM_STRING
},
605 { prop_typeW
, CIM_UINT32
},
606 { prop_varianttypeW
, CIM_UINT32
},
607 { prop_defaultvalueW
, CIM_UINT32
}
609 static const struct column col_physicalmedia
[] =
611 { prop_serialnumberW
, CIM_STRING
},
612 { prop_tagW
, CIM_STRING
}
614 static const struct column col_physicalmemory
[] =
616 { prop_capacityW
, CIM_UINT64
},
617 { prop_memorytypeW
, CIM_UINT16
, VT_I4
}
619 static const struct column col_pnpentity
[] =
621 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
623 static const struct column col_printer
[] =
625 { prop_attributesW
, CIM_UINT32
},
626 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
627 { prop_drivernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
628 { prop_horizontalresolutionW
, CIM_UINT32
},
629 { prop_localW
, CIM_BOOLEAN
},
630 { prop_locationW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
631 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
632 { prop_networkW
, CIM_BOOLEAN
},
633 { prop_portnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
635 static const struct column col_process
[] =
637 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
638 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
639 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
640 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
641 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
642 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
643 { prop_processidW
, CIM_UINT32
, VT_I4
},
644 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
645 { prop_workingsetsizeW
, CIM_UINT64
},
647 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
649 static const struct column col_processor
[] =
651 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
652 { prop_architectureW
, CIM_UINT16
, VT_I4
},
653 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
654 { prop_cpustatusW
, CIM_UINT16
},
655 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
656 { prop_datawidthW
, CIM_UINT16
, VT_I4
},
657 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
658 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
659 { prop_familyW
, CIM_UINT16
, VT_I4
},
660 { prop_levelW
, CIM_UINT16
, VT_I4
},
661 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
662 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
663 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
664 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
665 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
666 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
667 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
668 { prop_revisionW
, CIM_UINT16
, VT_I4
},
669 { prop_uniqueidW
, CIM_STRING
},
670 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
672 static const struct column col_qualifier
[] =
674 { prop_classW
, CIM_STRING
},
675 { prop_memberW
, CIM_STRING
},
676 { prop_typeW
, CIM_UINT32
},
677 { prop_flavorW
, CIM_SINT32
},
678 { prop_nameW
, CIM_STRING
},
679 { prop_intvalueW
, CIM_SINT32
},
680 { prop_strvalueW
, CIM_STRING
}
682 static const struct column col_service
[] =
684 { prop_acceptpauseW
, CIM_BOOLEAN
},
685 { prop_acceptstopW
, CIM_BOOLEAN
},
686 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
687 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
688 { prop_processidW
, CIM_UINT32
},
689 { prop_servicetypeW
, CIM_STRING
},
690 { prop_startmodeW
, CIM_STRING
},
691 { prop_stateW
, CIM_STRING
},
692 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
694 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
695 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
696 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
697 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
699 static const struct column col_sid
[] =
701 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
702 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
703 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
704 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
705 { prop_sidlengthW
, CIM_UINT32
}
707 static const struct column col_sounddevice
[] =
709 { prop_nameW
, CIM_STRING
},
710 { prop_productnameW
, CIM_STRING
},
711 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
713 static const struct column col_stdregprov
[] =
715 { method_createkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
716 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
717 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
718 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
720 static const struct column col_systemenclosure
[] =
722 { prop_captionW
, CIM_STRING
},
723 { prop_chassistypesW
, CIM_UINT16
|CIM_FLAG_ARRAY
, VT_I4
|VT_ARRAY
},
724 { prop_descriptionW
, CIM_STRING
},
725 { prop_lockpresentW
, CIM_BOOLEAN
},
726 { prop_manufacturerW
, CIM_STRING
},
727 { prop_nameW
, CIM_STRING
},
728 { prop_tagW
, CIM_STRING
},
730 static const struct column col_systemsecurity
[] =
732 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
733 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
735 static const struct column col_videocontroller
[] =
737 { prop_adapterdactypeW
, CIM_STRING
},
738 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
739 { prop_availabilityW
, CIM_UINT16
},
740 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
741 { prop_configmanagererrorcodeW
, CIM_UINT32
, VT_I4
},
742 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
743 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
744 { prop_currentrefreshrateW
, CIM_UINT32
, VT_I4
},
745 { prop_currentscanmodeW
, CIM_UINT16
, VT_I4
},
746 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
747 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
748 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
749 { prop_driverdateW
, CIM_DATETIME
},
750 { prop_driverversionW
, CIM_STRING
},
751 { prop_installeddisplaydriversW
,CIM_STRING
},
752 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
753 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
754 { prop_statusW
, CIM_STRING
},
755 { prop_videoarchitectureW
, CIM_UINT16
, VT_I4
},
756 { prop_videomemorytypeW
, CIM_UINT16
, VT_I4
},
757 { prop_videomodedescriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
758 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
761 static const WCHAR baseboard_manufacturerW
[] =
762 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
763 static const WCHAR baseboard_serialnumberW
[] =
765 static const WCHAR baseboard_tagW
[] =
766 {'B','a','s','e',' ','B','o','a','r','d',0};
767 static const WCHAR baseboard_versionW
[] =
769 static const WCHAR bios_descriptionW
[] =
770 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
771 static const WCHAR bios_manufacturerW
[] =
772 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
773 static const WCHAR bios_nameW
[] =
774 {'W','I','N','E',' ','B','I','O','S',0};
775 static const WCHAR bios_releasedateW
[] =
776 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
777 static const WCHAR bios_serialnumberW
[] =
779 static const WCHAR bios_smbiosbiosversionW
[] =
781 static const WCHAR bios_versionW
[] =
782 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
783 static const WCHAR cdromdrive_mediatypeW
[] =
784 {'C','D','-','R','O','M',0};
785 static const WCHAR cdromdrive_nameW
[] =
786 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
787 static const WCHAR cdromdrive_pnpdeviceidW
[]=
788 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
789 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
790 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
791 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
792 static const WCHAR compsys_descriptionW
[] =
793 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
794 static const WCHAR compsys_domainW
[] =
795 {'W','O','R','K','G','R','O','U','P',0};
796 static const WCHAR compsys_manufacturerW
[] =
797 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
798 static const WCHAR compsys_modelW
[] =
800 static const WCHAR compsysproduct_identifyingnumberW
[] =
802 static const WCHAR compsysproduct_nameW
[] =
804 static const WCHAR compsysproduct_uuidW
[] =
805 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
806 'd','e','a','d','d','e','a','d','d','e','a','d',0};
807 static const WCHAR compsysproduct_vendorW
[] =
808 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
809 static const WCHAR compsysproduct_versionW
[] =
811 static const WCHAR diskdrive_interfacetypeW
[] =
813 static const WCHAR diskdrive_manufacturerW
[] =
814 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
815 static const WCHAR diskdrive_mediatype_fixedW
[] =
816 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
817 static const WCHAR diskdrive_mediatype_removableW
[] =
818 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
819 static const WCHAR diskdrive_modelW
[] =
820 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
821 static const WCHAR diskdrive_pnpdeviceidW
[] =
822 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
823 static const WCHAR diskdrive_serialW
[] =
824 {'W','I','N','E','H','D','I','S','K',0};
825 static const WCHAR networkadapter_pnpdeviceidW
[]=
826 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
827 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
828 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
829 static const WCHAR os_32bitW
[] =
830 {'3','2','-','b','i','t',0};
831 static const WCHAR os_64bitW
[] =
832 {'6','4','-','b','i','t',0};
833 static const WCHAR os_installdateW
[] =
834 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
835 static const WCHAR os_serialnumberW
[] =
836 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
837 static const WCHAR physicalmedia_tagW
[] =
838 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
839 static const WCHAR sounddevice_productnameW
[] =
840 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
841 static const WCHAR systemenclosure_systemenclosureW
[] =
842 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
843 static const WCHAR systemenclosure_tagW
[] =
844 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
845 static const WCHAR systemenclosure_manufacturerW
[] =
847 static const WCHAR videocontroller_dactypeW
[] =
848 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
849 static const WCHAR videocontroller_deviceidW
[] =
850 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
851 static const WCHAR videocontroller_driverdateW
[] =
852 {'2','0','1','7','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
853 static const WCHAR videocontroller_driverversionW
[] =
855 static const WCHAR videocontroller_statusW
[] =
858 #include "pshpack1.h"
859 struct record_baseboard
861 const WCHAR
*manufacturer
;
864 const WCHAR
*product
;
865 const WCHAR
*serialnumber
;
867 const WCHAR
*version
;
871 const WCHAR
*description
;
872 const WCHAR
*identificationcode
;
873 const WCHAR
*manufacturer
;
875 const WCHAR
*releasedate
;
876 const WCHAR
*serialnumber
;
877 const WCHAR
*smbiosbiosversion
;
878 UINT16 smbiosmajorversion
;
879 UINT16 smbiosminorversion
;
880 const WCHAR
*version
;
882 struct record_cdromdrive
884 const WCHAR
*device_id
;
886 const WCHAR
*mediatype
;
888 const WCHAR
*pnpdevice_id
;
890 struct record_computersystem
892 const WCHAR
*description
;
895 const WCHAR
*manufacturer
;
898 UINT32 num_logical_processors
;
899 UINT32 num_processors
;
900 UINT64 total_physical_memory
;
901 const WCHAR
*username
;
903 struct record_computersystemproduct
905 const WCHAR
*identifyingnumber
;
907 const WCHAR
*skunumber
;
910 const WCHAR
*version
;
912 struct record_datafile
915 const WCHAR
*version
;
917 struct record_desktopmonitor
919 UINT32 pixelsperxlogicalinch
;
921 struct record_directory
926 struct record_diskdrive
928 const WCHAR
*device_id
;
930 const WCHAR
*interfacetype
;
931 const WCHAR
*manufacturer
;
932 const WCHAR
*mediatype
;
934 const WCHAR
*pnpdevice_id
;
935 const WCHAR
*serialnumber
;
938 struct record_diskpartition
942 const WCHAR
*device_id
;
945 const WCHAR
*pnpdevice_id
;
947 UINT64 startingoffset
;
950 struct record_ip4routetable
952 const WCHAR
*destination
;
953 INT32 interfaceindex
;
954 const WCHAR
*nexthop
;
956 struct record_logicaldisk
958 const WCHAR
*device_id
;
960 const WCHAR
*filesystem
;
964 const WCHAR
*volumename
;
965 const WCHAR
*volumeserialnumber
;
967 struct record_networkadapter
969 const WCHAR
*adaptertype
;
970 const WCHAR
*device_id
;
972 UINT32 interface_index
;
973 const WCHAR
*mac_address
;
974 const WCHAR
*manufacturer
;
976 UINT16 netconnection_status
;
978 const WCHAR
*pnpdevice_id
;
981 struct record_networkadapterconfig
983 const struct array
*defaultipgateway
;
984 const WCHAR
*description
;
986 const WCHAR
*dnshostname
;
987 const struct array
*dnsserversearchorder
;
989 const struct array
*ipaddress
;
990 UINT32 ipconnectionmetric
;
992 const struct array
*ipsubnet
;
993 const WCHAR
*mac_address
;
994 const WCHAR
*settingid
;
996 struct record_operatingsystem
998 const WCHAR
*buildnumber
;
999 const WCHAR
*caption
;
1000 const WCHAR
*codeset
;
1001 const WCHAR
*countrycode
;
1002 const WCHAR
*csdversion
;
1003 UINT64 freephysicalmemory
;
1004 const WCHAR
*installdate
;
1005 const WCHAR
*lastbootuptime
;
1006 const WCHAR
*localdatetime
;
1007 const WCHAR
*locale
;
1009 const WCHAR
*osarchitecture
;
1011 UINT32 osproductsuite
;
1014 const WCHAR
*serialnumber
;
1015 UINT16 servicepackmajor
;
1016 UINT16 servicepackminor
;
1018 const WCHAR
*systemdirectory
;
1019 UINT64 totalvirtualmemorysize
;
1020 UINT64 totalvisiblememorysize
;
1021 const WCHAR
*version
;
1026 const WCHAR
*method
;
1028 const WCHAR
*parameter
;
1031 UINT32 defaultvalue
;
1033 struct record_physicalmedia
1035 const WCHAR
*serialnumber
;
1038 struct record_physicalmemory
1043 struct record_pnpentity
1045 const WCHAR
*device_id
;
1047 struct record_printer
1050 const WCHAR
*device_id
;
1051 const WCHAR
*drivername
;
1052 UINT32 horizontalresolution
;
1054 const WCHAR
*location
;
1057 const WCHAR
*portname
;
1059 struct record_process
1061 const WCHAR
*caption
;
1062 const WCHAR
*commandline
;
1063 const WCHAR
*description
;
1064 const WCHAR
*handle
;
1068 UINT32 thread_count
;
1069 UINT64 workingsetsize
;
1071 class_method
*get_owner
;
1073 struct record_processor
1075 UINT16 addresswidth
;
1076 UINT16 architecture
;
1077 const WCHAR
*caption
;
1079 UINT32 currentclockspeed
;
1081 const WCHAR
*description
;
1082 const WCHAR
*device_id
;
1085 const WCHAR
*manufacturer
;
1086 UINT32 maxclockspeed
;
1089 UINT32 num_logical_processors
;
1090 const WCHAR
*processor_id
;
1091 UINT16 processortype
;
1093 const WCHAR
*unique_id
;
1094 const WCHAR
*version
;
1096 struct record_qualifier
1099 const WCHAR
*member
;
1104 const WCHAR
*strvalue
;
1106 struct record_service
1110 const WCHAR
*displayname
;
1113 const WCHAR
*servicetype
;
1114 const WCHAR
*startmode
;
1116 const WCHAR
*systemname
;
1118 class_method
*pause_service
;
1119 class_method
*resume_service
;
1120 class_method
*start_service
;
1121 class_method
*stop_service
;
1125 const WCHAR
*accountname
;
1126 const struct array
*binaryrepresentation
;
1127 const WCHAR
*referenceddomainname
;
1131 struct record_sounddevice
1134 const WCHAR
*productname
;
1137 struct record_stdregprov
1139 class_method
*createkey
;
1140 class_method
*enumkey
;
1141 class_method
*enumvalues
;
1142 class_method
*getstringvalue
;
1144 struct record_systemsecurity
1146 class_method
*getsd
;
1147 class_method
*setsd
;
1149 struct record_systemenclosure
1151 const WCHAR
*caption
;
1152 const struct array
*chassistypes
;
1153 const WCHAR
*description
;
1155 const WCHAR
*manufacturer
;
1159 struct record_videocontroller
1161 const WCHAR
*adapter_dactype
;
1163 UINT16 availability
;
1164 const WCHAR
*caption
;
1165 UINT32 config_errorcode
;
1166 UINT32 current_bitsperpixel
;
1167 UINT32 current_horizontalres
;
1168 UINT32 current_refreshrate
;
1169 UINT16 current_scanmode
;
1170 UINT32 current_verticalres
;
1171 const WCHAR
*description
;
1172 const WCHAR
*device_id
;
1173 const WCHAR
*driverdate
;
1174 const WCHAR
*driverversion
;
1175 const WCHAR
*installeddriver
;
1177 const WCHAR
*pnpdevice_id
;
1178 const WCHAR
*status
;
1179 UINT16 videoarchitecture
;
1180 UINT16 videomemorytype
;
1181 const WCHAR
*videomodedescription
;
1182 const WCHAR
*videoprocessor
;
1184 #include "poppack.h"
1186 static const struct record_baseboard data_baseboard
[] =
1188 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
1190 static const struct record_bios data_bios
[] =
1192 { bios_descriptionW
, NULL
, bios_manufacturerW
, bios_nameW
, bios_releasedateW
, bios_serialnumberW
,
1193 bios_smbiosbiosversionW
, 1, 0, bios_versionW
}
1195 static const struct record_param data_param
[] =
1197 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1198 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
1199 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
1200 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1201 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1202 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1203 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1204 { class_stdregprovW
, method_createkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1205 { class_stdregprovW
, method_createkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1206 { class_stdregprovW
, method_createkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1207 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1208 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1209 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1210 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1211 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1212 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
1213 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1214 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1215 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
1216 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1217 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
1218 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
1219 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1220 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
1221 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1222 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1223 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1224 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1227 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1228 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1230 static const struct record_physicalmedia data_physicalmedia
[] =
1232 { diskdrive_serialW
, physicalmedia_tagW
}
1234 static const struct record_qualifier data_qualifier
[] =
1236 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
1237 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
1239 static const struct record_sounddevice data_sounddevice
[] =
1241 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
1243 static const struct record_stdregprov data_stdregprov
[] =
1245 { reg_create_key
, reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
1247 static UINT16 systemenclosure_chassistypes
[] =
1251 static const struct array systemenclosure_chassistypes_array
=
1253 ARRAY_SIZE(systemenclosure_chassistypes
),
1254 &systemenclosure_chassistypes
1256 static const struct record_systemenclosure data_systemenclosure
[] =
1259 systemenclosure_systemenclosureW
,
1260 &systemenclosure_chassistypes_array
,
1261 systemenclosure_systemenclosureW
,
1263 systemenclosure_manufacturerW
,
1264 systemenclosure_systemenclosureW
,
1265 systemenclosure_tagW
,
1268 static const struct record_systemsecurity data_systemsecurity
[] =
1270 { security_get_sd
, security_set_sd
}
1273 /* check if row matches condition and update status */
1274 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1281 *status
= FILL_STATUS_UNFILTERED
;
1284 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1286 *status
= FILL_STATUS_FAILED
;
1289 *status
= FILL_STATUS_FILTERED
;
1293 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1295 if (!table
->num_rows_allocated
)
1297 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1298 table
->num_rows_allocated
= row_count
;
1301 if (row_count
> table
->num_rows_allocated
)
1304 UINT count
= max( row_count
, table
->num_rows_allocated
* 2 );
1305 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1307 table
->num_rows_allocated
= count
;
1312 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1314 static const WCHAR fmtW
[] = {'%','c',':',0};
1315 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1316 struct record_cdromdrive
*rec
;
1317 UINT i
, row
= 0, offset
= 0;
1318 DWORD drives
= GetLogicalDrives();
1319 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1321 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1323 for (i
= 0; i
< 26; i
++)
1325 if (drives
& (1 << i
))
1328 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1331 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1333 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1334 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1335 sprintfW( drive
, fmtW
, 'A' + i
);
1336 rec
->drive
= heap_strdupW( drive
);
1337 rec
->mediatype
= cdromdrive_mediatypeW
;
1338 rec
->name
= cdromdrive_nameW
;
1339 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1340 if (!match_row( table
, row
, cond
, &status
))
1342 free_row_values( table
, row
);
1345 offset
+= sizeof(*rec
);
1349 TRACE("created %u rows\n", row
);
1350 table
->num_rows
= row
;
1354 static UINT
get_processor_count(void)
1356 SYSTEM_BASIC_INFORMATION info
;
1358 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1359 return info
.NumberOfProcessors
;
1362 static UINT
get_logical_processor_count( UINT
*num_cores
)
1364 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1365 UINT i
, j
, count
= 0;
1369 if (num_cores
) *num_cores
= get_processor_count();
1370 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1371 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1373 if (!(info
= heap_alloc( len
))) return get_processor_count();
1374 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1375 if (status
!= STATUS_SUCCESS
)
1378 return get_processor_count();
1380 if (num_cores
) *num_cores
= 0;
1381 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1383 if (info
[i
].Relationship
== RelationProcessorCore
)
1385 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1387 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1389 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1396 static UINT64
get_total_physical_memory(void)
1398 MEMORYSTATUSEX status
;
1400 status
.dwLength
= sizeof(status
);
1401 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1402 return status
.ullTotalPhys
;
1405 static UINT64
get_available_physical_memory(void)
1407 MEMORYSTATUSEX status
;
1409 status
.dwLength
= sizeof(status
);
1410 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1411 return status
.ullAvailPhys
;
1414 static WCHAR
*get_computername(void)
1417 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1419 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1420 GetComputerNameW( ret
, &size
);
1424 static WCHAR
*get_username(void)
1427 DWORD compsize
, usersize
;
1431 GetComputerNameW( NULL
, &compsize
);
1433 GetUserNameW( NULL
, &usersize
);
1434 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1435 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1436 GetComputerNameW( ret
, &compsize
);
1437 ret
[compsize
] = '\\';
1438 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1442 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1444 struct record_computersystem
*rec
;
1445 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1448 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1450 rec
= (struct record_computersystem
*)table
->data
;
1451 rec
->description
= compsys_descriptionW
;
1452 rec
->domain
= compsys_domainW
;
1453 rec
->domainrole
= 0; /* standalone workstation */
1454 rec
->manufacturer
= compsys_manufacturerW
;
1455 rec
->model
= compsys_modelW
;
1456 rec
->name
= get_computername();
1457 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1458 rec
->num_processors
= get_processor_count();
1459 rec
->total_physical_memory
= get_total_physical_memory();
1460 rec
->username
= get_username();
1461 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1464 TRACE("created %u rows\n", row
);
1465 table
->num_rows
= row
;
1469 static WCHAR
*get_compsysproduct_uuid(void)
1472 unsigned char uuid
[16];
1473 const struct timespec timeout
= {1, 0};
1474 if (!gethostuuid( uuid
, &timeout
))
1476 static const WCHAR fmtW
[] =
1477 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1478 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1479 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1480 WCHAR
*ret
= heap_alloc( 37 * sizeof(WCHAR
) );
1481 if (!ret
) return NULL
;
1482 sprintfW( ret
, fmtW
, uuid
[0], uuid
[1], uuid
[2], uuid
[3], uuid
[4], uuid
[5], uuid
[6], uuid
[7],
1483 uuid
[8], uuid
[9], uuid
[10], uuid
[11], uuid
[12], uuid
[13], uuid
[14], uuid
[15] );
1489 if ((file
= open( "/var/lib/dbus/machine-id", O_RDONLY
)) != -1)
1491 unsigned char buf
[32];
1492 if (read( file
, buf
, sizeof(buf
) ) == sizeof(buf
))
1498 if (!(p
= ret
= heap_alloc( 37 * sizeof(WCHAR
) ))) return NULL
;
1499 for (i
= 0, j
= 0; i
< 8; i
++) p
[i
] = toupperW( buf
[j
++] );
1501 for (i
= 9; i
< 13; i
++) p
[i
] = toupperW( buf
[j
++] );
1503 for (i
= 14; i
< 18; i
++) p
[i
] = toupperW( buf
[j
++] );
1505 for (i
= 19; i
< 23; i
++) p
[i
] = toupperW( buf
[j
++] );
1507 for (i
= 24; i
< 36; i
++) p
[i
] = toupperW( buf
[j
++] );
1514 return heap_strdupW( compsysproduct_uuidW
);
1517 static enum fill_status
fill_compsysproduct( struct table
*table
, const struct expr
*cond
)
1519 struct record_computersystemproduct
*rec
;
1520 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1523 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1525 rec
= (struct record_computersystemproduct
*)table
->data
;
1526 rec
->identifyingnumber
= compsysproduct_identifyingnumberW
;
1527 rec
->name
= compsysproduct_nameW
;
1528 rec
->skunumber
= NULL
;
1529 rec
->uuid
= get_compsysproduct_uuid();
1530 rec
->vendor
= compsysproduct_vendorW
;
1531 rec
->version
= compsysproduct_versionW
;
1532 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1535 TRACE("created %u rows\n", row
);
1536 table
->num_rows
= row
;
1548 static struct dirstack
*alloc_dirstack( UINT size
)
1550 struct dirstack
*dirstack
;
1552 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1553 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1555 heap_free( dirstack
);
1558 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1560 heap_free( dirstack
->dirs
);
1561 heap_free( dirstack
);
1564 dirstack
->num_dirs
= 0;
1565 dirstack
->num_allocated
= size
;
1569 static void clear_dirstack( struct dirstack
*dirstack
)
1572 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1573 dirstack
->num_dirs
= 0;
1576 static void free_dirstack( struct dirstack
*dirstack
)
1578 clear_dirstack( dirstack
);
1579 heap_free( dirstack
->dirs
);
1580 heap_free( dirstack
->len_dirs
);
1581 heap_free( dirstack
);
1584 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1586 UINT size
, i
= dirstack
->num_dirs
;
1588 if (!dir
) return FALSE
;
1590 if (i
== dirstack
->num_allocated
)
1595 size
= dirstack
->num_allocated
* 2;
1596 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1597 dirstack
->dirs
= tmp
;
1598 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1599 dirstack
->len_dirs
= len_tmp
;
1600 dirstack
->num_allocated
= size
;
1602 dirstack
->dirs
[i
] = dir
;
1603 dirstack
->len_dirs
[i
] = len
;
1604 dirstack
->num_dirs
++;
1608 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1610 if (!dirstack
->num_dirs
)
1615 dirstack
->num_dirs
--;
1616 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1617 return dirstack
->dirs
[dirstack
->num_dirs
];
1620 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1622 if (!dirstack
->num_dirs
) return NULL
;
1623 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1626 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1631 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1637 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1646 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1648 UINT i
= 0, len
= 0;
1652 for (p
= path
; *p
; p
++)
1654 if (*p
== '\\') len
+= 2;
1657 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1662 for (p
= path
; *p
; p
++)
1664 if (*p
!= '\\') ret
[i
++] = *p
;
1675 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1677 const WCHAR
*p
= path
, *start
;
1681 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1683 len
= strlenW( start
);
1684 p
= start
+ len
- 1;
1685 if (*p
== '\\') return NULL
;
1687 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1688 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1690 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1691 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1693 if (p
[0] == '\\' && p
[1] == '\\')
1705 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1708 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1712 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1713 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1715 const struct expr
*left
, *right
;
1717 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1719 left
= cond
->u
.expr
.left
;
1720 right
= cond
->u
.expr
.right
;
1721 if (cond
->u
.expr
.op
== OP_EQ
)
1725 const WCHAR
*str
= NULL
;
1727 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1728 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1729 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1731 str
= right
->u
.sval
;
1733 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1734 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1735 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1739 if (str
&& (path
= build_dirname( str
, &len
)))
1741 if (seen_dir( dirstack
, path
))
1746 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1751 else if (cond
->u
.expr
.op
== OP_OR
)
1753 UINT left_count
= 0, right_count
= 0;
1755 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1756 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1757 return *count
+= left_count
+ right_count
;
1762 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1764 UINT len_path
= 0, len_segment
= strlenW( segment
);
1768 if (path
) len_path
= strlenW( path
);
1769 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1770 if (path
&& len_path
)
1772 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1773 ret
[len_path
] = '\\';
1774 *len
+= len_path
+ 1;
1776 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1777 *len
+= len_segment
;
1782 static WCHAR
*get_file_version( const WCHAR
*filename
)
1784 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1785 VS_FIXEDFILEINFO
*info
;
1790 if (!(ret
= heap_alloc( (4 * 5 + ARRAY_SIZE( fmtW
)) * sizeof(WCHAR
) ))) return NULL
;
1791 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1796 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1797 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1803 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1804 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1809 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1811 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1812 struct record_datafile
*rec
;
1813 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1814 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1815 DWORD drives
= GetLogicalDrives();
1816 WIN32_FIND_DATAW data
;
1818 struct dirstack
*dirstack
;
1819 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1821 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1823 dirstack
= alloc_dirstack(2);
1825 for (i
= 0; i
< 26; i
++)
1827 if (!(drives
& (1 << i
))) continue;
1830 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1832 num_expected_rows
= 0;
1833 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1839 path
= pop_dir( dirstack
, &len
);
1840 if (!(glob
= build_glob( root
[0], path
, len
)))
1842 status
= FILL_STATUS_FAILED
;
1845 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1849 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1851 status
= FILL_STATUS_FAILED
;
1852 FindClose( handle
);
1855 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1856 new_path
= append_path( path
, data
.cFileName
, &len
);
1858 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1860 if (push_dir( dirstack
, new_path
, len
)) continue;
1861 heap_free( new_path
);
1862 FindClose( handle
);
1863 status
= FILL_STATUS_FAILED
;
1866 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1867 rec
->name
= build_name( root
[0], new_path
);
1868 rec
->version
= get_file_version( rec
->name
);
1869 if (!match_row( table
, row
, cond
, &status
))
1871 free_row_values( table
, row
);
1874 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1877 FindClose( handle
);
1878 status
= FILL_STATUS_FILTERED
;
1881 offset
+= sizeof(*rec
);
1884 while (FindNextFileW( handle
, &data
));
1885 FindClose( handle
);
1887 if (!peek_dir( dirstack
)) break;
1892 free_dirstack( dirstack
);
1896 TRACE("created %u rows\n", row
);
1897 table
->num_rows
= row
;
1901 static UINT32
get_pixelsperxlogicalinch(void)
1903 HDC hdc
= GetDC( NULL
);
1906 if (!hdc
) return 96;
1907 ret
= GetDeviceCaps( hdc
, LOGPIXELSX
);
1908 ReleaseDC( NULL
, hdc
);
1912 static enum fill_status
fill_desktopmonitor( struct table
*table
, const struct expr
*cond
)
1914 struct record_desktopmonitor
*rec
;
1915 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1918 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1920 rec
= (struct record_desktopmonitor
*)table
->data
;
1921 rec
->pixelsperxlogicalinch
= get_pixelsperxlogicalinch();
1923 if (match_row( table
, row
, cond
, &status
)) row
++;
1925 TRACE("created %u rows\n", row
);
1926 table
->num_rows
= row
;
1930 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1932 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1933 struct record_directory
*rec
;
1934 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1935 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1936 DWORD drives
= GetLogicalDrives();
1937 WIN32_FIND_DATAW data
;
1939 struct dirstack
*dirstack
;
1940 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1942 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1944 dirstack
= alloc_dirstack(2);
1946 for (i
= 0; i
< 26; i
++)
1948 if (!(drives
& (1 << i
))) continue;
1951 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1953 num_expected_rows
= 0;
1954 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1960 path
= pop_dir( dirstack
, &len
);
1961 if (!(glob
= build_glob( root
[0], path
, len
)))
1963 status
= FILL_STATUS_FAILED
;
1966 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1970 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1972 FindClose( handle
);
1973 status
= FILL_STATUS_FAILED
;
1976 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1977 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1980 new_path
= append_path( path
, data
.cFileName
, &len
);
1981 if (!(push_dir( dirstack
, new_path
, len
)))
1983 heap_free( new_path
);
1984 FindClose( handle
);
1985 status
= FILL_STATUS_FAILED
;
1988 rec
= (struct record_directory
*)(table
->data
+ offset
);
1989 rec
->accessmask
= FILE_ALL_ACCESS
;
1990 rec
->name
= build_name( root
[0], new_path
);
1991 if (!match_row( table
, row
, cond
, &status
))
1993 free_row_values( table
, row
);
1996 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1999 FindClose( handle
);
2000 status
= FILL_STATUS_FILTERED
;
2003 offset
+= sizeof(*rec
);
2006 while (FindNextFileW( handle
, &data
));
2007 FindClose( handle
);
2009 if (!peek_dir( dirstack
)) break;
2014 free_dirstack( dirstack
);
2018 TRACE("created %u rows\n", row
);
2019 table
->num_rows
= row
;
2023 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
2025 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
2026 ULARGE_INTEGER free
;
2027 DISK_GEOMETRY_EX info
;
2029 DWORD bytes_returned
;
2031 free
.QuadPart
= 512 * 1024 * 1024;
2032 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
2035 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
2036 if (handle
!= INVALID_HANDLE_VALUE
)
2038 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
2039 *disksize
= info
.DiskSize
.QuadPart
;
2040 CloseHandle( handle
);
2042 return free
.QuadPart
;
2045 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
2047 static const WCHAR fmtW
[] =
2048 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
2049 WCHAR device_id
[ARRAY_SIZE( fmtW
) + 10], root
[] = {'A',':','\\',0};
2050 struct record_diskdrive
*rec
;
2051 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
2052 UINT64 size
= 1024 * 1024 * 1024;
2053 DWORD drives
= GetLogicalDrives();
2054 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2056 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2058 for (i
= 0; i
< 26; i
++)
2060 if (drives
& (1 << i
))
2063 type
= GetDriveTypeW( root
);
2064 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
2067 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2069 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
2070 sprintfW( device_id
, fmtW
, index
);
2071 rec
->device_id
= heap_strdupW( device_id
);
2073 rec
->interfacetype
= diskdrive_interfacetypeW
;
2074 rec
->manufacturer
= diskdrive_manufacturerW
;
2075 if (type
== DRIVE_FIXED
)
2076 rec
->mediatype
= diskdrive_mediatype_fixedW
;
2078 rec
->mediatype
= diskdrive_mediatype_removableW
;
2079 rec
->model
= diskdrive_modelW
;
2080 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
2081 rec
->serialnumber
= diskdrive_serialW
;
2082 get_freespace( root
, &size
);
2084 if (!match_row( table
, row
, cond
, &status
))
2086 free_row_values( table
, row
);
2089 offset
+= sizeof(*rec
);
2094 TRACE("created %u rows\n", row
);
2095 table
->num_rows
= row
;
2099 static WCHAR
*get_filesystem( const WCHAR
*root
)
2101 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
2102 WCHAR buffer
[MAX_PATH
+ 1];
2104 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
2105 return heap_strdupW( buffer
);
2106 return heap_strdupW( ntfsW
);
2109 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
2111 static const WCHAR fmtW
[] =
2112 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
2113 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
2114 struct record_diskpartition
*rec
;
2115 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
2116 UINT64 size
= 1024 * 1024 * 1024;
2117 DWORD drives
= GetLogicalDrives();
2118 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2120 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2122 for (i
= 0; i
< 26; i
++)
2124 if (drives
& (1 << i
))
2127 type
= GetDriveTypeW( root
);
2128 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
2131 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2133 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
2134 rec
->bootable
= (i
== 2) ? -1 : 0;
2135 rec
->bootpartition
= (i
== 2) ? -1 : 0;
2136 sprintfW( device_id
, fmtW
, index
);
2137 rec
->device_id
= heap_strdupW( device_id
);
2138 rec
->diskindex
= index
;
2140 rec
->pnpdevice_id
= heap_strdupW( device_id
);
2141 get_freespace( root
, &size
);
2143 rec
->startingoffset
= 0;
2144 rec
->type
= get_filesystem( root
);
2145 if (!match_row( table
, row
, cond
, &status
))
2147 free_row_values( table
, row
);
2150 offset
+= sizeof(*rec
);
2155 TRACE("created %u rows\n", row
);
2156 table
->num_rows
= row
;
2160 static WCHAR
*get_ip4_string( DWORD addr
)
2162 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2165 if (!(ret
= heap_alloc( sizeof("ddd.ddd.ddd.ddd") * sizeof(WCHAR
) ))) return NULL
;
2166 sprintfW( ret
, fmtW
, (addr
>> 24) & 0xff, (addr
>> 16) & 0xff, (addr
>> 8) & 0xff, addr
& 0xff );
2170 static enum fill_status
fill_ip4routetable( struct table
*table
, const struct expr
*cond
)
2172 struct record_ip4routetable
*rec
;
2173 UINT i
, row
= 0, offset
= 0, size
= 0;
2174 MIB_IPFORWARDTABLE
*forwards
;
2175 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2177 if (GetIpForwardTable( NULL
, &size
, TRUE
) != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2178 if (!(forwards
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2179 if (GetIpForwardTable( forwards
, &size
, TRUE
))
2181 heap_free( forwards
);
2182 return FILL_STATUS_FAILED
;
2184 if (!resize_table( table
, max(forwards
->dwNumEntries
, 1), sizeof(*rec
) ))
2186 heap_free( forwards
);
2187 return FILL_STATUS_FAILED
;
2190 for (i
= 0; i
< forwards
->dwNumEntries
; i
++)
2192 rec
= (struct record_ip4routetable
*)(table
->data
+ offset
);
2194 rec
->destination
= get_ip4_string( ntohl(forwards
->table
[i
].dwForwardDest
) );
2195 rec
->interfaceindex
= forwards
->table
[i
].dwForwardIfIndex
;
2196 rec
->nexthop
= get_ip4_string( ntohl(forwards
->table
[i
].dwForwardNextHop
) );
2198 if (!match_row( table
, row
, cond
, &status
))
2200 free_row_values( table
, row
);
2203 offset
+= sizeof(*rec
);
2206 TRACE("created %u rows\n", row
);
2207 table
->num_rows
= row
;
2209 heap_free( forwards
);
2213 static WCHAR
*get_volumename( const WCHAR
*root
)
2215 WCHAR buf
[MAX_PATH
+ 1] = {0};
2216 GetVolumeInformationW( root
, buf
, ARRAY_SIZE( buf
), NULL
, NULL
, NULL
, NULL
, 0 );
2217 return heap_strdupW( buf
);
2219 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
2221 static const WCHAR fmtW
[] = {'%','0','8','X',0};
2225 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
2226 sprintfW( buffer
, fmtW
, serial
);
2227 return heap_strdupW( buffer
);
2230 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
2232 static const WCHAR fmtW
[] = {'%','c',':',0};
2233 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
2234 struct record_logicaldisk
*rec
;
2235 UINT i
, row
= 0, offset
= 0, type
;
2236 UINT64 size
= 1024 * 1024 * 1024;
2237 DWORD drives
= GetLogicalDrives();
2238 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2240 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2242 for (i
= 0; i
< 26; i
++)
2244 if (drives
& (1 << i
))
2247 type
= GetDriveTypeW( root
);
2248 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
2251 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2253 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
2254 sprintfW( device_id
, fmtW
, 'A' + i
);
2255 rec
->device_id
= heap_strdupW( device_id
);
2256 rec
->drivetype
= type
;
2257 rec
->filesystem
= get_filesystem( root
);
2258 rec
->freespace
= get_freespace( root
, &size
);
2259 rec
->name
= heap_strdupW( device_id
);
2261 rec
->volumename
= get_volumename( root
);
2262 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
2263 if (!match_row( table
, row
, cond
, &status
))
2265 free_row_values( table
, row
);
2268 offset
+= sizeof(*rec
);
2272 TRACE("created %u rows\n", row
);
2273 table
->num_rows
= row
;
2277 static UINT16
get_connection_status( IF_OPER_STATUS status
)
2281 case IfOperStatusDown
:
2282 return 0; /* Disconnected */
2283 case IfOperStatusUp
:
2284 return 2; /* Connected */
2286 ERR("unhandled status %u\n", status
);
2291 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
2293 static const WCHAR fmtW
[] =
2294 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2295 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2298 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
2299 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
2302 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
2304 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2305 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
2306 static const WCHAR firewireW
[] = {'1','3','9','4',0};
2307 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
2311 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
2312 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
2313 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
2314 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
2315 default: *physical
= 0; return NULL
;
2319 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
2321 static const WCHAR fmtW
[] = {'%','u',0};
2322 WCHAR device_id
[11];
2323 struct record_networkadapter
*rec
;
2324 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2325 UINT row
= 0, offset
= 0, count
= 0;
2326 DWORD size
= 0, ret
;
2328 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2330 ret
= GetAdaptersAddresses( WS_AF_UNSPEC
, 0, NULL
, NULL
, &size
);
2331 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2333 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2334 if (GetAdaptersAddresses( WS_AF_UNSPEC
, 0, NULL
, buffer
, &size
))
2336 heap_free( buffer
);
2337 return FILL_STATUS_FAILED
;
2339 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2341 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2343 if (!resize_table( table
, count
, sizeof(*rec
) ))
2345 heap_free( buffer
);
2346 return FILL_STATUS_FAILED
;
2348 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2350 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2352 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
2353 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
2354 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
2355 rec
->device_id
= heap_strdupW( device_id
);
2356 rec
->index
= aa
->u
.s
.IfIndex
;
2357 rec
->interface_index
= aa
->u
.s
.IfIndex
;
2358 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2359 rec
->manufacturer
= compsys_manufacturerW
;
2360 rec
->name
= heap_strdupW( aa
->FriendlyName
);
2361 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
2362 rec
->physicaladapter
= physical
;
2363 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
2364 rec
->speed
= 1000000;
2365 if (!match_row( table
, row
, cond
, &status
))
2367 free_row_values( table
, row
);
2370 offset
+= sizeof(*rec
);
2373 TRACE("created %u rows\n", row
);
2374 table
->num_rows
= row
;
2376 heap_free( buffer
);
2380 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
2382 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
2383 WCHAR buf
[WS_NI_MAXHOST
];
2385 if (!addr
) return NULL
;
2386 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, ARRAY_SIZE( buf
), NULL
,
2387 0, WS_NI_NAMEREQD
)) return NULL
;
2388 return heap_strdupW( buf
);
2390 static struct array
*get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS
*list
)
2392 IP_ADAPTER_GATEWAY_ADDRESS
*gateway
;
2394 ULONG buflen
, i
= 0, count
= 0;
2395 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
2397 if (!list
) return NULL
;
2398 for (gateway
= list
; gateway
; gateway
= gateway
->Next
) count
++;
2400 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2401 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2406 for (gateway
= list
; gateway
; gateway
= gateway
->Next
)
2408 buflen
= ARRAY_SIZE( buf
);
2409 if (WSAAddressToStringW( gateway
->Address
.lpSockaddr
, gateway
->Address
.iSockaddrLength
,
2410 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2412 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2422 static struct array
*get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS
*list
)
2424 IP_ADAPTER_DNS_SERVER_ADDRESS
*server
;
2426 ULONG buflen
, i
= 0, count
= 0;
2427 WCHAR
**ptr
, *p
, buf
[54]; /* max IPv6 address length */
2429 if (!list
) return NULL
;
2430 for (server
= list
; server
; server
= server
->Next
) count
++;
2432 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2433 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2438 for (server
= list
; server
; server
= server
->Next
)
2440 buflen
= ARRAY_SIZE( buf
);
2441 if (WSAAddressToStringW( server
->Address
.lpSockaddr
, server
->Address
.iSockaddrLength
,
2442 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2444 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2449 if ((p
= strrchrW( ptr
[i
- 1], ':' ))) *p
= 0;
2455 static struct array
*get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH
*list
)
2457 IP_ADAPTER_UNICAST_ADDRESS_LH
*address
;
2459 ULONG buflen
, i
= 0, count
= 0;
2460 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
2462 if (!list
) return NULL
;
2463 for (address
= list
; address
; address
= address
->Next
) count
++;
2465 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2466 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2471 for (address
= list
; address
; address
= address
->Next
)
2473 buflen
= ARRAY_SIZE( buf
);
2474 if (WSAAddressToStringW( address
->Address
.lpSockaddr
, address
->Address
.iSockaddrLength
,
2475 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2477 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2487 static struct array
*get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH
*list
)
2489 IP_ADAPTER_UNICAST_ADDRESS_LH
*address
;
2491 ULONG i
= 0, count
= 0;
2494 if (!list
) return NULL
;
2495 for (address
= list
; address
; address
= address
->Next
) count
++;
2497 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2498 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2503 for (address
= list
; address
; address
= address
->Next
)
2505 if (address
->Address
.lpSockaddr
->sa_family
== WS_AF_INET
)
2507 WCHAR buf
[INET_ADDRSTRLEN
];
2509 ULONG buflen
= ARRAY_SIZE( buf
);
2511 memset( &addr
, 0, sizeof(addr
) );
2512 addr
.sin_family
= WS_AF_INET
;
2513 if (ConvertLengthToIpv4Mask( address
->OnLinkPrefixLength
, &addr
.sin_addr
.S_un
.S_addr
) != NO_ERROR
2514 || WSAAddressToStringW( (SOCKADDR
*)&addr
, sizeof(addr
), NULL
, buf
, &buflen
))
2517 ptr
[i
] = heap_strdupW( buf
);
2521 static const WCHAR fmtW
[] = {'%','u',0};
2524 sprintfW(buf
, fmtW
, address
->OnLinkPrefixLength
);
2525 ptr
[i
] = heap_strdupW( buf
);
2529 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2539 static WCHAR
*get_settingid( UINT32 index
)
2543 memset( &guid
, 0, sizeof(guid
) );
2545 UuidToStringW( &guid
, &str
);
2546 ret
= heap_strdupW( str
);
2547 RpcStringFreeW( &str
);
2551 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
2553 struct record_networkadapterconfig
*rec
;
2554 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2555 UINT row
= 0, offset
= 0, count
= 0;
2556 DWORD size
= 0, ret
;
2557 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2559 ret
= GetAdaptersAddresses( WS_AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, NULL
, &size
);
2560 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2562 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2563 if (GetAdaptersAddresses( WS_AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, buffer
, &size
))
2565 heap_free( buffer
);
2566 return FILL_STATUS_FAILED
;
2568 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2570 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2572 if (!resize_table( table
, count
, sizeof(*rec
) ))
2574 heap_free( buffer
);
2575 return FILL_STATUS_FAILED
;
2577 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2579 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2581 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
2582 rec
->defaultipgateway
= get_defaultipgateway( aa
->FirstGatewayAddress
);
2583 rec
->description
= heap_strdupW( aa
->Description
);
2584 rec
->dhcpenabled
= -1;
2585 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
2586 rec
->dnsserversearchorder
= get_dnsserversearchorder( aa
->FirstDnsServerAddress
);
2587 rec
->index
= aa
->u
.s
.IfIndex
;
2588 rec
->ipaddress
= get_ipaddress( aa
->FirstUnicastAddress
);
2589 rec
->ipconnectionmetric
= 20;
2590 rec
->ipenabled
= -1;
2591 rec
->ipsubnet
= get_ipsubnet( aa
->FirstUnicastAddress
);
2592 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2593 rec
->settingid
= get_settingid( rec
->index
);
2594 if (!match_row( table
, row
, cond
, &status
))
2596 free_row_values( table
, row
);
2599 offset
+= sizeof(*rec
);
2602 TRACE("created %u rows\n", row
);
2603 table
->num_rows
= row
;
2605 heap_free( buffer
);
2609 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
2611 struct record_physicalmemory
*rec
;
2612 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2615 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2617 rec
= (struct record_physicalmemory
*)table
->data
;
2618 rec
->capacity
= get_total_physical_memory();
2619 rec
->memorytype
= 9; /* RAM */
2620 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2623 TRACE("created %u rows\n", row
);
2624 table
->num_rows
= row
;
2628 static enum fill_status
fill_pnpentity( struct table
*table
, const struct expr
*cond
)
2630 struct record_pnpentity
*rec
;
2631 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2632 HDEVINFO device_info_set
;
2633 SP_DEVINFO_DATA devinfo
= {0};
2636 device_info_set
= SetupDiGetClassDevsW( NULL
, NULL
, NULL
, DIGCF_ALLCLASSES
|DIGCF_PRESENT
);
2638 devinfo
.cbSize
= sizeof(devinfo
);
2641 while (SetupDiEnumDeviceInfo( device_info_set
, idx
++, &devinfo
))
2646 resize_table( table
, idx
, sizeof(*rec
) );
2647 table
->num_rows
= 0;
2648 rec
= (struct record_pnpentity
*)table
->data
;
2651 while (SetupDiEnumDeviceInfo( device_info_set
, idx
++, &devinfo
))
2653 WCHAR device_id
[MAX_PATH
];
2654 if (SetupDiGetDeviceInstanceIdW( device_info_set
, &devinfo
, device_id
,
2655 ARRAY_SIZE(device_id
), NULL
))
2657 rec
->device_id
= heap_strdupW( device_id
);
2660 if (!match_row( table
, table
->num_rows
- 1, cond
, &status
))
2662 free_row_values( table
, table
->num_rows
- 1 );
2670 SetupDiDestroyDeviceInfoList( device_info_set
);
2675 static enum fill_status
fill_printer( struct table
*table
, const struct expr
*cond
)
2677 static const WCHAR fmtW
[] = {'P','r','i','n','t','e','r','%','d',0};
2678 struct record_printer
*rec
;
2679 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2680 PRINTER_INFO_2W
*info
;
2681 DWORD i
, offset
= 0, count
= 0, size
= 0, num_rows
= 0;
2684 EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &size
, &count
);
2685 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2687 if (!(info
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2688 if (!EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, (BYTE
*)info
, size
, &size
, &count
))
2691 return FILL_STATUS_FAILED
;
2693 if (!resize_table( table
, count
, sizeof(*rec
) ))
2696 return FILL_STATUS_FAILED
;
2699 for (i
= 0; i
< count
; i
++)
2701 rec
= (struct record_printer
*)(table
->data
+ offset
);
2702 rec
->attributes
= info
[i
].Attributes
;
2703 sprintfW( id
, fmtW
, i
);
2704 rec
->device_id
= heap_strdupW( id
);
2705 rec
->drivername
= heap_strdupW( info
[i
].pDriverName
);
2706 rec
->horizontalresolution
= info
[i
].pDevMode
->u1
.s1
.dmPrintQuality
;
2708 rec
->location
= heap_strdupW( info
[i
].pLocation
);
2709 rec
->name
= heap_strdupW( info
[i
].pPrinterName
);
2711 rec
->portname
= heap_strdupW( info
[i
].pPortName
);
2712 if (!match_row( table
, i
, cond
, &status
))
2714 free_row_values( table
, i
);
2717 offset
+= sizeof(*rec
);
2720 TRACE("created %u rows\n", num_rows
);
2721 table
->num_rows
= num_rows
;
2727 static WCHAR
*get_cmdline( DWORD process_id
)
2729 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2730 return NULL
; /* FIXME handle different process case */
2733 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2735 static const WCHAR fmtW
[] = {'%','u',0};
2737 struct record_process
*rec
;
2738 PROCESSENTRY32W entry
;
2740 enum fill_status status
= FILL_STATUS_FAILED
;
2741 UINT row
= 0, offset
= 0;
2743 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2744 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2746 entry
.dwSize
= sizeof(entry
);
2747 if (!Process32FirstW( snap
, &entry
)) goto done
;
2748 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2752 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2754 rec
= (struct record_process
*)(table
->data
+ offset
);
2755 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2756 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2757 rec
->description
= heap_strdupW( entry
.szExeFile
);
2758 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2759 rec
->handle
= heap_strdupW( handle
);
2760 rec
->name
= heap_strdupW( entry
.szExeFile
);
2761 rec
->process_id
= entry
.th32ProcessID
;
2762 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2763 rec
->thread_count
= entry
.cntThreads
;
2764 rec
->workingsetsize
= 0;
2765 rec
->get_owner
= process_get_owner
;
2766 if (!match_row( table
, row
, cond
, &status
))
2768 free_row_values( table
, row
);
2771 offset
+= sizeof(*rec
);
2773 } while (Process32NextW( snap
, &entry
));
2775 TRACE("created %u rows\n", row
);
2776 table
->num_rows
= row
;
2777 status
= FILL_STATUS_UNFILTERED
;
2780 CloseHandle( snap
);
2784 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2790 __asm__("pushl %%ebx\n\t"
2792 "movl %%ebx, %%esi\n\t"
2794 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2799 static const WCHAR
*get_osarchitecture(void)
2802 GetNativeSystemInfo( &info
);
2803 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2806 static void get_processor_caption( WCHAR
*caption
)
2808 static const WCHAR fmtW
[] =
2809 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2810 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2811 static const WCHAR x86W
[] = {'x','8','6',0};
2812 static const WCHAR intel64W
[] = {'I','n','t','e','l','6','4',0};
2813 const WCHAR
*arch
= (get_osarchitecture() == os_32bitW
) ? x86W
: intel64W
;
2814 unsigned int regs
[4] = {0, 0, 0, 0};
2816 do_cpuid( 1, regs
);
2817 sprintfW( caption
, fmtW
, arch
, (regs
[0] & (15 << 8)) >> 8, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2819 static void get_processor_version( WCHAR
*version
)
2821 static const WCHAR fmtW
[] =
2822 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2823 unsigned int regs
[4] = {0, 0, 0, 0};
2825 do_cpuid( 1, regs
);
2826 sprintfW( version
, fmtW
, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2828 static UINT16
get_processor_revision(void)
2830 unsigned int regs
[4] = {0, 0, 0, 0};
2831 do_cpuid( 1, regs
);
2834 static void get_processor_id( WCHAR
*processor_id
)
2836 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2837 unsigned int regs
[4] = {0, 0, 0, 0};
2839 do_cpuid( 1, regs
);
2840 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2842 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2845 unsigned char *p
= (unsigned char *)regs
;
2847 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2850 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2852 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2854 do_cpuid( 0, regs
);
2855 tmp
= regs
[2]; /* swap edx and ecx */
2859 regs_to_str( regs
+ 1, 12, manufacturer
);
2861 static void get_processor_name( WCHAR
*name
)
2863 unsigned int regs
[4] = {0, 0, 0, 0};
2865 do_cpuid( 0x80000000, regs
);
2866 if (regs
[0] >= 0x80000004)
2868 do_cpuid( 0x80000002, regs
);
2869 regs_to_str( regs
, 16, name
);
2870 do_cpuid( 0x80000003, regs
);
2871 regs_to_str( regs
, 16, name
+ 16 );
2872 do_cpuid( 0x80000004, regs
);
2873 regs_to_str( regs
, 16, name
+ 32 );
2876 static UINT
get_processor_currentclockspeed( UINT index
)
2878 PROCESSOR_POWER_INFORMATION
*info
;
2879 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2882 if ((info
= heap_alloc( size
)))
2884 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2885 if (!status
) ret
= info
[index
].CurrentMhz
;
2890 static UINT
get_processor_maxclockspeed( UINT index
)
2892 PROCESSOR_POWER_INFORMATION
*info
;
2893 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2896 if ((info
= heap_alloc( size
)))
2898 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2899 if (!status
) ret
= info
[index
].MaxMhz
;
2905 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2907 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2908 WCHAR caption
[100], device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0}, version
[50];
2909 struct record_processor
*rec
;
2910 UINT i
, offset
= 0, num_rows
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2911 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2913 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2915 get_processor_caption( caption
);
2916 get_processor_id( processor_id
);
2917 get_processor_manufacturer( manufacturer
);
2918 get_processor_name( name
);
2919 get_processor_version( version
);
2921 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2924 for (i
= 0; i
< count
; i
++)
2926 rec
= (struct record_processor
*)(table
->data
+ offset
);
2927 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2928 rec
->architecture
= get_osarchitecture() == os_32bitW
? 0 : 9;
2929 rec
->caption
= heap_strdupW( caption
);
2930 rec
->cpu_status
= 1; /* CPU Enabled */
2931 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2932 rec
->datawidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2933 rec
->description
= heap_strdupW( caption
);
2934 sprintfW( device_id
, fmtW
, i
);
2935 rec
->device_id
= heap_strdupW( device_id
);
2936 rec
->family
= 2; /* Unknown */
2938 rec
->manufacturer
= heap_strdupW( manufacturer
);
2939 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2940 rec
->name
= heap_strdupW( name
);
2941 rec
->num_cores
= num_cores
;
2942 rec
->num_logical_processors
= num_logical_processors
;
2943 rec
->processor_id
= heap_strdupW( processor_id
);
2944 rec
->processortype
= 3; /* central processor */
2945 rec
->revision
= get_processor_revision();
2946 rec
->unique_id
= NULL
;
2947 rec
->version
= heap_strdupW( version
);
2948 if (!match_row( table
, i
, cond
, &status
))
2950 free_row_values( table
, i
);
2953 offset
+= sizeof(*rec
);
2957 TRACE("created %u rows\n", num_rows
);
2958 table
->num_rows
= num_rows
;
2962 static WCHAR
*get_lastbootuptime(void)
2964 static const WCHAR fmtW
[] =
2965 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2966 '.','%','0','6','u','+','0','0','0',0};
2967 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2971 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2973 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2974 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2975 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2978 static WCHAR
*get_localdatetime(void)
2980 static const WCHAR fmtW
[] =
2981 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2982 '.','%','0','6','u','%','+','0','3','d',0};
2983 TIME_ZONE_INFORMATION tzi
;
2989 Status
= GetTimeZoneInformation(&tzi
);
2991 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2993 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2994 Bias
+= tzi
.DaylightBias
;
2996 Bias
+= tzi
.StandardBias
;
2997 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
3000 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
3003 static WCHAR
*get_systemdirectory(void)
3008 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
3009 Wow64DisableWow64FsRedirection( &redir
);
3010 GetSystemDirectoryW( ret
, MAX_PATH
);
3011 Wow64RevertWow64FsRedirection( redir
);
3014 static WCHAR
*get_codeset(void)
3016 static const WCHAR fmtW
[] = {'%','u',0};
3017 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
3018 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
3021 static WCHAR
*get_countrycode(void)
3023 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
3024 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
3027 static WCHAR
*get_locale(void)
3029 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
3030 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
3033 static WCHAR
*get_osbuildnumber( OSVERSIONINFOEXW
*ver
)
3035 static const WCHAR fmtW
[] = {'%','u',0};
3036 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
3037 if (ret
) sprintfW( ret
, fmtW
, ver
->dwBuildNumber
);
3040 static WCHAR
*get_oscaption( OSVERSIONINFOEXW
*ver
)
3042 static const WCHAR windowsW
[] =
3043 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
3044 static const WCHAR win2000W
[] =
3045 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3046 static const WCHAR win2003W
[] =
3047 {'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};
3048 static const WCHAR winxpW
[] =
3049 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3050 static const WCHAR winxp64W
[] =
3051 {'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};
3052 static const WCHAR vistaW
[] =
3053 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
3054 static const WCHAR win2008W
[] =
3055 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
3056 static const WCHAR win7W
[] =
3057 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
3058 static const WCHAR win2008r2W
[] =
3059 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
3060 static const WCHAR win8W
[] =
3061 {'8',' ','P','r','o',0};
3062 static const WCHAR win81W
[] =
3063 {'8','.','1',' ','P','r','o',0};
3064 static const WCHAR win10W
[] =
3065 {'1','0',' ','P','r','o',0};
3066 int len
= ARRAY_SIZE( windowsW
);
3069 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(win2003W
) ))) return NULL
;
3070 memcpy( ret
, windowsW
, sizeof(windowsW
) );
3071 if (ver
->dwMajorVersion
== 10 && ver
->dwMinorVersion
== 0) memcpy( ret
+ len
, win10W
, sizeof(win10W
) );
3072 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 3) memcpy( ret
+ len
, win8W
, sizeof(win8W
) );
3073 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 2) memcpy( ret
+ len
, win81W
, sizeof(win81W
) );
3074 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 1)
3076 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, win7W
, sizeof(win7W
) );
3077 else memcpy( ret
+ len
, win2008r2W
, sizeof(win2008r2W
) );
3079 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 0)
3081 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, vistaW
, sizeof(vistaW
) );
3082 else memcpy( ret
+ len
, win2008W
, sizeof(win2008W
) );
3084 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 2)
3086 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, winxp64W
, sizeof(winxp64W
) );
3087 else memcpy( ret
+ len
, win2003W
, sizeof(win2003W
) );
3089 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 1) memcpy( ret
+ len
, winxpW
, sizeof(winxpW
) );
3090 else memcpy( ret
+ len
, win2000W
, sizeof(win2000W
) );
3093 static WCHAR
*get_osname( const WCHAR
*caption
)
3095 static const WCHAR partitionW
[] =
3096 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
3097 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
3098 int len
= strlenW( caption
);
3101 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(partitionW
) ))) return NULL
;
3102 memcpy( ret
, caption
, len
* sizeof(WCHAR
) );
3103 memcpy( ret
+ len
, partitionW
, sizeof(partitionW
) );
3106 static WCHAR
*get_osversion( OSVERSIONINFOEXW
*ver
)
3108 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u',0};
3109 WCHAR
*ret
= heap_alloc( 33 * sizeof(WCHAR
) );
3110 if (ret
) sprintfW( ret
, fmtW
, ver
->dwMajorVersion
, ver
->dwMinorVersion
, ver
->dwBuildNumber
);
3114 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
3116 struct record_operatingsystem
*rec
;
3117 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3118 OSVERSIONINFOEXW ver
;
3121 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3123 ver
.dwOSVersionInfoSize
= sizeof(ver
);
3124 GetVersionExW( (OSVERSIONINFOW
*)&ver
);
3126 rec
= (struct record_operatingsystem
*)table
->data
;
3127 rec
->buildnumber
= get_osbuildnumber( &ver
);
3128 rec
->caption
= get_oscaption( &ver
);
3129 rec
->codeset
= get_codeset();
3130 rec
->countrycode
= get_countrycode();
3131 rec
->csdversion
= ver
.szCSDVersion
[0] ? heap_strdupW( ver
.szCSDVersion
) : NULL
;
3132 rec
->freephysicalmemory
= get_available_physical_memory() / 1024;
3133 rec
->installdate
= os_installdateW
;
3134 rec
->lastbootuptime
= get_lastbootuptime();
3135 rec
->localdatetime
= get_localdatetime();
3136 rec
->locale
= get_locale();
3137 rec
->name
= get_osname( rec
->caption
);
3138 rec
->osarchitecture
= get_osarchitecture();
3139 rec
->oslanguage
= GetSystemDefaultLangID();
3140 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
3141 rec
->ostype
= 18; /* WINNT */
3143 rec
->serialnumber
= os_serialnumberW
;
3144 rec
->servicepackmajor
= ver
.wServicePackMajor
;
3145 rec
->servicepackminor
= ver
.wServicePackMinor
;
3146 rec
->suitemask
= 272; /* Single User + Terminal */
3147 rec
->systemdirectory
= get_systemdirectory();
3148 rec
->totalvirtualmemorysize
= get_total_physical_memory() / 1024;
3149 rec
->totalvisiblememorysize
= rec
->totalvirtualmemorysize
;
3150 rec
->version
= get_osversion( &ver
);
3151 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3154 TRACE("created %u rows\n", row
);
3155 table
->num_rows
= row
;
3159 static const WCHAR
*get_service_type( DWORD type
)
3161 static const WCHAR filesystem_driverW
[] =
3162 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
3163 static const WCHAR kernel_driverW
[] =
3164 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
3165 static const WCHAR own_processW
[] =
3166 {'O','w','n',' ','P','r','o','c','e','s','s',0};
3167 static const WCHAR share_processW
[] =
3168 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
3170 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
3171 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
3172 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
3173 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
3174 else ERR("unhandled type 0x%08x\n", type
);
3177 static const WCHAR
*get_service_state( DWORD state
)
3179 static const WCHAR runningW
[] =
3180 {'R','u','n','n','i','n','g',0};
3181 static const WCHAR start_pendingW
[] =
3182 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
3183 static const WCHAR stop_pendingW
[] =
3184 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
3185 static const WCHAR stoppedW
[] =
3186 {'S','t','o','p','p','e','d',0};
3187 static const WCHAR unknownW
[] =
3188 {'U','n','k','n','o','w','n',0};
3192 case SERVICE_STOPPED
: return stoppedW
;
3193 case SERVICE_START_PENDING
: return start_pendingW
;
3194 case SERVICE_STOP_PENDING
: return stop_pendingW
;
3195 case SERVICE_RUNNING
: return runningW
;
3197 ERR("unknown state %u\n", state
);
3201 static const WCHAR
*get_service_startmode( DWORD mode
)
3203 static const WCHAR bootW
[] = {'B','o','o','t',0};
3204 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
3205 static const WCHAR autoW
[] = {'A','u','t','o',0};
3206 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
3207 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
3208 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
3212 case SERVICE_BOOT_START
: return bootW
;
3213 case SERVICE_SYSTEM_START
: return systemW
;
3214 case SERVICE_AUTO_START
: return autoW
;
3215 case SERVICE_DEMAND_START
: return manualW
;
3216 case SERVICE_DISABLED
: return disabledW
;
3218 ERR("unknown mode 0x%x\n", mode
);
3222 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
3224 QUERY_SERVICE_CONFIGW
*config
= NULL
;
3228 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
3229 QueryServiceConfigW( service
, NULL
, 0, &size
);
3230 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
3231 if (!(config
= heap_alloc( size
))) goto done
;
3232 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
3233 heap_free( config
);
3237 CloseServiceHandle( service
);
3241 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
3243 struct record_service
*rec
;
3245 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
3246 SERVICE_STATUS_PROCESS
*status
;
3247 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
3248 DWORD len
= ARRAY_SIZE( sysnameW
);
3249 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
3250 enum fill_status fill_status
= FILL_STATUS_FAILED
;
3253 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
3254 if (!(services
= heap_alloc( size
))) goto done
;
3256 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
3257 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
3258 &count
, NULL
, NULL
);
3261 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
3263 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
3265 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
3266 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
3267 &count
, NULL
, NULL
);
3268 if (!ret
) goto done
;
3270 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
3272 GetComputerNameW( sysnameW
, &len
);
3273 fill_status
= FILL_STATUS_UNFILTERED
;
3275 for (i
= 0; i
< count
; i
++)
3277 QUERY_SERVICE_CONFIGW
*config
;
3279 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
3281 status
= &services
[i
].ServiceStatusProcess
;
3282 rec
= (struct record_service
*)(table
->data
+ offset
);
3283 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
3284 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
3285 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
3286 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
3287 rec
->process_id
= status
->dwProcessId
;
3288 rec
->servicetype
= get_service_type( status
->dwServiceType
);
3289 rec
->startmode
= get_service_startmode( config
->dwStartType
);
3290 rec
->state
= get_service_state( status
->dwCurrentState
);
3291 rec
->systemname
= heap_strdupW( sysnameW
);
3292 rec
->pause_service
= service_pause_service
;
3293 rec
->resume_service
= service_resume_service
;
3294 rec
->start_service
= service_start_service
;
3295 rec
->stop_service
= service_stop_service
;
3296 heap_free( config
);
3297 if (!match_row( table
, row
, cond
, &fill_status
))
3299 free_row_values( table
, row
);
3302 offset
+= sizeof(*rec
);
3306 TRACE("created %u rows\n", row
);
3307 table
->num_rows
= row
;
3310 CloseServiceHandle( manager
);
3311 heap_free( services
);
3315 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
3317 if (!name
|| !name
->Name
.Buffer
) return NULL
;
3318 return heap_strdupW( name
->Name
.Buffer
);
3320 static struct array
*get_binaryrepresentation( PSID sid
, UINT len
)
3322 struct array
*array
= heap_alloc( sizeof(struct array
) );
3325 UINT8
*ret
= heap_alloc( len
);
3328 memcpy( ret
, sid
, len
);
3337 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
3339 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
3340 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
3342 static const WCHAR
*find_sid_str( const struct expr
*cond
)
3344 const struct expr
*left
, *right
;
3345 const WCHAR
*ret
= NULL
;
3347 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
3349 left
= cond
->u
.expr
.left
;
3350 right
= cond
->u
.expr
.right
;
3351 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
3353 ret
= right
->u
.sval
;
3355 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
3362 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
3365 LSA_REFERENCED_DOMAIN_LIST
*domain
;
3366 LSA_TRANSLATED_NAME
*name
;
3368 LSA_OBJECT_ATTRIBUTES attrs
;
3370 struct record_sid
*rec
;
3373 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
3374 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3376 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
3377 len
= GetLengthSid( sid
);
3379 memset( &attrs
, 0, sizeof(attrs
) );
3380 attrs
.Length
= sizeof(attrs
);
3381 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
3384 return FILL_STATUS_FAILED
;
3386 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
3390 return FILL_STATUS_FAILED
;
3393 rec
= (struct record_sid
*)table
->data
;
3394 rec
->accountname
= get_accountname( name
);
3395 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
3396 rec
->referenceddomainname
= get_referenceddomainname( domain
);
3397 rec
->sid
= heap_strdupW( str
);
3398 rec
->sidlength
= len
;
3400 TRACE("created 1 row\n");
3401 table
->num_rows
= 1;
3403 LsaFreeMemory( domain
);
3404 LsaFreeMemory( name
);
3407 return FILL_STATUS_FILTERED
;
3410 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
3412 HDC hdc
= GetDC( NULL
);
3415 if (!hdc
) return 32;
3416 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
3417 *hres
= GetDeviceCaps( hdc
, HORZRES
);
3418 *vres
= GetDeviceCaps( hdc
, VERTRES
);
3419 ReleaseDC( NULL
, hdc
);
3422 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
3424 static const WCHAR fmtW
[] =
3425 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
3426 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
3427 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
3430 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
3431 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
3435 #define HW_VENDOR_AMD 0x1002
3436 #define HW_VENDOR_NVIDIA 0x10de
3437 #define HW_VENDOR_VMWARE 0x15ad
3438 #define HW_VENDOR_INTEL 0x8086
3440 static const WCHAR
*get_installeddriver( UINT vendorid
)
3442 static const WCHAR driver_amdW
[] = {'a','t','i','c','f','x','3','2','.','d','l','l',0};
3443 static const WCHAR driver_intelW
[] = {'i','g','d','u','m','d','i','m','3','2','.','d','l','l',0};
3444 static const WCHAR driver_nvidiaW
[] = {'n','v','d','3','d','u','m','.','d','l','l',0};
3445 static const WCHAR driver_wineW
[] = {'w','i','n','e','.','d','l','l',0};
3447 /* FIXME: wined3d has a better table, but we cannot access this information through dxgi */
3449 if (vendorid
== HW_VENDOR_AMD
)
3451 else if (vendorid
== HW_VENDOR_NVIDIA
)
3452 return driver_nvidiaW
;
3453 else if (vendorid
== HW_VENDOR_INTEL
)
3454 return driver_intelW
;
3455 return driver_wineW
;
3458 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
3460 static const WCHAR fmtW
[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
3461 struct record_videocontroller
*rec
;
3463 IDXGIFactory
*factory
= NULL
;
3464 IDXGIAdapter
*adapter
= NULL
;
3465 DXGI_ADAPTER_DESC desc
;
3466 UINT row
= 0, hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
3467 const WCHAR
*name
= videocontroller_deviceidW
;
3468 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3471 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3473 memset (&desc
, 0, sizeof(desc
));
3474 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
3475 if (FAILED(hr
)) goto done
;
3477 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
3478 if (FAILED(hr
)) goto done
;
3480 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
3483 vidmem
= desc
.DedicatedVideoMemory
;
3484 name
= desc
.Description
;
3488 rec
= (struct record_videocontroller
*)table
->data
;
3489 rec
->adapter_dactype
= videocontroller_dactypeW
;
3490 rec
->adapter_ram
= vidmem
;
3491 rec
->availability
= 3; /* Running or Full Power */
3492 rec
->config_errorcode
= 0; /* no error */
3493 rec
->caption
= heap_strdupW( name
);
3494 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
3495 rec
->current_horizontalres
= hres
;
3496 rec
->current_refreshrate
= 0; /* default refresh rate */
3497 rec
->current_scanmode
= 2; /* Unknown */
3498 rec
->current_verticalres
= vres
;
3499 rec
->description
= heap_strdupW( name
);
3500 rec
->device_id
= videocontroller_deviceidW
;
3501 rec
->driverdate
= videocontroller_driverdateW
;
3502 rec
->driverversion
= videocontroller_driverversionW
;
3503 rec
->installeddriver
= get_installeddriver( desc
.VendorId
);
3504 rec
->name
= heap_strdupW( name
);
3505 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
3506 rec
->status
= videocontroller_statusW
;
3507 rec
->videoarchitecture
= 2; /* Unknown */
3508 rec
->videomemorytype
= 2; /* Unknown */
3509 wsprintfW( mode
, fmtW
, hres
, vres
, (UINT64
)1 << rec
->current_bitsperpixel
);
3510 rec
->videomodedescription
= heap_strdupW( mode
);
3511 rec
->videoprocessor
= heap_strdupW( name
);
3512 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3515 TRACE("created %u rows\n", row
);
3516 table
->num_rows
= row
;
3518 if (adapter
) IDXGIAdapter_Release( adapter
);
3519 if (factory
) IDXGIFactory_Release( factory
);
3523 static struct table builtin_classes
[] =
3525 { class_baseboardW
, ARRAY_SIZE(col_baseboard
), col_baseboard
, ARRAY_SIZE(data_baseboard
), 0, (BYTE
*)data_baseboard
},
3526 { class_biosW
, ARRAY_SIZE(col_bios
), col_bios
, ARRAY_SIZE(data_bios
), 0, (BYTE
*)data_bios
},
3527 { class_cdromdriveW
, ARRAY_SIZE(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
3528 { class_compsysW
, ARRAY_SIZE(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
3529 { class_compsysproductW
, ARRAY_SIZE(col_compsysproduct
), col_compsysproduct
, 0, 0, NULL
, fill_compsysproduct
},
3530 { class_datafileW
, ARRAY_SIZE(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
3531 { class_desktopmonitorW
, ARRAY_SIZE(col_desktopmonitor
), col_desktopmonitor
, 0, 0, NULL
, fill_desktopmonitor
},
3532 { class_directoryW
, ARRAY_SIZE(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
3533 { class_diskdriveW
, ARRAY_SIZE(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
3534 { class_diskpartitionW
, ARRAY_SIZE(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
3535 { class_ip4routetableW
, ARRAY_SIZE(col_ip4routetable
), col_ip4routetable
, 0, 0, NULL
, fill_ip4routetable
},
3536 { class_logicaldiskW
, ARRAY_SIZE(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3537 { class_logicaldisk2W
, ARRAY_SIZE(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3538 { class_networkadapterW
, ARRAY_SIZE(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
3539 { class_networkadapterconfigW
, ARRAY_SIZE(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
3540 { class_osW
, ARRAY_SIZE(col_os
), col_os
, 0, 0, NULL
, fill_os
},
3541 { class_paramsW
, ARRAY_SIZE(col_param
), col_param
, ARRAY_SIZE(data_param
), 0, (BYTE
*)data_param
},
3542 { class_physicalmediaW
, ARRAY_SIZE(col_physicalmedia
), col_physicalmedia
, ARRAY_SIZE(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
3543 { class_physicalmemoryW
, ARRAY_SIZE(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
3544 { class_pnpentityW
, ARRAY_SIZE(col_pnpentity
), col_pnpentity
, 0, 0, NULL
, fill_pnpentity
},
3545 { class_printerW
, ARRAY_SIZE(col_printer
), col_printer
, 0, 0, NULL
, fill_printer
},
3546 { class_processW
, ARRAY_SIZE(col_process
), col_process
, 0, 0, NULL
, fill_process
},
3547 { class_processorW
, ARRAY_SIZE(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3548 { class_processor2W
, ARRAY_SIZE(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3549 { class_qualifiersW
, ARRAY_SIZE(col_qualifier
), col_qualifier
, ARRAY_SIZE(data_qualifier
), 0, (BYTE
*)data_qualifier
},
3550 { class_serviceW
, ARRAY_SIZE(col_service
), col_service
, 0, 0, NULL
, fill_service
},
3551 { class_sidW
, ARRAY_SIZE(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
3552 { class_sounddeviceW
, ARRAY_SIZE(col_sounddevice
), col_sounddevice
, ARRAY_SIZE(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
3553 { class_stdregprovW
, ARRAY_SIZE(col_stdregprov
), col_stdregprov
, ARRAY_SIZE(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
3554 { class_systemsecurityW
, ARRAY_SIZE(col_systemsecurity
), col_systemsecurity
, ARRAY_SIZE(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
3555 { class_systemenclosureW
, ARRAY_SIZE(col_systemenclosure
), col_systemenclosure
, ARRAY_SIZE(data_systemenclosure
), 0, (BYTE
*)data_systemenclosure
},
3556 { class_videocontrollerW
, ARRAY_SIZE(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
3559 void init_table_list( void )
3561 static struct list tables
= LIST_INIT( tables
);
3564 for (i
= 0; i
< ARRAY_SIZE(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
3565 table_list
= &tables
;