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
27 #define WIN32_NO_STATUS
42 #include "wine/debug.h"
43 #include "wbemprox_private.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
47 static const WCHAR class_baseboardW
[] =
48 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
49 static const WCHAR class_biosW
[] =
50 {'W','i','n','3','2','_','B','I','O','S',0};
51 static const WCHAR class_cdromdriveW
[] =
52 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
53 static const WCHAR class_compsysW
[] =
54 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
55 static const WCHAR class_datafileW
[] =
56 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
57 static const WCHAR class_directoryW
[] =
58 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
59 static const WCHAR class_diskdriveW
[] =
60 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
61 static const WCHAR class_diskpartitionW
[] =
62 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
63 static const WCHAR class_logicaldiskW
[] =
64 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
65 static const WCHAR class_logicaldisk2W
[] =
66 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
67 static const WCHAR class_networkadapterW
[] =
68 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
69 static const WCHAR class_networkadapterconfigW
[] =
70 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
71 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
72 static const WCHAR class_osW
[] =
73 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
74 static const WCHAR class_paramsW
[] =
75 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
76 static const WCHAR class_physicalmediaW
[] =
77 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
78 static const WCHAR class_physicalmemoryW
[] =
79 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
80 static const WCHAR class_qualifiersW
[] =
81 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
82 static const WCHAR class_process_getowner_outW
[] =
83 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
84 'N','E','R','_','O','U','T',0};
85 static const WCHAR class_processorW
[] =
86 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
87 static const WCHAR class_processor2W
[] =
88 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
89 static const WCHAR class_sounddeviceW
[] =
90 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
91 static const WCHAR class_videocontrollerW
[] =
92 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
94 static const WCHAR prop_acceptpauseW
[] =
95 {'A','c','c','e','p','t','P','a','u','s','e',0};
96 static const WCHAR prop_acceptstopW
[] =
97 {'A','c','c','e','p','t','S','t','o','p',0};
98 static const WCHAR prop_accessmaskW
[] =
99 {'A','c','c','e','s','s','M','a','s','k',0};
100 static const WCHAR prop_adapterdactypeW
[] =
101 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
102 static const WCHAR prop_adapterramW
[] =
103 {'A','d','a','p','t','e','r','R','A','M',0};
104 static const WCHAR prop_adaptertypeW
[] =
105 {'A','d','a','p','t','e','r','T','y','p','e',0};
106 static const WCHAR prop_addresswidthW
[] =
107 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
108 static const WCHAR prop_availabilityW
[] =
109 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
110 static const WCHAR prop_bootableW
[] =
111 {'B','o','o','t','a','b','l','e',0};
112 static const WCHAR prop_bootpartitionW
[] =
113 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
114 static const WCHAR prop_buildnumberW
[] =
115 {'B','u','i','l','d','N','u','m','b','e','r',0};
116 static const WCHAR prop_capacityW
[] =
117 {'C','a','p','a','c','i','t','y',0};
118 static const WCHAR prop_captionW
[] =
119 {'C','a','p','t','i','o','n',0};
120 static const WCHAR prop_classW
[] =
121 {'C','l','a','s','s',0};
122 static const WCHAR prop_codesetW
[] =
123 {'C','o','d','e','S','e','t',0};
124 static const WCHAR prop_commandlineW
[] =
125 {'C','o','m','m','a','n','d','L','i','n','e',0};
126 static const WCHAR prop_countrycodeW
[] =
127 {'C','o','u','n','t','r','y','C','o','d','e',0};
128 static const WCHAR prop_cpustatusW
[] =
129 {'C','p','u','S','t','a','t','u','s',0};
130 static const WCHAR prop_csdversionW
[] =
131 {'C','S','D','V','e','r','s','i','o','n',0};
132 static const WCHAR prop_currentbitsperpixelW
[] =
133 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
134 static const WCHAR prop_currentclockspeedW
[] =
135 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
136 static const WCHAR prop_currenthorizontalresW
[] =
137 {'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};
138 static const WCHAR prop_currentverticalresW
[] =
139 {'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};
140 static const WCHAR prop_defaultvalueW
[] =
141 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
142 static const WCHAR prop_descriptionW
[] =
143 {'D','e','s','c','r','i','p','t','i','o','n',0};
144 static const WCHAR prop_deviceidW
[] =
145 {'D','e','v','i','c','e','I','d',0};
146 static const WCHAR prop_directionW
[] =
147 {'D','i','r','e','c','t','i','o','n',0};
148 static const WCHAR prop_displaynameW
[] =
149 {'D','i','s','p','l','a','y','N','a','m','e',0};
150 static const WCHAR prop_diskindexW
[] =
151 {'D','i','s','k','I','n','d','e','x',0};
152 static const WCHAR prop_domainW
[] =
153 {'D','o','m','a','i','n',0};
154 static const WCHAR prop_domainroleW
[] =
155 {'D','o','m','a','i','n','R','o','l','e',0};
156 static const WCHAR prop_driveW
[] =
157 {'D','r','i','v','e',0};
158 static const WCHAR prop_drivetypeW
[] =
159 {'D','r','i','v','e','T','y','p','e',0};
160 static const WCHAR prop_familyW
[] =
161 {'F','a','m','i','l','y',0};
162 static const WCHAR prop_filesystemW
[] =
163 {'F','i','l','e','S','y','s','t','e','m',0};
164 static const WCHAR prop_flavorW
[] =
165 {'F','l','a','v','o','r',0};
166 static const WCHAR prop_freespaceW
[] =
167 {'F','r','e','e','S','p','a','c','e',0};
168 static const WCHAR prop_handleW
[] =
169 {'H','a','n','d','l','e',0};
170 static const WCHAR prop_idW
[] =
172 static const WCHAR prop_identificationcodeW
[] =
173 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
174 static const WCHAR prop_indexW
[] =
175 {'I','n','d','e','x',0};
176 static const WCHAR prop_installdateW
[] =
177 {'I','n','s','t','a','l','l','D','a','t','e',0};
178 static const WCHAR prop_interfaceindexW
[] =
179 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
180 static const WCHAR prop_interfacetypeW
[] =
181 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
182 static const WCHAR prop_intvalueW
[] =
183 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
184 static const WCHAR prop_ipconnectionmetricW
[] =
185 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
186 static const WCHAR prop_ipenabledW
[] =
187 {'I','P','E','n','a','b','l','e','d',0};
188 static const WCHAR prop_lastbootuptimeW
[] =
189 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
190 static const WCHAR prop_localdatetimeW
[] =
191 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
192 static const WCHAR prop_localeW
[] =
193 {'L','o','c','a','l','e',0};
194 static const WCHAR prop_macaddressW
[] =
195 {'M','A','C','A','d','d','r','e','s','s',0};
196 static const WCHAR prop_manufacturerW
[] =
197 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
198 static const WCHAR prop_maxclockspeedW
[] =
199 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
200 static const WCHAR prop_mediatypeW
[] =
201 {'M','e','d','i','a','T','y','p','e',0};
202 static const WCHAR prop_memberW
[] =
203 {'M','e','m','b','e','r',0};
204 static const WCHAR prop_methodW
[] =
205 {'M','e','t','h','o','d',0};
206 static const WCHAR prop_modelW
[] =
207 {'M','o','d','e','l',0};
208 static const WCHAR prop_netconnectionstatusW
[] =
209 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
210 static const WCHAR prop_numcoresW
[] =
211 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
212 static const WCHAR prop_numlogicalprocessorsW
[] =
213 {'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};
214 static const WCHAR prop_numprocessorsW
[] =
215 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
216 static const WCHAR prop_osarchitectureW
[] =
217 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
218 static const WCHAR prop_oslanguageW
[] =
219 {'O','S','L','a','n','g','u','a','g','e',0};
220 static const WCHAR prop_osproductsuiteW
[] =
221 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
222 static const WCHAR prop_ostypeW
[] =
223 {'O','S','T','y','p','e',0};
224 static const WCHAR prop_parameterW
[] =
225 {'P','a','r','a','m','e','t','e','r',0};
226 static const WCHAR prop_physicaladapterW
[] =
227 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
228 static const WCHAR prop_pnpdeviceidW
[] =
229 {'P','N','P','D','e','v','i','c','e','I','D',0};
230 static const WCHAR prop_pprocessidW
[] =
231 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
232 static const WCHAR prop_processidW
[] =
233 {'P','r','o','c','e','s','s','I','D',0};
234 static const WCHAR prop_processoridW
[] =
235 {'P','r','o','c','e','s','s','o','r','I','d',0};
236 static const WCHAR prop_productnameW
[] =
237 {'P','r','o','d','u','c','t','N','a','m','e',0};
238 static const WCHAR prop_releasedateW
[] =
239 {'R','e','l','e','a','s','e','D','a','t','e',0};
240 static const WCHAR prop_serialnumberW
[] =
241 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
242 static const WCHAR prop_servicepackmajorW
[] =
243 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
244 static const WCHAR prop_servicepackminorW
[] =
245 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
246 static const WCHAR prop_servicetypeW
[] =
247 {'S','e','r','v','i','c','e','T','y','p','e',0};
248 static const WCHAR prop_smbiosbiosversionW
[] =
249 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
250 static const WCHAR prop_startmodeW
[] =
251 {'S','t','a','r','t','M','o','d','e',0};
252 static const WCHAR prop_sizeW
[] =
254 static const WCHAR prop_speedW
[] =
255 {'S','p','e','e','d',0};
256 static const WCHAR prop_startingoffsetW
[] =
257 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
258 static const WCHAR prop_stateW
[] =
259 {'S','t','a','t','e',0};
260 static const WCHAR prop_strvalueW
[] =
261 {'S','t','r','i','n','g','V','a','l','u','e',0};
262 static const WCHAR prop_suitemaskW
[] =
263 {'S','u','i','t','e','M','a','s','k',0};
264 static const WCHAR prop_systemdirectoryW
[] =
265 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
266 static const WCHAR prop_systemnameW
[] =
267 {'S','y','s','t','e','m','N','a','m','e',0};
268 static const WCHAR prop_tagW
[] =
270 static const WCHAR prop_threadcountW
[] =
271 {'T','h','r','e','a','d','C','o','u','n','t',0};
272 static const WCHAR prop_totalphysicalmemoryW
[] =
273 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
274 static const WCHAR prop_typeW
[] =
276 static const WCHAR prop_uniqueidW
[] =
277 {'U','n','i','q','u','e','I','d',0};
278 static const WCHAR prop_varianttypeW
[] =
279 {'V','a','r','i','a','n','t','T','y','p','e',0};
280 static const WCHAR prop_versionW
[] =
281 {'V','e','r','s','i','o','n',0};
282 static const WCHAR prop_volumeserialnumberW
[] =
283 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
285 /* column definitions must be kept in sync with record structures below */
286 static const struct column col_baseboard
[] =
288 { prop_manufacturerW
, CIM_STRING
},
289 { prop_modelW
, CIM_STRING
},
290 { prop_nameW
, CIM_STRING
},
291 { prop_serialnumberW
, CIM_STRING
},
292 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
294 static const struct column col_bios
[] =
296 { prop_descriptionW
, CIM_STRING
},
297 { prop_identificationcodeW
, CIM_STRING
},
298 { prop_manufacturerW
, CIM_STRING
},
299 { prop_releasedateW
, CIM_DATETIME
},
300 { prop_serialnumberW
, CIM_STRING
},
301 { prop_smbiosbiosversionW
, CIM_STRING
},
302 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
304 static const struct column col_cdromdrive
[] =
306 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
307 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
308 { prop_mediatypeW
, CIM_STRING
},
309 { prop_nameW
, CIM_STRING
},
310 { prop_pnpdeviceidW
, CIM_STRING
}
312 static const struct column col_compsys
[] =
314 { prop_descriptionW
, CIM_STRING
},
315 { prop_domainW
, CIM_STRING
},
316 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
317 { prop_manufacturerW
, CIM_STRING
},
318 { prop_modelW
, CIM_STRING
},
319 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
320 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
321 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
322 { prop_totalphysicalmemoryW
, CIM_UINT64
}
324 static const struct column col_datafile
[] =
326 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
327 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
329 static const struct column col_directory
[] =
331 { prop_accessmaskW
, CIM_UINT32
},
332 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
334 static const struct column col_diskdrive
[] =
336 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
337 { prop_indexW
, CIM_UINT32
, VT_I4
},
338 { prop_interfacetypeW
, CIM_STRING
},
339 { prop_manufacturerW
, CIM_STRING
},
340 { prop_mediatypeW
, CIM_STRING
},
341 { prop_modelW
, CIM_STRING
},
342 { prop_serialnumberW
, CIM_STRING
},
343 { prop_sizeW
, CIM_UINT64
}
345 static const struct column col_diskpartition
[] =
347 { prop_bootableW
, CIM_BOOLEAN
},
348 { prop_bootpartitionW
, CIM_BOOLEAN
},
349 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
350 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
351 { prop_indexW
, CIM_UINT32
, VT_I4
},
352 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
353 { prop_sizeW
, CIM_UINT64
},
354 { prop_startingoffsetW
, CIM_UINT64
},
355 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
357 static const struct column col_logicaldisk
[] =
359 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
360 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
361 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
362 { prop_freespaceW
, CIM_UINT64
},
363 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
364 { prop_sizeW
, CIM_UINT64
},
365 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
367 static const struct column col_networkadapter
[] =
369 { prop_adaptertypeW
, CIM_STRING
},
370 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
371 { prop_indexW
, CIM_UINT32
, VT_I4
},
372 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
373 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
374 { prop_manufacturerW
, CIM_STRING
},
375 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
376 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
377 { prop_physicaladapterW
, CIM_BOOLEAN
},
378 { prop_pnpdeviceidW
, CIM_STRING
},
379 { prop_speedW
, CIM_UINT64
}
381 static const struct column col_networkadapterconfig
[] =
383 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
384 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
385 { prop_ipenabledW
, CIM_BOOLEAN
},
386 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
388 static const struct column col_os
[] =
390 { prop_buildnumberW
, CIM_STRING
},
391 { prop_captionW
, CIM_STRING
},
392 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
393 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
394 { prop_csdversionW
, CIM_STRING
},
395 { prop_installdateW
, CIM_DATETIME
},
396 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
397 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
398 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
399 { prop_nameW
, CIM_STRING
},
400 { prop_osarchitectureW
, CIM_STRING
},
401 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
402 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
403 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
404 { prop_serialnumberW
, CIM_STRING
},
405 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
406 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
407 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
408 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
409 { prop_versionW
, CIM_STRING
}
411 static const struct column col_param
[] =
413 { prop_classW
, CIM_STRING
},
414 { prop_methodW
, CIM_STRING
},
415 { prop_directionW
, CIM_SINT32
},
416 { prop_parameterW
, CIM_STRING
},
417 { prop_typeW
, CIM_UINT32
},
418 { prop_varianttypeW
, CIM_UINT32
},
419 { prop_defaultvalueW
, CIM_UINT32
}
421 static const struct column col_physicalmedia
[] =
423 { prop_serialnumberW
, CIM_STRING
},
424 { prop_tagW
, CIM_STRING
}
426 static const struct column col_physicalmemory
[] =
428 { prop_capacityW
, CIM_UINT64
}
430 static const struct column col_process
[] =
432 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
433 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
434 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
435 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
436 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
437 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
438 { prop_processidW
, CIM_UINT32
, VT_I4
},
439 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
441 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
443 static const struct column col_processor
[] =
445 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
446 { prop_cpustatusW
, CIM_UINT16
},
447 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
448 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
449 { prop_familyW
, CIM_UINT16
, VT_I4
},
450 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
451 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
452 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
453 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
454 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
455 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
456 { prop_uniqueidW
, CIM_STRING
}
458 static const struct column col_qualifier
[] =
460 { prop_classW
, CIM_STRING
},
461 { prop_memberW
, CIM_STRING
},
462 { prop_typeW
, CIM_UINT32
},
463 { prop_flavorW
, CIM_SINT32
},
464 { prop_nameW
, CIM_STRING
},
465 { prop_intvalueW
, CIM_SINT32
},
466 { prop_strvalueW
, CIM_STRING
}
468 static const struct column col_service
[] =
470 { prop_acceptpauseW
, CIM_BOOLEAN
},
471 { prop_acceptstopW
, CIM_BOOLEAN
},
472 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
473 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
474 { prop_processidW
, CIM_UINT32
},
475 { prop_servicetypeW
, CIM_STRING
},
476 { prop_startmodeW
, CIM_STRING
},
477 { prop_stateW
, CIM_STRING
},
478 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
480 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
481 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
482 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
483 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
485 static const struct column col_sounddevice
[] =
487 { prop_nameW
, CIM_STRING
},
488 { prop_productnameW
, CIM_STRING
}
490 static const struct column col_stdregprov
[] =
492 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
493 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
494 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
496 static const struct column col_systemsecurity
[] =
498 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
499 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
501 static const struct column col_videocontroller
[] =
503 { prop_adapterdactypeW
, CIM_STRING
},
504 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
505 { prop_availabilityW
, CIM_UINT16
},
506 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
507 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
508 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
509 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
510 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
511 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
512 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
515 static const WCHAR baseboard_manufacturerW
[] =
516 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
517 static const WCHAR baseboard_serialnumberW
[] =
519 static const WCHAR baseboard_tagW
[] =
520 {'B','a','s','e',' ','B','o','a','r','d',0};
521 static const WCHAR bios_descriptionW
[] =
522 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
523 static const WCHAR bios_manufacturerW
[] =
524 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
525 static const WCHAR bios_releasedateW
[] =
526 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
527 static const WCHAR bios_serialnumberW
[] =
529 static const WCHAR bios_smbiosbiosversionW
[] =
531 static const WCHAR bios_versionW
[] =
532 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
533 static const WCHAR cdromdrive_mediatypeW
[] =
534 {'C','D','-','R','O','M',0};
535 static const WCHAR cdromdrive_nameW
[] =
536 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
537 static const WCHAR cdromdrive_pnpdeviceidW
[]=
538 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
539 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
540 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
541 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
542 static const WCHAR compsys_descriptionW
[] =
543 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
544 static const WCHAR compsys_domainW
[] =
545 {'W','O','R','K','G','R','O','U','P',0};
546 static const WCHAR compsys_manufacturerW
[] =
547 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
548 static const WCHAR compsys_modelW
[] =
550 static const WCHAR diskdrive_interfacetypeW
[] =
552 static const WCHAR diskdrive_manufacturerW
[] =
553 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
554 static const WCHAR diskdrive_mediatype_fixedW
[] =
555 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
556 static const WCHAR diskdrive_mediatype_removableW
[] =
557 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
558 static const WCHAR diskdrive_modelW
[] =
559 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
560 static const WCHAR diskdrive_serialW
[] =
561 {'W','I','N','E','H','D','I','S','K',0};
562 static const WCHAR networkadapter_pnpdeviceidW
[]=
563 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
564 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
565 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
566 static const WCHAR os_32bitW
[] =
567 {'3','2','-','b','i','t',0};
568 static const WCHAR os_64bitW
[] =
569 {'6','4','-','b','i','t',0};
570 static const WCHAR os_buildnumberW
[] =
572 static const WCHAR os_captionW
[] =
573 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
574 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
575 static const WCHAR os_csdversionW
[] =
576 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
577 static const WCHAR os_installdateW
[] =
578 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
579 static const WCHAR os_nameW
[] =
580 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
581 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
582 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
583 '\\','P','a','r','t','i','t','i','o','n','1',0};
584 static const WCHAR os_serialnumberW
[] =
585 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
586 static const WCHAR os_versionW
[] =
587 {'5','.','1','.','2','6','0','0',0};
588 static const WCHAR physicalmedia_tagW
[] =
589 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
590 static const WCHAR sounddevice_productnameW
[] =
591 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
592 static const WCHAR videocontroller_dactypeW
[] =
593 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
594 static const WCHAR videocontroller_deviceidW
[] =
595 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
597 #include "pshpack1.h"
598 struct record_baseboard
600 const WCHAR
*manufacturer
;
603 const WCHAR
*serialnumber
;
608 const WCHAR
*description
;
609 const WCHAR
*identificationcode
;
610 const WCHAR
*manufacturer
;
611 const WCHAR
*releasedate
;
612 const WCHAR
*serialnumber
;
613 const WCHAR
*smbiosbiosversion
;
614 const WCHAR
*version
;
616 struct record_cdromdrive
618 const WCHAR
*device_id
;
620 const WCHAR
*mediatype
;
622 const WCHAR
*pnpdevice_id
;
624 struct record_computersystem
626 const WCHAR
*description
;
629 const WCHAR
*manufacturer
;
632 UINT32 num_logical_processors
;
633 UINT32 num_processors
;
634 UINT64 total_physical_memory
;
636 struct record_datafile
639 const WCHAR
*version
;
641 struct record_directory
646 struct record_diskdrive
648 const WCHAR
*device_id
;
650 const WCHAR
*interfacetype
;
651 const WCHAR
*manufacturer
;
652 const WCHAR
*mediatype
;
654 const WCHAR
*serialnumber
;
657 struct record_diskpartition
661 const WCHAR
*device_id
;
664 const WCHAR
*pnpdevice_id
;
666 UINT64 startingoffset
;
669 struct record_logicaldisk
671 const WCHAR
*device_id
;
673 const WCHAR
*filesystem
;
677 const WCHAR
*volumeserialnumber
;
679 struct record_networkadapter
681 const WCHAR
*adaptertype
;
682 const WCHAR
*device_id
;
684 UINT32 interface_index
;
685 const WCHAR
*mac_address
;
686 const WCHAR
*manufacturer
;
688 UINT16 netconnection_status
;
690 const WCHAR
*pnpdevice_id
;
693 struct record_networkadapterconfig
696 UINT32 ipconnectionmetric
;
698 const WCHAR
*mac_address
;
700 struct record_operatingsystem
702 const WCHAR
*buildnumber
;
703 const WCHAR
*caption
;
704 const WCHAR
*codeset
;
705 const WCHAR
*countrycode
;
706 const WCHAR
*csdversion
;
707 const WCHAR
*installdate
;
708 const WCHAR
*lastbootuptime
;
709 const WCHAR
*localdatetime
;
712 const WCHAR
*osarchitecture
;
714 UINT32 osproductsuite
;
716 const WCHAR
*serialnumber
;
717 UINT16 servicepackmajor
;
718 UINT16 servicepackminor
;
720 const WCHAR
*systemdirectory
;
721 const WCHAR
*version
;
728 const WCHAR
*parameter
;
733 struct record_physicalmedia
735 const WCHAR
*serialnumber
;
738 struct record_physicalmemory
742 struct record_process
744 const WCHAR
*caption
;
745 const WCHAR
*commandline
;
746 const WCHAR
*description
;
753 class_method
*get_owner
;
755 struct record_processor
759 UINT32 currentclockspeed
;
760 const WCHAR
*device_id
;
762 const WCHAR
*manufacturer
;
763 UINT32 maxclockspeed
;
766 UINT32 num_logical_processors
;
767 const WCHAR
*processor_id
;
768 const WCHAR
*unique_id
;
770 struct record_qualifier
778 const WCHAR
*strvalue
;
780 struct record_service
784 const WCHAR
*displayname
;
787 const WCHAR
*servicetype
;
788 const WCHAR
*startmode
;
790 const WCHAR
*systemname
;
792 class_method
*pause_service
;
793 class_method
*resume_service
;
794 class_method
*start_service
;
795 class_method
*stop_service
;
797 struct record_sounddevice
800 const WCHAR
*productname
;
802 struct record_stdregprov
804 class_method
*enumkey
;
805 class_method
*enumvalues
;
806 class_method
*getstringvalue
;
808 struct record_systemsecurity
813 struct record_videocontroller
815 const WCHAR
*adapter_dactype
;
818 UINT32 current_bitsperpixel
;
819 UINT32 current_horizontalres
;
820 UINT32 current_verticalres
;
821 const WCHAR
*description
;
822 const WCHAR
*device_id
;
824 const WCHAR
*pnpdevice_id
;
828 static const struct record_baseboard data_baseboard
[] =
830 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_tagW
}
832 static const struct record_bios data_bios
[] =
834 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
835 bios_smbiosbiosversionW
, bios_versionW
}
837 static const struct record_param data_param
[] =
839 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
840 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
841 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
842 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
843 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
844 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
845 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
846 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
847 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
848 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
849 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
850 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
851 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
852 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
853 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
854 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
855 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
856 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
857 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
858 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
859 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
860 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
861 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
862 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
863 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
866 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
867 WBEM_FLAVOR_ORIGIN_PROPAGATED)
869 static const struct record_physicalmedia data_physicalmedia
[] =
871 { diskdrive_serialW
, physicalmedia_tagW
}
873 static const struct record_qualifier data_qualifier
[] =
875 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
876 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
878 static const struct record_sounddevice data_sounddevice
[] =
880 { sounddevice_productnameW
, sounddevice_productnameW
}
882 static const struct record_stdregprov data_stdregprov
[] =
884 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
886 static const struct record_systemsecurity data_systemsecurity
[] =
888 { security_get_sd
, security_set_sd
}
891 /* check if row matches condition and update status */
892 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
899 *status
= FILL_STATUS_UNFILTERED
;
902 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
904 *status
= FILL_STATUS_FAILED
;
907 *status
= FILL_STATUS_FILTERED
;
911 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
913 if (!table
->num_rows_allocated
)
915 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
916 table
->num_rows_allocated
= row_count
;
919 if (row_count
>= table
->num_rows_allocated
)
922 UINT count
= table
->num_rows_allocated
* 2;
923 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
925 table
->num_rows_allocated
= count
;
930 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
932 static const WCHAR fmtW
[] = {'%','c',':',0};
933 WCHAR drive
[3], root
[] = {'A',':','\\',0};
934 struct record_cdromdrive
*rec
;
935 UINT i
, row
= 0, offset
= 0;
936 DWORD drives
= GetLogicalDrives();
937 enum fill_status status
= FILL_STATUS_UNFILTERED
;
939 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
941 for (i
= 0; i
< sizeof(drives
); i
++)
943 if (drives
& (1 << i
))
946 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
949 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
951 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
952 rec
->device_id
= cdromdrive_pnpdeviceidW
;
953 sprintfW( drive
, fmtW
, 'A' + i
);
954 rec
->drive
= heap_strdupW( drive
);
955 rec
->mediatype
= cdromdrive_mediatypeW
;
956 rec
->name
= cdromdrive_nameW
;
957 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
958 if (!match_row( table
, row
, cond
, &status
))
960 free_row_values( table
, row
);
963 offset
+= sizeof(*rec
);
967 TRACE("created %u rows\n", row
);
968 table
->num_rows
= row
;
972 static UINT
get_processor_count(void)
974 SYSTEM_BASIC_INFORMATION info
;
976 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
977 return info
.NumberOfProcessors
;
980 static UINT
get_logical_processor_count( UINT
*num_cores
)
982 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
983 UINT i
, j
, count
= 0;
987 if (num_cores
) *num_cores
= get_processor_count();
988 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
989 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
991 if (!(info
= heap_alloc( len
))) return get_processor_count();
992 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
993 if (status
!= STATUS_SUCCESS
)
996 return get_processor_count();
998 if (num_cores
) *num_cores
= 0;
999 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1001 if (info
[i
].Relationship
== RelationProcessorCore
)
1003 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1005 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1007 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1014 static UINT64
get_total_physical_memory(void)
1016 MEMORYSTATUSEX status
;
1018 status
.dwLength
= sizeof(status
);
1019 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1020 return status
.ullTotalPhys
;
1023 static WCHAR
*get_computername(void)
1026 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
1028 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1029 GetComputerNameW( ret
, &size
);
1033 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1035 struct record_computersystem
*rec
;
1036 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1039 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1041 rec
= (struct record_computersystem
*)table
->data
;
1042 rec
->description
= compsys_descriptionW
;
1043 rec
->domain
= compsys_domainW
;
1044 rec
->domainrole
= 0; /* standalone workstation */
1045 rec
->manufacturer
= compsys_manufacturerW
;
1046 rec
->model
= compsys_modelW
;
1047 rec
->name
= get_computername();
1048 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1049 rec
->num_processors
= get_processor_count();
1050 rec
->total_physical_memory
= get_total_physical_memory();
1051 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1054 TRACE("created %u rows\n", row
);
1055 table
->num_rows
= row
;
1067 static struct dirstack
*alloc_dirstack( UINT size
)
1069 struct dirstack
*dirstack
;
1071 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1072 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1074 heap_free( dirstack
);
1077 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1079 heap_free( dirstack
->dirs
);
1080 heap_free( dirstack
);
1083 dirstack
->num_dirs
= 0;
1084 dirstack
->num_allocated
= size
;
1088 static void clear_dirstack( struct dirstack
*dirstack
)
1091 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1092 dirstack
->num_dirs
= 0;
1095 static void free_dirstack( struct dirstack
*dirstack
)
1097 clear_dirstack( dirstack
);
1098 heap_free( dirstack
->dirs
);
1099 heap_free( dirstack
->len_dirs
);
1100 heap_free( dirstack
);
1103 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1105 UINT size
, i
= dirstack
->num_dirs
;
1107 if (!dir
) return FALSE
;
1109 if (i
== dirstack
->num_allocated
)
1114 size
= dirstack
->num_allocated
* 2;
1115 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1116 dirstack
->dirs
= tmp
;
1117 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1118 dirstack
->len_dirs
= len_tmp
;
1119 dirstack
->num_allocated
= size
;
1121 dirstack
->dirs
[i
] = dir
;
1122 dirstack
->len_dirs
[i
] = len
;
1123 dirstack
->num_dirs
++;
1127 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1129 if (!dirstack
->num_dirs
)
1134 dirstack
->num_dirs
--;
1135 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1136 return dirstack
->dirs
[dirstack
->num_dirs
];
1139 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1141 if (!dirstack
->num_dirs
) return NULL
;
1142 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1145 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1150 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1156 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1165 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1167 UINT i
= 0, len
= 0;
1171 for (p
= path
; *p
; p
++)
1173 if (*p
== '\\') len
+= 2;
1176 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1181 for (p
= path
; *p
; p
++)
1183 if (*p
!= '\\') ret
[i
++] = *p
;
1194 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1196 const WCHAR
*p
= path
, *start
;
1200 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1202 len
= strlenW( start
);
1203 p
= start
+ len
- 1;
1204 if (*p
== '\\') return NULL
;
1206 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1207 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1209 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1210 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1212 if (p
[0] == '\\' && p
[1] == '\\')
1224 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1227 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1231 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1232 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1234 const struct expr
*left
, *right
;
1236 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1238 left
= cond
->u
.expr
.left
;
1239 right
= cond
->u
.expr
.right
;
1240 if (cond
->u
.expr
.op
== OP_EQ
)
1244 const WCHAR
*str
= NULL
;
1246 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1247 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1248 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1250 str
= right
->u
.sval
;
1252 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1253 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1254 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1258 if (str
&& (path
= build_dirname( str
, &len
)))
1260 if (seen_dir( dirstack
, path
))
1265 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1270 else if (cond
->u
.expr
.op
== OP_OR
)
1272 UINT left_count
= 0, right_count
= 0;
1274 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1275 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1276 return *count
+= left_count
+ right_count
;
1281 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1283 UINT len_path
= 0, len_segment
= strlenW( segment
);
1287 if (path
) len_path
= strlenW( path
);
1288 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1289 if (path
&& len_path
)
1291 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1292 ret
[len_path
] = '\\';
1293 *len
+= len_path
+ 1;
1295 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1296 *len
+= len_segment
;
1301 static WCHAR
*get_file_version( const WCHAR
*filename
)
1303 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1304 VS_FIXEDFILEINFO
*info
;
1309 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1310 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1315 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1316 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1322 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1323 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1328 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1330 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1331 struct record_datafile
*rec
;
1332 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1333 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1334 DWORD drives
= GetLogicalDrives();
1335 WIN32_FIND_DATAW data
;
1337 struct dirstack
*dirstack
;
1338 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1340 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1342 dirstack
= alloc_dirstack(2);
1344 for (i
= 0; i
< sizeof(drives
); i
++)
1346 if (!(drives
& (1 << i
))) continue;
1349 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1351 num_expected_rows
= 0;
1352 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1356 path
= pop_dir( dirstack
, &len
);
1357 if (!(glob
= build_glob( root
[0], path
, len
)))
1359 status
= FILL_STATUS_FAILED
;
1362 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1366 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1368 status
= FILL_STATUS_FAILED
;
1369 FindClose( handle
);
1372 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1373 new_path
= append_path( path
, data
.cFileName
, &len
);
1375 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1377 if (push_dir( dirstack
, new_path
, len
)) continue;
1378 heap_free( new_path
);
1379 FindClose( handle
);
1380 status
= FILL_STATUS_FAILED
;
1383 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1384 rec
->name
= build_name( root
[0], new_path
);
1385 rec
->version
= get_file_version( rec
->name
);
1386 if (!match_row( table
, row
, cond
, &status
))
1388 free_row_values( table
, row
);
1391 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1394 FindClose( handle
);
1395 status
= FILL_STATUS_FILTERED
;
1398 offset
+= sizeof(*rec
);
1401 while (FindNextFileW( handle
, &data
));
1402 FindClose( handle
);
1404 if (!peek_dir( dirstack
)) break;
1411 free_dirstack( dirstack
);
1415 TRACE("created %u rows\n", row
);
1416 table
->num_rows
= row
;
1420 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1422 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1423 struct record_directory
*rec
;
1424 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1425 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1426 DWORD drives
= GetLogicalDrives();
1427 WIN32_FIND_DATAW data
;
1429 struct dirstack
*dirstack
;
1430 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1432 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1434 dirstack
= alloc_dirstack(2);
1436 for (i
= 0; i
< sizeof(drives
); i
++)
1438 if (!(drives
& (1 << i
))) continue;
1441 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1443 num_expected_rows
= 0;
1444 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1448 path
= pop_dir( dirstack
, &len
);
1449 if (!(glob
= build_glob( root
[0], path
, len
)))
1451 status
= FILL_STATUS_FAILED
;
1454 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1458 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1460 FindClose( handle
);
1461 status
= FILL_STATUS_FAILED
;
1464 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1465 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1468 new_path
= append_path( path
, data
.cFileName
, &len
);
1469 if (!(push_dir( dirstack
, new_path
, len
)))
1471 heap_free( new_path
);
1472 FindClose( handle
);
1473 status
= FILL_STATUS_FAILED
;
1476 rec
= (struct record_directory
*)(table
->data
+ offset
);
1477 rec
->accessmask
= FILE_ALL_ACCESS
;
1478 rec
->name
= build_name( root
[0], new_path
);
1479 if (!match_row( table
, row
, cond
, &status
))
1481 free_row_values( table
, row
);
1484 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1487 FindClose( handle
);
1488 status
= FILL_STATUS_FILTERED
;
1491 offset
+= sizeof(*rec
);
1494 while (FindNextFileW( handle
, &data
));
1495 FindClose( handle
);
1497 if (!peek_dir( dirstack
)) break;
1504 free_dirstack( dirstack
);
1508 TRACE("created %u rows\n", row
);
1509 table
->num_rows
= row
;
1513 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1515 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1516 ULARGE_INTEGER free
;
1517 DISK_GEOMETRY_EX info
;
1519 DWORD bytes_returned
;
1521 free
.QuadPart
= 512 * 1024 * 1024;
1522 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1525 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1526 if (handle
!= INVALID_HANDLE_VALUE
)
1528 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1529 *disksize
= info
.DiskSize
.QuadPart
;
1530 CloseHandle( handle
);
1532 return free
.QuadPart
;
1535 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1537 static const WCHAR fmtW
[] =
1538 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1539 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1540 struct record_diskdrive
*rec
;
1541 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1542 UINT64 size
= 1024 * 1024 * 1024;
1543 DWORD drives
= GetLogicalDrives();
1544 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1546 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1548 for (i
= 0; i
< sizeof(drives
); i
++)
1550 if (drives
& (1 << i
))
1553 type
= GetDriveTypeW( root
);
1554 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1557 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1559 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1560 sprintfW( device_id
, fmtW
, index
);
1561 rec
->device_id
= heap_strdupW( device_id
);
1563 rec
->interfacetype
= diskdrive_interfacetypeW
;
1564 rec
->manufacturer
= diskdrive_manufacturerW
;
1565 if (type
== DRIVE_FIXED
)
1566 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1568 rec
->mediatype
= diskdrive_mediatype_removableW
;
1569 rec
->model
= diskdrive_modelW
;
1570 rec
->serialnumber
= diskdrive_serialW
;
1571 get_freespace( root
, &size
);
1573 if (!match_row( table
, row
, cond
, &status
))
1575 free_row_values( table
, row
);
1578 offset
+= sizeof(*rec
);
1583 TRACE("created %u rows\n", row
);
1584 table
->num_rows
= row
;
1588 static WCHAR
*get_filesystem( const WCHAR
*root
)
1590 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1591 WCHAR buffer
[MAX_PATH
+ 1];
1593 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1594 return heap_strdupW( buffer
);
1595 return heap_strdupW( ntfsW
);
1598 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1600 static const WCHAR fmtW
[] =
1601 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1602 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1603 struct record_diskpartition
*rec
;
1604 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1605 UINT64 size
= 1024 * 1024 * 1024;
1606 DWORD drives
= GetLogicalDrives();
1607 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1609 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1611 for (i
= 0; i
< sizeof(drives
); i
++)
1613 if (drives
& (1 << i
))
1616 type
= GetDriveTypeW( root
);
1617 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1620 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1622 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1623 rec
->bootable
= (i
== 2) ? -1 : 0;
1624 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1625 sprintfW( device_id
, fmtW
, index
);
1626 rec
->device_id
= heap_strdupW( device_id
);
1627 rec
->diskindex
= index
;
1629 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1630 get_freespace( root
, &size
);
1632 rec
->startingoffset
= 0;
1633 rec
->type
= get_filesystem( root
);
1634 if (!match_row( table
, row
, cond
, &status
))
1636 free_row_values( table
, row
);
1639 offset
+= sizeof(*rec
);
1644 TRACE("created %u rows\n", row
);
1645 table
->num_rows
= row
;
1649 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1651 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1655 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1656 sprintfW( buffer
, fmtW
, serial
);
1657 return heap_strdupW( buffer
);
1660 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1662 static const WCHAR fmtW
[] = {'%','c',':',0};
1663 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1664 struct record_logicaldisk
*rec
;
1665 UINT i
, row
= 0, offset
= 0, type
;
1666 UINT64 size
= 1024 * 1024 * 1024;
1667 DWORD drives
= GetLogicalDrives();
1668 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1670 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1672 for (i
= 0; i
< sizeof(drives
); i
++)
1674 if (drives
& (1 << i
))
1677 type
= GetDriveTypeW( root
);
1678 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1681 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1683 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1684 sprintfW( device_id
, fmtW
, 'A' + i
);
1685 rec
->device_id
= heap_strdupW( device_id
);
1686 rec
->drivetype
= type
;
1687 rec
->filesystem
= get_filesystem( root
);
1688 rec
->freespace
= get_freespace( root
, &size
);
1689 rec
->name
= heap_strdupW( device_id
);
1691 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1692 if (!match_row( table
, row
, cond
, &status
))
1694 free_row_values( table
, row
);
1697 offset
+= sizeof(*rec
);
1701 TRACE("created %u rows\n", row
);
1702 table
->num_rows
= row
;
1706 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1710 case IfOperStatusDown
:
1711 return 0; /* Disconnected */
1712 case IfOperStatusUp
:
1713 return 2; /* Connected */
1715 ERR("unhandled status %u\n", status
);
1720 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1722 static const WCHAR fmtW
[] =
1723 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1724 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1727 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1728 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1731 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1733 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1734 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1735 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1736 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1740 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1741 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1742 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1743 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1744 default: *physical
= 0; return NULL
;
1748 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1750 static const WCHAR fmtW
[] = {'%','u',0};
1751 WCHAR device_id
[11];
1752 struct record_networkadapter
*rec
;
1753 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1754 UINT row
= 0, offset
= 0, count
= 0;
1755 DWORD size
= 0, ret
;
1757 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1759 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1760 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1762 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1763 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1765 heap_free( buffer
);
1766 return FILL_STATUS_FAILED
;
1768 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1770 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1772 if (!resize_table( table
, count
, sizeof(*rec
) ))
1774 heap_free( buffer
);
1775 return FILL_STATUS_FAILED
;
1777 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1779 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1781 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1782 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1783 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1784 rec
->device_id
= heap_strdupW( device_id
);
1785 rec
->index
= aa
->u
.s
.IfIndex
;
1786 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1787 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1788 rec
->manufacturer
= compsys_manufacturerW
;
1789 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1790 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1791 rec
->physicaladapter
= physical
;
1792 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1793 rec
->speed
= 1000000;
1794 if (!match_row( table
, row
, cond
, &status
))
1796 free_row_values( table
, row
);
1799 offset
+= sizeof(*rec
);
1802 TRACE("created %u rows\n", row
);
1803 table
->num_rows
= row
;
1805 heap_free( buffer
);
1809 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1811 struct record_networkadapterconfig
*rec
;
1812 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1813 UINT row
= 0, offset
= 0, count
= 0;
1814 DWORD size
= 0, ret
;
1815 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1817 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1818 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1820 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1821 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1823 heap_free( buffer
);
1824 return FILL_STATUS_FAILED
;
1826 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1828 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1830 if (!resize_table( table
, count
, sizeof(*rec
) ))
1832 heap_free( buffer
);
1833 return FILL_STATUS_FAILED
;
1835 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1837 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1839 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1840 rec
->index
= aa
->u
.s
.IfIndex
;
1841 rec
->ipconnectionmetric
= 20;
1842 rec
->ipenabled
= -1;
1843 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1844 if (!match_row( table
, row
, cond
, &status
))
1846 free_row_values( table
, row
);
1849 offset
+= sizeof(*rec
);
1852 TRACE("created %u rows\n", row
);
1853 table
->num_rows
= row
;
1855 heap_free( buffer
);
1859 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
1861 struct record_physicalmemory
*rec
;
1862 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1865 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1867 rec
= (struct record_physicalmemory
*)table
->data
;
1868 rec
->capacity
= get_total_physical_memory();
1869 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1872 TRACE("created %u rows\n", row
);
1873 table
->num_rows
= row
;
1877 static WCHAR
*get_cmdline( DWORD process_id
)
1879 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1880 return NULL
; /* FIXME handle different process case */
1883 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1885 static const WCHAR fmtW
[] = {'%','u',0};
1887 struct record_process
*rec
;
1888 PROCESSENTRY32W entry
;
1890 enum fill_status status
= FILL_STATUS_FAILED
;
1891 UINT row
= 0, offset
= 0;
1893 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1894 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1896 entry
.dwSize
= sizeof(entry
);
1897 if (!Process32FirstW( snap
, &entry
)) goto done
;
1898 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1902 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1904 rec
= (struct record_process
*)(table
->data
+ offset
);
1905 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1906 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1907 rec
->description
= heap_strdupW( entry
.szExeFile
);
1908 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1909 rec
->handle
= heap_strdupW( handle
);
1910 rec
->name
= heap_strdupW( entry
.szExeFile
);
1911 rec
->process_id
= entry
.th32ProcessID
;
1912 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1913 rec
->thread_count
= entry
.cntThreads
;
1914 rec
->get_owner
= process_get_owner
;
1915 if (!match_row( table
, row
, cond
, &status
))
1917 free_row_values( table
, row
);
1920 offset
+= sizeof(*rec
);
1922 } while (Process32NextW( snap
, &entry
));
1924 TRACE("created %u rows\n", row
);
1925 table
->num_rows
= row
;
1926 status
= FILL_STATUS_UNFILTERED
;
1929 CloseHandle( snap
);
1933 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
1936 __asm__("pushl %%ebx\n\t"
1938 "movl %%ebx, %%esi\n\t"
1940 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
1945 static void get_processor_id( WCHAR
*processor_id
)
1947 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
1948 unsigned int regs
[4] = {0, 0, 0, 0};
1950 do_cpuid( 1, regs
);
1951 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
1953 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
1956 unsigned char *p
= (unsigned char *)regs
;
1958 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
1961 static void get_processor_manufacturer( WCHAR
*manufacturer
)
1963 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
1965 do_cpuid( 0, regs
);
1966 tmp
= regs
[2]; /* swap edx and ecx */
1970 regs_to_str( regs
+ 1, 12, manufacturer
);
1972 static void get_processor_name( WCHAR
*name
)
1974 unsigned int regs
[4] = {0, 0, 0, 0};
1976 do_cpuid( 0x80000000, regs
);
1977 if (regs
[0] >= 0x80000004)
1979 do_cpuid( 0x80000002, regs
);
1980 regs_to_str( regs
, 16, name
);
1981 do_cpuid( 0x80000003, regs
);
1982 regs_to_str( regs
, 16, name
+ 16 );
1983 do_cpuid( 0x80000004, regs
);
1984 regs_to_str( regs
, 16, name
+ 32 );
1987 static UINT
get_processor_currentclockspeed( UINT index
)
1989 PROCESSOR_POWER_INFORMATION
*info
;
1990 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1993 if ((info
= heap_alloc( size
)))
1995 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1996 if (!status
) ret
= info
[index
].CurrentMhz
;
2001 static UINT
get_processor_maxclockspeed( UINT index
)
2003 PROCESSOR_POWER_INFORMATION
*info
;
2004 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2007 if ((info
= heap_alloc( size
)))
2009 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2010 if (!status
) ret
= info
[index
].MaxMhz
;
2015 static const WCHAR
*get_osarchitecture(void)
2018 GetNativeSystemInfo( &info
);
2019 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2023 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2025 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2026 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2027 struct record_processor
*rec
;
2028 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2029 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2031 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2033 get_processor_id( processor_id
);
2034 get_processor_manufacturer( manufacturer
);
2035 get_processor_name( name
);
2037 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2040 for (i
= 0; i
< count
; i
++)
2042 rec
= (struct record_processor
*)(table
->data
+ offset
);
2043 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2044 rec
->cpu_status
= 1; /* CPU Enabled */
2045 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2046 sprintfW( device_id
, fmtW
, i
);
2047 rec
->device_id
= heap_strdupW( device_id
);
2048 rec
->family
= 2; /* Unknown */
2049 rec
->manufacturer
= heap_strdupW( manufacturer
);
2050 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2051 rec
->name
= heap_strdupW( name
);
2052 rec
->num_cores
= num_cores
;
2053 rec
->num_logical_processors
= num_logical_processors
;
2054 rec
->processor_id
= heap_strdupW( processor_id
);
2055 rec
->unique_id
= NULL
;
2056 if (!match_row( table
, i
, cond
, &status
))
2058 free_row_values( table
, i
);
2061 offset
+= sizeof(*rec
);
2064 TRACE("created %u rows\n", count
);
2065 table
->num_rows
= count
;
2069 static WCHAR
*get_lastbootuptime(void)
2071 static const WCHAR fmtW
[] =
2072 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2073 '.','%','0','6','u','+','0','0','0',0};
2074 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2078 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2080 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2081 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2082 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2085 static WCHAR
*get_localdatetime(void)
2087 static const WCHAR fmtW
[] =
2088 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2089 '.','%','0','6','u','%','+','0','3','d',0};
2090 TIME_ZONE_INFORMATION tzi
;
2096 Status
= GetTimeZoneInformation(&tzi
);
2098 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2100 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2101 Bias
+= tzi
.DaylightBias
;
2103 Bias
+= tzi
.StandardBias
;
2104 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2107 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2110 static WCHAR
*get_systemdirectory(void)
2115 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2116 Wow64DisableWow64FsRedirection( &redir
);
2117 GetSystemDirectoryW( ret
, MAX_PATH
);
2118 Wow64RevertWow64FsRedirection( redir
);
2121 static WCHAR
*get_codeset(void)
2123 static const WCHAR fmtW
[] = {'%','u',0};
2124 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2125 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2128 static WCHAR
*get_countrycode(void)
2130 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2131 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2134 static WCHAR
*get_locale(void)
2136 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2137 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2141 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2143 struct record_operatingsystem
*rec
;
2144 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2147 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2149 rec
= (struct record_operatingsystem
*)table
->data
;
2150 rec
->buildnumber
= os_buildnumberW
;
2151 rec
->caption
= os_captionW
;
2152 rec
->codeset
= get_codeset();
2153 rec
->countrycode
= get_countrycode();
2154 rec
->csdversion
= os_csdversionW
;
2155 rec
->installdate
= os_installdateW
;
2156 rec
->lastbootuptime
= get_lastbootuptime();
2157 rec
->localdatetime
= get_localdatetime();
2158 rec
->locale
= get_locale();
2159 rec
->name
= os_nameW
;
2160 rec
->osarchitecture
= get_osarchitecture();
2161 rec
->oslanguage
= GetSystemDefaultLangID();
2162 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2163 rec
->ostype
= 18; /* WINNT */
2164 rec
->serialnumber
= os_serialnumberW
;
2165 rec
->servicepackmajor
= 3;
2166 rec
->servicepackminor
= 0;
2167 rec
->suitemask
= 272; /* Single User + Terminal */
2168 rec
->systemdirectory
= get_systemdirectory();
2169 rec
->version
= os_versionW
;
2170 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2173 TRACE("created %u rows\n", row
);
2174 table
->num_rows
= row
;
2178 static const WCHAR
*get_service_type( DWORD type
)
2180 static const WCHAR filesystem_driverW
[] =
2181 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2182 static const WCHAR kernel_driverW
[] =
2183 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2184 static const WCHAR own_processW
[] =
2185 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2186 static const WCHAR share_processW
[] =
2187 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2189 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2190 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2191 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2192 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2193 else ERR("unhandled type 0x%08x\n", type
);
2196 static const WCHAR
*get_service_state( DWORD state
)
2198 static const WCHAR runningW
[] =
2199 {'R','u','n','n','i','n','g',0};
2200 static const WCHAR start_pendingW
[] =
2201 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2202 static const WCHAR stop_pendingW
[] =
2203 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2204 static const WCHAR stoppedW
[] =
2205 {'S','t','o','p','p','e','d',0};
2206 static const WCHAR unknownW
[] =
2207 {'U','n','k','n','o','w','n',0};
2211 case SERVICE_STOPPED
: return stoppedW
;
2212 case SERVICE_START_PENDING
: return start_pendingW
;
2213 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2214 case SERVICE_RUNNING
: return runningW
;
2216 ERR("unknown state %u\n", state
);
2220 static const WCHAR
*get_service_startmode( DWORD mode
)
2222 static const WCHAR bootW
[] = {'B','o','o','t',0};
2223 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2224 static const WCHAR autoW
[] = {'A','u','t','o',0};
2225 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2226 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2227 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2231 case SERVICE_BOOT_START
: return bootW
;
2232 case SERVICE_SYSTEM_START
: return systemW
;
2233 case SERVICE_AUTO_START
: return autoW
;
2234 case SERVICE_DEMAND_START
: return manualW
;
2235 case SERVICE_DISABLED
: return disabledW
;
2237 ERR("unknown mode 0x%x\n", mode
);
2241 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2243 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2247 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2248 QueryServiceConfigW( service
, NULL
, 0, &size
);
2249 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2250 if (!(config
= heap_alloc( size
))) goto done
;
2251 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2252 heap_free( config
);
2256 CloseServiceHandle( service
);
2260 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2262 struct record_service
*rec
;
2264 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2265 SERVICE_STATUS_PROCESS
*status
;
2266 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2267 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2268 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2269 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2272 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2273 if (!(services
= heap_alloc( size
))) goto done
;
2275 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2276 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2277 &count
, NULL
, NULL
);
2280 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2282 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2284 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2285 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2286 &count
, NULL
, NULL
);
2287 if (!ret
) goto done
;
2289 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2291 GetComputerNameW( sysnameW
, &len
);
2292 fill_status
= FILL_STATUS_UNFILTERED
;
2294 for (i
= 0; i
< count
; i
++)
2296 QUERY_SERVICE_CONFIGW
*config
;
2298 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2300 status
= &services
[i
].ServiceStatusProcess
;
2301 rec
= (struct record_service
*)(table
->data
+ offset
);
2302 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2303 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2304 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2305 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2306 rec
->process_id
= status
->dwProcessId
;
2307 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2308 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2309 rec
->state
= get_service_state( status
->dwCurrentState
);
2310 rec
->systemname
= heap_strdupW( sysnameW
);
2311 rec
->pause_service
= service_pause_service
;
2312 rec
->resume_service
= service_resume_service
;
2313 rec
->start_service
= service_start_service
;
2314 rec
->stop_service
= service_stop_service
;
2315 heap_free( config
);
2316 if (!match_row( table
, row
, cond
, &fill_status
))
2318 free_row_values( table
, row
);
2321 offset
+= sizeof(*rec
);
2325 TRACE("created %u rows\n", row
);
2326 table
->num_rows
= row
;
2329 CloseServiceHandle( manager
);
2330 heap_free( services
);
2334 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2336 HDC hdc
= GetDC( NULL
);
2339 if (!hdc
) return 32;
2340 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2341 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2342 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2343 ReleaseDC( NULL
, hdc
);
2346 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2348 static const WCHAR fmtW
[] =
2349 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2350 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2351 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2354 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2355 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2359 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2362 struct record_videocontroller
*rec
;
2364 IDXGIFactory
*factory
= NULL
;
2365 IDXGIAdapter
*adapter
= NULL
;
2366 DXGI_ADAPTER_DESC desc
;
2367 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2368 const WCHAR
*name
= videocontroller_deviceidW
;
2369 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2372 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2374 memset (&desc
, 0, sizeof(desc
));
2375 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2376 if (FAILED(hr
)) goto done
;
2378 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2379 if (FAILED(hr
)) goto done
;
2381 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2384 vidmem
= desc
.DedicatedVideoMemory
;
2385 name
= desc
.Description
;
2389 rec
= (struct record_videocontroller
*)table
->data
;
2390 rec
->adapter_dactype
= videocontroller_dactypeW
;
2391 rec
->adapter_ram
= vidmem
;
2392 rec
->availability
= 3; /* Running or Full Power */
2393 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2394 rec
->current_horizontalres
= hres
;
2395 rec
->current_verticalres
= vres
;
2396 rec
->description
= heap_strdupW( name
);
2397 rec
->device_id
= videocontroller_deviceidW
;
2398 rec
->name
= heap_strdupW( name
);
2399 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2400 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2403 TRACE("created %u rows\n", row
);
2404 table
->num_rows
= row
;
2406 if (adapter
) IDXGIAdapter_Release( adapter
);
2407 if (factory
) IDXGIFactory_Release( factory
);
2411 static struct table builtin_classes
[] =
2413 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2414 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2415 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2416 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2417 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2418 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2419 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2420 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2421 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2422 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2423 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2424 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
,
2425 fill_networkadapterconfig
},
2426 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2427 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2428 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2429 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2430 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2431 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2432 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2433 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2434 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2435 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2436 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2437 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2438 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2441 void init_table_list( void )
2443 static struct list tables
= LIST_INIT( tables
);
2446 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2447 table_list
= &tables
;