2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
27 #define WIN32_NO_STATUS
42 #include "wine/debug.h"
43 #include "wbemprox_private.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
47 static const WCHAR class_baseboardW
[] =
48 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
49 static const WCHAR class_biosW
[] =
50 {'W','i','n','3','2','_','B','I','O','S',0};
51 static const WCHAR class_cdromdriveW
[] =
52 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
53 static const WCHAR class_compsysW
[] =
54 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
55 static const WCHAR class_datafileW
[] =
56 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
57 static const WCHAR class_directoryW
[] =
58 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
59 static const WCHAR class_diskdriveW
[] =
60 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
61 static const WCHAR class_diskpartitionW
[] =
62 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
63 static const WCHAR class_logicaldiskW
[] =
64 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
65 static const WCHAR class_logicaldisk2W
[] =
66 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
67 static const WCHAR class_networkadapterW
[] =
68 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
69 static const WCHAR class_networkadapterconfigW
[] =
70 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
71 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
72 static const WCHAR class_osW
[] =
73 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
74 static const WCHAR class_paramsW
[] =
75 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
76 static const WCHAR class_physicalmediaW
[] =
77 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
78 static const WCHAR class_qualifiersW
[] =
79 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
80 static const WCHAR class_process_getowner_outW
[] =
81 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
82 'N','E','R','_','O','U','T',0};
83 static const WCHAR class_processorW
[] =
84 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
85 static const WCHAR class_sounddeviceW
[] =
86 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
87 static const WCHAR class_videocontrollerW
[] =
88 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
90 static const WCHAR prop_acceptpauseW
[] =
91 {'A','c','c','e','p','t','P','a','u','s','e',0};
92 static const WCHAR prop_acceptstopW
[] =
93 {'A','c','c','e','p','t','S','t','o','p',0};
94 static const WCHAR prop_accessmaskW
[] =
95 {'A','c','c','e','s','s','M','a','s','k',0};
96 static const WCHAR prop_adapterdactypeW
[] =
97 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
98 static const WCHAR prop_adapterramW
[] =
99 {'A','d','a','p','t','e','r','R','A','M',0};
100 static const WCHAR prop_adaptertypeW
[] =
101 {'A','d','a','p','t','e','r','T','y','p','e',0};
102 static const WCHAR prop_addresswidthW
[] =
103 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
104 static const WCHAR prop_bootableW
[] =
105 {'B','o','o','t','a','b','l','e',0};
106 static const WCHAR prop_bootpartitionW
[] =
107 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
108 static const WCHAR prop_captionW
[] =
109 {'C','a','p','t','i','o','n',0};
110 static const WCHAR prop_classW
[] =
111 {'C','l','a','s','s',0};
112 static const WCHAR prop_codesetW
[] =
113 {'C','o','d','e','S','e','t',0};
114 static const WCHAR prop_commandlineW
[] =
115 {'C','o','m','m','a','n','d','L','i','n','e',0};
116 static const WCHAR prop_countrycodeW
[] =
117 {'C','o','u','n','t','r','y','C','o','d','e',0};
118 static const WCHAR prop_cpustatusW
[] =
119 {'C','p','u','S','t','a','t','u','s',0};
120 static const WCHAR prop_csdversionW
[] =
121 {'C','S','D','V','e','r','s','i','o','n',0};
122 static const WCHAR prop_currentbitsperpixelW
[] =
123 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
124 static const WCHAR prop_currenthorizontalresW
[] =
125 {'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};
126 static const WCHAR prop_currentverticalresW
[] =
127 {'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};
128 static const WCHAR prop_defaultvalueW
[] =
129 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
130 static const WCHAR prop_descriptionW
[] =
131 {'D','e','s','c','r','i','p','t','i','o','n',0};
132 static const WCHAR prop_deviceidW
[] =
133 {'D','e','v','i','c','e','I','d',0};
134 static const WCHAR prop_directionW
[] =
135 {'D','i','r','e','c','t','i','o','n',0};
136 static const WCHAR prop_displaynameW
[] =
137 {'D','i','s','p','l','a','y','N','a','m','e',0};
138 static const WCHAR prop_diskindexW
[] =
139 {'D','i','s','k','I','n','d','e','x',0};
140 static const WCHAR prop_domainW
[] =
141 {'D','o','m','a','i','n',0};
142 static const WCHAR prop_domainroleW
[] =
143 {'D','o','m','a','i','n','R','o','l','e',0};
144 static const WCHAR prop_driveW
[] =
145 {'D','r','i','v','e',0};
146 static const WCHAR prop_drivetypeW
[] =
147 {'D','r','i','v','e','T','y','p','e',0};
148 static const WCHAR prop_familyW
[] =
149 {'F','a','m','i','l','y',0};
150 static const WCHAR prop_filesystemW
[] =
151 {'F','i','l','e','S','y','s','t','e','m',0};
152 static const WCHAR prop_flavorW
[] =
153 {'F','l','a','v','o','r',0};
154 static const WCHAR prop_freespaceW
[] =
155 {'F','r','e','e','S','p','a','c','e',0};
156 static const WCHAR prop_handleW
[] =
157 {'H','a','n','d','l','e',0};
158 static const WCHAR prop_idW
[] =
160 static const WCHAR prop_identificationcodeW
[] =
161 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
162 static const WCHAR prop_indexW
[] =
163 {'I','n','d','e','x',0};
164 static const WCHAR prop_interfaceindexW
[] =
165 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
166 static const WCHAR prop_intvalueW
[] =
167 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
168 static const WCHAR prop_ipconnectionmetricW
[] =
169 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
170 static const WCHAR prop_ipenabledW
[] =
171 {'I','P','E','n','a','b','l','e','d',0};
172 static const WCHAR prop_lastbootuptimeW
[] =
173 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
174 static const WCHAR prop_localdatetimeW
[] =
175 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
176 static const WCHAR prop_localeW
[] =
177 {'L','o','c','a','l','e',0};
178 static const WCHAR prop_macaddressW
[] =
179 {'M','A','C','A','d','d','r','e','s','s',0};
180 static const WCHAR prop_manufacturerW
[] =
181 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
182 static const WCHAR prop_maxclockspeedW
[] =
183 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
184 static const WCHAR prop_mediatypeW
[] =
185 {'M','e','d','i','a','T','y','p','e',0};
186 static const WCHAR prop_memberW
[] =
187 {'M','e','m','b','e','r',0};
188 static const WCHAR prop_methodW
[] =
189 {'M','e','t','h','o','d',0};
190 static const WCHAR prop_modelW
[] =
191 {'M','o','d','e','l',0};
192 static const WCHAR prop_netconnectionstatusW
[] =
193 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
194 static const WCHAR prop_numcoresW
[] =
195 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
196 static const WCHAR prop_numlogicalprocessorsW
[] =
197 {'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};
198 static const WCHAR prop_numprocessorsW
[] =
199 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
200 static const WCHAR prop_osarchitectureW
[] =
201 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
202 static const WCHAR prop_oslanguageW
[] =
203 {'O','S','L','a','n','g','u','a','g','e',0};
204 static const WCHAR prop_osproductsuiteW
[] =
205 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
206 static const WCHAR prop_ostypeW
[] =
207 {'O','S','T','y','p','e',0};
208 static const WCHAR prop_parameterW
[] =
209 {'P','a','r','a','m','e','t','e','r',0};
210 static const WCHAR prop_physicaladapterW
[] =
211 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
212 static const WCHAR prop_pnpdeviceidW
[] =
213 {'P','N','P','D','e','v','i','c','e','I','D',0};
214 static const WCHAR prop_pprocessidW
[] =
215 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
216 static const WCHAR prop_processidW
[] =
217 {'P','r','o','c','e','s','s','I','D',0};
218 static const WCHAR prop_processoridW
[] =
219 {'P','r','o','c','e','s','s','o','r','I','d',0};
220 static const WCHAR prop_productnameW
[] =
221 {'P','r','o','d','u','c','t','N','a','m','e',0};
222 static const WCHAR prop_releasedateW
[] =
223 {'R','e','l','e','a','s','e','D','a','t','e',0};
224 static const WCHAR prop_serialnumberW
[] =
225 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
226 static const WCHAR prop_servicepackmajorW
[] =
227 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
228 static const WCHAR prop_servicepackminorW
[] =
229 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
230 static const WCHAR prop_servicetypeW
[] =
231 {'S','e','r','v','i','c','e','T','y','p','e',0};
232 static const WCHAR prop_smbiosbiosversionW
[] =
233 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
234 static const WCHAR prop_startmodeW
[] =
235 {'S','t','a','r','t','M','o','d','e',0};
236 static const WCHAR prop_sizeW
[] =
238 static const WCHAR prop_speedW
[] =
239 {'S','p','e','e','d',0};
240 static const WCHAR prop_startingoffsetW
[] =
241 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
242 static const WCHAR prop_stateW
[] =
243 {'S','t','a','t','e',0};
244 static const WCHAR prop_strvalueW
[] =
245 {'S','t','r','i','n','g','V','a','l','u','e',0};
246 static const WCHAR prop_suitemaskW
[] =
247 {'S','u','i','t','e','M','a','s','k',0};
248 static const WCHAR prop_systemdirectoryW
[] =
249 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
250 static const WCHAR prop_systemnameW
[] =
251 {'S','y','s','t','e','m','N','a','m','e',0};
252 static const WCHAR prop_tagW
[] =
254 static const WCHAR prop_threadcountW
[] =
255 {'T','h','r','e','a','d','C','o','u','n','t',0};
256 static const WCHAR prop_totalphysicalmemoryW
[] =
257 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
258 static const WCHAR prop_typeW
[] =
260 static const WCHAR prop_uniqueidW
[] =
261 {'U','n','i','q','u','e','I','d',0};
262 static const WCHAR prop_varianttypeW
[] =
263 {'V','a','r','i','a','n','t','T','y','p','e',0};
264 static const WCHAR prop_versionW
[] =
265 {'V','e','r','s','i','o','n',0};
267 /* column definitions must be kept in sync with record structures below */
268 static const struct column col_baseboard
[] =
270 { prop_manufacturerW
, CIM_STRING
},
271 { prop_modelW
, CIM_STRING
},
272 { prop_nameW
, CIM_STRING
},
273 { prop_serialnumberW
, CIM_STRING
},
274 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
276 static const struct column col_bios
[] =
278 { prop_descriptionW
, CIM_STRING
},
279 { prop_identificationcodeW
, CIM_STRING
},
280 { prop_manufacturerW
, CIM_STRING
},
281 { prop_releasedateW
, CIM_DATETIME
},
282 { prop_serialnumberW
, CIM_STRING
},
283 { prop_smbiosbiosversionW
, CIM_STRING
},
284 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
286 static const struct column col_cdromdrive
[] =
288 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
289 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
290 { prop_nameW
, CIM_STRING
},
291 { prop_pnpdeviceidW
, CIM_STRING
}
293 static const struct column col_compsys
[] =
295 { prop_descriptionW
, CIM_STRING
},
296 { prop_domainW
, CIM_STRING
},
297 { prop_domainroleW
, CIM_UINT16
},
298 { prop_manufacturerW
, CIM_STRING
},
299 { prop_modelW
, CIM_STRING
},
300 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
301 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
302 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
303 { prop_totalphysicalmemoryW
, CIM_UINT64
}
305 static const struct column col_datafile
[] =
307 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
308 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
310 static const struct column col_directory
[] =
312 { prop_accessmaskW
, CIM_UINT32
},
313 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
315 static const struct column col_diskdrive
[] =
317 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
318 { prop_indexW
, CIM_UINT32
, VT_I4
},
319 { prop_manufacturerW
, CIM_STRING
},
320 { prop_mediatypeW
, CIM_STRING
},
321 { prop_modelW
, CIM_STRING
},
322 { prop_serialnumberW
, CIM_STRING
}
324 static const struct column col_diskpartition
[] =
326 { prop_bootableW
, CIM_BOOLEAN
},
327 { prop_bootpartitionW
, CIM_BOOLEAN
},
328 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
329 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
330 { prop_indexW
, CIM_UINT32
, VT_I4
},
331 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
332 { prop_sizeW
, CIM_UINT64
},
333 { prop_startingoffsetW
, CIM_UINT64
},
334 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
336 static const struct column col_logicaldisk
[] =
338 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
339 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
340 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
341 { prop_freespaceW
, CIM_UINT64
},
342 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
343 { prop_sizeW
, CIM_UINT64
}
345 static const struct column col_networkadapter
[] =
347 { prop_adaptertypeW
, CIM_STRING
},
348 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
349 { prop_indexW
, CIM_UINT32
, VT_I4
},
350 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
351 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
352 { prop_manufacturerW
, CIM_STRING
},
353 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
354 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
355 { prop_physicaladapterW
, CIM_BOOLEAN
},
356 { prop_pnpdeviceidW
, CIM_STRING
},
357 { prop_speedW
, CIM_UINT64
}
359 static const struct column col_networkadapterconfig
[] =
361 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
},
362 { prop_ipconnectionmetricW
, CIM_UINT32
},
363 { prop_ipenabledW
, CIM_BOOLEAN
},
364 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
366 static const struct column col_os
[] =
368 { prop_captionW
, CIM_STRING
},
369 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
370 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
371 { prop_csdversionW
, CIM_STRING
},
372 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
373 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
374 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
375 { prop_nameW
, CIM_STRING
},
376 { prop_osarchitectureW
, CIM_STRING
},
377 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
378 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
379 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
380 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
381 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
382 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
383 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
384 { prop_versionW
, CIM_STRING
}
386 static const struct column col_param
[] =
388 { prop_classW
, CIM_STRING
},
389 { prop_methodW
, CIM_STRING
},
390 { prop_directionW
, CIM_SINT32
},
391 { prop_parameterW
, CIM_STRING
},
392 { prop_typeW
, CIM_UINT32
},
393 { prop_varianttypeW
, CIM_UINT32
},
394 { prop_defaultvalueW
, CIM_UINT32
}
396 static const struct column col_physicalmedia
[] =
398 { prop_serialnumberW
, CIM_STRING
},
399 { prop_tagW
, CIM_STRING
}
401 static const struct column col_process
[] =
403 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
404 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
405 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
406 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
407 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
408 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
409 { prop_processidW
, CIM_UINT32
, VT_I4
},
410 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
412 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
414 static const struct column col_processor
[] =
416 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
417 { prop_cpustatusW
, CIM_UINT16
},
418 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
419 { prop_familyW
, CIM_UINT16
, VT_I4
},
420 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
421 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
422 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
423 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
424 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
425 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
426 { prop_uniqueidW
, CIM_STRING
}
428 static const struct column col_qualifier
[] =
430 { prop_classW
, CIM_STRING
},
431 { prop_memberW
, CIM_STRING
},
432 { prop_typeW
, CIM_UINT32
},
433 { prop_flavorW
, CIM_SINT32
},
434 { prop_nameW
, CIM_STRING
},
435 { prop_intvalueW
, CIM_SINT32
},
436 { prop_strvalueW
, CIM_STRING
}
438 static const struct column col_service
[] =
440 { prop_acceptpauseW
, CIM_BOOLEAN
},
441 { prop_acceptstopW
, CIM_BOOLEAN
},
442 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
443 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
444 { prop_processidW
, CIM_UINT32
},
445 { prop_servicetypeW
, CIM_STRING
},
446 { prop_startmodeW
, CIM_STRING
},
447 { prop_stateW
, CIM_STRING
},
448 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
450 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
451 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
452 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
453 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
455 static const struct column col_sounddevice
[] =
457 { prop_nameW
, CIM_STRING
},
458 { prop_productnameW
, CIM_STRING
}
460 static const struct column col_stdregprov
[] =
462 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
463 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
464 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
466 static const struct column col_videocontroller
[] =
468 { prop_adapterdactypeW
, CIM_STRING
},
469 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
470 { prop_currentbitsperpixelW
, CIM_UINT32
},
471 { prop_currenthorizontalresW
, CIM_UINT32
},
472 { prop_currentverticalresW
, CIM_UINT32
},
473 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
474 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
475 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
476 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
479 static const WCHAR baseboard_manufacturerW
[] =
480 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
481 static const WCHAR baseboard_serialnumberW
[] =
483 static const WCHAR baseboard_tagW
[] =
484 {'B','a','s','e',' ','B','o','a','r','d',0};
485 static const WCHAR bios_descriptionW
[] =
486 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
487 static const WCHAR bios_manufacturerW
[] =
488 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
489 static const WCHAR bios_releasedateW
[] =
490 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
491 static const WCHAR bios_serialnumberW
[] =
493 static const WCHAR bios_smbiosbiosversionW
[] =
495 static const WCHAR bios_versionW
[] =
496 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
497 static const WCHAR cdromdrive_nameW
[] =
498 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
499 static const WCHAR cdromdrive_pnpdeviceidW
[]=
500 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
501 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
502 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
503 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
504 static const WCHAR compsys_descriptionW
[] =
505 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
506 static const WCHAR compsys_domainW
[] =
507 {'W','O','R','K','G','R','O','U','P',0};
508 static const WCHAR compsys_manufacturerW
[] =
509 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
510 static const WCHAR compsys_modelW
[] =
512 static const WCHAR diskdrive_deviceidW
[] =
513 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
514 static const WCHAR diskdrive_manufacturerW
[] =
515 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
516 static const WCHAR diskdrive_mediatypeW
[] =
517 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
518 static const WCHAR diskdrive_modelW
[] =
519 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
520 static const WCHAR diskdrive_serialW
[] =
521 {'W','I','N','E','H','D','I','S','K',0};
522 static const WCHAR networkadapter_pnpdeviceidW
[]=
523 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
524 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
525 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
526 static const WCHAR os_captionW
[] =
527 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
528 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
529 static const WCHAR os_csdversionW
[] =
530 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
531 static const WCHAR os_32bitW
[] =
532 {'3','2','-','b','i','t',0};
533 static const WCHAR os_64bitW
[] =
534 {'6','4','-','b','i','t',0};
535 static const WCHAR os_nameW
[] =
536 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
537 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
538 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
539 '\\','P','a','r','t','i','t','i','o','n','1',0};
540 static const WCHAR os_versionW
[] =
541 {'5','.','1','.','2','6','0','0',0};
542 static const WCHAR physicalmedia_tagW
[] =
543 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
544 static const WCHAR sounddevice_productnameW
[] =
545 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
546 static const WCHAR videocontroller_dactypeW
[] =
547 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
548 static const WCHAR videocontroller_deviceidW
[] =
549 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
551 #include "pshpack1.h"
552 struct record_baseboard
554 const WCHAR
*manufacturer
;
557 const WCHAR
*serialnumber
;
562 const WCHAR
*description
;
563 const WCHAR
*identificationcode
;
564 const WCHAR
*manufacturer
;
565 const WCHAR
*releasedate
;
566 const WCHAR
*serialnumber
;
567 const WCHAR
*smbiosbiosversion
;
568 const WCHAR
*version
;
570 struct record_cdromdrive
572 const WCHAR
*device_id
;
575 const WCHAR
*pnpdevice_id
;
577 struct record_computersystem
579 const WCHAR
*description
;
582 const WCHAR
*manufacturer
;
585 UINT32 num_logical_processors
;
586 UINT32 num_processors
;
587 UINT64 total_physical_memory
;
589 struct record_datafile
592 const WCHAR
*version
;
594 struct record_directory
599 struct record_diskdrive
601 const WCHAR
*device_id
;
603 const WCHAR
*manufacturer
;
604 const WCHAR
*mediatype
;
606 const WCHAR
*serialnumber
;
608 struct record_diskpartition
612 const WCHAR
*device_id
;
615 const WCHAR
*pnpdevice_id
;
617 UINT64 startingoffset
;
620 struct record_logicaldisk
622 const WCHAR
*device_id
;
624 const WCHAR
*filesystem
;
629 struct record_networkadapter
631 const WCHAR
*adaptertype
;
632 const WCHAR
*device_id
;
634 UINT32 interface_index
;
635 const WCHAR
*mac_address
;
636 const WCHAR
*manufacturer
;
638 UINT16 netconnection_status
;
640 const WCHAR
*pnpdevice_id
;
643 struct record_networkadapterconfig
646 UINT32 ipconnectionmetric
;
648 const WCHAR
*mac_address
;
650 struct record_operatingsystem
652 const WCHAR
*caption
;
653 const WCHAR
*codeset
;
654 const WCHAR
*countrycode
;
655 const WCHAR
*csdversion
;
656 const WCHAR
*lastbootuptime
;
657 const WCHAR
*localdatetime
;
660 const WCHAR
*osarchitecture
;
662 UINT32 osproductsuite
;
664 UINT16 servicepackmajor
;
665 UINT16 servicepackminor
;
667 const WCHAR
*systemdirectory
;
668 const WCHAR
*version
;
675 const WCHAR
*parameter
;
680 struct record_physicalmedia
682 const WCHAR
*serialnumber
;
685 struct record_process
687 const WCHAR
*caption
;
688 const WCHAR
*commandline
;
689 const WCHAR
*description
;
696 class_method
*get_owner
;
698 struct record_processor
702 const WCHAR
*device_id
;
704 const WCHAR
*manufacturer
;
705 UINT32 maxclockspeed
;
708 UINT32 num_logical_processors
;
709 const WCHAR
*processor_id
;
710 const WCHAR
*unique_id
;
712 struct record_qualifier
720 const WCHAR
*strvalue
;
722 struct record_service
726 const WCHAR
*displayname
;
729 const WCHAR
*servicetype
;
730 const WCHAR
*startmode
;
732 const WCHAR
*systemname
;
734 class_method
*pause_service
;
735 class_method
*resume_service
;
736 class_method
*start_service
;
737 class_method
*stop_service
;
739 struct record_sounddevice
742 const WCHAR
*productname
;
744 struct record_stdregprov
746 class_method
*enumkey
;
747 class_method
*enumvalues
;
748 class_method
*getstringvalue
;
750 struct record_videocontroller
752 const WCHAR
*adapter_dactype
;
754 UINT32 current_bitsperpixel
;
755 UINT32 current_horizontalres
;
756 UINT32 current_verticalres
;
757 const WCHAR
*description
;
758 const WCHAR
*device_id
;
760 const WCHAR
*pnpdevice_id
;
764 static const struct record_baseboard data_baseboard
[] =
766 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_tagW
}
768 static const struct record_bios data_bios
[] =
770 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
771 bios_smbiosbiosversionW
, bios_versionW
}
773 static const struct record_diskdrive data_diskdrive
[] =
775 { diskdrive_deviceidW
, 0, diskdrive_manufacturerW
, diskdrive_mediatypeW
, diskdrive_modelW
,
778 static const struct record_param data_param
[] =
780 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
781 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
782 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
783 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
784 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
785 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
786 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
787 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
788 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
789 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
790 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
791 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
792 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
793 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
794 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
795 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
796 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
797 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
798 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
799 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
800 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
}
803 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
804 WBEM_FLAVOR_ORIGIN_PROPAGATED)
806 static const struct record_physicalmedia data_physicalmedia
[] =
808 { diskdrive_serialW
, physicalmedia_tagW
}
810 static const struct record_qualifier data_qualifier
[] =
812 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
813 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
815 static const struct record_sounddevice data_sounddevice
[] =
817 { sounddevice_productnameW
, sounddevice_productnameW
}
819 static const struct record_stdregprov data_stdregprov
[] =
821 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
824 /* check if row matches condition and update status */
825 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
832 *status
= FILL_STATUS_UNFILTERED
;
835 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
837 *status
= FILL_STATUS_FAILED
;
840 *status
= FILL_STATUS_FILTERED
;
844 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
846 if (!table
->num_rows_allocated
)
848 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
849 table
->num_rows_allocated
= row_count
;
852 if (row_count
>= table
->num_rows_allocated
)
855 UINT count
= table
->num_rows_allocated
* 2;
856 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
858 table
->num_rows_allocated
= count
;
863 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
865 static const WCHAR fmtW
[] = {'%','c',':',0};
866 WCHAR drive
[3], root
[] = {'A',':','\\',0};
867 struct record_cdromdrive
*rec
;
868 UINT i
, row
= 0, offset
= 0;
869 DWORD drives
= GetLogicalDrives();
870 enum fill_status status
= FILL_STATUS_UNFILTERED
;
872 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
874 for (i
= 0; i
< sizeof(drives
); i
++)
876 if (drives
& (1 << i
))
879 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
882 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
884 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
885 rec
->device_id
= cdromdrive_pnpdeviceidW
;
886 sprintfW( drive
, fmtW
, 'A' + i
);
887 rec
->drive
= heap_strdupW( drive
);
888 rec
->name
= cdromdrive_nameW
;
889 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
890 if (!match_row( table
, row
, cond
, &status
))
892 free_row_values( table
, row
);
895 offset
+= sizeof(*rec
);
899 TRACE("created %u rows\n", row
);
900 table
->num_rows
= row
;
904 static UINT
get_processor_count(void)
906 SYSTEM_BASIC_INFORMATION info
;
908 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
909 return info
.NumberOfProcessors
;
912 static UINT
get_logical_processor_count( UINT
*num_cores
)
914 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
915 UINT i
, j
, count
= 0;
919 if (num_cores
) *num_cores
= get_processor_count();
920 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
921 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
923 if (!(info
= heap_alloc( len
))) return get_processor_count();
924 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
925 if (status
!= STATUS_SUCCESS
)
928 return get_processor_count();
930 if (num_cores
) *num_cores
= 0;
931 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
933 if (info
[i
].Relationship
== RelationProcessorCore
)
935 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
937 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
939 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
946 static UINT64
get_total_physical_memory(void)
948 MEMORYSTATUSEX status
;
950 status
.dwLength
= sizeof(status
);
951 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
952 return status
.ullTotalPhys
;
955 static WCHAR
*get_computername(void)
958 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
960 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
961 GetComputerNameW( ret
, &size
);
965 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
967 struct record_computersystem
*rec
;
968 enum fill_status status
= FILL_STATUS_UNFILTERED
;
971 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
973 rec
= (struct record_computersystem
*)table
->data
;
974 rec
->description
= compsys_descriptionW
;
975 rec
->domain
= compsys_domainW
;
976 rec
->domainrole
= 0; /* standalone workstation */
977 rec
->manufacturer
= compsys_manufacturerW
;
978 rec
->model
= compsys_modelW
;
979 rec
->name
= get_computername();
980 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
981 rec
->num_processors
= get_processor_count();
982 rec
->total_physical_memory
= get_total_physical_memory();
983 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
986 TRACE("created %u rows\n", row
);
987 table
->num_rows
= row
;
999 static struct dirstack
*alloc_dirstack( UINT size
)
1001 struct dirstack
*dirstack
;
1003 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1004 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1006 heap_free( dirstack
);
1009 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1011 heap_free( dirstack
->dirs
);
1012 heap_free( dirstack
);
1015 dirstack
->num_dirs
= 0;
1016 dirstack
->num_allocated
= size
;
1020 static void clear_dirstack( struct dirstack
*dirstack
)
1023 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1024 dirstack
->num_dirs
= 0;
1027 static void free_dirstack( struct dirstack
*dirstack
)
1029 clear_dirstack( dirstack
);
1030 heap_free( dirstack
->dirs
);
1031 heap_free( dirstack
->len_dirs
);
1032 heap_free( dirstack
);
1035 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1037 UINT size
, i
= dirstack
->num_dirs
;
1039 if (!dir
) return FALSE
;
1041 if (i
== dirstack
->num_allocated
)
1046 size
= dirstack
->num_allocated
* 2;
1047 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1048 dirstack
->dirs
= tmp
;
1049 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1050 dirstack
->len_dirs
= len_tmp
;
1051 dirstack
->num_allocated
= size
;
1053 dirstack
->dirs
[i
] = dir
;
1054 dirstack
->len_dirs
[i
] = len
;
1055 dirstack
->num_dirs
++;
1059 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1061 if (!dirstack
->num_dirs
)
1066 dirstack
->num_dirs
--;
1067 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1068 return dirstack
->dirs
[dirstack
->num_dirs
];
1071 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1073 if (!dirstack
->num_dirs
) return NULL
;
1074 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1077 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1082 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1088 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1097 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1099 UINT i
= 0, len
= 0;
1103 for (p
= path
; *p
; p
++)
1105 if (*p
== '\\') len
+= 2;
1108 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1113 for (p
= path
; *p
; p
++)
1115 if (*p
!= '\\') ret
[i
++] = *p
;
1126 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1128 const WCHAR
*p
= path
, *start
;
1132 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1134 len
= strlenW( start
);
1135 p
= start
+ len
- 1;
1136 if (*p
== '\\') return NULL
;
1138 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1139 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1141 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1142 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1144 if (p
[0] == '\\' && p
[1] == '\\')
1156 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1159 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1163 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1164 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1166 const struct expr
*left
, *right
;
1168 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1170 left
= cond
->u
.expr
.left
;
1171 right
= cond
->u
.expr
.right
;
1172 if (cond
->u
.expr
.op
== OP_EQ
)
1176 const WCHAR
*str
= NULL
;
1178 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1179 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1180 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1182 str
= right
->u
.sval
;
1184 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1185 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1186 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1190 if (str
&& (path
= build_dirname( str
, &len
)))
1192 if (seen_dir( dirstack
, path
))
1197 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1202 else if (cond
->u
.expr
.op
== OP_OR
)
1204 UINT left_count
= 0, right_count
= 0;
1206 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1207 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1208 return *count
+= left_count
+ right_count
;
1213 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1215 UINT len_path
= 0, len_segment
= strlenW( segment
);
1219 if (path
) len_path
= strlenW( path
);
1220 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1221 if (path
&& len_path
)
1223 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1224 ret
[len_path
] = '\\';
1225 *len
+= len_path
+ 1;
1227 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1228 *len
+= len_segment
;
1233 static WCHAR
*get_file_version( const WCHAR
*filename
)
1235 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1236 VS_FIXEDFILEINFO
*info
;
1241 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1242 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1247 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1248 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1254 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1255 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1260 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1262 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1263 struct record_datafile
*rec
;
1264 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1265 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1266 DWORD drives
= GetLogicalDrives();
1267 WIN32_FIND_DATAW data
;
1269 struct dirstack
*dirstack
= alloc_dirstack(2);
1270 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1272 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1274 for (i
= 0; i
< sizeof(drives
); i
++)
1276 if (!(drives
& (1 << i
))) continue;
1279 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1281 num_expected_rows
= 0;
1282 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1286 path
= pop_dir( dirstack
, &len
);
1287 if (!(glob
= build_glob( root
[0], path
, len
)))
1289 status
= FILL_STATUS_FAILED
;
1292 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1296 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1298 status
= FILL_STATUS_FAILED
;
1301 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1302 new_path
= append_path( path
, data
.cFileName
, &len
);
1304 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1306 if (push_dir( dirstack
, new_path
, len
)) continue;
1307 heap_free( new_path
);
1308 status
= FILL_STATUS_FAILED
;
1311 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1312 rec
->name
= build_name( root
[0], new_path
);
1313 rec
->version
= get_file_version( rec
->name
);
1314 if (!match_row( table
, row
, cond
, &status
))
1316 free_row_values( table
, row
);
1319 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1322 FindClose( handle
);
1323 status
= FILL_STATUS_FILTERED
;
1326 offset
+= sizeof(*rec
);
1329 while (FindNextFileW( handle
, &data
));
1330 FindClose( handle
);
1332 if (!peek_dir( dirstack
)) break;
1339 free_dirstack( dirstack
);
1343 TRACE("created %u rows\n", row
);
1344 table
->num_rows
= row
;
1348 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1350 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1351 struct record_directory
*rec
;
1352 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1353 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1354 DWORD drives
= GetLogicalDrives();
1355 WIN32_FIND_DATAW data
;
1357 struct dirstack
*dirstack
;
1358 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1360 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1362 dirstack
= alloc_dirstack(2);
1364 for (i
= 0; i
< sizeof(drives
); i
++)
1366 if (!(drives
& (1 << i
))) continue;
1369 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1371 num_expected_rows
= 0;
1372 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1376 path
= pop_dir( dirstack
, &len
);
1377 if (!(glob
= build_glob( root
[0], path
, len
)))
1379 status
= FILL_STATUS_FAILED
;
1382 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1386 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1388 FindClose( handle
);
1389 status
= FILL_STATUS_FAILED
;
1392 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1393 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1396 new_path
= append_path( path
, data
.cFileName
, &len
);
1397 if (!(push_dir( dirstack
, new_path
, len
)))
1399 heap_free( new_path
);
1400 FindClose( handle
);
1401 status
= FILL_STATUS_FAILED
;
1404 rec
= (struct record_directory
*)(table
->data
+ offset
);
1405 rec
->accessmask
= FILE_ALL_ACCESS
;
1406 rec
->name
= build_name( root
[0], new_path
);
1407 if (!match_row( table
, row
, cond
, &status
))
1409 free_row_values( table
, row
);
1412 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1415 FindClose( handle
);
1416 status
= FILL_STATUS_FILTERED
;
1419 offset
+= sizeof(*rec
);
1422 while (FindNextFileW( handle
, &data
));
1423 FindClose( handle
);
1425 if (!peek_dir( dirstack
)) break;
1432 free_dirstack( dirstack
);
1436 TRACE("created %u rows\n", row
);
1437 table
->num_rows
= row
;
1441 static WCHAR
*get_filesystem( const WCHAR
*root
)
1443 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1444 WCHAR buffer
[MAX_PATH
+ 1];
1446 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1447 return heap_strdupW( buffer
);
1448 return heap_strdupW( ntfsW
);
1451 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1453 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1454 ULARGE_INTEGER free
;
1455 DISK_GEOMETRY_EX info
;
1458 free
.QuadPart
= 512 * 1024 * 1024;
1459 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1462 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1463 if (handle
!= INVALID_HANDLE_VALUE
)
1465 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), NULL
, NULL
))
1466 *disksize
= info
.DiskSize
.QuadPart
;
1467 CloseHandle( handle
);
1469 return free
.QuadPart
;
1472 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1474 static const WCHAR fmtW
[] =
1475 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1476 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1477 struct record_diskpartition
*rec
;
1478 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1479 UINT64 size
= 1024 * 1024 * 1024;
1480 DWORD drives
= GetLogicalDrives();
1481 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1483 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1485 for (i
= 0; i
< sizeof(drives
); i
++)
1487 if (drives
& (1 << i
))
1490 type
= GetDriveTypeW( root
);
1491 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1494 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1496 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1497 rec
->bootable
= (i
== 2) ? -1 : 0;
1498 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1499 sprintfW( device_id
, fmtW
, index
);
1500 rec
->device_id
= heap_strdupW( device_id
);
1501 rec
->diskindex
= index
;
1503 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1504 get_freespace( root
, &size
);
1506 rec
->startingoffset
= 0;
1507 rec
->type
= get_filesystem( root
);
1508 if (!match_row( table
, row
, cond
, &status
))
1510 free_row_values( table
, row
);
1513 offset
+= sizeof(*rec
);
1518 TRACE("created %u rows\n", row
);
1519 table
->num_rows
= row
;
1523 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1525 static const WCHAR fmtW
[] = {'%','c',':',0};
1526 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1527 struct record_logicaldisk
*rec
;
1528 UINT i
, row
= 0, offset
= 0, type
;
1529 UINT64 size
= 1024 * 1024 * 1024;
1530 DWORD drives
= GetLogicalDrives();
1531 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1533 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1535 for (i
= 0; i
< sizeof(drives
); i
++)
1537 if (drives
& (1 << i
))
1540 type
= GetDriveTypeW( root
);
1541 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1544 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1546 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1547 sprintfW( device_id
, fmtW
, 'A' + i
);
1548 rec
->device_id
= heap_strdupW( device_id
);
1549 rec
->drivetype
= type
;
1550 rec
->filesystem
= get_filesystem( root
);
1551 rec
->freespace
= get_freespace( root
, &size
);
1552 rec
->name
= heap_strdupW( device_id
);
1554 if (!match_row( table
, row
, cond
, &status
))
1556 free_row_values( table
, row
);
1559 offset
+= sizeof(*rec
);
1563 TRACE("created %u rows\n", row
);
1564 table
->num_rows
= row
;
1568 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1572 case IfOperStatusDown
:
1573 return 0; /* Disconnected */
1574 case IfOperStatusUp
:
1575 return 2; /* Connected */
1577 ERR("unhandled status %u\n", status
);
1582 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1584 static const WCHAR fmtW
[] =
1585 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1586 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1589 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1590 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1593 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1595 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1596 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1597 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1598 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1602 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1603 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1604 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1605 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1606 default: *physical
= 0; return NULL
;
1610 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1612 static const WCHAR fmtW
[] = {'%','u',0};
1613 WCHAR device_id
[11];
1614 struct record_networkadapter
*rec
;
1615 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1616 UINT row
= 0, offset
= 0, count
= 0;
1617 DWORD size
= 0, ret
;
1619 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1621 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1622 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1624 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1625 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1627 heap_free( buffer
);
1628 return FILL_STATUS_FAILED
;
1630 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1632 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1634 if (!resize_table( table
, count
, sizeof(*rec
) ))
1636 heap_free( buffer
);
1637 return FILL_STATUS_FAILED
;
1639 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1641 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1643 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1644 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1645 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1646 rec
->device_id
= heap_strdupW( device_id
);
1647 rec
->index
= aa
->u
.s
.IfIndex
;
1648 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1649 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1650 rec
->manufacturer
= compsys_manufacturerW
;
1651 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1652 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1653 rec
->physicaladapter
= physical
;
1654 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1655 rec
->speed
= 1000000;
1656 if (!match_row( table
, row
, cond
, &status
))
1658 free_row_values( table
, row
);
1661 offset
+= sizeof(*rec
);
1664 TRACE("created %u rows\n", row
);
1665 table
->num_rows
= row
;
1667 heap_free( buffer
);
1671 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1673 struct record_networkadapterconfig
*rec
;
1674 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1675 UINT row
= 0, offset
= 0, count
= 0;
1676 DWORD size
= 0, ret
;
1677 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1679 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1680 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1682 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1683 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1685 heap_free( buffer
);
1686 return FILL_STATUS_FAILED
;
1688 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1690 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1692 if (!resize_table( table
, count
, sizeof(*rec
) ))
1694 heap_free( buffer
);
1695 return FILL_STATUS_FAILED
;
1697 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1699 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1701 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1702 rec
->index
= aa
->u
.s
.IfIndex
;
1703 rec
->ipconnectionmetric
= 20;
1704 rec
->ipenabled
= -1;
1705 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1706 if (!match_row( table
, row
, cond
, &status
))
1708 free_row_values( table
, row
);
1711 offset
+= sizeof(*rec
);
1714 TRACE("created %u rows\n", row
);
1715 table
->num_rows
= row
;
1717 heap_free( buffer
);
1721 static WCHAR
*get_cmdline( DWORD process_id
)
1723 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1724 return NULL
; /* FIXME handle different process case */
1727 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1729 static const WCHAR fmtW
[] = {'%','u',0};
1731 struct record_process
*rec
;
1732 PROCESSENTRY32W entry
;
1734 enum fill_status status
= FILL_STATUS_FAILED
;
1735 UINT row
= 0, offset
= 0;
1737 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1738 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1740 entry
.dwSize
= sizeof(entry
);
1741 if (!Process32FirstW( snap
, &entry
)) goto done
;
1742 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1746 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1748 rec
= (struct record_process
*)(table
->data
+ offset
);
1749 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1750 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1751 rec
->description
= heap_strdupW( entry
.szExeFile
);
1752 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1753 rec
->handle
= heap_strdupW( handle
);
1754 rec
->name
= heap_strdupW( entry
.szExeFile
);
1755 rec
->process_id
= entry
.th32ProcessID
;
1756 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1757 rec
->thread_count
= entry
.cntThreads
;
1758 rec
->get_owner
= process_get_owner
;
1759 if (!match_row( table
, row
, cond
, &status
))
1761 free_row_values( table
, row
);
1764 offset
+= sizeof(*rec
);
1766 } while (Process32NextW( snap
, &entry
));
1768 TRACE("created %u rows\n", row
);
1769 table
->num_rows
= row
;
1770 status
= FILL_STATUS_UNFILTERED
;
1773 CloseHandle( snap
);
1777 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
1780 __asm__("pushl %%ebx\n\t"
1782 "movl %%ebx, %%esi\n\t"
1784 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
1789 static void get_processor_id( WCHAR
*processor_id
)
1791 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
1792 unsigned int regs
[4] = {0, 0, 0, 0};
1794 do_cpuid( 1, regs
);
1795 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
1797 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
1800 unsigned char *p
= (unsigned char *)regs
;
1802 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
1805 static void get_processor_manufacturer( WCHAR
*manufacturer
)
1807 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
1809 do_cpuid( 0, regs
);
1810 tmp
= regs
[2]; /* swap edx and ecx */
1814 regs_to_str( regs
+ 1, 12, manufacturer
);
1816 static void get_processor_name( WCHAR
*name
)
1818 unsigned int regs
[4] = {0, 0, 0, 0};
1820 do_cpuid( 0x80000000, regs
);
1821 if (regs
[0] >= 0x80000004)
1823 do_cpuid( 0x80000002, regs
);
1824 regs_to_str( regs
, 16, name
);
1825 do_cpuid( 0x80000003, regs
);
1826 regs_to_str( regs
, 16, name
+ 16 );
1827 do_cpuid( 0x80000004, regs
);
1828 regs_to_str( regs
, 16, name
+ 32 );
1831 static UINT
get_processor_maxclockspeed( void )
1833 PROCESSOR_POWER_INFORMATION
*info
;
1834 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1837 if ((info
= heap_alloc( size
)))
1839 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1840 if (!status
) ret
= info
[0].MaxMhz
;
1845 static const WCHAR
*get_osarchitecture(void)
1848 GetNativeSystemInfo( &info
);
1849 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
1853 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
1855 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
1856 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
1857 struct record_processor
*rec
;
1858 UINT i
, offset
= 0, maxclockspeed
, num_cores
, num_logical_processors
, count
= get_processor_count();
1859 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1861 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1863 get_processor_id( processor_id
);
1864 get_processor_manufacturer( manufacturer
);
1865 get_processor_name( name
);
1867 maxclockspeed
= get_processor_maxclockspeed();
1868 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
1871 for (i
= 0; i
< count
; i
++)
1873 rec
= (struct record_processor
*)(table
->data
+ offset
);
1874 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
1875 rec
->cpu_status
= 1; /* CPU Enabled */
1876 sprintfW( device_id
, fmtW
, i
);
1877 rec
->device_id
= heap_strdupW( device_id
);
1878 rec
->family
= 2; /* Unknown */
1879 rec
->manufacturer
= heap_strdupW( manufacturer
);
1880 rec
->maxclockspeed
= maxclockspeed
;
1881 rec
->name
= heap_strdupW( name
);
1882 rec
->num_cores
= num_cores
;
1883 rec
->num_logical_processors
= num_logical_processors
;
1884 rec
->processor_id
= heap_strdupW( processor_id
);
1885 rec
->unique_id
= NULL
;
1886 if (!match_row( table
, i
, cond
, &status
))
1888 free_row_values( table
, i
);
1891 offset
+= sizeof(*rec
);
1894 TRACE("created %u rows\n", count
);
1895 table
->num_rows
= count
;
1899 static WCHAR
*get_lastbootuptime(void)
1901 static const WCHAR fmtW
[] =
1902 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1903 '.','%','0','6','u','+','0','0','0',0};
1904 SYSTEM_TIMEOFDAY_INFORMATION ti
;
1908 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1910 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
1911 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
1912 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
1915 static WCHAR
*get_localdatetime(void)
1917 static const WCHAR fmtW
[] =
1918 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1919 '.','%','0','6','u','%','+','0','3','d',0};
1920 TIME_ZONE_INFORMATION tzi
;
1926 Status
= GetTimeZoneInformation(&tzi
);
1928 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
1930 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
1931 Bias
+= tzi
.DaylightBias
;
1933 Bias
+= tzi
.StandardBias
;
1934 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1937 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
1940 static WCHAR
*get_systemdirectory(void)
1945 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
1946 Wow64DisableWow64FsRedirection( &redir
);
1947 GetSystemDirectoryW( ret
, MAX_PATH
);
1948 Wow64RevertWow64FsRedirection( redir
);
1951 static WCHAR
*get_codeset(void)
1953 static const WCHAR fmtW
[] = {'%','u',0};
1954 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
1955 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
1958 static WCHAR
*get_countrycode(void)
1960 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
1961 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
1964 static WCHAR
*get_locale(void)
1966 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
1967 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
1971 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
1973 struct record_operatingsystem
*rec
;
1974 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1977 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1979 rec
= (struct record_operatingsystem
*)table
->data
;
1980 rec
->caption
= os_captionW
;
1981 rec
->codeset
= get_codeset();
1982 rec
->countrycode
= get_countrycode();
1983 rec
->csdversion
= os_csdversionW
;
1984 rec
->lastbootuptime
= get_lastbootuptime();
1985 rec
->localdatetime
= get_localdatetime();
1986 rec
->locale
= get_locale();
1987 rec
->name
= os_nameW
;
1988 rec
->osarchitecture
= get_osarchitecture();
1989 rec
->oslanguage
= GetSystemDefaultLangID();
1990 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
1991 rec
->ostype
= 18; /* WINNT */
1992 rec
->servicepackmajor
= 3;
1993 rec
->servicepackminor
= 0;
1994 rec
->suitemask
= 272; /* Single User + Terminal */
1995 rec
->systemdirectory
= get_systemdirectory();
1996 rec
->version
= os_versionW
;
1997 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2000 TRACE("created %u rows\n", row
);
2001 table
->num_rows
= row
;
2005 static const WCHAR
*get_service_type( DWORD type
)
2007 static const WCHAR filesystem_driverW
[] =
2008 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2009 static const WCHAR kernel_driverW
[] =
2010 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2011 static const WCHAR own_processW
[] =
2012 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2013 static const WCHAR share_processW
[] =
2014 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2016 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2017 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2018 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2019 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2020 else ERR("unhandled type 0x%08x\n", type
);
2023 static const WCHAR
*get_service_state( DWORD state
)
2025 static const WCHAR runningW
[] =
2026 {'R','u','n','n','i','n','g',0};
2027 static const WCHAR start_pendingW
[] =
2028 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2029 static const WCHAR stop_pendingW
[] =
2030 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2031 static const WCHAR stoppedW
[] =
2032 {'S','t','o','p','p','e','d',0};
2033 static const WCHAR unknownW
[] =
2034 {'U','n','k','n','o','w','n',0};
2038 case SERVICE_STOPPED
: return stoppedW
;
2039 case SERVICE_START_PENDING
: return start_pendingW
;
2040 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2041 case SERVICE_RUNNING
: return runningW
;
2043 ERR("unknown state %u\n", state
);
2047 static const WCHAR
*get_service_startmode( DWORD mode
)
2049 static const WCHAR bootW
[] = {'B','o','o','t',0};
2050 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2051 static const WCHAR autoW
[] = {'A','u','t','o',0};
2052 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2053 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2054 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2058 case SERVICE_BOOT_START
: return bootW
;
2059 case SERVICE_SYSTEM_START
: return systemW
;
2060 case SERVICE_AUTO_START
: return autoW
;
2061 case SERVICE_DEMAND_START
: return manualW
;
2062 case SERVICE_DISABLED
: return disabledW
;
2064 ERR("unknown mode 0x%x\n", mode
);
2068 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2070 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2074 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2075 QueryServiceConfigW( service
, NULL
, 0, &size
);
2076 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2077 if (!(config
= heap_alloc( size
))) goto done
;
2078 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2079 heap_free( config
);
2083 CloseServiceHandle( service
);
2087 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2089 struct record_service
*rec
;
2091 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2092 SERVICE_STATUS_PROCESS
*status
;
2093 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2094 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2095 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2096 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2099 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2100 if (!(services
= heap_alloc( size
))) goto done
;
2102 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2103 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2104 &count
, NULL
, NULL
);
2107 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2109 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2111 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2112 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2113 &count
, NULL
, NULL
);
2114 if (!ret
) goto done
;
2116 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2118 GetComputerNameW( sysnameW
, &len
);
2119 fill_status
= FILL_STATUS_UNFILTERED
;
2121 for (i
= 0; i
< count
; i
++)
2123 QUERY_SERVICE_CONFIGW
*config
;
2125 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2127 status
= &services
[i
].ServiceStatusProcess
;
2128 rec
= (struct record_service
*)(table
->data
+ offset
);
2129 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2130 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2131 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2132 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2133 rec
->process_id
= status
->dwProcessId
;
2134 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2135 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2136 rec
->state
= get_service_state( status
->dwCurrentState
);
2137 rec
->systemname
= heap_strdupW( sysnameW
);
2138 rec
->pause_service
= service_pause_service
;
2139 rec
->resume_service
= service_resume_service
;
2140 rec
->start_service
= service_start_service
;
2141 rec
->stop_service
= service_stop_service
;
2142 heap_free( config
);
2143 if (!match_row( table
, row
, cond
, &fill_status
))
2145 free_row_values( table
, row
);
2148 offset
+= sizeof(*rec
);
2152 TRACE("created %u rows\n", row
);
2153 table
->num_rows
= row
;
2156 CloseServiceHandle( manager
);
2157 heap_free( services
);
2161 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2163 HDC hdc
= GetDC( NULL
);
2166 if (!hdc
) return 32;
2167 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2168 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2169 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2170 ReleaseDC( NULL
, hdc
);
2173 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2175 static const WCHAR fmtW
[] =
2176 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2177 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2178 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2181 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2182 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2186 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2189 struct record_videocontroller
*rec
;
2191 IDXGIFactory
*factory
= NULL
;
2192 IDXGIAdapter
*adapter
= NULL
;
2193 DXGI_ADAPTER_DESC desc
;
2194 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2195 const WCHAR
*name
= videocontroller_deviceidW
;
2196 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2199 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2201 memset (&desc
, 0, sizeof(desc
));
2202 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2203 if (FAILED(hr
)) goto done
;
2205 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2206 if (FAILED(hr
)) goto done
;
2208 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2211 vidmem
= desc
.DedicatedVideoMemory
;
2212 name
= desc
.Description
;
2216 rec
= (struct record_videocontroller
*)table
->data
;
2217 rec
->adapter_dactype
= videocontroller_dactypeW
;
2218 rec
->adapter_ram
= vidmem
;
2219 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2220 rec
->current_horizontalres
= hres
;
2221 rec
->current_verticalres
= vres
;
2222 rec
->description
= heap_strdupW( name
);
2223 rec
->device_id
= videocontroller_deviceidW
;
2224 rec
->name
= heap_strdupW( name
);
2225 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2226 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2229 TRACE("created %u rows\n", row
);
2230 table
->num_rows
= row
;
2232 if (adapter
) IDXGIAdapter_Release( adapter
);
2233 if (factory
) IDXGIFactory_Release( factory
);
2237 static struct table builtin_classes
[] =
2239 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2240 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2241 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2242 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2243 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2244 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2245 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, SIZEOF(data_diskdrive
), 0, (BYTE
*)data_diskdrive
},
2246 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2247 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2248 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2249 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2250 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
,
2251 fill_networkadapterconfig
},
2252 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2253 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2254 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2255 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2256 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2257 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2258 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2259 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2260 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2261 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2264 void init_table_list( void )
2266 static struct list tables
= LIST_INIT( tables
);
2269 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2270 table_list
= &tables
;