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_osW
[] =
55 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
56 static const WCHAR class_paramsW
[] =
57 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
58 static const WCHAR class_qualifiersW
[] =
59 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
60 static const WCHAR class_process_getowner_outW
[] =
61 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
62 'N','E','R','_','O','U','T',0};
63 static const WCHAR class_processorW
[] =
64 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
65 static const WCHAR class_sounddeviceW
[] =
66 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
67 static const WCHAR class_videocontrollerW
[] =
68 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
70 static const WCHAR prop_acceptpauseW
[] =
71 {'A','c','c','e','p','t','P','a','u','s','e',0};
72 static const WCHAR prop_acceptstopW
[] =
73 {'A','c','c','e','p','t','S','t','o','p',0};
74 static const WCHAR prop_accessmaskW
[] =
75 {'A','c','c','e','s','s','M','a','s','k',0};
76 static const WCHAR prop_adapterdactypeW
[] =
77 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
78 static const WCHAR prop_adapterramW
[] =
79 {'A','d','a','p','t','e','r','R','A','M',0};
80 static const WCHAR prop_adaptertypeW
[] =
81 {'A','d','a','p','t','e','r','T','y','p','e',0};
82 static const WCHAR prop_addresswidthW
[] =
83 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
84 static const WCHAR prop_bootableW
[] =
85 {'B','o','o','t','a','b','l','e',0};
86 static const WCHAR prop_bootpartitionW
[] =
87 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
88 static const WCHAR prop_captionW
[] =
89 {'C','a','p','t','i','o','n',0};
90 static const WCHAR prop_classW
[] =
91 {'C','l','a','s','s',0};
92 static const WCHAR prop_codesetW
[] =
93 {'C','o','d','e','S','e','t',0};
94 static const WCHAR prop_commandlineW
[] =
95 {'C','o','m','m','a','n','d','L','i','n','e',0};
96 static const WCHAR prop_countrycodeW
[] =
97 {'C','o','u','n','t','r','y','C','o','d','e',0};
98 static const WCHAR prop_cpustatusW
[] =
99 {'C','p','u','S','t','a','t','u','s',0};
100 static const WCHAR prop_csdversionW
[] =
101 {'C','S','D','V','e','r','s','i','o','n',0};
102 static const WCHAR prop_currentbitsperpixelW
[] =
103 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
104 static const WCHAR prop_currenthorizontalresW
[] =
105 {'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};
106 static const WCHAR prop_currentverticalresW
[] =
107 {'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};
108 static const WCHAR prop_defaultvalueW
[] =
109 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
110 static const WCHAR prop_descriptionW
[] =
111 {'D','e','s','c','r','i','p','t','i','o','n',0};
112 static const WCHAR prop_deviceidW
[] =
113 {'D','e','v','i','c','e','I','d',0};
114 static const WCHAR prop_directionW
[] =
115 {'D','i','r','e','c','t','i','o','n',0};
116 static const WCHAR prop_displaynameW
[] =
117 {'D','i','s','p','l','a','y','N','a','m','e',0};
118 static const WCHAR prop_diskindexW
[] =
119 {'D','i','s','k','I','n','d','e','x',0};
120 static const WCHAR prop_domainW
[] =
121 {'D','o','m','a','i','n',0};
122 static const WCHAR prop_domainroleW
[] =
123 {'D','o','m','a','i','n','R','o','l','e',0};
124 static const WCHAR prop_driveW
[] =
125 {'D','r','i','v','e',0};
126 static const WCHAR prop_drivetypeW
[] =
127 {'D','r','i','v','e','T','y','p','e',0};
128 static const WCHAR prop_familyW
[] =
129 {'F','a','m','i','l','y',0};
130 static const WCHAR prop_filesystemW
[] =
131 {'F','i','l','e','S','y','s','t','e','m',0};
132 static const WCHAR prop_flavorW
[] =
133 {'F','l','a','v','o','r',0};
134 static const WCHAR prop_freespaceW
[] =
135 {'F','r','e','e','S','p','a','c','e',0};
136 static const WCHAR prop_handleW
[] =
137 {'H','a','n','d','l','e',0};
138 static const WCHAR prop_idW
[] =
140 static const WCHAR prop_indexW
[] =
141 {'I','n','d','e','x',0};
142 static const WCHAR prop_interfaceindexW
[] =
143 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
144 static const WCHAR prop_intvalueW
[] =
145 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
146 static const WCHAR prop_lastbootuptimeW
[] =
147 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
148 static const WCHAR prop_localdatetimeW
[] =
149 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
150 static const WCHAR prop_localeW
[] =
151 {'L','o','c','a','l','e',0};
152 static const WCHAR prop_macaddressW
[] =
153 {'M','A','C','A','d','d','r','e','s','s',0};
154 static const WCHAR prop_manufacturerW
[] =
155 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
156 static const WCHAR prop_maxclockspeedW
[] =
157 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
158 static const WCHAR prop_memberW
[] =
159 {'M','e','m','b','e','r',0};
160 static const WCHAR prop_methodW
[] =
161 {'M','e','t','h','o','d',0};
162 static const WCHAR prop_modelW
[] =
163 {'M','o','d','e','l',0};
164 static const WCHAR prop_netconnectionstatusW
[] =
165 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
166 static const WCHAR prop_numcoresW
[] =
167 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
168 static const WCHAR prop_numlogicalprocessorsW
[] =
169 {'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};
170 static const WCHAR prop_numprocessorsW
[] =
171 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
172 static const WCHAR prop_osarchitectureW
[] =
173 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
174 static const WCHAR prop_oslanguageW
[] =
175 {'O','S','L','a','n','g','u','a','g','e',0};
176 static const WCHAR prop_osproductsuiteW
[] =
177 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
178 static const WCHAR prop_ostypeW
[] =
179 {'O','S','T','y','p','e',0};
180 static const WCHAR prop_parameterW
[] =
181 {'P','a','r','a','m','e','t','e','r',0};
182 static const WCHAR prop_physicaladapterW
[] =
183 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
184 static const WCHAR prop_pnpdeviceidW
[] =
185 {'P','N','P','D','e','v','i','c','e','I','D',0};
186 static const WCHAR prop_pprocessidW
[] =
187 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
188 static const WCHAR prop_processidW
[] =
189 {'P','r','o','c','e','s','s','I','D',0};
190 static const WCHAR prop_processoridW
[] =
191 {'P','r','o','c','e','s','s','o','r','I','d',0};
192 static const WCHAR prop_productnameW
[] =
193 {'P','r','o','d','u','c','t','N','a','m','e',0};
194 static const WCHAR prop_releasedateW
[] =
195 {'R','e','l','e','a','s','e','D','a','t','e',0};
196 static const WCHAR prop_serialnumberW
[] =
197 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
198 static const WCHAR prop_servicepackmajorW
[] =
199 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
200 static const WCHAR prop_servicepackminorW
[] =
201 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
202 static const WCHAR prop_servicetypeW
[] =
203 {'S','e','r','v','i','c','e','T','y','p','e',0};
204 static const WCHAR prop_startmodeW
[] =
205 {'S','t','a','r','t','M','o','d','e',0};
206 static const WCHAR prop_sizeW
[] =
208 static const WCHAR prop_speedW
[] =
209 {'S','p','e','e','d',0};
210 static const WCHAR prop_startingoffsetW
[] =
211 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
212 static const WCHAR prop_stateW
[] =
213 {'S','t','a','t','e',0};
214 static const WCHAR prop_strvalueW
[] =
215 {'S','t','r','i','n','g','V','a','l','u','e',0};
216 static const WCHAR prop_suitemaskW
[] =
217 {'S','u','i','t','e','M','a','s','k',0};
218 static const WCHAR prop_systemdirectoryW
[] =
219 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
220 static const WCHAR prop_systemnameW
[] =
221 {'S','y','s','t','e','m','N','a','m','e',0};
222 static const WCHAR prop_tagW
[] =
224 static const WCHAR prop_threadcountW
[] =
225 {'T','h','r','e','a','d','C','o','u','n','t',0};
226 static const WCHAR prop_totalphysicalmemoryW
[] =
227 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
228 static const WCHAR prop_typeW
[] =
230 static const WCHAR prop_uniqueidW
[] =
231 {'U','n','i','q','u','e','I','d',0};
232 static const WCHAR prop_varianttypeW
[] =
233 {'V','a','r','i','a','n','t','T','y','p','e',0};
234 static const WCHAR prop_versionW
[] =
235 {'V','e','r','s','i','o','n',0};
237 /* column definitions must be kept in sync with record structures below */
238 static const struct column col_baseboard
[] =
240 { prop_manufacturerW
, CIM_STRING
},
241 { prop_serialnumberW
, CIM_STRING
},
242 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
244 static const struct column col_bios
[] =
246 { prop_descriptionW
, CIM_STRING
},
247 { prop_manufacturerW
, CIM_STRING
},
248 { prop_releasedateW
, CIM_DATETIME
},
249 { prop_serialnumberW
, CIM_STRING
},
250 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
252 static const struct column col_cdromdrive
[] =
254 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
255 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
256 { prop_nameW
, CIM_STRING
},
257 { prop_pnpdeviceidW
, CIM_STRING
}
259 static const struct column col_compsys
[] =
261 { prop_descriptionW
, CIM_STRING
},
262 { prop_domainW
, CIM_STRING
},
263 { prop_domainroleW
, CIM_UINT16
},
264 { prop_manufacturerW
, CIM_STRING
},
265 { prop_modelW
, CIM_STRING
},
266 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
267 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
268 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
269 { prop_totalphysicalmemoryW
, CIM_UINT64
}
271 static const struct column col_datafile
[] =
273 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
274 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
276 static const struct column col_directory
[] =
278 { prop_accessmaskW
, CIM_UINT32
},
279 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
281 static const struct column col_diskdrive
[] =
283 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
284 { prop_indexW
, CIM_UINT32
, VT_I4
},
285 { prop_manufacturerW
, CIM_STRING
},
286 { prop_modelW
, CIM_STRING
},
287 { prop_serialnumberW
, CIM_STRING
}
289 static const struct column col_diskpartition
[] =
291 { prop_bootableW
, CIM_BOOLEAN
},
292 { prop_bootpartitionW
, CIM_BOOLEAN
},
293 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
294 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
295 { prop_indexW
, CIM_UINT32
, VT_I4
},
296 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
297 { prop_sizeW
, CIM_UINT64
},
298 { prop_startingoffsetW
, CIM_UINT64
},
299 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
301 static const struct column col_logicaldisk
[] =
303 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
304 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
305 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
306 { prop_freespaceW
, CIM_UINT64
},
307 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
308 { prop_sizeW
, CIM_UINT64
}
310 static const struct column col_networkadapter
[] =
312 { prop_adaptertypeW
, CIM_STRING
},
313 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
314 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
315 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
316 { prop_manufacturerW
, CIM_STRING
},
317 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
318 { prop_physicaladapterW
, CIM_BOOLEAN
},
319 { prop_pnpdeviceidW
, CIM_STRING
},
320 { prop_speedW
, CIM_UINT64
}
322 static const struct column col_os
[] =
324 { prop_captionW
, CIM_STRING
},
325 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
326 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
327 { prop_csdversionW
, CIM_STRING
},
328 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
329 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
330 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
331 { prop_osarchitectureW
, CIM_STRING
},
332 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
333 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
334 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
335 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
336 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
337 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
338 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
339 { prop_versionW
, CIM_STRING
}
341 static const struct column col_param
[] =
343 { prop_classW
, CIM_STRING
},
344 { prop_methodW
, CIM_STRING
},
345 { prop_directionW
, CIM_SINT32
},
346 { prop_parameterW
, CIM_STRING
},
347 { prop_typeW
, CIM_UINT32
},
348 { prop_varianttypeW
, CIM_UINT32
},
349 { prop_defaultvalueW
, CIM_UINT32
}
351 static const struct column col_process
[] =
353 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
354 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
355 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
356 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
357 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
358 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
359 { prop_processidW
, CIM_UINT32
, VT_I4
},
360 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
362 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
364 static const struct column col_processor
[] =
366 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
367 { prop_cpustatusW
, CIM_UINT16
},
368 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
369 { prop_familyW
, CIM_UINT16
, VT_I4
},
370 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
371 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
372 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
373 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
374 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
375 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
376 { prop_uniqueidW
, CIM_STRING
}
378 static const struct column col_qualifier
[] =
380 { prop_classW
, CIM_STRING
},
381 { prop_memberW
, CIM_STRING
},
382 { prop_typeW
, CIM_UINT32
},
383 { prop_flavorW
, CIM_SINT32
},
384 { prop_nameW
, CIM_STRING
},
385 { prop_intvalueW
, CIM_SINT32
},
386 { prop_strvalueW
, CIM_STRING
}
388 static const struct column col_service
[] =
390 { prop_acceptpauseW
, CIM_BOOLEAN
},
391 { prop_acceptstopW
, CIM_BOOLEAN
},
392 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
393 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
394 { prop_processidW
, CIM_UINT32
},
395 { prop_servicetypeW
, CIM_STRING
},
396 { prop_startmodeW
, CIM_STRING
},
397 { prop_stateW
, CIM_STRING
},
398 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
400 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
401 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
402 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
403 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
405 static const struct column col_sounddevice
[] =
407 { prop_nameW
, CIM_STRING
},
408 { prop_productnameW
, CIM_STRING
}
410 static const struct column col_stdregprov
[] =
412 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
413 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
414 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
416 static const struct column col_videocontroller
[] =
418 { prop_adapterdactypeW
, CIM_STRING
},
419 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
420 { prop_currentbitsperpixelW
, CIM_UINT32
},
421 { prop_currenthorizontalresW
, CIM_UINT32
},
422 { prop_currentverticalresW
, CIM_UINT32
},
423 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
424 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
425 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
426 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
429 static const WCHAR baseboard_manufacturerW
[] =
430 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
431 static const WCHAR baseboard_serialnumberW
[] =
433 static const WCHAR baseboard_tagW
[] =
434 {'B','a','s','e',' ','B','o','a','r','d',0};
435 static const WCHAR bios_descriptionW
[] =
436 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
437 static const WCHAR bios_manufacturerW
[] =
438 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
439 static const WCHAR bios_releasedateW
[] =
440 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
441 static const WCHAR bios_serialnumberW
[] =
443 static const WCHAR bios_versionW
[] =
444 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
445 static const WCHAR cdromdrive_nameW
[] =
446 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
447 static const WCHAR cdromdrive_pnpdeviceidW
[]=
448 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
449 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
450 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
451 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
452 static const WCHAR compsys_descriptionW
[] =
453 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
454 static const WCHAR compsys_domainW
[] =
455 {'W','O','R','K','G','R','O','U','P',0};
456 static const WCHAR compsys_manufacturerW
[] =
457 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
458 static const WCHAR compsys_modelW
[] =
460 static const WCHAR diskdrive_deviceidW
[] =
461 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
462 static const WCHAR diskdrive_modelW
[] =
463 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
464 static const WCHAR diskdrive_manufacturerW
[] =
465 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
466 static const WCHAR diskdrive_serialW
[] =
467 {'W','I','N','E','H','D','I','S','K',0};
468 static const WCHAR networkadapter_pnpdeviceidW
[]=
469 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
470 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
471 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
472 static const WCHAR os_captionW
[] =
473 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
474 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
475 static const WCHAR os_csdversionW
[] =
476 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
477 static const WCHAR os_32bitW
[] =
478 {'3','2','-','b','i','t',0};
479 static const WCHAR os_64bitW
[] =
480 {'6','4','-','b','i','t',0};
481 static const WCHAR os_versionW
[] =
482 {'5','.','1','.','2','6','0','0',0};
483 static const WCHAR sounddevice_productnameW
[] =
484 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
485 static const WCHAR videocontroller_dactypeW
[] =
486 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
487 static const WCHAR videocontroller_deviceidW
[] =
488 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
490 #include "pshpack1.h"
491 struct record_baseboard
493 const WCHAR
*manufacturer
;
494 const WCHAR
*serialnumber
;
499 const WCHAR
*description
;
500 const WCHAR
*manufacturer
;
501 const WCHAR
*releasedate
;
502 const WCHAR
*serialnumber
;
503 const WCHAR
*version
;
505 struct record_cdromdrive
507 const WCHAR
*device_id
;
510 const WCHAR
*pnpdevice_id
;
512 struct record_computersystem
514 const WCHAR
*description
;
517 const WCHAR
*manufacturer
;
520 UINT32 num_logical_processors
;
521 UINT32 num_processors
;
522 UINT64 total_physical_memory
;
524 struct record_datafile
527 const WCHAR
*version
;
529 struct record_directory
534 struct record_diskdrive
536 const WCHAR
*device_id
;
538 const WCHAR
*manufacturer
;
540 const WCHAR
*serialnumber
;
542 struct record_diskpartition
546 const WCHAR
*device_id
;
549 const WCHAR
*pnpdevice_id
;
551 UINT64 startingoffset
;
554 struct record_logicaldisk
556 const WCHAR
*device_id
;
558 const WCHAR
*filesystem
;
563 struct record_networkadapter
565 const WCHAR
*adaptertype
;
566 const WCHAR
*device_id
;
567 INT32 interface_index
;
568 const WCHAR
*mac_address
;
569 const WCHAR
*manufacturer
;
570 UINT16 netconnection_status
;
572 const WCHAR
*pnpdevice_id
;
575 struct record_operatingsystem
577 const WCHAR
*caption
;
578 const WCHAR
*codeset
;
579 const WCHAR
*countrycode
;
580 const WCHAR
*csdversion
;
581 const WCHAR
*lastbootuptime
;
582 const WCHAR
*localdatetime
;
584 const WCHAR
*osarchitecture
;
586 UINT32 osproductsuite
;
588 UINT16 servicepackmajor
;
589 UINT16 servicepackminor
;
591 const WCHAR
*systemdirectory
;
592 const WCHAR
*version
;
599 const WCHAR
*parameter
;
604 struct record_process
606 const WCHAR
*caption
;
607 const WCHAR
*commandline
;
608 const WCHAR
*description
;
615 class_method
*get_owner
;
617 struct record_processor
621 const WCHAR
*device_id
;
623 const WCHAR
*manufacturer
;
624 UINT32 maxclockspeed
;
627 UINT32 num_logical_processors
;
628 const WCHAR
*processor_id
;
629 const WCHAR
*unique_id
;
631 struct record_qualifier
639 const WCHAR
*strvalue
;
641 struct record_service
645 const WCHAR
*displayname
;
648 const WCHAR
*servicetype
;
649 const WCHAR
*startmode
;
651 const WCHAR
*systemname
;
653 class_method
*pause_service
;
654 class_method
*resume_service
;
655 class_method
*start_service
;
656 class_method
*stop_service
;
658 struct record_sounddevice
661 const WCHAR
*productname
;
663 struct record_stdregprov
665 class_method
*enumkey
;
666 class_method
*enumvalues
;
667 class_method
*getstringvalue
;
669 struct record_videocontroller
671 const WCHAR
*adapter_dactype
;
673 UINT32 current_bitsperpixel
;
674 UINT32 current_horizontalres
;
675 UINT32 current_verticalres
;
676 const WCHAR
*description
;
677 const WCHAR
*device_id
;
679 const WCHAR
*pnpdevice_id
;
683 static const struct record_baseboard data_baseboard
[] =
685 { baseboard_manufacturerW
, baseboard_serialnumberW
, baseboard_tagW
}
687 static const struct record_bios data_bios
[] =
689 { bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
, bios_versionW
}
691 static const struct record_diskdrive data_diskdrive
[] =
693 { diskdrive_deviceidW
, 0, diskdrive_manufacturerW
, diskdrive_modelW
, diskdrive_serialW
}
695 static const struct record_param data_param
[] =
697 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
698 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
699 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
700 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
701 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
702 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
703 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
704 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
705 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
706 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
707 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
708 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
709 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
710 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
711 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
712 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
713 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
714 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
715 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
716 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
717 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
}
720 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
721 WBEM_FLAVOR_ORIGIN_PROPAGATED)
723 static const struct record_qualifier data_qualifier
[] =
725 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
726 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
728 static const struct record_sounddevice data_sounddevice
[] =
730 { sounddevice_productnameW
, sounddevice_productnameW
}
732 static const struct record_stdregprov data_stdregprov
[] =
734 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
737 /* check if row matches condition and update status */
738 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
743 *status
= FILL_STATUS_UNFILTERED
;
746 if (eval_cond( table
, row
, cond
, &val
) != S_OK
)
748 *status
= FILL_STATUS_FAILED
;
751 *status
= FILL_STATUS_FILTERED
;
755 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
757 if (!table
->num_rows_allocated
)
759 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
760 table
->num_rows_allocated
= row_count
;
763 if (row_count
>= table
->num_rows_allocated
)
766 UINT count
= table
->num_rows_allocated
* 2;
767 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
769 table
->num_rows_allocated
= count
;
774 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
776 static const WCHAR fmtW
[] = {'%','c',':',0};
777 WCHAR drive
[3], root
[] = {'A',':','\\',0};
778 struct record_cdromdrive
*rec
;
779 UINT i
, row
= 0, offset
= 0;
780 DWORD drives
= GetLogicalDrives();
781 enum fill_status status
= FILL_STATUS_UNFILTERED
;
783 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
785 for (i
= 0; i
< sizeof(drives
); i
++)
787 if (drives
& (1 << i
))
790 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
793 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
795 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
796 rec
->device_id
= cdromdrive_pnpdeviceidW
;
797 sprintfW( drive
, fmtW
, 'A' + i
);
798 rec
->drive
= heap_strdupW( drive
);
799 rec
->name
= cdromdrive_nameW
;
800 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
801 if (!match_row( table
, row
, cond
, &status
))
803 free_row_values( table
, row
);
806 offset
+= sizeof(*rec
);
810 TRACE("created %u rows\n", row
);
811 table
->num_rows
= row
;
815 static UINT
get_processor_count(void)
817 SYSTEM_BASIC_INFORMATION info
;
819 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
820 return info
.NumberOfProcessors
;
823 static UINT
get_logical_processor_count( UINT
*num_cores
)
825 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
826 UINT i
, j
, count
= 0;
830 if (num_cores
) *num_cores
= get_processor_count();
831 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
832 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
834 if (!(info
= heap_alloc( len
))) return get_processor_count();
835 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
836 if (status
!= STATUS_SUCCESS
)
839 return get_processor_count();
841 if (num_cores
) *num_cores
= 0;
842 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
844 if (info
[i
].Relationship
== RelationProcessorCore
)
846 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
848 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
850 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
857 static UINT64
get_total_physical_memory(void)
859 MEMORYSTATUSEX status
;
861 status
.dwLength
= sizeof(status
);
862 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
863 return status
.ullTotalPhys
;
866 static WCHAR
*get_computername(void)
869 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
871 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
872 GetComputerNameW( ret
, &size
);
876 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
878 struct record_computersystem
*rec
;
879 enum fill_status status
= FILL_STATUS_UNFILTERED
;
882 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
884 rec
= (struct record_computersystem
*)table
->data
;
885 rec
->description
= compsys_descriptionW
;
886 rec
->domain
= compsys_domainW
;
887 rec
->domainrole
= 0; /* standalone workstation */
888 rec
->manufacturer
= compsys_manufacturerW
;
889 rec
->model
= compsys_modelW
;
890 rec
->name
= get_computername();
891 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
892 rec
->num_processors
= get_processor_count();
893 rec
->total_physical_memory
= get_total_physical_memory();
894 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
897 TRACE("created %u rows\n", row
);
898 table
->num_rows
= row
;
910 static struct dirstack
*alloc_dirstack( UINT size
)
912 struct dirstack
*dirstack
;
914 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
915 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
917 heap_free( dirstack
);
920 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
922 heap_free( dirstack
->dirs
);
923 heap_free( dirstack
);
926 dirstack
->num_dirs
= 0;
927 dirstack
->num_allocated
= size
;
931 static void clear_dirstack( struct dirstack
*dirstack
)
934 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
935 dirstack
->num_dirs
= 0;
938 static void free_dirstack( struct dirstack
*dirstack
)
940 clear_dirstack( dirstack
);
941 heap_free( dirstack
->dirs
);
942 heap_free( dirstack
->len_dirs
);
943 heap_free( dirstack
);
946 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
948 UINT size
, i
= dirstack
->num_dirs
;
950 if (!dir
) return FALSE
;
952 if (i
== dirstack
->num_allocated
)
957 size
= dirstack
->num_allocated
* 2;
958 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
959 dirstack
->dirs
= tmp
;
960 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
961 dirstack
->len_dirs
= len_tmp
;
962 dirstack
->num_allocated
= size
;
964 dirstack
->dirs
[i
] = dir
;
965 dirstack
->len_dirs
[i
] = len
;
966 dirstack
->num_dirs
++;
970 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
972 if (!dirstack
->num_dirs
)
977 dirstack
->num_dirs
--;
978 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
979 return dirstack
->dirs
[dirstack
->num_dirs
];
982 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
984 if (!dirstack
->num_dirs
) return NULL
;
985 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
988 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
993 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
999 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1008 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1010 UINT i
= 0, len
= 0;
1014 for (p
= path
; *p
; p
++)
1016 if (*p
== '\\') len
+= 2;
1019 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1024 for (p
= path
; *p
; p
++)
1026 if (*p
!= '\\') ret
[i
++] = *p
;
1037 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1039 const WCHAR
*p
= path
, *start
;
1043 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1045 len
= strlenW( start
);
1046 p
= start
+ len
- 1;
1047 if (*p
== '\\') return NULL
;
1049 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1050 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1052 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1053 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1055 if (p
[0] == '\\' && p
[1] == '\\')
1067 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1070 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1074 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1075 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1077 const struct expr
*left
, *right
;
1079 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1081 left
= cond
->u
.expr
.left
;
1082 right
= cond
->u
.expr
.right
;
1083 if (cond
->u
.expr
.op
== OP_EQ
)
1087 const WCHAR
*str
= NULL
;
1089 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1090 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1091 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1093 str
= right
->u
.sval
;
1095 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1096 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1097 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1101 if (str
&& (path
= build_dirname( str
, &len
)))
1103 if (seen_dir( dirstack
, path
))
1108 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1113 else if (cond
->u
.expr
.op
== OP_OR
)
1115 UINT left_count
= 0, right_count
= 0;
1117 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1118 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1119 return *count
+= left_count
+ right_count
;
1124 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1126 UINT len_path
= 0, len_segment
= strlenW( segment
);
1130 if (path
) len_path
= strlenW( path
);
1131 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1132 if (path
&& len_path
)
1134 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1135 ret
[len_path
] = '\\';
1136 *len
+= len_path
+ 1;
1138 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1139 *len
+= len_segment
;
1144 static WCHAR
*get_file_version( const WCHAR
*filename
)
1146 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1147 VS_FIXEDFILEINFO
*info
;
1152 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1153 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1158 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1159 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1165 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1166 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1171 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1173 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1174 struct record_datafile
*rec
;
1175 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1176 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1177 DWORD drives
= GetLogicalDrives();
1178 WIN32_FIND_DATAW data
;
1180 struct dirstack
*dirstack
= alloc_dirstack(2);
1181 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1183 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1185 for (i
= 0; i
< sizeof(drives
); i
++)
1187 if (!(drives
& (1 << i
))) continue;
1190 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1192 num_expected_rows
= 0;
1193 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1197 path
= pop_dir( dirstack
, &len
);
1198 if (!(glob
= build_glob( root
[0], path
, len
)))
1200 status
= FILL_STATUS_FAILED
;
1203 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1207 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1209 status
= FILL_STATUS_FAILED
;
1212 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1213 new_path
= append_path( path
, data
.cFileName
, &len
);
1215 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1217 if (push_dir( dirstack
, new_path
, len
)) continue;
1218 heap_free( new_path
);
1219 status
= FILL_STATUS_FAILED
;
1222 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1223 rec
->name
= build_name( root
[0], new_path
);
1224 rec
->version
= get_file_version( rec
->name
);
1225 if (!match_row( table
, row
, cond
, &status
))
1227 free_row_values( table
, row
);
1230 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1233 FindClose( handle
);
1234 status
= FILL_STATUS_FILTERED
;
1237 offset
+= sizeof(*rec
);
1240 while (FindNextFileW( handle
, &data
));
1241 FindClose( handle
);
1243 if (!peek_dir( dirstack
)) break;
1250 free_dirstack( dirstack
);
1254 TRACE("created %u rows\n", row
);
1255 table
->num_rows
= row
;
1259 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1261 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1262 struct record_directory
*rec
;
1263 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1264 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1265 DWORD drives
= GetLogicalDrives();
1266 WIN32_FIND_DATAW data
;
1268 struct dirstack
*dirstack
;
1269 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1271 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1273 dirstack
= alloc_dirstack(2);
1275 for (i
= 0; i
< sizeof(drives
); i
++)
1277 if (!(drives
& (1 << i
))) continue;
1280 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1282 num_expected_rows
= 0;
1283 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1287 path
= pop_dir( dirstack
, &len
);
1288 if (!(glob
= build_glob( root
[0], path
, len
)))
1290 status
= FILL_STATUS_FAILED
;
1293 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1297 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1299 FindClose( handle
);
1300 status
= FILL_STATUS_FAILED
;
1303 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1304 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1307 new_path
= append_path( path
, data
.cFileName
, &len
);
1308 if (!(push_dir( dirstack
, new_path
, len
)))
1310 heap_free( new_path
);
1311 FindClose( handle
);
1312 status
= FILL_STATUS_FAILED
;
1315 rec
= (struct record_directory
*)(table
->data
+ offset
);
1316 rec
->accessmask
= FILE_ALL_ACCESS
;
1317 rec
->name
= build_name( root
[0], new_path
);
1318 if (!match_row( table
, row
, cond
, &status
))
1320 free_row_values( table
, row
);
1323 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1326 FindClose( handle
);
1327 status
= FILL_STATUS_FILTERED
;
1330 offset
+= sizeof(*rec
);
1333 while (FindNextFileW( handle
, &data
));
1334 FindClose( handle
);
1336 if (!peek_dir( dirstack
)) break;
1343 free_dirstack( dirstack
);
1347 TRACE("created %u rows\n", row
);
1348 table
->num_rows
= row
;
1352 static WCHAR
*get_filesystem( const WCHAR
*root
)
1354 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1355 WCHAR buffer
[MAX_PATH
+ 1];
1357 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1358 return heap_strdupW( buffer
);
1359 return heap_strdupW( ntfsW
);
1362 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1364 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1365 ULARGE_INTEGER free
;
1366 DISK_GEOMETRY_EX info
;
1369 free
.QuadPart
= 512 * 1024 * 1024;
1370 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1373 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1374 if (handle
!= INVALID_HANDLE_VALUE
)
1376 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), NULL
, NULL
))
1377 *disksize
= info
.DiskSize
.QuadPart
;
1378 CloseHandle( handle
);
1380 return free
.QuadPart
;
1383 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1385 static const WCHAR fmtW
[] =
1386 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1387 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1388 struct record_diskpartition
*rec
;
1389 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1390 UINT64 size
= 1024 * 1024 * 1024;
1391 DWORD drives
= GetLogicalDrives();
1392 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1394 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1396 for (i
= 0; i
< sizeof(drives
); i
++)
1398 if (drives
& (1 << i
))
1401 type
= GetDriveTypeW( root
);
1402 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1405 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1407 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1408 rec
->bootable
= (i
== 2) ? -1 : 0;
1409 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1410 sprintfW( device_id
, fmtW
, index
);
1411 rec
->device_id
= heap_strdupW( device_id
);
1412 rec
->diskindex
= index
;
1414 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1415 get_freespace( root
, &size
);
1417 rec
->startingoffset
= 0;
1418 rec
->type
= get_filesystem( root
);
1419 if (!match_row( table
, row
, cond
, &status
))
1421 free_row_values( table
, row
);
1424 offset
+= sizeof(*rec
);
1429 TRACE("created %u rows\n", row
);
1430 table
->num_rows
= row
;
1434 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1436 static const WCHAR fmtW
[] = {'%','c',':',0};
1437 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1438 struct record_logicaldisk
*rec
;
1439 UINT i
, row
= 0, offset
= 0, type
;
1440 UINT64 size
= 1024 * 1024 * 1024;
1441 DWORD drives
= GetLogicalDrives();
1442 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1444 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1446 for (i
= 0; i
< sizeof(drives
); i
++)
1448 if (drives
& (1 << i
))
1451 type
= GetDriveTypeW( root
);
1452 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1455 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1457 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1458 sprintfW( device_id
, fmtW
, 'A' + i
);
1459 rec
->device_id
= heap_strdupW( device_id
);
1460 rec
->drivetype
= type
;
1461 rec
->filesystem
= get_filesystem( root
);
1462 rec
->freespace
= get_freespace( root
, &size
);
1463 rec
->name
= heap_strdupW( device_id
);
1465 if (!match_row( table
, row
, cond
, &status
))
1467 free_row_values( table
, row
);
1470 offset
+= sizeof(*rec
);
1474 TRACE("created %u rows\n", row
);
1475 table
->num_rows
= row
;
1479 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1483 case IfOperStatusDown
:
1484 return 0; /* Disconnected */
1485 case IfOperStatusUp
:
1486 return 2; /* Connected */
1488 ERR("unhandled status %u\n", status
);
1493 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1495 static const WCHAR fmtW
[] =
1496 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1497 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1500 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1501 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1504 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1506 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1507 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1508 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1509 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1513 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1514 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1515 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1516 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1517 default: *physical
= 0; return NULL
;
1521 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1523 static const WCHAR fmtW
[] = {'%','u',0};
1524 WCHAR device_id
[11];
1525 struct record_networkadapter
*rec
;
1526 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1527 UINT row
= 0, offset
= 0, count
= 0;
1528 DWORD size
= 0, ret
;
1530 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1532 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1533 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1535 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1536 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1538 heap_free( buffer
);
1539 return FILL_STATUS_FAILED
;
1541 for (aa
= buffer
; aa
; aa
= aa
->Next
) count
++;
1542 if (!resize_table( table
, count
, sizeof(*rec
) ))
1544 heap_free( buffer
);
1545 return FILL_STATUS_FAILED
;
1547 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1549 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1550 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1551 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1552 rec
->device_id
= heap_strdupW( device_id
);
1553 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1554 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1555 rec
->manufacturer
= compsys_manufacturerW
;
1556 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1557 rec
->physicaladapter
= physical
;
1558 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1559 rec
->speed
= 1000000;
1560 if (!match_row( table
, row
, cond
, &status
))
1562 free_row_values( table
, row
);
1565 offset
+= sizeof(*rec
);
1568 TRACE("created %u rows\n", row
);
1569 table
->num_rows
= row
;
1571 heap_free( buffer
);
1575 static WCHAR
*get_cmdline( DWORD process_id
)
1577 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1578 return NULL
; /* FIXME handle different process case */
1581 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1583 static const WCHAR fmtW
[] = {'%','u',0};
1585 struct record_process
*rec
;
1586 PROCESSENTRY32W entry
;
1588 enum fill_status status
= FILL_STATUS_FAILED
;
1589 UINT row
= 0, offset
= 0;
1591 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1592 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1594 entry
.dwSize
= sizeof(entry
);
1595 if (!Process32FirstW( snap
, &entry
)) goto done
;
1596 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1600 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1602 rec
= (struct record_process
*)(table
->data
+ offset
);
1603 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1604 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1605 rec
->description
= heap_strdupW( entry
.szExeFile
);
1606 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1607 rec
->handle
= heap_strdupW( handle
);
1608 rec
->name
= heap_strdupW( entry
.szExeFile
);
1609 rec
->process_id
= entry
.th32ProcessID
;
1610 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1611 rec
->thread_count
= entry
.cntThreads
;
1612 rec
->get_owner
= process_get_owner
;
1613 if (!match_row( table
, row
, cond
, &status
))
1615 free_row_values( table
, row
);
1618 offset
+= sizeof(*rec
);
1620 } while (Process32NextW( snap
, &entry
));
1622 TRACE("created %u rows\n", row
);
1623 table
->num_rows
= row
;
1624 status
= FILL_STATUS_UNFILTERED
;
1627 CloseHandle( snap
);
1631 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
1637 __asm__("pushl %%ebx\n\t"
1639 "movl %%ebx, %%esi\n\t"
1641 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
1647 static void get_processor_id( WCHAR
*processor_id
)
1649 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
1650 unsigned int regs
[4] = {0, 0, 0, 0};
1652 do_cpuid( 1, regs
);
1653 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
1655 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
1658 unsigned char *p
= (unsigned char *)regs
;
1660 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
1663 static void get_processor_manufacturer( WCHAR
*manufacturer
)
1665 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
1667 do_cpuid( 0, regs
);
1668 tmp
= regs
[2]; /* swap edx and ecx */
1672 regs_to_str( regs
+ 1, 12, manufacturer
);
1674 static void get_processor_name( WCHAR
*name
)
1676 unsigned int regs
[4] = {0, 0, 0, 0};
1678 do_cpuid( 0x80000000, regs
);
1679 if (regs
[0] >= 0x80000004)
1681 do_cpuid( 0x80000002, regs
);
1682 regs_to_str( regs
, 16, name
);
1683 do_cpuid( 0x80000003, regs
);
1684 regs_to_str( regs
, 16, name
+ 16 );
1685 do_cpuid( 0x80000004, regs
);
1686 regs_to_str( regs
, 16, name
+ 32 );
1689 static UINT
get_processor_maxclockspeed( void )
1691 PROCESSOR_POWER_INFORMATION
*info
;
1692 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1695 if ((info
= heap_alloc( size
)))
1697 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1698 if (!status
) ret
= info
[0].MaxMhz
;
1703 static const WCHAR
*get_osarchitecture(void)
1706 GetNativeSystemInfo( &info
);
1707 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
1711 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
1713 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
1714 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
1715 struct record_processor
*rec
;
1716 UINT i
, offset
= 0, maxclockspeed
, num_cores
, num_logical_processors
, count
= get_processor_count();
1717 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1719 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1721 get_processor_id( processor_id
);
1722 get_processor_manufacturer( manufacturer
);
1723 get_processor_name( name
);
1725 maxclockspeed
= get_processor_maxclockspeed();
1726 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
1729 for (i
= 0; i
< count
; i
++)
1731 rec
= (struct record_processor
*)(table
->data
+ offset
);
1732 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
1733 rec
->cpu_status
= 1; /* CPU Enabled */
1734 sprintfW( device_id
, fmtW
, i
);
1735 rec
->device_id
= heap_strdupW( device_id
);
1736 rec
->family
= 2; /* Unknown */
1737 rec
->manufacturer
= heap_strdupW( manufacturer
);
1738 rec
->maxclockspeed
= maxclockspeed
;
1739 rec
->name
= heap_strdupW( name
);
1740 rec
->num_cores
= num_cores
;
1741 rec
->num_logical_processors
= num_logical_processors
;
1742 rec
->processor_id
= heap_strdupW( processor_id
);
1743 rec
->unique_id
= NULL
;
1744 if (!match_row( table
, i
, cond
, &status
))
1746 free_row_values( table
, i
);
1749 offset
+= sizeof(*rec
);
1752 TRACE("created %u rows\n", count
);
1753 table
->num_rows
= count
;
1757 static WCHAR
*get_lastbootuptime(void)
1759 static const WCHAR fmtW
[] =
1760 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1761 '.','%','0','6','u','+','0','0','0',0};
1762 SYSTEM_TIMEOFDAY_INFORMATION ti
;
1766 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1768 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
1769 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
1770 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
1773 static WCHAR
*get_localdatetime(void)
1775 static const WCHAR fmtW
[] =
1776 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1777 '.','%','0','6','u','%','+','0','3','d',0};
1778 TIME_ZONE_INFORMATION tzi
;
1784 Status
= GetTimeZoneInformation(&tzi
);
1786 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
1788 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
1789 Bias
+= tzi
.DaylightBias
;
1791 Bias
+= tzi
.StandardBias
;
1792 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1795 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
1798 static WCHAR
*get_systemdirectory(void)
1803 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
1804 Wow64DisableWow64FsRedirection( &redir
);
1805 GetSystemDirectoryW( ret
, MAX_PATH
);
1806 Wow64RevertWow64FsRedirection( redir
);
1809 static WCHAR
*get_codeset(void)
1811 static const WCHAR fmtW
[] = {'%','u',0};
1812 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
1813 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
1816 static WCHAR
*get_countrycode(void)
1818 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
1819 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
1822 static WCHAR
*get_locale(void)
1824 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
1825 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
1829 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
1831 struct record_operatingsystem
*rec
;
1832 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1835 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1837 rec
= (struct record_operatingsystem
*)table
->data
;
1838 rec
->caption
= os_captionW
;
1839 rec
->codeset
= get_codeset();
1840 rec
->countrycode
= get_countrycode();
1841 rec
->csdversion
= os_csdversionW
;
1842 rec
->lastbootuptime
= get_lastbootuptime();
1843 rec
->localdatetime
= get_localdatetime();
1844 rec
->locale
= get_locale();
1845 rec
->osarchitecture
= get_osarchitecture();
1846 rec
->oslanguage
= GetSystemDefaultLangID();
1847 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
1848 rec
->ostype
= 18; /* WINNT */
1849 rec
->servicepackmajor
= 3;
1850 rec
->servicepackminor
= 0;
1851 rec
->suitemask
= 272; /* Single User + Terminal */
1852 rec
->systemdirectory
= get_systemdirectory();
1853 rec
->version
= os_versionW
;
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 const WCHAR
*get_service_type( DWORD type
)
1864 static const WCHAR filesystem_driverW
[] =
1865 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
1866 static const WCHAR kernel_driverW
[] =
1867 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
1868 static const WCHAR own_processW
[] =
1869 {'O','w','n',' ','P','r','o','c','e','s','s',0};
1870 static const WCHAR share_processW
[] =
1871 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
1873 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
1874 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
1875 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
1876 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
1877 else ERR("unhandled type 0x%08x\n", type
);
1880 static const WCHAR
*get_service_state( DWORD state
)
1882 static const WCHAR runningW
[] =
1883 {'R','u','n','n','i','n','g',0};
1884 static const WCHAR start_pendingW
[] =
1885 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
1886 static const WCHAR stop_pendingW
[] =
1887 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
1888 static const WCHAR stoppedW
[] =
1889 {'S','t','o','p','p','e','d',0};
1890 static const WCHAR unknownW
[] =
1891 {'U','n','k','n','o','w','n',0};
1895 case SERVICE_STOPPED
: return stoppedW
;
1896 case SERVICE_START_PENDING
: return start_pendingW
;
1897 case SERVICE_STOP_PENDING
: return stop_pendingW
;
1898 case SERVICE_RUNNING
: return runningW
;
1900 ERR("unknown state %u\n", state
);
1904 static const WCHAR
*get_service_startmode( DWORD mode
)
1906 static const WCHAR bootW
[] = {'B','o','o','t',0};
1907 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
1908 static const WCHAR autoW
[] = {'A','u','t','o',0};
1909 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
1910 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
1911 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
1915 case SERVICE_BOOT_START
: return bootW
;
1916 case SERVICE_SYSTEM_START
: return systemW
;
1917 case SERVICE_AUTO_START
: return autoW
;
1918 case SERVICE_DEMAND_START
: return manualW
;
1919 case SERVICE_DISABLED
: return disabledW
;
1921 ERR("unknown mode 0x%x\n", mode
);
1925 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
1927 QUERY_SERVICE_CONFIGW
*config
= NULL
;
1931 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
1932 QueryServiceConfigW( service
, NULL
, 0, &size
);
1933 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
1934 if (!(config
= heap_alloc( size
))) goto done
;
1935 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
1936 heap_free( config
);
1940 CloseServiceHandle( service
);
1944 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
1946 struct record_service
*rec
;
1948 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
1949 SERVICE_STATUS_PROCESS
*status
;
1950 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
1951 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
1952 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
1953 enum fill_status fill_status
= FILL_STATUS_FAILED
;
1956 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
1957 if (!(services
= heap_alloc( size
))) goto done
;
1959 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
1960 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
1961 &count
, NULL
, NULL
);
1964 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
1966 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
1968 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
1969 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
1970 &count
, NULL
, NULL
);
1971 if (!ret
) goto done
;
1973 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
1975 GetComputerNameW( sysnameW
, &len
);
1976 fill_status
= FILL_STATUS_UNFILTERED
;
1978 for (i
= 0; i
< count
; i
++)
1980 QUERY_SERVICE_CONFIGW
*config
;
1982 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
1984 status
= &services
[i
].ServiceStatusProcess
;
1985 rec
= (struct record_service
*)(table
->data
+ offset
);
1986 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
1987 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
1988 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
1989 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
1990 rec
->process_id
= status
->dwProcessId
;
1991 rec
->servicetype
= get_service_type( status
->dwServiceType
);
1992 rec
->startmode
= get_service_startmode( config
->dwStartType
);
1993 rec
->state
= get_service_state( status
->dwCurrentState
);
1994 rec
->systemname
= heap_strdupW( sysnameW
);
1995 rec
->pause_service
= service_pause_service
;
1996 rec
->resume_service
= service_resume_service
;
1997 rec
->start_service
= service_start_service
;
1998 rec
->stop_service
= service_stop_service
;
1999 heap_free( config
);
2000 if (!match_row( table
, row
, cond
, &fill_status
))
2002 free_row_values( table
, row
);
2005 offset
+= sizeof(*rec
);
2009 TRACE("created %u rows\n", row
);
2010 table
->num_rows
= row
;
2013 CloseServiceHandle( manager
);
2014 heap_free( services
);
2018 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2020 HDC hdc
= GetDC( NULL
);
2023 if (!hdc
) return 32;
2024 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2025 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2026 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2027 ReleaseDC( NULL
, hdc
);
2030 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2032 static const WCHAR fmtW
[] =
2033 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2034 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2035 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2038 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2039 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2043 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2046 struct record_videocontroller
*rec
;
2048 IDXGIFactory
*factory
= NULL
;
2049 IDXGIAdapter
*adapter
= NULL
;
2050 DXGI_ADAPTER_DESC desc
;
2051 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2052 const WCHAR
*name
= videocontroller_deviceidW
;
2053 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2056 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2058 memset (&desc
, 0, sizeof(desc
));
2059 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2060 if (FAILED(hr
)) goto done
;
2062 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2063 if (FAILED(hr
)) goto done
;
2065 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2068 vidmem
= desc
.DedicatedVideoMemory
;
2069 name
= desc
.Description
;
2073 rec
= (struct record_videocontroller
*)table
->data
;
2074 rec
->adapter_dactype
= videocontroller_dactypeW
;
2075 rec
->adapter_ram
= vidmem
;
2076 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2077 rec
->current_horizontalres
= hres
;
2078 rec
->current_verticalres
= vres
;
2079 rec
->description
= heap_strdupW( name
);
2080 rec
->device_id
= videocontroller_deviceidW
;
2081 rec
->name
= heap_strdupW( name
);
2082 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2083 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2086 TRACE("created %u rows\n", row
);
2087 table
->num_rows
= row
;
2089 if (adapter
) IDXGIAdapter_Release( adapter
);
2090 if (factory
) IDXGIFactory_Release( factory
);
2094 static struct table builtin_classes
[] =
2096 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2097 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2098 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2099 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2100 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2101 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2102 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, SIZEOF(data_diskdrive
), 0, (BYTE
*)data_diskdrive
},
2103 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2104 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2105 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2106 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2107 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2108 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2109 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2110 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2111 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2112 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2113 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2114 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2115 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2118 void init_table_list( void )
2120 static struct list tables
= LIST_INIT( tables
);
2123 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2124 table_list
= &tables
;