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
43 #include "wine/debug.h"
44 #include "wbemprox_private.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
48 static const WCHAR class_baseboardW
[] =
49 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
50 static const WCHAR class_biosW
[] =
51 {'W','i','n','3','2','_','B','I','O','S',0};
52 static const WCHAR class_cdromdriveW
[] =
53 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
54 static const WCHAR class_compsysW
[] =
55 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
56 static const WCHAR class_compsysproductW
[] =
57 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
58 static const WCHAR class_datafileW
[] =
59 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
60 static const WCHAR class_directoryW
[] =
61 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
62 static const WCHAR class_diskdriveW
[] =
63 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
64 static const WCHAR class_diskpartitionW
[] =
65 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
66 static const WCHAR class_logicaldiskW
[] =
67 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
68 static const WCHAR class_logicaldisk2W
[] =
69 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
70 static const WCHAR class_networkadapterW
[] =
71 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
72 static const WCHAR class_networkadapterconfigW
[] =
73 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
74 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
75 static const WCHAR class_osW
[] =
76 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
77 static const WCHAR class_paramsW
[] =
78 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
79 static const WCHAR class_physicalmediaW
[] =
80 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
81 static const WCHAR class_physicalmemoryW
[] =
82 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
83 static const WCHAR class_qualifiersW
[] =
84 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
85 static const WCHAR class_process_getowner_outW
[] =
86 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
87 'N','E','R','_','O','U','T',0};
88 static const WCHAR class_processorW
[] =
89 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
90 static const WCHAR class_processor2W
[] =
91 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
92 static const WCHAR class_sounddeviceW
[] =
93 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
94 static const WCHAR class_videocontrollerW
[] =
95 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
97 static const WCHAR prop_acceptpauseW
[] =
98 {'A','c','c','e','p','t','P','a','u','s','e',0};
99 static const WCHAR prop_acceptstopW
[] =
100 {'A','c','c','e','p','t','S','t','o','p',0};
101 static const WCHAR prop_accessmaskW
[] =
102 {'A','c','c','e','s','s','M','a','s','k',0};
103 static const WCHAR prop_adapterdactypeW
[] =
104 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
105 static const WCHAR prop_adapterramW
[] =
106 {'A','d','a','p','t','e','r','R','A','M',0};
107 static const WCHAR prop_adaptertypeW
[] =
108 {'A','d','a','p','t','e','r','T','y','p','e',0};
109 static const WCHAR prop_addresswidthW
[] =
110 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
111 static const WCHAR prop_availabilityW
[] =
112 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
113 static const WCHAR prop_bootableW
[] =
114 {'B','o','o','t','a','b','l','e',0};
115 static const WCHAR prop_bootpartitionW
[] =
116 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
117 static const WCHAR prop_buildnumberW
[] =
118 {'B','u','i','l','d','N','u','m','b','e','r',0};
119 static const WCHAR prop_capacityW
[] =
120 {'C','a','p','a','c','i','t','y',0};
121 static const WCHAR prop_captionW
[] =
122 {'C','a','p','t','i','o','n',0};
123 static const WCHAR prop_classW
[] =
124 {'C','l','a','s','s',0};
125 static const WCHAR prop_codesetW
[] =
126 {'C','o','d','e','S','e','t',0};
127 static const WCHAR prop_commandlineW
[] =
128 {'C','o','m','m','a','n','d','L','i','n','e',0};
129 static const WCHAR prop_countrycodeW
[] =
130 {'C','o','u','n','t','r','y','C','o','d','e',0};
131 static const WCHAR prop_cpustatusW
[] =
132 {'C','p','u','S','t','a','t','u','s',0};
133 static const WCHAR prop_csdversionW
[] =
134 {'C','S','D','V','e','r','s','i','o','n',0};
135 static const WCHAR prop_currentbitsperpixelW
[] =
136 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
137 static const WCHAR prop_currentclockspeedW
[] =
138 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
139 static const WCHAR prop_currenthorizontalresW
[] =
140 {'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};
141 static const WCHAR prop_currentverticalresW
[] =
142 {'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};
143 static const WCHAR prop_defaultvalueW
[] =
144 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
145 static const WCHAR prop_descriptionW
[] =
146 {'D','e','s','c','r','i','p','t','i','o','n',0};
147 static const WCHAR prop_deviceidW
[] =
148 {'D','e','v','i','c','e','I','d',0};
149 static const WCHAR prop_directionW
[] =
150 {'D','i','r','e','c','t','i','o','n',0};
151 static const WCHAR prop_displaynameW
[] =
152 {'D','i','s','p','l','a','y','N','a','m','e',0};
153 static const WCHAR prop_diskindexW
[] =
154 {'D','i','s','k','I','n','d','e','x',0};
155 static const WCHAR prop_dnshostnameW
[] =
156 {'D','N','S','H','o','s','t','N','a','m','e',0};
157 static const WCHAR prop_domainW
[] =
158 {'D','o','m','a','i','n',0};
159 static const WCHAR prop_domainroleW
[] =
160 {'D','o','m','a','i','n','R','o','l','e',0};
161 static const WCHAR prop_driveW
[] =
162 {'D','r','i','v','e',0};
163 static const WCHAR prop_drivetypeW
[] =
164 {'D','r','i','v','e','T','y','p','e',0};
165 static const WCHAR prop_familyW
[] =
166 {'F','a','m','i','l','y',0};
167 static const WCHAR prop_filesystemW
[] =
168 {'F','i','l','e','S','y','s','t','e','m',0};
169 static const WCHAR prop_flavorW
[] =
170 {'F','l','a','v','o','r',0};
171 static const WCHAR prop_freespaceW
[] =
172 {'F','r','e','e','S','p','a','c','e',0};
173 static const WCHAR prop_handleW
[] =
174 {'H','a','n','d','l','e',0};
175 static const WCHAR prop_idW
[] =
177 static const WCHAR prop_identificationcodeW
[] =
178 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
179 static const WCHAR prop_identifyingnumberW
[] =
180 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
181 static const WCHAR prop_indexW
[] =
182 {'I','n','d','e','x',0};
183 static const WCHAR prop_installdateW
[] =
184 {'I','n','s','t','a','l','l','D','a','t','e',0};
185 static const WCHAR prop_interfaceindexW
[] =
186 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
187 static const WCHAR prop_interfacetypeW
[] =
188 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
189 static const WCHAR prop_intvalueW
[] =
190 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
191 static const WCHAR prop_ipconnectionmetricW
[] =
192 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
193 static const WCHAR prop_ipenabledW
[] =
194 {'I','P','E','n','a','b','l','e','d',0};
195 static const WCHAR prop_lastbootuptimeW
[] =
196 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
197 static const WCHAR prop_localdatetimeW
[] =
198 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
199 static const WCHAR prop_localeW
[] =
200 {'L','o','c','a','l','e',0};
201 static const WCHAR prop_macaddressW
[] =
202 {'M','A','C','A','d','d','r','e','s','s',0};
203 static const WCHAR prop_manufacturerW
[] =
204 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
205 static const WCHAR prop_maxclockspeedW
[] =
206 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
207 static const WCHAR prop_mediatypeW
[] =
208 {'M','e','d','i','a','T','y','p','e',0};
209 static const WCHAR prop_memberW
[] =
210 {'M','e','m','b','e','r',0};
211 static const WCHAR prop_methodW
[] =
212 {'M','e','t','h','o','d',0};
213 static const WCHAR prop_modelW
[] =
214 {'M','o','d','e','l',0};
215 static const WCHAR prop_netconnectionstatusW
[] =
216 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
217 static const WCHAR prop_numcoresW
[] =
218 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
219 static const WCHAR prop_numlogicalprocessorsW
[] =
220 {'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};
221 static const WCHAR prop_numprocessorsW
[] =
222 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
223 static const WCHAR prop_osarchitectureW
[] =
224 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
225 static const WCHAR prop_oslanguageW
[] =
226 {'O','S','L','a','n','g','u','a','g','e',0};
227 static const WCHAR prop_osproductsuiteW
[] =
228 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
229 static const WCHAR prop_ostypeW
[] =
230 {'O','S','T','y','p','e',0};
231 static const WCHAR prop_parameterW
[] =
232 {'P','a','r','a','m','e','t','e','r',0};
233 static const WCHAR prop_physicaladapterW
[] =
234 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
235 static const WCHAR prop_pnpdeviceidW
[] =
236 {'P','N','P','D','e','v','i','c','e','I','D',0};
237 static const WCHAR prop_pprocessidW
[] =
238 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
239 static const WCHAR prop_processidW
[] =
240 {'P','r','o','c','e','s','s','I','D',0};
241 static const WCHAR prop_processoridW
[] =
242 {'P','r','o','c','e','s','s','o','r','I','d',0};
243 static const WCHAR prop_processortypeW
[] =
244 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
245 static const WCHAR prop_productW
[] =
246 {'P','r','o','d','u','c','t',0};
247 static const WCHAR prop_productnameW
[] =
248 {'P','r','o','d','u','c','t','N','a','m','e',0};
249 static const WCHAR prop_releasedateW
[] =
250 {'R','e','l','e','a','s','e','D','a','t','e',0};
251 static const WCHAR prop_serialnumberW
[] =
252 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
253 static const WCHAR prop_servicepackmajorW
[] =
254 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
255 static const WCHAR prop_servicepackminorW
[] =
256 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
257 static const WCHAR prop_servicetypeW
[] =
258 {'S','e','r','v','i','c','e','T','y','p','e',0};
259 static const WCHAR prop_smbiosbiosversionW
[] =
260 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
261 static const WCHAR prop_startmodeW
[] =
262 {'S','t','a','r','t','M','o','d','e',0};
263 static const WCHAR prop_sizeW
[] =
265 static const WCHAR prop_speedW
[] =
266 {'S','p','e','e','d',0};
267 static const WCHAR prop_startingoffsetW
[] =
268 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
269 static const WCHAR prop_stateW
[] =
270 {'S','t','a','t','e',0};
271 static const WCHAR prop_statusinfoW
[] =
272 {'S','t','a','t','u','s','I','n','f','o',0};
273 static const WCHAR prop_strvalueW
[] =
274 {'S','t','r','i','n','g','V','a','l','u','e',0};
275 static const WCHAR prop_suitemaskW
[] =
276 {'S','u','i','t','e','M','a','s','k',0};
277 static const WCHAR prop_systemdirectoryW
[] =
278 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
279 static const WCHAR prop_systemnameW
[] =
280 {'S','y','s','t','e','m','N','a','m','e',0};
281 static const WCHAR prop_tagW
[] =
283 static const WCHAR prop_threadcountW
[] =
284 {'T','h','r','e','a','d','C','o','u','n','t',0};
285 static const WCHAR prop_totalphysicalmemoryW
[] =
286 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
287 static const WCHAR prop_totalvisiblememorysizeW
[] =
288 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
289 static const WCHAR prop_typeW
[] =
291 static const WCHAR prop_uniqueidW
[] =
292 {'U','n','i','q','u','e','I','d',0};
293 static const WCHAR prop_uuidW
[] =
295 static const WCHAR prop_varianttypeW
[] =
296 {'V','a','r','i','a','n','t','T','y','p','e',0};
297 static const WCHAR prop_versionW
[] =
298 {'V','e','r','s','i','o','n',0};
299 static const WCHAR prop_videoprocessorW
[] =
300 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
301 static const WCHAR prop_volumenameW
[] =
302 {'V','o','l','u','m','e','N','a','m','e',0};
303 static const WCHAR prop_volumeserialnumberW
[] =
304 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
306 /* column definitions must be kept in sync with record structures below */
307 static const struct column col_baseboard
[] =
309 { prop_manufacturerW
, CIM_STRING
},
310 { prop_modelW
, CIM_STRING
},
311 { prop_nameW
, CIM_STRING
},
312 { prop_productW
, CIM_STRING
},
313 { prop_serialnumberW
, CIM_STRING
},
314 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
316 static const struct column col_bios
[] =
318 { prop_descriptionW
, CIM_STRING
},
319 { prop_identificationcodeW
, CIM_STRING
},
320 { prop_manufacturerW
, CIM_STRING
},
321 { prop_releasedateW
, CIM_DATETIME
},
322 { prop_serialnumberW
, CIM_STRING
},
323 { prop_smbiosbiosversionW
, CIM_STRING
},
324 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
326 static const struct column col_cdromdrive
[] =
328 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
329 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
330 { prop_mediatypeW
, CIM_STRING
},
331 { prop_nameW
, CIM_STRING
},
332 { prop_pnpdeviceidW
, CIM_STRING
}
334 static const struct column col_compsys
[] =
336 { prop_descriptionW
, CIM_STRING
},
337 { prop_domainW
, CIM_STRING
},
338 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
339 { prop_manufacturerW
, CIM_STRING
},
340 { prop_modelW
, CIM_STRING
},
341 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
342 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
343 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
344 { prop_totalphysicalmemoryW
, CIM_UINT64
}
346 static const struct column col_compsysproduct
[] =
348 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
349 { prop_uuidW
, CIM_STRING
}
351 static const struct column col_datafile
[] =
353 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
354 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
356 static const struct column col_directory
[] =
358 { prop_accessmaskW
, CIM_UINT32
},
359 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
361 static const struct column col_diskdrive
[] =
363 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
364 { prop_indexW
, CIM_UINT32
, VT_I4
},
365 { prop_interfacetypeW
, CIM_STRING
},
366 { prop_manufacturerW
, CIM_STRING
},
367 { prop_mediatypeW
, CIM_STRING
},
368 { prop_modelW
, CIM_STRING
},
369 { prop_serialnumberW
, CIM_STRING
},
370 { prop_sizeW
, CIM_UINT64
}
372 static const struct column col_diskpartition
[] =
374 { prop_bootableW
, CIM_BOOLEAN
},
375 { prop_bootpartitionW
, CIM_BOOLEAN
},
376 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
377 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
378 { prop_indexW
, CIM_UINT32
, VT_I4
},
379 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
380 { prop_sizeW
, CIM_UINT64
},
381 { prop_startingoffsetW
, CIM_UINT64
},
382 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
384 static const struct column col_logicaldisk
[] =
386 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
387 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
388 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
389 { prop_freespaceW
, CIM_UINT64
},
390 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
391 { prop_sizeW
, CIM_UINT64
},
392 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
393 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
395 static const struct column col_networkadapter
[] =
397 { prop_adaptertypeW
, CIM_STRING
},
398 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
399 { prop_indexW
, CIM_UINT32
, VT_I4
},
400 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
401 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
402 { prop_manufacturerW
, CIM_STRING
},
403 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
404 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
405 { prop_physicaladapterW
, CIM_BOOLEAN
},
406 { prop_pnpdeviceidW
, CIM_STRING
},
407 { prop_speedW
, CIM_UINT64
}
409 static const struct column col_networkadapterconfig
[] =
411 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
412 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
413 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
414 { prop_ipenabledW
, CIM_BOOLEAN
},
415 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
417 static const struct column col_os
[] =
419 { prop_buildnumberW
, CIM_STRING
},
420 { prop_captionW
, CIM_STRING
},
421 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
422 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
423 { prop_csdversionW
, CIM_STRING
},
424 { prop_installdateW
, CIM_DATETIME
},
425 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
426 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
427 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
428 { prop_nameW
, CIM_STRING
},
429 { prop_osarchitectureW
, CIM_STRING
},
430 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
431 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
432 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
433 { prop_serialnumberW
, CIM_STRING
},
434 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
435 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
436 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
437 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
438 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
439 { prop_versionW
, CIM_STRING
}
441 static const struct column col_param
[] =
443 { prop_classW
, CIM_STRING
},
444 { prop_methodW
, CIM_STRING
},
445 { prop_directionW
, CIM_SINT32
},
446 { prop_parameterW
, CIM_STRING
},
447 { prop_typeW
, CIM_UINT32
},
448 { prop_varianttypeW
, CIM_UINT32
},
449 { prop_defaultvalueW
, CIM_UINT32
}
451 static const struct column col_physicalmedia
[] =
453 { prop_serialnumberW
, CIM_STRING
},
454 { prop_tagW
, CIM_STRING
}
456 static const struct column col_physicalmemory
[] =
458 { prop_capacityW
, CIM_UINT64
}
460 static const struct column col_process
[] =
462 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
463 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
464 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
465 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
466 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
467 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
468 { prop_processidW
, CIM_UINT32
, VT_I4
},
469 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
471 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
473 static const struct column col_processor
[] =
475 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
476 { prop_cpustatusW
, CIM_UINT16
},
477 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
478 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
479 { prop_familyW
, CIM_UINT16
, VT_I4
},
480 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
481 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
482 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
483 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
484 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
485 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
486 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
487 { prop_uniqueidW
, CIM_STRING
}
489 static const struct column col_qualifier
[] =
491 { prop_classW
, CIM_STRING
},
492 { prop_memberW
, CIM_STRING
},
493 { prop_typeW
, CIM_UINT32
},
494 { prop_flavorW
, CIM_SINT32
},
495 { prop_nameW
, CIM_STRING
},
496 { prop_intvalueW
, CIM_SINT32
},
497 { prop_strvalueW
, CIM_STRING
}
499 static const struct column col_service
[] =
501 { prop_acceptpauseW
, CIM_BOOLEAN
},
502 { prop_acceptstopW
, CIM_BOOLEAN
},
503 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
504 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
505 { prop_processidW
, CIM_UINT32
},
506 { prop_servicetypeW
, CIM_STRING
},
507 { prop_startmodeW
, CIM_STRING
},
508 { prop_stateW
, CIM_STRING
},
509 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
511 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
512 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
513 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
514 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
516 static const struct column col_sounddevice
[] =
518 { prop_nameW
, CIM_STRING
},
519 { prop_productnameW
, CIM_STRING
},
520 { prop_statusinfoW
, CIM_UINT16
}
522 static const struct column col_stdregprov
[] =
524 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
525 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
526 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
528 static const struct column col_systemsecurity
[] =
530 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
531 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
533 static const struct column col_videocontroller
[] =
535 { prop_adapterdactypeW
, CIM_STRING
},
536 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
537 { prop_availabilityW
, CIM_UINT16
},
538 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
539 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
540 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
541 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
542 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
543 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
544 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
545 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
548 static const WCHAR baseboard_manufacturerW
[] =
549 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
550 static const WCHAR baseboard_serialnumberW
[] =
552 static const WCHAR baseboard_tagW
[] =
553 {'B','a','s','e',' ','B','o','a','r','d',0};
554 static const WCHAR bios_descriptionW
[] =
555 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
556 static const WCHAR bios_manufacturerW
[] =
557 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
558 static const WCHAR bios_releasedateW
[] =
559 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
560 static const WCHAR bios_serialnumberW
[] =
562 static const WCHAR bios_smbiosbiosversionW
[] =
564 static const WCHAR bios_versionW
[] =
565 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
566 static const WCHAR cdromdrive_mediatypeW
[] =
567 {'C','D','-','R','O','M',0};
568 static const WCHAR cdromdrive_nameW
[] =
569 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
570 static const WCHAR cdromdrive_pnpdeviceidW
[]=
571 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
572 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
573 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
574 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
575 static const WCHAR compsys_descriptionW
[] =
576 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
577 static const WCHAR compsys_domainW
[] =
578 {'W','O','R','K','G','R','O','U','P',0};
579 static const WCHAR compsys_manufacturerW
[] =
580 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
581 static const WCHAR compsys_modelW
[] =
583 static const WCHAR compsysproduct_identifyingnumberW
[] =
585 static const WCHAR compsysproduct_uuidW
[] =
586 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
587 '0','0','0','0','0','0','0','0','0','0','0','0',0};
588 static const WCHAR diskdrive_interfacetypeW
[] =
590 static const WCHAR diskdrive_manufacturerW
[] =
591 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
592 static const WCHAR diskdrive_mediatype_fixedW
[] =
593 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
594 static const WCHAR diskdrive_mediatype_removableW
[] =
595 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
596 static const WCHAR diskdrive_modelW
[] =
597 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
598 static const WCHAR diskdrive_serialW
[] =
599 {'W','I','N','E','H','D','I','S','K',0};
600 static const WCHAR networkadapter_pnpdeviceidW
[]=
601 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
602 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
603 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
604 static const WCHAR os_32bitW
[] =
605 {'3','2','-','b','i','t',0};
606 static const WCHAR os_64bitW
[] =
607 {'6','4','-','b','i','t',0};
608 static const WCHAR os_buildnumberW
[] =
610 static const WCHAR os_captionW
[] =
611 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
612 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
613 static const WCHAR os_csdversionW
[] =
614 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
615 static const WCHAR os_installdateW
[] =
616 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
617 static const WCHAR os_nameW
[] =
618 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
619 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
620 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
621 '\\','P','a','r','t','i','t','i','o','n','1',0};
622 static const WCHAR os_serialnumberW
[] =
623 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
624 static const WCHAR os_versionW
[] =
625 {'5','.','1','.','2','6','0','0',0};
626 static const WCHAR physicalmedia_tagW
[] =
627 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
628 static const WCHAR sounddevice_productnameW
[] =
629 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
630 static const WCHAR videocontroller_dactypeW
[] =
631 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
632 static const WCHAR videocontroller_deviceidW
[] =
633 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
635 #include "pshpack1.h"
636 struct record_baseboard
638 const WCHAR
*manufacturer
;
641 const WCHAR
*product
;
642 const WCHAR
*serialnumber
;
647 const WCHAR
*description
;
648 const WCHAR
*identificationcode
;
649 const WCHAR
*manufacturer
;
650 const WCHAR
*releasedate
;
651 const WCHAR
*serialnumber
;
652 const WCHAR
*smbiosbiosversion
;
653 const WCHAR
*version
;
655 struct record_cdromdrive
657 const WCHAR
*device_id
;
659 const WCHAR
*mediatype
;
661 const WCHAR
*pnpdevice_id
;
663 struct record_computersystem
665 const WCHAR
*description
;
668 const WCHAR
*manufacturer
;
671 UINT32 num_logical_processors
;
672 UINT32 num_processors
;
673 UINT64 total_physical_memory
;
675 struct record_computersystemproduct
677 const WCHAR
*identifyingnumber
;
680 struct record_datafile
683 const WCHAR
*version
;
685 struct record_directory
690 struct record_diskdrive
692 const WCHAR
*device_id
;
694 const WCHAR
*interfacetype
;
695 const WCHAR
*manufacturer
;
696 const WCHAR
*mediatype
;
698 const WCHAR
*serialnumber
;
701 struct record_diskpartition
705 const WCHAR
*device_id
;
708 const WCHAR
*pnpdevice_id
;
710 UINT64 startingoffset
;
713 struct record_logicaldisk
715 const WCHAR
*device_id
;
717 const WCHAR
*filesystem
;
721 const WCHAR
*volumename
;
722 const WCHAR
*volumeserialnumber
;
724 struct record_networkadapter
726 const WCHAR
*adaptertype
;
727 const WCHAR
*device_id
;
729 UINT32 interface_index
;
730 const WCHAR
*mac_address
;
731 const WCHAR
*manufacturer
;
733 UINT16 netconnection_status
;
735 const WCHAR
*pnpdevice_id
;
738 struct record_networkadapterconfig
740 const WCHAR
*dnshostname
;
742 UINT32 ipconnectionmetric
;
744 const WCHAR
*mac_address
;
746 struct record_operatingsystem
748 const WCHAR
*buildnumber
;
749 const WCHAR
*caption
;
750 const WCHAR
*codeset
;
751 const WCHAR
*countrycode
;
752 const WCHAR
*csdversion
;
753 const WCHAR
*installdate
;
754 const WCHAR
*lastbootuptime
;
755 const WCHAR
*localdatetime
;
758 const WCHAR
*osarchitecture
;
760 UINT32 osproductsuite
;
762 const WCHAR
*serialnumber
;
763 UINT16 servicepackmajor
;
764 UINT16 servicepackminor
;
766 const WCHAR
*systemdirectory
;
767 UINT64 totalvisiblememorysize
;
768 const WCHAR
*version
;
775 const WCHAR
*parameter
;
780 struct record_physicalmedia
782 const WCHAR
*serialnumber
;
785 struct record_physicalmemory
789 struct record_process
791 const WCHAR
*caption
;
792 const WCHAR
*commandline
;
793 const WCHAR
*description
;
800 class_method
*get_owner
;
802 struct record_processor
806 UINT32 currentclockspeed
;
807 const WCHAR
*device_id
;
809 const WCHAR
*manufacturer
;
810 UINT32 maxclockspeed
;
813 UINT32 num_logical_processors
;
814 const WCHAR
*processor_id
;
815 UINT16 processortype
;
816 const WCHAR
*unique_id
;
818 struct record_qualifier
826 const WCHAR
*strvalue
;
828 struct record_service
832 const WCHAR
*displayname
;
835 const WCHAR
*servicetype
;
836 const WCHAR
*startmode
;
838 const WCHAR
*systemname
;
840 class_method
*pause_service
;
841 class_method
*resume_service
;
842 class_method
*start_service
;
843 class_method
*stop_service
;
845 struct record_sounddevice
848 const WCHAR
*productname
;
851 struct record_stdregprov
853 class_method
*enumkey
;
854 class_method
*enumvalues
;
855 class_method
*getstringvalue
;
857 struct record_systemsecurity
862 struct record_videocontroller
864 const WCHAR
*adapter_dactype
;
867 UINT32 current_bitsperpixel
;
868 UINT32 current_horizontalres
;
869 UINT32 current_verticalres
;
870 const WCHAR
*description
;
871 const WCHAR
*device_id
;
873 const WCHAR
*pnpdevice_id
;
874 const WCHAR
*videoprocessor
;
878 static const struct record_baseboard data_baseboard
[] =
880 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_tagW
}
882 static const struct record_bios data_bios
[] =
884 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
885 bios_smbiosbiosversionW
, bios_versionW
}
887 static const struct record_computersystemproduct data_compsysproduct
[] =
889 { compsysproduct_identifyingnumberW
, compsysproduct_uuidW
}
891 static const struct record_param data_param
[] =
893 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
894 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
895 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
896 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
897 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
898 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
899 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
900 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
901 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
902 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
903 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
904 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
905 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
906 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
907 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
908 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
909 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
910 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
911 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
912 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
913 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
914 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
915 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
916 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
917 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
920 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
921 WBEM_FLAVOR_ORIGIN_PROPAGATED)
923 static const struct record_physicalmedia data_physicalmedia
[] =
925 { diskdrive_serialW
, physicalmedia_tagW
}
927 static const struct record_qualifier data_qualifier
[] =
929 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
930 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
932 static const struct record_sounddevice data_sounddevice
[] =
934 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
936 static const struct record_stdregprov data_stdregprov
[] =
938 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
940 static const struct record_systemsecurity data_systemsecurity
[] =
942 { security_get_sd
, security_set_sd
}
945 /* check if row matches condition and update status */
946 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
953 *status
= FILL_STATUS_UNFILTERED
;
956 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
958 *status
= FILL_STATUS_FAILED
;
961 *status
= FILL_STATUS_FILTERED
;
965 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
967 if (!table
->num_rows_allocated
)
969 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
970 table
->num_rows_allocated
= row_count
;
973 if (row_count
>= table
->num_rows_allocated
)
976 UINT count
= table
->num_rows_allocated
* 2;
977 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
979 table
->num_rows_allocated
= count
;
984 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
986 static const WCHAR fmtW
[] = {'%','c',':',0};
987 WCHAR drive
[3], root
[] = {'A',':','\\',0};
988 struct record_cdromdrive
*rec
;
989 UINT i
, row
= 0, offset
= 0;
990 DWORD drives
= GetLogicalDrives();
991 enum fill_status status
= FILL_STATUS_UNFILTERED
;
993 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
995 for (i
= 0; i
< sizeof(drives
); i
++)
997 if (drives
& (1 << i
))
1000 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1003 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1005 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1006 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1007 sprintfW( drive
, fmtW
, 'A' + i
);
1008 rec
->drive
= heap_strdupW( drive
);
1009 rec
->mediatype
= cdromdrive_mediatypeW
;
1010 rec
->name
= cdromdrive_nameW
;
1011 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1012 if (!match_row( table
, row
, cond
, &status
))
1014 free_row_values( table
, row
);
1017 offset
+= sizeof(*rec
);
1021 TRACE("created %u rows\n", row
);
1022 table
->num_rows
= row
;
1026 static UINT
get_processor_count(void)
1028 SYSTEM_BASIC_INFORMATION info
;
1030 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1031 return info
.NumberOfProcessors
;
1034 static UINT
get_logical_processor_count( UINT
*num_cores
)
1036 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1037 UINT i
, j
, count
= 0;
1041 if (num_cores
) *num_cores
= get_processor_count();
1042 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1043 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1045 if (!(info
= heap_alloc( len
))) return get_processor_count();
1046 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1047 if (status
!= STATUS_SUCCESS
)
1050 return get_processor_count();
1052 if (num_cores
) *num_cores
= 0;
1053 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1055 if (info
[i
].Relationship
== RelationProcessorCore
)
1057 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1059 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1061 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1068 static UINT64
get_total_physical_memory(void)
1070 MEMORYSTATUSEX status
;
1072 status
.dwLength
= sizeof(status
);
1073 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1074 return status
.ullTotalPhys
;
1077 static WCHAR
*get_computername(void)
1080 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
1082 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1083 GetComputerNameW( ret
, &size
);
1087 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1089 struct record_computersystem
*rec
;
1090 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1093 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1095 rec
= (struct record_computersystem
*)table
->data
;
1096 rec
->description
= compsys_descriptionW
;
1097 rec
->domain
= compsys_domainW
;
1098 rec
->domainrole
= 0; /* standalone workstation */
1099 rec
->manufacturer
= compsys_manufacturerW
;
1100 rec
->model
= compsys_modelW
;
1101 rec
->name
= get_computername();
1102 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1103 rec
->num_processors
= get_processor_count();
1104 rec
->total_physical_memory
= get_total_physical_memory();
1105 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1108 TRACE("created %u rows\n", row
);
1109 table
->num_rows
= row
;
1121 static struct dirstack
*alloc_dirstack( UINT size
)
1123 struct dirstack
*dirstack
;
1125 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1126 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1128 heap_free( dirstack
);
1131 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1133 heap_free( dirstack
->dirs
);
1134 heap_free( dirstack
);
1137 dirstack
->num_dirs
= 0;
1138 dirstack
->num_allocated
= size
;
1142 static void clear_dirstack( struct dirstack
*dirstack
)
1145 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1146 dirstack
->num_dirs
= 0;
1149 static void free_dirstack( struct dirstack
*dirstack
)
1151 clear_dirstack( dirstack
);
1152 heap_free( dirstack
->dirs
);
1153 heap_free( dirstack
->len_dirs
);
1154 heap_free( dirstack
);
1157 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1159 UINT size
, i
= dirstack
->num_dirs
;
1161 if (!dir
) return FALSE
;
1163 if (i
== dirstack
->num_allocated
)
1168 size
= dirstack
->num_allocated
* 2;
1169 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1170 dirstack
->dirs
= tmp
;
1171 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1172 dirstack
->len_dirs
= len_tmp
;
1173 dirstack
->num_allocated
= size
;
1175 dirstack
->dirs
[i
] = dir
;
1176 dirstack
->len_dirs
[i
] = len
;
1177 dirstack
->num_dirs
++;
1181 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1183 if (!dirstack
->num_dirs
)
1188 dirstack
->num_dirs
--;
1189 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1190 return dirstack
->dirs
[dirstack
->num_dirs
];
1193 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1195 if (!dirstack
->num_dirs
) return NULL
;
1196 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1199 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1204 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1210 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1219 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1221 UINT i
= 0, len
= 0;
1225 for (p
= path
; *p
; p
++)
1227 if (*p
== '\\') len
+= 2;
1230 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1235 for (p
= path
; *p
; p
++)
1237 if (*p
!= '\\') ret
[i
++] = *p
;
1248 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1250 const WCHAR
*p
= path
, *start
;
1254 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1256 len
= strlenW( start
);
1257 p
= start
+ len
- 1;
1258 if (*p
== '\\') return NULL
;
1260 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1261 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1263 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1264 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1266 if (p
[0] == '\\' && p
[1] == '\\')
1278 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1281 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1285 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1286 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1288 const struct expr
*left
, *right
;
1290 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1292 left
= cond
->u
.expr
.left
;
1293 right
= cond
->u
.expr
.right
;
1294 if (cond
->u
.expr
.op
== OP_EQ
)
1298 const WCHAR
*str
= NULL
;
1300 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1301 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1302 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1304 str
= right
->u
.sval
;
1306 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1307 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1308 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1312 if (str
&& (path
= build_dirname( str
, &len
)))
1314 if (seen_dir( dirstack
, path
))
1319 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1324 else if (cond
->u
.expr
.op
== OP_OR
)
1326 UINT left_count
= 0, right_count
= 0;
1328 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1329 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1330 return *count
+= left_count
+ right_count
;
1335 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1337 UINT len_path
= 0, len_segment
= strlenW( segment
);
1341 if (path
) len_path
= strlenW( path
);
1342 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1343 if (path
&& len_path
)
1345 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1346 ret
[len_path
] = '\\';
1347 *len
+= len_path
+ 1;
1349 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1350 *len
+= len_segment
;
1355 static WCHAR
*get_file_version( const WCHAR
*filename
)
1357 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1358 VS_FIXEDFILEINFO
*info
;
1363 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1364 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1369 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1370 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1376 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1377 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1382 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1384 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1385 struct record_datafile
*rec
;
1386 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1387 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1388 DWORD drives
= GetLogicalDrives();
1389 WIN32_FIND_DATAW data
;
1391 struct dirstack
*dirstack
;
1392 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1394 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1396 dirstack
= alloc_dirstack(2);
1398 for (i
= 0; i
< sizeof(drives
); i
++)
1400 if (!(drives
& (1 << i
))) continue;
1403 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1405 num_expected_rows
= 0;
1406 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1410 path
= pop_dir( dirstack
, &len
);
1411 if (!(glob
= build_glob( root
[0], path
, len
)))
1413 status
= FILL_STATUS_FAILED
;
1416 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1420 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1422 status
= FILL_STATUS_FAILED
;
1423 FindClose( handle
);
1426 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1427 new_path
= append_path( path
, data
.cFileName
, &len
);
1429 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1431 if (push_dir( dirstack
, new_path
, len
)) continue;
1432 heap_free( new_path
);
1433 FindClose( handle
);
1434 status
= FILL_STATUS_FAILED
;
1437 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1438 rec
->name
= build_name( root
[0], new_path
);
1439 rec
->version
= get_file_version( rec
->name
);
1440 if (!match_row( table
, row
, cond
, &status
))
1442 free_row_values( table
, row
);
1445 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1448 FindClose( handle
);
1449 status
= FILL_STATUS_FILTERED
;
1452 offset
+= sizeof(*rec
);
1455 while (FindNextFileW( handle
, &data
));
1456 FindClose( handle
);
1458 if (!peek_dir( dirstack
)) break;
1465 free_dirstack( dirstack
);
1469 TRACE("created %u rows\n", row
);
1470 table
->num_rows
= row
;
1474 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1476 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1477 struct record_directory
*rec
;
1478 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1479 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1480 DWORD drives
= GetLogicalDrives();
1481 WIN32_FIND_DATAW data
;
1483 struct dirstack
*dirstack
;
1484 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1486 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1488 dirstack
= alloc_dirstack(2);
1490 for (i
= 0; i
< sizeof(drives
); i
++)
1492 if (!(drives
& (1 << i
))) continue;
1495 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1497 num_expected_rows
= 0;
1498 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1502 path
= pop_dir( dirstack
, &len
);
1503 if (!(glob
= build_glob( root
[0], path
, len
)))
1505 status
= FILL_STATUS_FAILED
;
1508 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1512 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1514 FindClose( handle
);
1515 status
= FILL_STATUS_FAILED
;
1518 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1519 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1522 new_path
= append_path( path
, data
.cFileName
, &len
);
1523 if (!(push_dir( dirstack
, new_path
, len
)))
1525 heap_free( new_path
);
1526 FindClose( handle
);
1527 status
= FILL_STATUS_FAILED
;
1530 rec
= (struct record_directory
*)(table
->data
+ offset
);
1531 rec
->accessmask
= FILE_ALL_ACCESS
;
1532 rec
->name
= build_name( root
[0], new_path
);
1533 if (!match_row( table
, row
, cond
, &status
))
1535 free_row_values( table
, row
);
1538 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1541 FindClose( handle
);
1542 status
= FILL_STATUS_FILTERED
;
1545 offset
+= sizeof(*rec
);
1548 while (FindNextFileW( handle
, &data
));
1549 FindClose( handle
);
1551 if (!peek_dir( dirstack
)) break;
1558 free_dirstack( dirstack
);
1562 TRACE("created %u rows\n", row
);
1563 table
->num_rows
= row
;
1567 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1569 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1570 ULARGE_INTEGER free
;
1571 DISK_GEOMETRY_EX info
;
1573 DWORD bytes_returned
;
1575 free
.QuadPart
= 512 * 1024 * 1024;
1576 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1579 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1580 if (handle
!= INVALID_HANDLE_VALUE
)
1582 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1583 *disksize
= info
.DiskSize
.QuadPart
;
1584 CloseHandle( handle
);
1586 return free
.QuadPart
;
1589 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1591 static const WCHAR fmtW
[] =
1592 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1593 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1594 struct record_diskdrive
*rec
;
1595 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1596 UINT64 size
= 1024 * 1024 * 1024;
1597 DWORD drives
= GetLogicalDrives();
1598 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1600 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1602 for (i
= 0; i
< sizeof(drives
); i
++)
1604 if (drives
& (1 << i
))
1607 type
= GetDriveTypeW( root
);
1608 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1611 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1613 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1614 sprintfW( device_id
, fmtW
, index
);
1615 rec
->device_id
= heap_strdupW( device_id
);
1617 rec
->interfacetype
= diskdrive_interfacetypeW
;
1618 rec
->manufacturer
= diskdrive_manufacturerW
;
1619 if (type
== DRIVE_FIXED
)
1620 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1622 rec
->mediatype
= diskdrive_mediatype_removableW
;
1623 rec
->model
= diskdrive_modelW
;
1624 rec
->serialnumber
= diskdrive_serialW
;
1625 get_freespace( root
, &size
);
1627 if (!match_row( table
, row
, cond
, &status
))
1629 free_row_values( table
, row
);
1632 offset
+= sizeof(*rec
);
1637 TRACE("created %u rows\n", row
);
1638 table
->num_rows
= row
;
1642 static WCHAR
*get_filesystem( const WCHAR
*root
)
1644 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1645 WCHAR buffer
[MAX_PATH
+ 1];
1647 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1648 return heap_strdupW( buffer
);
1649 return heap_strdupW( ntfsW
);
1652 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1654 static const WCHAR fmtW
[] =
1655 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1656 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1657 struct record_diskpartition
*rec
;
1658 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1659 UINT64 size
= 1024 * 1024 * 1024;
1660 DWORD drives
= GetLogicalDrives();
1661 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1663 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1665 for (i
= 0; i
< sizeof(drives
); i
++)
1667 if (drives
& (1 << i
))
1670 type
= GetDriveTypeW( root
);
1671 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1674 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1676 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1677 rec
->bootable
= (i
== 2) ? -1 : 0;
1678 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1679 sprintfW( device_id
, fmtW
, index
);
1680 rec
->device_id
= heap_strdupW( device_id
);
1681 rec
->diskindex
= index
;
1683 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1684 get_freespace( root
, &size
);
1686 rec
->startingoffset
= 0;
1687 rec
->type
= get_filesystem( root
);
1688 if (!match_row( table
, row
, cond
, &status
))
1690 free_row_values( table
, row
);
1693 offset
+= sizeof(*rec
);
1698 TRACE("created %u rows\n", row
);
1699 table
->num_rows
= row
;
1703 static WCHAR
*get_volumename( const WCHAR
*root
)
1705 WCHAR buf
[MAX_PATH
+ 1] = {0};
1706 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1707 return heap_strdupW( buf
);
1709 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1711 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1715 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1716 sprintfW( buffer
, fmtW
, serial
);
1717 return heap_strdupW( buffer
);
1720 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1722 static const WCHAR fmtW
[] = {'%','c',':',0};
1723 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1724 struct record_logicaldisk
*rec
;
1725 UINT i
, row
= 0, offset
= 0, type
;
1726 UINT64 size
= 1024 * 1024 * 1024;
1727 DWORD drives
= GetLogicalDrives();
1728 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1730 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1732 for (i
= 0; i
< sizeof(drives
); i
++)
1734 if (drives
& (1 << i
))
1737 type
= GetDriveTypeW( root
);
1738 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1741 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1743 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1744 sprintfW( device_id
, fmtW
, 'A' + i
);
1745 rec
->device_id
= heap_strdupW( device_id
);
1746 rec
->drivetype
= type
;
1747 rec
->filesystem
= get_filesystem( root
);
1748 rec
->freespace
= get_freespace( root
, &size
);
1749 rec
->name
= heap_strdupW( device_id
);
1751 rec
->volumename
= get_volumename( root
);
1752 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1753 if (!match_row( table
, row
, cond
, &status
))
1755 free_row_values( table
, row
);
1758 offset
+= sizeof(*rec
);
1762 TRACE("created %u rows\n", row
);
1763 table
->num_rows
= row
;
1767 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1771 case IfOperStatusDown
:
1772 return 0; /* Disconnected */
1773 case IfOperStatusUp
:
1774 return 2; /* Connected */
1776 ERR("unhandled status %u\n", status
);
1781 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1783 static const WCHAR fmtW
[] =
1784 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1785 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1788 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1789 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1792 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1794 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1795 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1796 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1797 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1801 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1802 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1803 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1804 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1805 default: *physical
= 0; return NULL
;
1809 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1811 static const WCHAR fmtW
[] = {'%','u',0};
1812 WCHAR device_id
[11];
1813 struct record_networkadapter
*rec
;
1814 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1815 UINT row
= 0, offset
= 0, count
= 0;
1816 DWORD size
= 0, ret
;
1818 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1820 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1821 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1823 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1824 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1826 heap_free( buffer
);
1827 return FILL_STATUS_FAILED
;
1829 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1831 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1833 if (!resize_table( table
, count
, sizeof(*rec
) ))
1835 heap_free( buffer
);
1836 return FILL_STATUS_FAILED
;
1838 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1840 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1842 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1843 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1844 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1845 rec
->device_id
= heap_strdupW( device_id
);
1846 rec
->index
= aa
->u
.s
.IfIndex
;
1847 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1848 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1849 rec
->manufacturer
= compsys_manufacturerW
;
1850 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1851 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1852 rec
->physicaladapter
= physical
;
1853 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1854 rec
->speed
= 1000000;
1855 if (!match_row( table
, row
, cond
, &status
))
1857 free_row_values( table
, row
);
1860 offset
+= sizeof(*rec
);
1863 TRACE("created %u rows\n", row
);
1864 table
->num_rows
= row
;
1866 heap_free( buffer
);
1870 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
1872 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
1873 WCHAR buf
[NI_MAXHOST
];
1875 if (!addr
) return NULL
;
1876 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
1877 0, NI_NAMEREQD
)) return NULL
;
1878 return heap_strdupW( buf
);
1881 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1883 struct record_networkadapterconfig
*rec
;
1884 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1885 UINT row
= 0, offset
= 0, count
= 0;
1886 DWORD size
= 0, ret
;
1887 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1889 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1890 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1892 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1893 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1895 heap_free( buffer
);
1896 return FILL_STATUS_FAILED
;
1898 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1900 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1902 if (!resize_table( table
, count
, sizeof(*rec
) ))
1904 heap_free( buffer
);
1905 return FILL_STATUS_FAILED
;
1907 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1909 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1911 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1912 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
1913 rec
->index
= aa
->u
.s
.IfIndex
;
1914 rec
->ipconnectionmetric
= 20;
1915 rec
->ipenabled
= -1;
1916 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1917 if (!match_row( table
, row
, cond
, &status
))
1919 free_row_values( table
, row
);
1922 offset
+= sizeof(*rec
);
1925 TRACE("created %u rows\n", row
);
1926 table
->num_rows
= row
;
1928 heap_free( buffer
);
1932 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
1934 struct record_physicalmemory
*rec
;
1935 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1938 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1940 rec
= (struct record_physicalmemory
*)table
->data
;
1941 rec
->capacity
= get_total_physical_memory();
1942 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1945 TRACE("created %u rows\n", row
);
1946 table
->num_rows
= row
;
1950 static WCHAR
*get_cmdline( DWORD process_id
)
1952 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1953 return NULL
; /* FIXME handle different process case */
1956 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1958 static const WCHAR fmtW
[] = {'%','u',0};
1960 struct record_process
*rec
;
1961 PROCESSENTRY32W entry
;
1963 enum fill_status status
= FILL_STATUS_FAILED
;
1964 UINT row
= 0, offset
= 0;
1966 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1967 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1969 entry
.dwSize
= sizeof(entry
);
1970 if (!Process32FirstW( snap
, &entry
)) goto done
;
1971 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1975 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1977 rec
= (struct record_process
*)(table
->data
+ offset
);
1978 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1979 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1980 rec
->description
= heap_strdupW( entry
.szExeFile
);
1981 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1982 rec
->handle
= heap_strdupW( handle
);
1983 rec
->name
= heap_strdupW( entry
.szExeFile
);
1984 rec
->process_id
= entry
.th32ProcessID
;
1985 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1986 rec
->thread_count
= entry
.cntThreads
;
1987 rec
->get_owner
= process_get_owner
;
1988 if (!match_row( table
, row
, cond
, &status
))
1990 free_row_values( table
, row
);
1993 offset
+= sizeof(*rec
);
1995 } while (Process32NextW( snap
, &entry
));
1997 TRACE("created %u rows\n", row
);
1998 table
->num_rows
= row
;
1999 status
= FILL_STATUS_UNFILTERED
;
2002 CloseHandle( snap
);
2006 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2009 __asm__("pushl %%ebx\n\t"
2011 "movl %%ebx, %%esi\n\t"
2013 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2018 static void get_processor_id( WCHAR
*processor_id
)
2020 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2021 unsigned int regs
[4] = {0, 0, 0, 0};
2023 do_cpuid( 1, regs
);
2024 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2026 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2029 unsigned char *p
= (unsigned char *)regs
;
2031 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2034 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2036 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2038 do_cpuid( 0, regs
);
2039 tmp
= regs
[2]; /* swap edx and ecx */
2043 regs_to_str( regs
+ 1, 12, manufacturer
);
2045 static void get_processor_name( WCHAR
*name
)
2047 unsigned int regs
[4] = {0, 0, 0, 0};
2049 do_cpuid( 0x80000000, regs
);
2050 if (regs
[0] >= 0x80000004)
2052 do_cpuid( 0x80000002, regs
);
2053 regs_to_str( regs
, 16, name
);
2054 do_cpuid( 0x80000003, regs
);
2055 regs_to_str( regs
, 16, name
+ 16 );
2056 do_cpuid( 0x80000004, regs
);
2057 regs_to_str( regs
, 16, name
+ 32 );
2060 static UINT
get_processor_currentclockspeed( UINT index
)
2062 PROCESSOR_POWER_INFORMATION
*info
;
2063 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2066 if ((info
= heap_alloc( size
)))
2068 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2069 if (!status
) ret
= info
[index
].CurrentMhz
;
2074 static UINT
get_processor_maxclockspeed( UINT index
)
2076 PROCESSOR_POWER_INFORMATION
*info
;
2077 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2080 if ((info
= heap_alloc( size
)))
2082 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2083 if (!status
) ret
= info
[index
].MaxMhz
;
2088 static const WCHAR
*get_osarchitecture(void)
2091 GetNativeSystemInfo( &info
);
2092 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2096 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2098 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2099 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2100 struct record_processor
*rec
;
2101 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2102 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2104 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2106 get_processor_id( processor_id
);
2107 get_processor_manufacturer( manufacturer
);
2108 get_processor_name( name
);
2110 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2113 for (i
= 0; i
< count
; i
++)
2115 rec
= (struct record_processor
*)(table
->data
+ offset
);
2116 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2117 rec
->cpu_status
= 1; /* CPU Enabled */
2118 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2119 sprintfW( device_id
, fmtW
, i
);
2120 rec
->device_id
= heap_strdupW( device_id
);
2121 rec
->family
= 2; /* Unknown */
2122 rec
->manufacturer
= heap_strdupW( manufacturer
);
2123 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2124 rec
->name
= heap_strdupW( name
);
2125 rec
->num_cores
= num_cores
;
2126 rec
->num_logical_processors
= num_logical_processors
;
2127 rec
->processor_id
= heap_strdupW( processor_id
);
2128 rec
->processortype
= 3; /* central processor */
2129 rec
->unique_id
= NULL
;
2130 if (!match_row( table
, i
, cond
, &status
))
2132 free_row_values( table
, i
);
2135 offset
+= sizeof(*rec
);
2138 TRACE("created %u rows\n", count
);
2139 table
->num_rows
= count
;
2143 static WCHAR
*get_lastbootuptime(void)
2145 static const WCHAR fmtW
[] =
2146 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2147 '.','%','0','6','u','+','0','0','0',0};
2148 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2152 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2154 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2155 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2156 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2159 static WCHAR
*get_localdatetime(void)
2161 static const WCHAR fmtW
[] =
2162 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2163 '.','%','0','6','u','%','+','0','3','d',0};
2164 TIME_ZONE_INFORMATION tzi
;
2170 Status
= GetTimeZoneInformation(&tzi
);
2172 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2174 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2175 Bias
+= tzi
.DaylightBias
;
2177 Bias
+= tzi
.StandardBias
;
2178 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2181 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2184 static WCHAR
*get_systemdirectory(void)
2189 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2190 Wow64DisableWow64FsRedirection( &redir
);
2191 GetSystemDirectoryW( ret
, MAX_PATH
);
2192 Wow64RevertWow64FsRedirection( redir
);
2195 static WCHAR
*get_codeset(void)
2197 static const WCHAR fmtW
[] = {'%','u',0};
2198 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2199 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2202 static WCHAR
*get_countrycode(void)
2204 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2205 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2208 static WCHAR
*get_locale(void)
2210 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2211 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2215 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2217 struct record_operatingsystem
*rec
;
2218 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2221 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2223 rec
= (struct record_operatingsystem
*)table
->data
;
2224 rec
->buildnumber
= os_buildnumberW
;
2225 rec
->caption
= os_captionW
;
2226 rec
->codeset
= get_codeset();
2227 rec
->countrycode
= get_countrycode();
2228 rec
->csdversion
= os_csdversionW
;
2229 rec
->installdate
= os_installdateW
;
2230 rec
->lastbootuptime
= get_lastbootuptime();
2231 rec
->localdatetime
= get_localdatetime();
2232 rec
->locale
= get_locale();
2233 rec
->name
= os_nameW
;
2234 rec
->osarchitecture
= get_osarchitecture();
2235 rec
->oslanguage
= GetSystemDefaultLangID();
2236 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2237 rec
->ostype
= 18; /* WINNT */
2238 rec
->serialnumber
= os_serialnumberW
;
2239 rec
->servicepackmajor
= 3;
2240 rec
->servicepackminor
= 0;
2241 rec
->suitemask
= 272; /* Single User + Terminal */
2242 rec
->systemdirectory
= get_systemdirectory();
2243 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2244 rec
->version
= os_versionW
;
2245 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2248 TRACE("created %u rows\n", row
);
2249 table
->num_rows
= row
;
2253 static const WCHAR
*get_service_type( DWORD type
)
2255 static const WCHAR filesystem_driverW
[] =
2256 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2257 static const WCHAR kernel_driverW
[] =
2258 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2259 static const WCHAR own_processW
[] =
2260 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2261 static const WCHAR share_processW
[] =
2262 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2264 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2265 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2266 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2267 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2268 else ERR("unhandled type 0x%08x\n", type
);
2271 static const WCHAR
*get_service_state( DWORD state
)
2273 static const WCHAR runningW
[] =
2274 {'R','u','n','n','i','n','g',0};
2275 static const WCHAR start_pendingW
[] =
2276 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2277 static const WCHAR stop_pendingW
[] =
2278 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2279 static const WCHAR stoppedW
[] =
2280 {'S','t','o','p','p','e','d',0};
2281 static const WCHAR unknownW
[] =
2282 {'U','n','k','n','o','w','n',0};
2286 case SERVICE_STOPPED
: return stoppedW
;
2287 case SERVICE_START_PENDING
: return start_pendingW
;
2288 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2289 case SERVICE_RUNNING
: return runningW
;
2291 ERR("unknown state %u\n", state
);
2295 static const WCHAR
*get_service_startmode( DWORD mode
)
2297 static const WCHAR bootW
[] = {'B','o','o','t',0};
2298 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2299 static const WCHAR autoW
[] = {'A','u','t','o',0};
2300 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2301 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2302 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2306 case SERVICE_BOOT_START
: return bootW
;
2307 case SERVICE_SYSTEM_START
: return systemW
;
2308 case SERVICE_AUTO_START
: return autoW
;
2309 case SERVICE_DEMAND_START
: return manualW
;
2310 case SERVICE_DISABLED
: return disabledW
;
2312 ERR("unknown mode 0x%x\n", mode
);
2316 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2318 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2322 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2323 QueryServiceConfigW( service
, NULL
, 0, &size
);
2324 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2325 if (!(config
= heap_alloc( size
))) goto done
;
2326 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2327 heap_free( config
);
2331 CloseServiceHandle( service
);
2335 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2337 struct record_service
*rec
;
2339 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2340 SERVICE_STATUS_PROCESS
*status
;
2341 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2342 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2343 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2344 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2347 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2348 if (!(services
= heap_alloc( size
))) goto done
;
2350 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2351 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2352 &count
, NULL
, NULL
);
2355 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2357 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2359 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2360 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2361 &count
, NULL
, NULL
);
2362 if (!ret
) goto done
;
2364 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2366 GetComputerNameW( sysnameW
, &len
);
2367 fill_status
= FILL_STATUS_UNFILTERED
;
2369 for (i
= 0; i
< count
; i
++)
2371 QUERY_SERVICE_CONFIGW
*config
;
2373 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2375 status
= &services
[i
].ServiceStatusProcess
;
2376 rec
= (struct record_service
*)(table
->data
+ offset
);
2377 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2378 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2379 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2380 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2381 rec
->process_id
= status
->dwProcessId
;
2382 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2383 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2384 rec
->state
= get_service_state( status
->dwCurrentState
);
2385 rec
->systemname
= heap_strdupW( sysnameW
);
2386 rec
->pause_service
= service_pause_service
;
2387 rec
->resume_service
= service_resume_service
;
2388 rec
->start_service
= service_start_service
;
2389 rec
->stop_service
= service_stop_service
;
2390 heap_free( config
);
2391 if (!match_row( table
, row
, cond
, &fill_status
))
2393 free_row_values( table
, row
);
2396 offset
+= sizeof(*rec
);
2400 TRACE("created %u rows\n", row
);
2401 table
->num_rows
= row
;
2404 CloseServiceHandle( manager
);
2405 heap_free( services
);
2409 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2411 HDC hdc
= GetDC( NULL
);
2414 if (!hdc
) return 32;
2415 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2416 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2417 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2418 ReleaseDC( NULL
, hdc
);
2421 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2423 static const WCHAR fmtW
[] =
2424 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2425 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2426 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2429 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2430 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2434 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2437 struct record_videocontroller
*rec
;
2439 IDXGIFactory
*factory
= NULL
;
2440 IDXGIAdapter
*adapter
= NULL
;
2441 DXGI_ADAPTER_DESC desc
;
2442 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2443 const WCHAR
*name
= videocontroller_deviceidW
;
2444 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2447 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2449 memset (&desc
, 0, sizeof(desc
));
2450 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2451 if (FAILED(hr
)) goto done
;
2453 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2454 if (FAILED(hr
)) goto done
;
2456 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2459 vidmem
= desc
.DedicatedVideoMemory
;
2460 name
= desc
.Description
;
2464 rec
= (struct record_videocontroller
*)table
->data
;
2465 rec
->adapter_dactype
= videocontroller_dactypeW
;
2466 rec
->adapter_ram
= vidmem
;
2467 rec
->availability
= 3; /* Running or Full Power */
2468 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2469 rec
->current_horizontalres
= hres
;
2470 rec
->current_verticalres
= vres
;
2471 rec
->description
= heap_strdupW( name
);
2472 rec
->device_id
= videocontroller_deviceidW
;
2473 rec
->name
= heap_strdupW( name
);
2474 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2475 rec
->videoprocessor
= heap_strdupW( name
);
2476 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2479 TRACE("created %u rows\n", row
);
2480 table
->num_rows
= row
;
2482 if (adapter
) IDXGIAdapter_Release( adapter
);
2483 if (factory
) IDXGIFactory_Release( factory
);
2487 static struct table builtin_classes
[] =
2489 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2490 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2491 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2492 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2493 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, SIZEOF(data_compsysproduct
), 0, (BYTE
*)data_compsysproduct
},
2494 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2495 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2496 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2497 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2498 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2499 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2500 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2501 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
2502 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2503 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2504 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2505 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2506 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2507 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2508 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2509 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2510 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2511 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2512 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2513 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2514 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2517 void init_table_list( void )
2519 static struct list tables
= LIST_INIT( tables
);
2522 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2523 table_list
= &tables
;