2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wbemprox_private.h"
32 static const WCHAR class_baseboardW
[] =
33 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
34 static const WCHAR class_biosW
[] =
35 {'W','i','n','3','2','_','B','I','O','S',0};
36 static const WCHAR class_cdromdriveW
[] =
37 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
38 static const WCHAR class_compsysW
[] =
39 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
40 static const WCHAR class_datafileW
[] =
41 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
42 static const WCHAR class_directoryW
[] =
43 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
44 static const WCHAR class_diskdriveW
[] =
45 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
46 static const WCHAR class_diskpartitionW
[] =
47 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
48 static const WCHAR class_logicaldiskW
[] =
49 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
50 static const WCHAR class_logicaldisk2W
[] =
51 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
52 static const WCHAR class_networkadapterW
[] =
53 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
54 static const WCHAR class_networkadapterconfigW
[] =
55 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
56 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
57 static const WCHAR class_osW
[] =
58 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
59 static const WCHAR class_paramsW
[] =
60 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
61 static const WCHAR class_physicalmediaW
[] =
62 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
63 static const WCHAR class_physicalmemoryW
[] =
64 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
65 static const WCHAR class_qualifiersW
[] =
66 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
67 static const WCHAR class_process_getowner_outW
[] =
68 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
69 'N','E','R','_','O','U','T',0};
70 static const WCHAR class_processorW
[] =
71 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
72 static const WCHAR class_processor2W
[] =
73 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
74 static const WCHAR class_sounddeviceW
[] =
75 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
76 static const WCHAR class_videocontrollerW
[] =
77 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
79 static const WCHAR prop_acceptpauseW
[] =
80 {'A','c','c','e','p','t','P','a','u','s','e',0};
81 static const WCHAR prop_acceptstopW
[] =
82 {'A','c','c','e','p','t','S','t','o','p',0};
83 static const WCHAR prop_accessmaskW
[] =
84 {'A','c','c','e','s','s','M','a','s','k',0};
85 static const WCHAR prop_adapterdactypeW
[] =
86 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
87 static const WCHAR prop_adapterramW
[] =
88 {'A','d','a','p','t','e','r','R','A','M',0};
89 static const WCHAR prop_adaptertypeW
[] =
90 {'A','d','a','p','t','e','r','T','y','p','e',0};
91 static const WCHAR prop_addresswidthW
[] =
92 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
93 static const WCHAR prop_availabilityW
[] =
94 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
95 static const WCHAR prop_bootableW
[] =
96 {'B','o','o','t','a','b','l','e',0};
97 static const WCHAR prop_bootpartitionW
[] =
98 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
99 static const WCHAR prop_buildnumberW
[] =
100 {'B','u','i','l','d','N','u','m','b','e','r',0};
101 static const WCHAR prop_capacityW
[] =
102 {'C','a','p','a','c','i','t','y',0};
103 static const WCHAR prop_captionW
[] =
104 {'C','a','p','t','i','o','n',0};
105 static const WCHAR prop_classW
[] =
106 {'C','l','a','s','s',0};
107 static const WCHAR prop_codesetW
[] =
108 {'C','o','d','e','S','e','t',0};
109 static const WCHAR prop_commandlineW
[] =
110 {'C','o','m','m','a','n','d','L','i','n','e',0};
111 static const WCHAR prop_countrycodeW
[] =
112 {'C','o','u','n','t','r','y','C','o','d','e',0};
113 static const WCHAR prop_cpustatusW
[] =
114 {'C','p','u','S','t','a','t','u','s',0};
115 static const WCHAR prop_csdversionW
[] =
116 {'C','S','D','V','e','r','s','i','o','n',0};
117 static const WCHAR prop_currentbitsperpixelW
[] =
118 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
119 static const WCHAR prop_currentclockspeedW
[] =
120 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
121 static const WCHAR prop_currenthorizontalresW
[] =
122 {'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};
123 static const WCHAR prop_currentverticalresW
[] =
124 {'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};
125 static const WCHAR prop_defaultvalueW
[] =
126 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
127 static const WCHAR prop_descriptionW
[] =
128 {'D','e','s','c','r','i','p','t','i','o','n',0};
129 static const WCHAR prop_deviceidW
[] =
130 {'D','e','v','i','c','e','I','d',0};
131 static const WCHAR prop_directionW
[] =
132 {'D','i','r','e','c','t','i','o','n',0};
133 static const WCHAR prop_displaynameW
[] =
134 {'D','i','s','p','l','a','y','N','a','m','e',0};
135 static const WCHAR prop_diskindexW
[] =
136 {'D','i','s','k','I','n','d','e','x',0};
137 static const WCHAR prop_domainW
[] =
138 {'D','o','m','a','i','n',0};
139 static const WCHAR prop_domainroleW
[] =
140 {'D','o','m','a','i','n','R','o','l','e',0};
141 static const WCHAR prop_driveW
[] =
142 {'D','r','i','v','e',0};
143 static const WCHAR prop_drivetypeW
[] =
144 {'D','r','i','v','e','T','y','p','e',0};
145 static const WCHAR prop_familyW
[] =
146 {'F','a','m','i','l','y',0};
147 static const WCHAR prop_filesystemW
[] =
148 {'F','i','l','e','S','y','s','t','e','m',0};
149 static const WCHAR prop_flavorW
[] =
150 {'F','l','a','v','o','r',0};
151 static const WCHAR prop_freespaceW
[] =
152 {'F','r','e','e','S','p','a','c','e',0};
153 static const WCHAR prop_handleW
[] =
154 {'H','a','n','d','l','e',0};
155 static const WCHAR prop_idW
[] =
157 static const WCHAR prop_identificationcodeW
[] =
158 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
159 static const WCHAR prop_indexW
[] =
160 {'I','n','d','e','x',0};
161 static const WCHAR prop_installdateW
[] =
162 {'I','n','s','t','a','l','l','D','a','t','e',0};
163 static const WCHAR prop_interfaceindexW
[] =
164 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
165 static const WCHAR prop_interfacetypeW
[] =
166 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
167 static const WCHAR prop_intvalueW
[] =
168 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
169 static const WCHAR prop_ipconnectionmetricW
[] =
170 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
171 static const WCHAR prop_ipenabledW
[] =
172 {'I','P','E','n','a','b','l','e','d',0};
173 static const WCHAR prop_lastbootuptimeW
[] =
174 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
175 static const WCHAR prop_localdatetimeW
[] =
176 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
177 static const WCHAR prop_localeW
[] =
178 {'L','o','c','a','l','e',0};
179 static const WCHAR prop_macaddressW
[] =
180 {'M','A','C','A','d','d','r','e','s','s',0};
181 static const WCHAR prop_manufacturerW
[] =
182 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
183 static const WCHAR prop_maxclockspeedW
[] =
184 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
185 static const WCHAR prop_mediatypeW
[] =
186 {'M','e','d','i','a','T','y','p','e',0};
187 static const WCHAR prop_memberW
[] =
188 {'M','e','m','b','e','r',0};
189 static const WCHAR prop_methodW
[] =
190 {'M','e','t','h','o','d',0};
191 static const WCHAR prop_modelW
[] =
192 {'M','o','d','e','l',0};
193 static const WCHAR prop_netconnectionstatusW
[] =
194 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
195 static const WCHAR prop_numcoresW
[] =
196 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
197 static const WCHAR prop_numlogicalprocessorsW
[] =
198 {'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};
199 static const WCHAR prop_numprocessorsW
[] =
200 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
201 static const WCHAR prop_osarchitectureW
[] =
202 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
203 static const WCHAR prop_oslanguageW
[] =
204 {'O','S','L','a','n','g','u','a','g','e',0};
205 static const WCHAR prop_osproductsuiteW
[] =
206 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
207 static const WCHAR prop_ostypeW
[] =
208 {'O','S','T','y','p','e',0};
209 static const WCHAR prop_parameterW
[] =
210 {'P','a','r','a','m','e','t','e','r',0};
211 static const WCHAR prop_physicaladapterW
[] =
212 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
213 static const WCHAR prop_pnpdeviceidW
[] =
214 {'P','N','P','D','e','v','i','c','e','I','D',0};
215 static const WCHAR prop_pprocessidW
[] =
216 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
217 static const WCHAR prop_processidW
[] =
218 {'P','r','o','c','e','s','s','I','D',0};
219 static const WCHAR prop_processoridW
[] =
220 {'P','r','o','c','e','s','s','o','r','I','d',0};
221 static const WCHAR prop_productnameW
[] =
222 {'P','r','o','d','u','c','t','N','a','m','e',0};
223 static const WCHAR prop_releasedateW
[] =
224 {'R','e','l','e','a','s','e','D','a','t','e',0};
225 static const WCHAR prop_serialnumberW
[] =
226 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
227 static const WCHAR prop_servicepackmajorW
[] =
228 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
229 static const WCHAR prop_servicepackminorW
[] =
230 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
231 static const WCHAR prop_servicetypeW
[] =
232 {'S','e','r','v','i','c','e','T','y','p','e',0};
233 static const WCHAR prop_smbiosbiosversionW
[] =
234 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
235 static const WCHAR prop_startmodeW
[] =
236 {'S','t','a','r','t','M','o','d','e',0};
237 static const WCHAR prop_sizeW
[] =
239 static const WCHAR prop_speedW
[] =
240 {'S','p','e','e','d',0};
241 static const WCHAR prop_startingoffsetW
[] =
242 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
243 static const WCHAR prop_stateW
[] =
244 {'S','t','a','t','e',0};
245 static const WCHAR prop_strvalueW
[] =
246 {'S','t','r','i','n','g','V','a','l','u','e',0};
247 static const WCHAR prop_suitemaskW
[] =
248 {'S','u','i','t','e','M','a','s','k',0};
249 static const WCHAR prop_systemdirectoryW
[] =
250 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
251 static const WCHAR prop_systemnameW
[] =
252 {'S','y','s','t','e','m','N','a','m','e',0};
253 static const WCHAR prop_tagW
[] =
255 static const WCHAR prop_threadcountW
[] =
256 {'T','h','r','e','a','d','C','o','u','n','t',0};
257 static const WCHAR prop_totalphysicalmemoryW
[] =
258 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
259 static const WCHAR prop_typeW
[] =
261 static const WCHAR prop_uniqueidW
[] =
262 {'U','n','i','q','u','e','I','d',0};
263 static const WCHAR prop_varianttypeW
[] =
264 {'V','a','r','i','a','n','t','T','y','p','e',0};
265 static const WCHAR prop_versionW
[] =
266 {'V','e','r','s','i','o','n',0};
267 static const WCHAR prop_volumeserialnumberW
[] =
268 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
270 /* column definitions must be kept in sync with record structures below */
271 static const struct column col_baseboard
[] =
273 { prop_manufacturerW
, CIM_STRING
},
274 { prop_modelW
, CIM_STRING
},
275 { prop_nameW
, CIM_STRING
},
276 { prop_serialnumberW
, CIM_STRING
},
277 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
279 static const struct column col_bios
[] =
281 { prop_descriptionW
, CIM_STRING
},
282 { prop_identificationcodeW
, CIM_STRING
},
283 { prop_manufacturerW
, CIM_STRING
},
284 { prop_releasedateW
, CIM_DATETIME
},
285 { prop_serialnumberW
, CIM_STRING
},
286 { prop_smbiosbiosversionW
, CIM_STRING
},
287 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
289 static const struct column col_cdromdrive
[] =
291 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
292 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
293 { prop_mediatypeW
, CIM_STRING
},
294 { prop_nameW
, CIM_STRING
},
295 { prop_pnpdeviceidW
, CIM_STRING
}
297 static const struct column col_compsys
[] =
299 { prop_descriptionW
, CIM_STRING
},
300 { prop_domainW
, CIM_STRING
},
301 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
302 { prop_manufacturerW
, CIM_STRING
},
303 { prop_modelW
, CIM_STRING
},
304 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
305 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
306 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
307 { prop_totalphysicalmemoryW
, CIM_UINT64
}
309 static const struct column col_datafile
[] =
311 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
312 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
314 static const struct column col_directory
[] =
316 { prop_accessmaskW
, CIM_UINT32
},
317 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
319 static const struct column col_diskdrive
[] =
321 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
322 { prop_indexW
, CIM_UINT32
, VT_I4
},
323 { prop_interfacetypeW
, CIM_STRING
},
324 { prop_manufacturerW
, CIM_STRING
},
325 { prop_mediatypeW
, CIM_STRING
},
326 { prop_modelW
, CIM_STRING
},
327 { prop_serialnumberW
, CIM_STRING
},
328 { prop_sizeW
, CIM_UINT64
}
330 static const struct column col_diskpartition
[] =
332 { prop_bootableW
, CIM_BOOLEAN
},
333 { prop_bootpartitionW
, CIM_BOOLEAN
},
334 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
335 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
336 { prop_indexW
, CIM_UINT32
, VT_I4
},
337 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
338 { prop_sizeW
, CIM_UINT64
},
339 { prop_startingoffsetW
, CIM_UINT64
},
340 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
342 static const struct column col_logicaldisk
[] =
344 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
345 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
346 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
347 { prop_freespaceW
, CIM_UINT64
},
348 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
349 { prop_sizeW
, CIM_UINT64
},
350 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
352 static const struct column col_networkadapter
[] =
354 { prop_adaptertypeW
, CIM_STRING
},
355 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
356 { prop_indexW
, CIM_UINT32
, VT_I4
},
357 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
358 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
359 { prop_manufacturerW
, CIM_STRING
},
360 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
361 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
362 { prop_physicaladapterW
, CIM_BOOLEAN
},
363 { prop_pnpdeviceidW
, CIM_STRING
},
364 { prop_speedW
, CIM_UINT64
}
366 static const struct column col_networkadapterconfig
[] =
368 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
369 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
370 { prop_ipenabledW
, CIM_BOOLEAN
},
371 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
373 static const struct column col_os
[] =
375 { prop_buildnumberW
, CIM_STRING
},
376 { prop_captionW
, CIM_STRING
},
377 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
378 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
379 { prop_csdversionW
, CIM_STRING
},
380 { prop_installdateW
, CIM_DATETIME
},
381 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
382 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
383 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
384 { prop_nameW
, CIM_STRING
},
385 { prop_osarchitectureW
, CIM_STRING
},
386 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
387 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
388 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
389 { prop_serialnumberW
, CIM_STRING
},
390 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
391 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
392 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
393 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
394 { prop_versionW
, CIM_STRING
}
396 static const struct column col_param
[] =
398 { prop_classW
, CIM_STRING
},
399 { prop_methodW
, CIM_STRING
},
400 { prop_directionW
, CIM_SINT32
},
401 { prop_parameterW
, CIM_STRING
},
402 { prop_typeW
, CIM_UINT32
},
403 { prop_varianttypeW
, CIM_UINT32
},
404 { prop_defaultvalueW
, CIM_UINT32
}
406 static const struct column col_physicalmedia
[] =
408 { prop_serialnumberW
, CIM_STRING
},
409 { prop_tagW
, CIM_STRING
}
411 static const struct column col_physicalmemory
[] =
413 { prop_capacityW
, CIM_UINT64
}
415 static const struct column col_process
[] =
417 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
418 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
419 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
420 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
421 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
422 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
423 { prop_processidW
, CIM_UINT32
, VT_I4
},
424 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
426 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
428 static const struct column col_processor
[] =
430 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
431 { prop_cpustatusW
, CIM_UINT16
},
432 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
433 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
434 { prop_familyW
, CIM_UINT16
, VT_I4
},
435 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
436 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
437 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
438 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
439 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
440 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
441 { prop_uniqueidW
, CIM_STRING
}
443 static const struct column col_qualifier
[] =
445 { prop_classW
, CIM_STRING
},
446 { prop_memberW
, CIM_STRING
},
447 { prop_typeW
, CIM_UINT32
},
448 { prop_flavorW
, CIM_SINT32
},
449 { prop_nameW
, CIM_STRING
},
450 { prop_intvalueW
, CIM_SINT32
},
451 { prop_strvalueW
, CIM_STRING
}
453 static const struct column col_service
[] =
455 { prop_acceptpauseW
, CIM_BOOLEAN
},
456 { prop_acceptstopW
, CIM_BOOLEAN
},
457 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
458 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
459 { prop_processidW
, CIM_UINT32
},
460 { prop_servicetypeW
, CIM_STRING
},
461 { prop_startmodeW
, CIM_STRING
},
462 { prop_stateW
, CIM_STRING
},
463 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
465 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
466 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
467 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
468 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
470 static const struct column col_sounddevice
[] =
472 { prop_nameW
, CIM_STRING
},
473 { prop_productnameW
, CIM_STRING
}
475 static const struct column col_stdregprov
[] =
477 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
478 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
479 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
481 static const struct column col_systemsecurity
[] =
483 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
484 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
486 static const struct column col_videocontroller
[] =
488 { prop_adapterdactypeW
, CIM_STRING
},
489 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
490 { prop_availabilityW
, CIM_UINT16
},
491 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
492 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
493 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
494 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
495 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
496 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
497 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
500 static const WCHAR baseboard_manufacturerW
[] =
501 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
502 static const WCHAR baseboard_serialnumberW
[] =
504 static const WCHAR baseboard_tagW
[] =
505 {'B','a','s','e',' ','B','o','a','r','d',0};
506 static const WCHAR bios_descriptionW
[] =
507 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
508 static const WCHAR bios_manufacturerW
[] =
509 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
510 static const WCHAR bios_releasedateW
[] =
511 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
512 static const WCHAR bios_serialnumberW
[] =
514 static const WCHAR bios_smbiosbiosversionW
[] =
516 static const WCHAR bios_versionW
[] =
517 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
518 static const WCHAR cdromdrive_mediatypeW
[] =
519 {'C','D','-','R','O','M',0};
520 static const WCHAR cdromdrive_nameW
[] =
521 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
522 static const WCHAR cdromdrive_pnpdeviceidW
[]=
523 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
524 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
525 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
526 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
527 static const WCHAR compsys_descriptionW
[] =
528 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
529 static const WCHAR compsys_domainW
[] =
530 {'W','O','R','K','G','R','O','U','P',0};
531 static const WCHAR compsys_manufacturerW
[] =
532 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
533 static const WCHAR compsys_modelW
[] =
535 static const WCHAR diskdrive_interfacetypeW
[] =
537 static const WCHAR diskdrive_manufacturerW
[] =
538 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
539 static const WCHAR diskdrive_mediatype_fixedW
[] =
540 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
541 static const WCHAR diskdrive_mediatype_removableW
[] =
542 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
543 static const WCHAR diskdrive_modelW
[] =
544 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
545 static const WCHAR diskdrive_serialW
[] =
546 {'W','I','N','E','H','D','I','S','K',0};
547 static const WCHAR networkadapter_pnpdeviceidW
[]=
548 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
549 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
550 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
551 static const WCHAR os_32bitW
[] =
552 {'3','2','-','b','i','t',0};
553 static const WCHAR os_64bitW
[] =
554 {'6','4','-','b','i','t',0};
555 static const WCHAR os_buildnumberW
[] =
557 static const WCHAR os_captionW
[] =
558 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
559 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
560 static const WCHAR os_csdversionW
[] =
561 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
562 static const WCHAR os_installdateW
[] =
563 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
564 static const WCHAR os_nameW
[] =
565 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
566 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
567 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
568 '\\','P','a','r','t','i','t','i','o','n','1',0};
569 static const WCHAR os_serialnumberW
[] =
570 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
571 static const WCHAR os_versionW
[] =
572 {'5','.','1','.','2','6','0','0',0};
573 static const WCHAR physicalmedia_tagW
[] =
574 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
575 static const WCHAR sounddevice_productnameW
[] =
576 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
577 static const WCHAR videocontroller_dactypeW
[] =
578 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
579 static const WCHAR videocontroller_deviceidW
[] =
580 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
582 #include "pshpack1.h"
583 struct record_baseboard
585 const WCHAR
*manufacturer
;
588 const WCHAR
*serialnumber
;
593 const WCHAR
*description
;
594 const WCHAR
*identificationcode
;
595 const WCHAR
*manufacturer
;
596 const WCHAR
*releasedate
;
597 const WCHAR
*serialnumber
;
598 const WCHAR
*smbiosbiosversion
;
599 const WCHAR
*version
;
601 struct record_cdromdrive
603 const WCHAR
*device_id
;
605 const WCHAR
*mediatype
;
607 const WCHAR
*pnpdevice_id
;
609 struct record_computersystem
611 const WCHAR
*description
;
614 const WCHAR
*manufacturer
;
617 UINT32 num_logical_processors
;
618 UINT32 num_processors
;
619 UINT64 total_physical_memory
;
621 struct record_datafile
624 const WCHAR
*version
;
626 struct record_directory
631 struct record_diskdrive
633 const WCHAR
*device_id
;
635 const WCHAR
*interfacetype
;
636 const WCHAR
*manufacturer
;
637 const WCHAR
*mediatype
;
639 const WCHAR
*serialnumber
;
642 struct record_diskpartition
646 const WCHAR
*device_id
;
649 const WCHAR
*pnpdevice_id
;
651 UINT64 startingoffset
;
654 struct record_logicaldisk
656 const WCHAR
*device_id
;
658 const WCHAR
*filesystem
;
662 const WCHAR
*volumeserialnumber
;
664 struct record_networkadapter
666 const WCHAR
*adaptertype
;
667 const WCHAR
*device_id
;
669 UINT32 interface_index
;
670 const WCHAR
*mac_address
;
671 const WCHAR
*manufacturer
;
673 UINT16 netconnection_status
;
675 const WCHAR
*pnpdevice_id
;
678 struct record_networkadapterconfig
681 UINT32 ipconnectionmetric
;
683 const WCHAR
*mac_address
;
685 struct record_operatingsystem
687 const WCHAR
*buildnumber
;
688 const WCHAR
*caption
;
689 const WCHAR
*codeset
;
690 const WCHAR
*countrycode
;
691 const WCHAR
*csdversion
;
692 const WCHAR
*installdate
;
693 const WCHAR
*lastbootuptime
;
694 const WCHAR
*localdatetime
;
697 const WCHAR
*osarchitecture
;
699 UINT32 osproductsuite
;
701 const WCHAR
*serialnumber
;
702 UINT16 servicepackmajor
;
703 UINT16 servicepackminor
;
705 const WCHAR
*systemdirectory
;
706 const WCHAR
*version
;
713 const WCHAR
*parameter
;
718 struct record_physicalmedia
720 const WCHAR
*serialnumber
;
723 struct record_physicalmemory
727 struct record_process
729 const WCHAR
*caption
;
730 const WCHAR
*commandline
;
731 const WCHAR
*description
;
738 class_method
*get_owner
;
740 struct record_processor
744 UINT32 currentclockspeed
;
745 const WCHAR
*device_id
;
747 const WCHAR
*manufacturer
;
748 UINT32 maxclockspeed
;
751 UINT32 num_logical_processors
;
752 const WCHAR
*processor_id
;
753 const WCHAR
*unique_id
;
755 struct record_qualifier
763 const WCHAR
*strvalue
;
765 struct record_service
769 const WCHAR
*displayname
;
772 const WCHAR
*servicetype
;
773 const WCHAR
*startmode
;
775 const WCHAR
*systemname
;
777 class_method
*pause_service
;
778 class_method
*resume_service
;
779 class_method
*start_service
;
780 class_method
*stop_service
;
782 struct record_sounddevice
785 const WCHAR
*productname
;
787 struct record_stdregprov
789 class_method
*enumkey
;
790 class_method
*enumvalues
;
791 class_method
*getstringvalue
;
793 struct record_systemsecurity
798 struct record_videocontroller
800 const WCHAR
*adapter_dactype
;
803 UINT32 current_bitsperpixel
;
804 UINT32 current_horizontalres
;
805 UINT32 current_verticalres
;
806 const WCHAR
*description
;
807 const WCHAR
*device_id
;
809 const WCHAR
*pnpdevice_id
;
813 static const struct record_baseboard data_baseboard
[] =
815 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_tagW
}
817 static const struct record_bios data_bios
[] =
819 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
820 bios_smbiosbiosversionW
, bios_versionW
}
822 static const struct record_param data_param
[] =
824 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
825 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
826 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
827 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
828 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
829 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
830 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
831 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
832 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
833 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
834 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
835 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
836 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
837 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
838 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
839 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
840 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
841 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
842 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
843 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
844 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
845 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
846 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
847 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
848 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
851 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
852 WBEM_FLAVOR_ORIGIN_PROPAGATED)
854 static const struct record_physicalmedia data_physicalmedia
[] =
856 { diskdrive_serialW
, physicalmedia_tagW
}
858 static const struct record_qualifier data_qualifier
[] =
860 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
861 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
863 static const struct record_sounddevice data_sounddevice
[] =
865 { sounddevice_productnameW
, sounddevice_productnameW
}
867 static const struct record_stdregprov data_stdregprov
[] =
869 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
871 static const struct record_systemsecurity data_systemsecurity
[] =
873 { security_get_sd
, security_set_sd
}
876 /* check if row matches condition and update status */
877 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
884 *status
= FILL_STATUS_UNFILTERED
;
887 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
889 *status
= FILL_STATUS_FAILED
;
892 *status
= FILL_STATUS_FILTERED
;
896 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
898 if (!table
->num_rows_allocated
)
900 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
901 table
->num_rows_allocated
= row_count
;
904 if (row_count
>= table
->num_rows_allocated
)
907 UINT count
= table
->num_rows_allocated
* 2;
908 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
910 table
->num_rows_allocated
= count
;
915 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
917 static const WCHAR fmtW
[] = {'%','c',':',0};
918 WCHAR drive
[3], root
[] = {'A',':','\\',0};
919 struct record_cdromdrive
*rec
;
920 UINT i
, row
= 0, offset
= 0;
921 DWORD drives
= GetLogicalDrives();
922 enum fill_status status
= FILL_STATUS_UNFILTERED
;
924 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
926 for (i
= 0; i
< sizeof(drives
); i
++)
928 if (drives
& (1 << i
))
931 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
934 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
936 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
937 rec
->device_id
= cdromdrive_pnpdeviceidW
;
938 sprintfW( drive
, fmtW
, 'A' + i
);
939 rec
->drive
= heap_strdupW( drive
);
940 rec
->mediatype
= cdromdrive_mediatypeW
;
941 rec
->name
= cdromdrive_nameW
;
942 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
943 if (!match_row( table
, row
, cond
, &status
))
945 free_row_values( table
, row
);
948 offset
+= sizeof(*rec
);
952 TRACE("created %u rows\n", row
);
953 table
->num_rows
= row
;
957 static UINT
get_processor_count(void)
959 SYSTEM_BASIC_INFORMATION info
;
961 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
962 return info
.NumberOfProcessors
;
965 static UINT
get_logical_processor_count( UINT
*num_cores
)
967 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
968 UINT i
, j
, count
= 0;
972 if (num_cores
) *num_cores
= get_processor_count();
973 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
974 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
976 if (!(info
= heap_alloc( len
))) return get_processor_count();
977 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
978 if (status
!= STATUS_SUCCESS
)
981 return get_processor_count();
983 if (num_cores
) *num_cores
= 0;
984 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
986 if (info
[i
].Relationship
== RelationProcessorCore
)
988 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
990 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
992 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
999 static UINT64
get_total_physical_memory(void)
1001 MEMORYSTATUSEX status
;
1003 status
.dwLength
= sizeof(status
);
1004 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1005 return status
.ullTotalPhys
;
1008 static WCHAR
*get_computername(void)
1011 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
1013 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1014 GetComputerNameW( ret
, &size
);
1018 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1020 struct record_computersystem
*rec
;
1021 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1024 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1026 rec
= (struct record_computersystem
*)table
->data
;
1027 rec
->description
= compsys_descriptionW
;
1028 rec
->domain
= compsys_domainW
;
1029 rec
->domainrole
= 0; /* standalone workstation */
1030 rec
->manufacturer
= compsys_manufacturerW
;
1031 rec
->model
= compsys_modelW
;
1032 rec
->name
= get_computername();
1033 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1034 rec
->num_processors
= get_processor_count();
1035 rec
->total_physical_memory
= get_total_physical_memory();
1036 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1039 TRACE("created %u rows\n", row
);
1040 table
->num_rows
= row
;
1052 static struct dirstack
*alloc_dirstack( UINT size
)
1054 struct dirstack
*dirstack
;
1056 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1057 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1059 heap_free( dirstack
);
1062 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1064 heap_free( dirstack
->dirs
);
1065 heap_free( dirstack
);
1068 dirstack
->num_dirs
= 0;
1069 dirstack
->num_allocated
= size
;
1073 static void clear_dirstack( struct dirstack
*dirstack
)
1076 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1077 dirstack
->num_dirs
= 0;
1080 static void free_dirstack( struct dirstack
*dirstack
)
1082 clear_dirstack( dirstack
);
1083 heap_free( dirstack
->dirs
);
1084 heap_free( dirstack
->len_dirs
);
1085 heap_free( dirstack
);
1088 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1090 UINT size
, i
= dirstack
->num_dirs
;
1092 if (!dir
) return FALSE
;
1094 if (i
== dirstack
->num_allocated
)
1099 size
= dirstack
->num_allocated
* 2;
1100 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1101 dirstack
->dirs
= tmp
;
1102 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1103 dirstack
->len_dirs
= len_tmp
;
1104 dirstack
->num_allocated
= size
;
1106 dirstack
->dirs
[i
] = dir
;
1107 dirstack
->len_dirs
[i
] = len
;
1108 dirstack
->num_dirs
++;
1112 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1114 if (!dirstack
->num_dirs
)
1119 dirstack
->num_dirs
--;
1120 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1121 return dirstack
->dirs
[dirstack
->num_dirs
];
1124 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1126 if (!dirstack
->num_dirs
) return NULL
;
1127 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1130 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1135 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1141 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1150 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1152 UINT i
= 0, len
= 0;
1156 for (p
= path
; *p
; p
++)
1158 if (*p
== '\\') len
+= 2;
1161 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1166 for (p
= path
; *p
; p
++)
1168 if (*p
!= '\\') ret
[i
++] = *p
;
1179 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1181 const WCHAR
*p
= path
, *start
;
1185 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1187 len
= strlenW( start
);
1188 p
= start
+ len
- 1;
1189 if (*p
== '\\') return NULL
;
1191 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1192 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1194 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1195 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1197 if (p
[0] == '\\' && p
[1] == '\\')
1209 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1212 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1216 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1217 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1219 const struct expr
*left
, *right
;
1221 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1223 left
= cond
->u
.expr
.left
;
1224 right
= cond
->u
.expr
.right
;
1225 if (cond
->u
.expr
.op
== OP_EQ
)
1229 const WCHAR
*str
= NULL
;
1231 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1232 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1233 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1235 str
= right
->u
.sval
;
1237 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1238 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1239 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1243 if (str
&& (path
= build_dirname( str
, &len
)))
1245 if (seen_dir( dirstack
, path
))
1250 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1255 else if (cond
->u
.expr
.op
== OP_OR
)
1257 UINT left_count
= 0, right_count
= 0;
1259 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1260 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1261 return *count
+= left_count
+ right_count
;
1266 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1268 UINT len_path
= 0, len_segment
= strlenW( segment
);
1272 if (path
) len_path
= strlenW( path
);
1273 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1274 if (path
&& len_path
)
1276 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1277 ret
[len_path
] = '\\';
1278 *len
+= len_path
+ 1;
1280 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1281 *len
+= len_segment
;
1286 static WCHAR
*get_file_version( const WCHAR
*filename
)
1288 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1289 VS_FIXEDFILEINFO
*info
;
1294 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1295 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1300 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1301 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1307 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1308 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1313 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1315 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1316 struct record_datafile
*rec
;
1317 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1318 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1319 DWORD drives
= GetLogicalDrives();
1320 WIN32_FIND_DATAW data
;
1322 struct dirstack
*dirstack
;
1323 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1325 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1327 dirstack
= alloc_dirstack(2);
1329 for (i
= 0; i
< sizeof(drives
); i
++)
1331 if (!(drives
& (1 << i
))) continue;
1334 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1336 num_expected_rows
= 0;
1337 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1341 path
= pop_dir( dirstack
, &len
);
1342 if (!(glob
= build_glob( root
[0], path
, len
)))
1344 status
= FILL_STATUS_FAILED
;
1347 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1351 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1353 status
= FILL_STATUS_FAILED
;
1354 FindClose( handle
);
1357 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1358 new_path
= append_path( path
, data
.cFileName
, &len
);
1360 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1362 if (push_dir( dirstack
, new_path
, len
)) continue;
1363 heap_free( new_path
);
1364 FindClose( handle
);
1365 status
= FILL_STATUS_FAILED
;
1368 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1369 rec
->name
= build_name( root
[0], new_path
);
1370 rec
->version
= get_file_version( rec
->name
);
1371 if (!match_row( table
, row
, cond
, &status
))
1373 free_row_values( table
, row
);
1376 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1379 FindClose( handle
);
1380 status
= FILL_STATUS_FILTERED
;
1383 offset
+= sizeof(*rec
);
1386 while (FindNextFileW( handle
, &data
));
1387 FindClose( handle
);
1389 if (!peek_dir( dirstack
)) break;
1396 free_dirstack( dirstack
);
1400 TRACE("created %u rows\n", row
);
1401 table
->num_rows
= row
;
1405 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1407 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1408 struct record_directory
*rec
;
1409 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1410 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1411 DWORD drives
= GetLogicalDrives();
1412 WIN32_FIND_DATAW data
;
1414 struct dirstack
*dirstack
;
1415 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1417 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1419 dirstack
= alloc_dirstack(2);
1421 for (i
= 0; i
< sizeof(drives
); i
++)
1423 if (!(drives
& (1 << i
))) continue;
1426 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1428 num_expected_rows
= 0;
1429 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1433 path
= pop_dir( dirstack
, &len
);
1434 if (!(glob
= build_glob( root
[0], path
, len
)))
1436 status
= FILL_STATUS_FAILED
;
1439 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1443 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1445 FindClose( handle
);
1446 status
= FILL_STATUS_FAILED
;
1449 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1450 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1453 new_path
= append_path( path
, data
.cFileName
, &len
);
1454 if (!(push_dir( dirstack
, new_path
, len
)))
1456 heap_free( new_path
);
1457 FindClose( handle
);
1458 status
= FILL_STATUS_FAILED
;
1461 rec
= (struct record_directory
*)(table
->data
+ offset
);
1462 rec
->accessmask
= FILE_ALL_ACCESS
;
1463 rec
->name
= build_name( root
[0], new_path
);
1464 if (!match_row( table
, row
, cond
, &status
))
1466 free_row_values( table
, row
);
1469 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1472 FindClose( handle
);
1473 status
= FILL_STATUS_FILTERED
;
1476 offset
+= sizeof(*rec
);
1479 while (FindNextFileW( handle
, &data
));
1480 FindClose( handle
);
1482 if (!peek_dir( dirstack
)) break;
1489 free_dirstack( dirstack
);
1493 TRACE("created %u rows\n", row
);
1494 table
->num_rows
= row
;
1498 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1500 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1501 ULARGE_INTEGER free
;
1502 DISK_GEOMETRY_EX info
;
1504 DWORD bytes_returned
;
1506 free
.QuadPart
= 512 * 1024 * 1024;
1507 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1510 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1511 if (handle
!= INVALID_HANDLE_VALUE
)
1513 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1514 *disksize
= info
.DiskSize
.QuadPart
;
1515 CloseHandle( handle
);
1517 return free
.QuadPart
;
1520 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1522 static const WCHAR fmtW
[] =
1523 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1524 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1525 struct record_diskdrive
*rec
;
1526 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1527 UINT64 size
= 1024 * 1024 * 1024;
1528 DWORD drives
= GetLogicalDrives();
1529 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1531 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1533 for (i
= 0; i
< sizeof(drives
); i
++)
1535 if (drives
& (1 << i
))
1538 type
= GetDriveTypeW( root
);
1539 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1542 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1544 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1545 sprintfW( device_id
, fmtW
, index
);
1546 rec
->device_id
= heap_strdupW( device_id
);
1548 rec
->interfacetype
= diskdrive_interfacetypeW
;
1549 rec
->manufacturer
= diskdrive_manufacturerW
;
1550 if (type
== DRIVE_FIXED
)
1551 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1553 rec
->mediatype
= diskdrive_mediatype_removableW
;
1554 rec
->model
= diskdrive_modelW
;
1555 rec
->serialnumber
= diskdrive_serialW
;
1556 get_freespace( root
, &size
);
1558 if (!match_row( table
, row
, cond
, &status
))
1560 free_row_values( table
, row
);
1563 offset
+= sizeof(*rec
);
1568 TRACE("created %u rows\n", row
);
1569 table
->num_rows
= row
;
1573 static WCHAR
*get_filesystem( const WCHAR
*root
)
1575 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1576 WCHAR buffer
[MAX_PATH
+ 1];
1578 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1579 return heap_strdupW( buffer
);
1580 return heap_strdupW( ntfsW
);
1583 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1585 static const WCHAR fmtW
[] =
1586 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1587 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1588 struct record_diskpartition
*rec
;
1589 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1590 UINT64 size
= 1024 * 1024 * 1024;
1591 DWORD drives
= GetLogicalDrives();
1592 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1594 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1596 for (i
= 0; i
< sizeof(drives
); i
++)
1598 if (drives
& (1 << i
))
1601 type
= GetDriveTypeW( root
);
1602 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1605 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1607 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1608 rec
->bootable
= (i
== 2) ? -1 : 0;
1609 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1610 sprintfW( device_id
, fmtW
, index
);
1611 rec
->device_id
= heap_strdupW( device_id
);
1612 rec
->diskindex
= index
;
1614 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1615 get_freespace( root
, &size
);
1617 rec
->startingoffset
= 0;
1618 rec
->type
= get_filesystem( root
);
1619 if (!match_row( table
, row
, cond
, &status
))
1621 free_row_values( table
, row
);
1624 offset
+= sizeof(*rec
);
1629 TRACE("created %u rows\n", row
);
1630 table
->num_rows
= row
;
1634 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1636 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1640 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1641 sprintfW( buffer
, fmtW
, serial
);
1642 return heap_strdupW( buffer
);
1645 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1647 static const WCHAR fmtW
[] = {'%','c',':',0};
1648 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1649 struct record_logicaldisk
*rec
;
1650 UINT i
, row
= 0, offset
= 0, type
;
1651 UINT64 size
= 1024 * 1024 * 1024;
1652 DWORD drives
= GetLogicalDrives();
1653 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1655 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1657 for (i
= 0; i
< sizeof(drives
); i
++)
1659 if (drives
& (1 << i
))
1662 type
= GetDriveTypeW( root
);
1663 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1666 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1668 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1669 sprintfW( device_id
, fmtW
, 'A' + i
);
1670 rec
->device_id
= heap_strdupW( device_id
);
1671 rec
->drivetype
= type
;
1672 rec
->filesystem
= get_filesystem( root
);
1673 rec
->freespace
= get_freespace( root
, &size
);
1674 rec
->name
= heap_strdupW( device_id
);
1676 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1677 if (!match_row( table
, row
, cond
, &status
))
1679 free_row_values( table
, row
);
1682 offset
+= sizeof(*rec
);
1686 TRACE("created %u rows\n", row
);
1687 table
->num_rows
= row
;
1691 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1695 case IfOperStatusDown
:
1696 return 0; /* Disconnected */
1697 case IfOperStatusUp
:
1698 return 2; /* Connected */
1700 ERR("unhandled status %u\n", status
);
1705 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1707 static const WCHAR fmtW
[] =
1708 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1709 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1712 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1713 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1716 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1718 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1719 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1720 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1721 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1725 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1726 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1727 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1728 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1729 default: *physical
= 0; return NULL
;
1733 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1735 static const WCHAR fmtW
[] = {'%','u',0};
1736 WCHAR device_id
[11];
1737 struct record_networkadapter
*rec
;
1738 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1739 UINT row
= 0, offset
= 0, count
= 0;
1740 DWORD size
= 0, ret
;
1742 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1744 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1745 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1747 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1748 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1750 heap_free( buffer
);
1751 return FILL_STATUS_FAILED
;
1753 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1755 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1757 if (!resize_table( table
, count
, sizeof(*rec
) ))
1759 heap_free( buffer
);
1760 return FILL_STATUS_FAILED
;
1762 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1764 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1766 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1767 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1768 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1769 rec
->device_id
= heap_strdupW( device_id
);
1770 rec
->index
= aa
->u
.s
.IfIndex
;
1771 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1772 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1773 rec
->manufacturer
= compsys_manufacturerW
;
1774 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1775 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1776 rec
->physicaladapter
= physical
;
1777 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1778 rec
->speed
= 1000000;
1779 if (!match_row( table
, row
, cond
, &status
))
1781 free_row_values( table
, row
);
1784 offset
+= sizeof(*rec
);
1787 TRACE("created %u rows\n", row
);
1788 table
->num_rows
= row
;
1790 heap_free( buffer
);
1794 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1796 struct record_networkadapterconfig
*rec
;
1797 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1798 UINT row
= 0, offset
= 0, count
= 0;
1799 DWORD size
= 0, ret
;
1800 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1802 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1803 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1805 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1806 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1808 heap_free( buffer
);
1809 return FILL_STATUS_FAILED
;
1811 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1813 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1815 if (!resize_table( table
, count
, sizeof(*rec
) ))
1817 heap_free( buffer
);
1818 return FILL_STATUS_FAILED
;
1820 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1822 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1824 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1825 rec
->index
= aa
->u
.s
.IfIndex
;
1826 rec
->ipconnectionmetric
= 20;
1827 rec
->ipenabled
= -1;
1828 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1829 if (!match_row( table
, row
, cond
, &status
))
1831 free_row_values( table
, row
);
1834 offset
+= sizeof(*rec
);
1837 TRACE("created %u rows\n", row
);
1838 table
->num_rows
= row
;
1840 heap_free( buffer
);
1844 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
1846 struct record_physicalmemory
*rec
;
1847 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1850 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1852 rec
= (struct record_physicalmemory
*)table
->data
;
1853 rec
->capacity
= get_total_physical_memory();
1854 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1857 TRACE("created %u rows\n", row
);
1858 table
->num_rows
= row
;
1862 static WCHAR
*get_cmdline( DWORD process_id
)
1864 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1865 return NULL
; /* FIXME handle different process case */
1868 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1870 static const WCHAR fmtW
[] = {'%','u',0};
1872 struct record_process
*rec
;
1873 PROCESSENTRY32W entry
;
1875 enum fill_status status
= FILL_STATUS_FAILED
;
1876 UINT row
= 0, offset
= 0;
1878 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1879 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1881 entry
.dwSize
= sizeof(entry
);
1882 if (!Process32FirstW( snap
, &entry
)) goto done
;
1883 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1887 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1889 rec
= (struct record_process
*)(table
->data
+ offset
);
1890 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1891 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1892 rec
->description
= heap_strdupW( entry
.szExeFile
);
1893 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1894 rec
->handle
= heap_strdupW( handle
);
1895 rec
->name
= heap_strdupW( entry
.szExeFile
);
1896 rec
->process_id
= entry
.th32ProcessID
;
1897 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1898 rec
->thread_count
= entry
.cntThreads
;
1899 rec
->get_owner
= process_get_owner
;
1900 if (!match_row( table
, row
, cond
, &status
))
1902 free_row_values( table
, row
);
1905 offset
+= sizeof(*rec
);
1907 } while (Process32NextW( snap
, &entry
));
1909 TRACE("created %u rows\n", row
);
1910 table
->num_rows
= row
;
1911 status
= FILL_STATUS_UNFILTERED
;
1914 CloseHandle( snap
);
1918 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
1924 __asm__("pushl %%ebx\n\t"
1926 "movl %%ebx, %%esi\n\t"
1928 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
1934 static void get_processor_id( WCHAR
*processor_id
)
1936 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
1937 unsigned int regs
[4] = {0, 0, 0, 0};
1939 do_cpuid( 1, regs
);
1940 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
1942 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
1945 unsigned char *p
= (unsigned char *)regs
;
1947 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
1950 static void get_processor_manufacturer( WCHAR
*manufacturer
)
1952 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
1954 do_cpuid( 0, regs
);
1955 tmp
= regs
[2]; /* swap edx and ecx */
1959 regs_to_str( regs
+ 1, 12, manufacturer
);
1961 static void get_processor_name( WCHAR
*name
)
1963 unsigned int regs
[4] = {0, 0, 0, 0};
1965 do_cpuid( 0x80000000, regs
);
1966 if (regs
[0] >= 0x80000004)
1968 do_cpuid( 0x80000002, regs
);
1969 regs_to_str( regs
, 16, name
);
1970 do_cpuid( 0x80000003, regs
);
1971 regs_to_str( regs
, 16, name
+ 16 );
1972 do_cpuid( 0x80000004, regs
);
1973 regs_to_str( regs
, 16, name
+ 32 );
1976 static UINT
get_processor_currentclockspeed( UINT index
)
1978 PROCESSOR_POWER_INFORMATION
*info
;
1979 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1982 if ((info
= heap_alloc( size
)))
1984 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1985 if (!status
) ret
= info
[index
].CurrentMhz
;
1990 static UINT
get_processor_maxclockspeed( UINT index
)
1992 PROCESSOR_POWER_INFORMATION
*info
;
1993 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1996 if ((info
= heap_alloc( size
)))
1998 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1999 if (!status
) ret
= info
[index
].MaxMhz
;
2004 static const WCHAR
*get_osarchitecture(void)
2007 GetNativeSystemInfo( &info
);
2008 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2012 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2014 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2015 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2016 struct record_processor
*rec
;
2017 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2018 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2020 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2022 get_processor_id( processor_id
);
2023 get_processor_manufacturer( manufacturer
);
2024 get_processor_name( name
);
2026 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2029 for (i
= 0; i
< count
; i
++)
2031 rec
= (struct record_processor
*)(table
->data
+ offset
);
2032 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2033 rec
->cpu_status
= 1; /* CPU Enabled */
2034 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2035 sprintfW( device_id
, fmtW
, i
);
2036 rec
->device_id
= heap_strdupW( device_id
);
2037 rec
->family
= 2; /* Unknown */
2038 rec
->manufacturer
= heap_strdupW( manufacturer
);
2039 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2040 rec
->name
= heap_strdupW( name
);
2041 rec
->num_cores
= num_cores
;
2042 rec
->num_logical_processors
= num_logical_processors
;
2043 rec
->processor_id
= heap_strdupW( processor_id
);
2044 rec
->unique_id
= NULL
;
2045 if (!match_row( table
, i
, cond
, &status
))
2047 free_row_values( table
, i
);
2050 offset
+= sizeof(*rec
);
2053 TRACE("created %u rows\n", count
);
2054 table
->num_rows
= count
;
2058 static WCHAR
*get_lastbootuptime(void)
2060 static const WCHAR fmtW
[] =
2061 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2062 '.','%','0','6','u','+','0','0','0',0};
2063 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2067 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2069 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2070 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2071 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2074 static WCHAR
*get_localdatetime(void)
2076 static const WCHAR fmtW
[] =
2077 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2078 '.','%','0','6','u','%','+','0','3','d',0};
2079 TIME_ZONE_INFORMATION tzi
;
2085 Status
= GetTimeZoneInformation(&tzi
);
2087 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2089 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2090 Bias
+= tzi
.DaylightBias
;
2092 Bias
+= tzi
.StandardBias
;
2093 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2096 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2099 static WCHAR
*get_systemdirectory(void)
2104 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2105 Wow64DisableWow64FsRedirection( &redir
);
2106 GetSystemDirectoryW( ret
, MAX_PATH
);
2107 Wow64RevertWow64FsRedirection( redir
);
2110 static WCHAR
*get_codeset(void)
2112 static const WCHAR fmtW
[] = {'%','u',0};
2113 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2114 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2117 static WCHAR
*get_countrycode(void)
2119 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2120 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2123 static WCHAR
*get_locale(void)
2125 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2126 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2130 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2132 struct record_operatingsystem
*rec
;
2133 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2136 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2138 rec
= (struct record_operatingsystem
*)table
->data
;
2139 rec
->buildnumber
= os_buildnumberW
;
2140 rec
->caption
= os_captionW
;
2141 rec
->codeset
= get_codeset();
2142 rec
->countrycode
= get_countrycode();
2143 rec
->csdversion
= os_csdversionW
;
2144 rec
->installdate
= os_installdateW
;
2145 rec
->lastbootuptime
= get_lastbootuptime();
2146 rec
->localdatetime
= get_localdatetime();
2147 rec
->locale
= get_locale();
2148 rec
->name
= os_nameW
;
2149 rec
->osarchitecture
= get_osarchitecture();
2150 rec
->oslanguage
= GetSystemDefaultLangID();
2151 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2152 rec
->ostype
= 18; /* WINNT */
2153 rec
->serialnumber
= os_serialnumberW
;
2154 rec
->servicepackmajor
= 3;
2155 rec
->servicepackminor
= 0;
2156 rec
->suitemask
= 272; /* Single User + Terminal */
2157 rec
->systemdirectory
= get_systemdirectory();
2158 rec
->version
= os_versionW
;
2159 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2162 TRACE("created %u rows\n", row
);
2163 table
->num_rows
= row
;
2167 static const WCHAR
*get_service_type( DWORD type
)
2169 static const WCHAR filesystem_driverW
[] =
2170 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2171 static const WCHAR kernel_driverW
[] =
2172 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2173 static const WCHAR own_processW
[] =
2174 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2175 static const WCHAR share_processW
[] =
2176 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2178 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2179 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2180 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2181 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2182 else ERR("unhandled type 0x%08x\n", type
);
2185 static const WCHAR
*get_service_state( DWORD state
)
2187 static const WCHAR runningW
[] =
2188 {'R','u','n','n','i','n','g',0};
2189 static const WCHAR start_pendingW
[] =
2190 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2191 static const WCHAR stop_pendingW
[] =
2192 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2193 static const WCHAR stoppedW
[] =
2194 {'S','t','o','p','p','e','d',0};
2195 static const WCHAR unknownW
[] =
2196 {'U','n','k','n','o','w','n',0};
2200 case SERVICE_STOPPED
: return stoppedW
;
2201 case SERVICE_START_PENDING
: return start_pendingW
;
2202 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2203 case SERVICE_RUNNING
: return runningW
;
2205 ERR("unknown state %u\n", state
);
2209 static const WCHAR
*get_service_startmode( DWORD mode
)
2211 static const WCHAR bootW
[] = {'B','o','o','t',0};
2212 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2213 static const WCHAR autoW
[] = {'A','u','t','o',0};
2214 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2215 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2216 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2220 case SERVICE_BOOT_START
: return bootW
;
2221 case SERVICE_SYSTEM_START
: return systemW
;
2222 case SERVICE_AUTO_START
: return autoW
;
2223 case SERVICE_DEMAND_START
: return manualW
;
2224 case SERVICE_DISABLED
: return disabledW
;
2226 ERR("unknown mode 0x%x\n", mode
);
2230 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2232 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2236 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2237 QueryServiceConfigW( service
, NULL
, 0, &size
);
2238 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2239 if (!(config
= heap_alloc( size
))) goto done
;
2240 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2241 heap_free( config
);
2245 CloseServiceHandle( service
);
2249 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2251 struct record_service
*rec
;
2253 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2254 SERVICE_STATUS_PROCESS
*status
;
2255 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2256 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2257 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2258 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2261 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2262 if (!(services
= heap_alloc( size
))) goto done
;
2264 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2265 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2266 &count
, NULL
, NULL
);
2269 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2271 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2273 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2274 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2275 &count
, NULL
, NULL
);
2276 if (!ret
) goto done
;
2278 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2280 GetComputerNameW( sysnameW
, &len
);
2281 fill_status
= FILL_STATUS_UNFILTERED
;
2283 for (i
= 0; i
< count
; i
++)
2285 QUERY_SERVICE_CONFIGW
*config
;
2287 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2289 status
= &services
[i
].ServiceStatusProcess
;
2290 rec
= (struct record_service
*)(table
->data
+ offset
);
2291 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2292 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2293 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2294 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2295 rec
->process_id
= status
->dwProcessId
;
2296 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2297 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2298 rec
->state
= get_service_state( status
->dwCurrentState
);
2299 rec
->systemname
= heap_strdupW( sysnameW
);
2300 rec
->pause_service
= service_pause_service
;
2301 rec
->resume_service
= service_resume_service
;
2302 rec
->start_service
= service_start_service
;
2303 rec
->stop_service
= service_stop_service
;
2304 heap_free( config
);
2305 if (!match_row( table
, row
, cond
, &fill_status
))
2307 free_row_values( table
, row
);
2310 offset
+= sizeof(*rec
);
2314 TRACE("created %u rows\n", row
);
2315 table
->num_rows
= row
;
2318 CloseServiceHandle( manager
);
2319 heap_free( services
);
2323 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2325 HDC hdc
= GetDC( NULL
);
2328 if (!hdc
) return 32;
2329 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2330 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2331 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2332 ReleaseDC( NULL
, hdc
);
2335 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2337 static const WCHAR fmtW
[] =
2338 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2339 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2340 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2343 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2344 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2348 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2351 struct record_videocontroller
*rec
;
2353 IDXGIFactory
*factory
= NULL
;
2354 IDXGIAdapter
*adapter
= NULL
;
2355 DXGI_ADAPTER_DESC desc
;
2356 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2357 const WCHAR
*name
= videocontroller_deviceidW
;
2358 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2361 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2363 memset (&desc
, 0, sizeof(desc
));
2364 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2365 if (FAILED(hr
)) goto done
;
2367 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2368 if (FAILED(hr
)) goto done
;
2370 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2373 vidmem
= desc
.DedicatedVideoMemory
;
2374 name
= desc
.Description
;
2378 rec
= (struct record_videocontroller
*)table
->data
;
2379 rec
->adapter_dactype
= videocontroller_dactypeW
;
2380 rec
->adapter_ram
= vidmem
;
2381 rec
->availability
= 3; /* Running or Full Power */
2382 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2383 rec
->current_horizontalres
= hres
;
2384 rec
->current_verticalres
= vres
;
2385 rec
->description
= heap_strdupW( name
);
2386 rec
->device_id
= videocontroller_deviceidW
;
2387 rec
->name
= heap_strdupW( name
);
2388 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2389 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2392 TRACE("created %u rows\n", row
);
2393 table
->num_rows
= row
;
2395 if (adapter
) IDXGIAdapter_Release( adapter
);
2396 if (factory
) IDXGIFactory_Release( factory
);
2400 static struct table builtin_classes
[] =
2402 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2403 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2404 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2405 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2406 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2407 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2408 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2409 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2410 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2411 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2412 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2413 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
,
2414 fill_networkadapterconfig
},
2415 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2416 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2417 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2418 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2419 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2420 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2421 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2422 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2423 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2424 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2425 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2426 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2427 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2430 void init_table_list( void )
2432 static struct list tables
= LIST_INIT( tables
);
2435 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2436 table_list
= &tables
;