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_osW
[] =
70 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
71 static const WCHAR class_paramsW
[] =
72 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
73 static const WCHAR class_qualifiersW
[] =
74 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
75 static const WCHAR class_process_getowner_outW
[] =
76 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
77 'N','E','R','_','O','U','T',0};
78 static const WCHAR class_processorW
[] =
79 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
80 static const WCHAR class_sounddeviceW
[] =
81 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
82 static const WCHAR class_videocontrollerW
[] =
83 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
85 static const WCHAR prop_acceptpauseW
[] =
86 {'A','c','c','e','p','t','P','a','u','s','e',0};
87 static const WCHAR prop_acceptstopW
[] =
88 {'A','c','c','e','p','t','S','t','o','p',0};
89 static const WCHAR prop_accessmaskW
[] =
90 {'A','c','c','e','s','s','M','a','s','k',0};
91 static const WCHAR prop_adapterdactypeW
[] =
92 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
93 static const WCHAR prop_adapterramW
[] =
94 {'A','d','a','p','t','e','r','R','A','M',0};
95 static const WCHAR prop_adaptertypeW
[] =
96 {'A','d','a','p','t','e','r','T','y','p','e',0};
97 static const WCHAR prop_addresswidthW
[] =
98 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
99 static const WCHAR prop_bootableW
[] =
100 {'B','o','o','t','a','b','l','e',0};
101 static const WCHAR prop_bootpartitionW
[] =
102 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
103 static const WCHAR prop_captionW
[] =
104 {'C','a','p','t','i','o','n',0};
105 static const WCHAR prop_classW
[] =
106 {'C','l','a','s','s',0};
107 static const WCHAR prop_codesetW
[] =
108 {'C','o','d','e','S','e','t',0};
109 static const WCHAR prop_commandlineW
[] =
110 {'C','o','m','m','a','n','d','L','i','n','e',0};
111 static const WCHAR prop_countrycodeW
[] =
112 {'C','o','u','n','t','r','y','C','o','d','e',0};
113 static const WCHAR prop_cpustatusW
[] =
114 {'C','p','u','S','t','a','t','u','s',0};
115 static const WCHAR prop_csdversionW
[] =
116 {'C','S','D','V','e','r','s','i','o','n',0};
117 static const WCHAR prop_currentbitsperpixelW
[] =
118 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
119 static const WCHAR prop_currenthorizontalresW
[] =
120 {'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};
121 static const WCHAR prop_currentverticalresW
[] =
122 {'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};
123 static const WCHAR prop_defaultvalueW
[] =
124 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
125 static const WCHAR prop_descriptionW
[] =
126 {'D','e','s','c','r','i','p','t','i','o','n',0};
127 static const WCHAR prop_deviceidW
[] =
128 {'D','e','v','i','c','e','I','d',0};
129 static const WCHAR prop_directionW
[] =
130 {'D','i','r','e','c','t','i','o','n',0};
131 static const WCHAR prop_displaynameW
[] =
132 {'D','i','s','p','l','a','y','N','a','m','e',0};
133 static const WCHAR prop_diskindexW
[] =
134 {'D','i','s','k','I','n','d','e','x',0};
135 static const WCHAR prop_domainW
[] =
136 {'D','o','m','a','i','n',0};
137 static const WCHAR prop_domainroleW
[] =
138 {'D','o','m','a','i','n','R','o','l','e',0};
139 static const WCHAR prop_driveW
[] =
140 {'D','r','i','v','e',0};
141 static const WCHAR prop_drivetypeW
[] =
142 {'D','r','i','v','e','T','y','p','e',0};
143 static const WCHAR prop_familyW
[] =
144 {'F','a','m','i','l','y',0};
145 static const WCHAR prop_filesystemW
[] =
146 {'F','i','l','e','S','y','s','t','e','m',0};
147 static const WCHAR prop_flavorW
[] =
148 {'F','l','a','v','o','r',0};
149 static const WCHAR prop_freespaceW
[] =
150 {'F','r','e','e','S','p','a','c','e',0};
151 static const WCHAR prop_handleW
[] =
152 {'H','a','n','d','l','e',0};
153 static const WCHAR prop_idW
[] =
155 static const WCHAR prop_identificationcodeW
[] =
156 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
157 static const WCHAR prop_indexW
[] =
158 {'I','n','d','e','x',0};
159 static const WCHAR prop_interfaceindexW
[] =
160 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
161 static const WCHAR prop_intvalueW
[] =
162 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
163 static const WCHAR prop_lastbootuptimeW
[] =
164 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
165 static const WCHAR prop_localdatetimeW
[] =
166 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
167 static const WCHAR prop_localeW
[] =
168 {'L','o','c','a','l','e',0};
169 static const WCHAR prop_macaddressW
[] =
170 {'M','A','C','A','d','d','r','e','s','s',0};
171 static const WCHAR prop_manufacturerW
[] =
172 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
173 static const WCHAR prop_maxclockspeedW
[] =
174 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
175 static const WCHAR prop_memberW
[] =
176 {'M','e','m','b','e','r',0};
177 static const WCHAR prop_methodW
[] =
178 {'M','e','t','h','o','d',0};
179 static const WCHAR prop_modelW
[] =
180 {'M','o','d','e','l',0};
181 static const WCHAR prop_netconnectionstatusW
[] =
182 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
183 static const WCHAR prop_numcoresW
[] =
184 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
185 static const WCHAR prop_numlogicalprocessorsW
[] =
186 {'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};
187 static const WCHAR prop_numprocessorsW
[] =
188 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
189 static const WCHAR prop_osarchitectureW
[] =
190 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
191 static const WCHAR prop_oslanguageW
[] =
192 {'O','S','L','a','n','g','u','a','g','e',0};
193 static const WCHAR prop_osproductsuiteW
[] =
194 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
195 static const WCHAR prop_ostypeW
[] =
196 {'O','S','T','y','p','e',0};
197 static const WCHAR prop_parameterW
[] =
198 {'P','a','r','a','m','e','t','e','r',0};
199 static const WCHAR prop_physicaladapterW
[] =
200 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
201 static const WCHAR prop_pnpdeviceidW
[] =
202 {'P','N','P','D','e','v','i','c','e','I','D',0};
203 static const WCHAR prop_pprocessidW
[] =
204 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
205 static const WCHAR prop_processidW
[] =
206 {'P','r','o','c','e','s','s','I','D',0};
207 static const WCHAR prop_processoridW
[] =
208 {'P','r','o','c','e','s','s','o','r','I','d',0};
209 static const WCHAR prop_productnameW
[] =
210 {'P','r','o','d','u','c','t','N','a','m','e',0};
211 static const WCHAR prop_releasedateW
[] =
212 {'R','e','l','e','a','s','e','D','a','t','e',0};
213 static const WCHAR prop_serialnumberW
[] =
214 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
215 static const WCHAR prop_servicepackmajorW
[] =
216 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
217 static const WCHAR prop_servicepackminorW
[] =
218 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
219 static const WCHAR prop_servicetypeW
[] =
220 {'S','e','r','v','i','c','e','T','y','p','e',0};
221 static const WCHAR prop_smbiosbiosversionW
[] =
222 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
223 static const WCHAR prop_startmodeW
[] =
224 {'S','t','a','r','t','M','o','d','e',0};
225 static const WCHAR prop_sizeW
[] =
227 static const WCHAR prop_speedW
[] =
228 {'S','p','e','e','d',0};
229 static const WCHAR prop_startingoffsetW
[] =
230 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
231 static const WCHAR prop_stateW
[] =
232 {'S','t','a','t','e',0};
233 static const WCHAR prop_strvalueW
[] =
234 {'S','t','r','i','n','g','V','a','l','u','e',0};
235 static const WCHAR prop_suitemaskW
[] =
236 {'S','u','i','t','e','M','a','s','k',0};
237 static const WCHAR prop_systemdirectoryW
[] =
238 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
239 static const WCHAR prop_systemnameW
[] =
240 {'S','y','s','t','e','m','N','a','m','e',0};
241 static const WCHAR prop_tagW
[] =
243 static const WCHAR prop_threadcountW
[] =
244 {'T','h','r','e','a','d','C','o','u','n','t',0};
245 static const WCHAR prop_totalphysicalmemoryW
[] =
246 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
247 static const WCHAR prop_typeW
[] =
249 static const WCHAR prop_uniqueidW
[] =
250 {'U','n','i','q','u','e','I','d',0};
251 static const WCHAR prop_varianttypeW
[] =
252 {'V','a','r','i','a','n','t','T','y','p','e',0};
253 static const WCHAR prop_versionW
[] =
254 {'V','e','r','s','i','o','n',0};
256 /* column definitions must be kept in sync with record structures below */
257 static const struct column col_baseboard
[] =
259 { prop_manufacturerW
, CIM_STRING
},
260 { prop_modelW
, CIM_STRING
},
261 { prop_nameW
, CIM_STRING
},
262 { prop_serialnumberW
, CIM_STRING
},
263 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
265 static const struct column col_bios
[] =
267 { prop_descriptionW
, CIM_STRING
},
268 { prop_identificationcodeW
, CIM_STRING
},
269 { prop_manufacturerW
, CIM_STRING
},
270 { prop_releasedateW
, CIM_DATETIME
},
271 { prop_serialnumberW
, CIM_STRING
},
272 { prop_smbiosbiosversionW
, CIM_STRING
},
273 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
275 static const struct column col_cdromdrive
[] =
277 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
278 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
279 { prop_nameW
, CIM_STRING
},
280 { prop_pnpdeviceidW
, CIM_STRING
}
282 static const struct column col_compsys
[] =
284 { prop_descriptionW
, CIM_STRING
},
285 { prop_domainW
, CIM_STRING
},
286 { prop_domainroleW
, CIM_UINT16
},
287 { prop_manufacturerW
, CIM_STRING
},
288 { prop_modelW
, CIM_STRING
},
289 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
290 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
291 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
292 { prop_totalphysicalmemoryW
, CIM_UINT64
}
294 static const struct column col_datafile
[] =
296 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
297 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
299 static const struct column col_directory
[] =
301 { prop_accessmaskW
, CIM_UINT32
},
302 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
304 static const struct column col_diskdrive
[] =
306 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
307 { prop_indexW
, CIM_UINT32
, VT_I4
},
308 { prop_manufacturerW
, CIM_STRING
},
309 { prop_modelW
, CIM_STRING
},
310 { prop_serialnumberW
, CIM_STRING
}
312 static const struct column col_diskpartition
[] =
314 { prop_bootableW
, CIM_BOOLEAN
},
315 { prop_bootpartitionW
, CIM_BOOLEAN
},
316 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
317 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
318 { prop_indexW
, CIM_UINT32
, VT_I4
},
319 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
320 { prop_sizeW
, CIM_UINT64
},
321 { prop_startingoffsetW
, CIM_UINT64
},
322 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
324 static const struct column col_logicaldisk
[] =
326 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
327 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
328 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
329 { prop_freespaceW
, CIM_UINT64
},
330 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
331 { prop_sizeW
, CIM_UINT64
}
333 static const struct column col_networkadapter
[] =
335 { prop_adaptertypeW
, CIM_STRING
},
336 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
337 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
338 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
339 { prop_manufacturerW
, CIM_STRING
},
340 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
341 { prop_physicaladapterW
, CIM_BOOLEAN
},
342 { prop_pnpdeviceidW
, CIM_STRING
},
343 { prop_speedW
, CIM_UINT64
}
345 static const struct column col_os
[] =
347 { prop_captionW
, CIM_STRING
},
348 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
349 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
350 { prop_csdversionW
, CIM_STRING
},
351 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
352 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
353 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
354 { prop_osarchitectureW
, CIM_STRING
},
355 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
356 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
357 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
358 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
359 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
360 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
361 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
362 { prop_versionW
, CIM_STRING
}
364 static const struct column col_param
[] =
366 { prop_classW
, CIM_STRING
},
367 { prop_methodW
, CIM_STRING
},
368 { prop_directionW
, CIM_SINT32
},
369 { prop_parameterW
, CIM_STRING
},
370 { prop_typeW
, CIM_UINT32
},
371 { prop_varianttypeW
, CIM_UINT32
},
372 { prop_defaultvalueW
, CIM_UINT32
}
374 static const struct column col_process
[] =
376 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
377 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
378 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
379 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
380 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
381 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
382 { prop_processidW
, CIM_UINT32
, VT_I4
},
383 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
385 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
387 static const struct column col_processor
[] =
389 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
390 { prop_cpustatusW
, CIM_UINT16
},
391 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
392 { prop_familyW
, CIM_UINT16
, VT_I4
},
393 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
394 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
395 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
396 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
397 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
398 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
399 { prop_uniqueidW
, CIM_STRING
}
401 static const struct column col_qualifier
[] =
403 { prop_classW
, CIM_STRING
},
404 { prop_memberW
, CIM_STRING
},
405 { prop_typeW
, CIM_UINT32
},
406 { prop_flavorW
, CIM_SINT32
},
407 { prop_nameW
, CIM_STRING
},
408 { prop_intvalueW
, CIM_SINT32
},
409 { prop_strvalueW
, CIM_STRING
}
411 static const struct column col_service
[] =
413 { prop_acceptpauseW
, CIM_BOOLEAN
},
414 { prop_acceptstopW
, CIM_BOOLEAN
},
415 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
416 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
417 { prop_processidW
, CIM_UINT32
},
418 { prop_servicetypeW
, CIM_STRING
},
419 { prop_startmodeW
, CIM_STRING
},
420 { prop_stateW
, CIM_STRING
},
421 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
423 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
424 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
425 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
426 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
428 static const struct column col_sounddevice
[] =
430 { prop_nameW
, CIM_STRING
},
431 { prop_productnameW
, CIM_STRING
}
433 static const struct column col_stdregprov
[] =
435 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
436 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
437 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
439 static const struct column col_videocontroller
[] =
441 { prop_adapterdactypeW
, CIM_STRING
},
442 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
443 { prop_currentbitsperpixelW
, CIM_UINT32
},
444 { prop_currenthorizontalresW
, CIM_UINT32
},
445 { prop_currentverticalresW
, CIM_UINT32
},
446 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
447 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
448 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
449 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
452 static const WCHAR baseboard_manufacturerW
[] =
453 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
454 static const WCHAR baseboard_serialnumberW
[] =
456 static const WCHAR baseboard_tagW
[] =
457 {'B','a','s','e',' ','B','o','a','r','d',0};
458 static const WCHAR bios_descriptionW
[] =
459 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
460 static const WCHAR bios_manufacturerW
[] =
461 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
462 static const WCHAR bios_releasedateW
[] =
463 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
464 static const WCHAR bios_serialnumberW
[] =
466 static const WCHAR bios_smbiosbiosversionW
[] =
468 static const WCHAR bios_versionW
[] =
469 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
470 static const WCHAR cdromdrive_nameW
[] =
471 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
472 static const WCHAR cdromdrive_pnpdeviceidW
[]=
473 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
474 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
475 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
476 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
477 static const WCHAR compsys_descriptionW
[] =
478 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
479 static const WCHAR compsys_domainW
[] =
480 {'W','O','R','K','G','R','O','U','P',0};
481 static const WCHAR compsys_manufacturerW
[] =
482 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
483 static const WCHAR compsys_modelW
[] =
485 static const WCHAR diskdrive_deviceidW
[] =
486 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
487 static const WCHAR diskdrive_modelW
[] =
488 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
489 static const WCHAR diskdrive_manufacturerW
[] =
490 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
491 static const WCHAR diskdrive_serialW
[] =
492 {'W','I','N','E','H','D','I','S','K',0};
493 static const WCHAR networkadapter_pnpdeviceidW
[]=
494 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
495 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
496 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
497 static const WCHAR os_captionW
[] =
498 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
499 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
500 static const WCHAR os_csdversionW
[] =
501 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
502 static const WCHAR os_32bitW
[] =
503 {'3','2','-','b','i','t',0};
504 static const WCHAR os_64bitW
[] =
505 {'6','4','-','b','i','t',0};
506 static const WCHAR os_versionW
[] =
507 {'5','.','1','.','2','6','0','0',0};
508 static const WCHAR sounddevice_productnameW
[] =
509 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
510 static const WCHAR videocontroller_dactypeW
[] =
511 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
512 static const WCHAR videocontroller_deviceidW
[] =
513 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
515 #include "pshpack1.h"
516 struct record_baseboard
518 const WCHAR
*manufacturer
;
521 const WCHAR
*serialnumber
;
526 const WCHAR
*description
;
527 const WCHAR
*identificationcode
;
528 const WCHAR
*manufacturer
;
529 const WCHAR
*releasedate
;
530 const WCHAR
*serialnumber
;
531 const WCHAR
*smbiosbiosversion
;
532 const WCHAR
*version
;
534 struct record_cdromdrive
536 const WCHAR
*device_id
;
539 const WCHAR
*pnpdevice_id
;
541 struct record_computersystem
543 const WCHAR
*description
;
546 const WCHAR
*manufacturer
;
549 UINT32 num_logical_processors
;
550 UINT32 num_processors
;
551 UINT64 total_physical_memory
;
553 struct record_datafile
556 const WCHAR
*version
;
558 struct record_directory
563 struct record_diskdrive
565 const WCHAR
*device_id
;
567 const WCHAR
*manufacturer
;
569 const WCHAR
*serialnumber
;
571 struct record_diskpartition
575 const WCHAR
*device_id
;
578 const WCHAR
*pnpdevice_id
;
580 UINT64 startingoffset
;
583 struct record_logicaldisk
585 const WCHAR
*device_id
;
587 const WCHAR
*filesystem
;
592 struct record_networkadapter
594 const WCHAR
*adaptertype
;
595 const WCHAR
*device_id
;
596 INT32 interface_index
;
597 const WCHAR
*mac_address
;
598 const WCHAR
*manufacturer
;
599 UINT16 netconnection_status
;
601 const WCHAR
*pnpdevice_id
;
604 struct record_operatingsystem
606 const WCHAR
*caption
;
607 const WCHAR
*codeset
;
608 const WCHAR
*countrycode
;
609 const WCHAR
*csdversion
;
610 const WCHAR
*lastbootuptime
;
611 const WCHAR
*localdatetime
;
613 const WCHAR
*osarchitecture
;
615 UINT32 osproductsuite
;
617 UINT16 servicepackmajor
;
618 UINT16 servicepackminor
;
620 const WCHAR
*systemdirectory
;
621 const WCHAR
*version
;
628 const WCHAR
*parameter
;
633 struct record_process
635 const WCHAR
*caption
;
636 const WCHAR
*commandline
;
637 const WCHAR
*description
;
644 class_method
*get_owner
;
646 struct record_processor
650 const WCHAR
*device_id
;
652 const WCHAR
*manufacturer
;
653 UINT32 maxclockspeed
;
656 UINT32 num_logical_processors
;
657 const WCHAR
*processor_id
;
658 const WCHAR
*unique_id
;
660 struct record_qualifier
668 const WCHAR
*strvalue
;
670 struct record_service
674 const WCHAR
*displayname
;
677 const WCHAR
*servicetype
;
678 const WCHAR
*startmode
;
680 const WCHAR
*systemname
;
682 class_method
*pause_service
;
683 class_method
*resume_service
;
684 class_method
*start_service
;
685 class_method
*stop_service
;
687 struct record_sounddevice
690 const WCHAR
*productname
;
692 struct record_stdregprov
694 class_method
*enumkey
;
695 class_method
*enumvalues
;
696 class_method
*getstringvalue
;
698 struct record_videocontroller
700 const WCHAR
*adapter_dactype
;
702 UINT32 current_bitsperpixel
;
703 UINT32 current_horizontalres
;
704 UINT32 current_verticalres
;
705 const WCHAR
*description
;
706 const WCHAR
*device_id
;
708 const WCHAR
*pnpdevice_id
;
712 static const struct record_baseboard data_baseboard
[] =
714 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_tagW
}
716 static const struct record_bios data_bios
[] =
718 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
719 bios_smbiosbiosversionW
, bios_versionW
}
721 static const struct record_diskdrive data_diskdrive
[] =
723 { diskdrive_deviceidW
, 0, diskdrive_manufacturerW
, diskdrive_modelW
, diskdrive_serialW
}
725 static const struct record_param data_param
[] =
727 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
728 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
729 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
730 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
731 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
732 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
733 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
734 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
735 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
736 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
737 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
738 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
739 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
740 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
741 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
742 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
743 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
744 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
745 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
746 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
747 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
}
750 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
751 WBEM_FLAVOR_ORIGIN_PROPAGATED)
753 static const struct record_qualifier data_qualifier
[] =
755 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
756 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
758 static const struct record_sounddevice data_sounddevice
[] =
760 { sounddevice_productnameW
, sounddevice_productnameW
}
762 static const struct record_stdregprov data_stdregprov
[] =
764 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
767 /* check if row matches condition and update status */
768 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
773 *status
= FILL_STATUS_UNFILTERED
;
776 if (eval_cond( table
, row
, cond
, &val
) != S_OK
)
778 *status
= FILL_STATUS_FAILED
;
781 *status
= FILL_STATUS_FILTERED
;
785 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
787 if (!table
->num_rows_allocated
)
789 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
790 table
->num_rows_allocated
= row_count
;
793 if (row_count
>= table
->num_rows_allocated
)
796 UINT count
= table
->num_rows_allocated
* 2;
797 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
799 table
->num_rows_allocated
= count
;
804 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
806 static const WCHAR fmtW
[] = {'%','c',':',0};
807 WCHAR drive
[3], root
[] = {'A',':','\\',0};
808 struct record_cdromdrive
*rec
;
809 UINT i
, row
= 0, offset
= 0;
810 DWORD drives
= GetLogicalDrives();
811 enum fill_status status
= FILL_STATUS_UNFILTERED
;
813 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
815 for (i
= 0; i
< sizeof(drives
); i
++)
817 if (drives
& (1 << i
))
820 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
823 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
825 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
826 rec
->device_id
= cdromdrive_pnpdeviceidW
;
827 sprintfW( drive
, fmtW
, 'A' + i
);
828 rec
->drive
= heap_strdupW( drive
);
829 rec
->name
= cdromdrive_nameW
;
830 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
831 if (!match_row( table
, row
, cond
, &status
))
833 free_row_values( table
, row
);
836 offset
+= sizeof(*rec
);
840 TRACE("created %u rows\n", row
);
841 table
->num_rows
= row
;
845 static UINT
get_processor_count(void)
847 SYSTEM_BASIC_INFORMATION info
;
849 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
850 return info
.NumberOfProcessors
;
853 static UINT
get_logical_processor_count( UINT
*num_cores
)
855 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
856 UINT i
, j
, count
= 0;
860 if (num_cores
) *num_cores
= get_processor_count();
861 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
862 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
864 if (!(info
= heap_alloc( len
))) return get_processor_count();
865 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
866 if (status
!= STATUS_SUCCESS
)
869 return get_processor_count();
871 if (num_cores
) *num_cores
= 0;
872 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
874 if (info
[i
].Relationship
== RelationProcessorCore
)
876 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
878 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
880 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
887 static UINT64
get_total_physical_memory(void)
889 MEMORYSTATUSEX status
;
891 status
.dwLength
= sizeof(status
);
892 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
893 return status
.ullTotalPhys
;
896 static WCHAR
*get_computername(void)
899 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
901 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
902 GetComputerNameW( ret
, &size
);
906 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
908 struct record_computersystem
*rec
;
909 enum fill_status status
= FILL_STATUS_UNFILTERED
;
912 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
914 rec
= (struct record_computersystem
*)table
->data
;
915 rec
->description
= compsys_descriptionW
;
916 rec
->domain
= compsys_domainW
;
917 rec
->domainrole
= 0; /* standalone workstation */
918 rec
->manufacturer
= compsys_manufacturerW
;
919 rec
->model
= compsys_modelW
;
920 rec
->name
= get_computername();
921 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
922 rec
->num_processors
= get_processor_count();
923 rec
->total_physical_memory
= get_total_physical_memory();
924 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
927 TRACE("created %u rows\n", row
);
928 table
->num_rows
= row
;
940 static struct dirstack
*alloc_dirstack( UINT size
)
942 struct dirstack
*dirstack
;
944 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
945 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
947 heap_free( dirstack
);
950 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
952 heap_free( dirstack
->dirs
);
953 heap_free( dirstack
);
956 dirstack
->num_dirs
= 0;
957 dirstack
->num_allocated
= size
;
961 static void clear_dirstack( struct dirstack
*dirstack
)
964 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
965 dirstack
->num_dirs
= 0;
968 static void free_dirstack( struct dirstack
*dirstack
)
970 clear_dirstack( dirstack
);
971 heap_free( dirstack
->dirs
);
972 heap_free( dirstack
->len_dirs
);
973 heap_free( dirstack
);
976 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
978 UINT size
, i
= dirstack
->num_dirs
;
980 if (!dir
) return FALSE
;
982 if (i
== dirstack
->num_allocated
)
987 size
= dirstack
->num_allocated
* 2;
988 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
989 dirstack
->dirs
= tmp
;
990 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
991 dirstack
->len_dirs
= len_tmp
;
992 dirstack
->num_allocated
= size
;
994 dirstack
->dirs
[i
] = dir
;
995 dirstack
->len_dirs
[i
] = len
;
996 dirstack
->num_dirs
++;
1000 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1002 if (!dirstack
->num_dirs
)
1007 dirstack
->num_dirs
--;
1008 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1009 return dirstack
->dirs
[dirstack
->num_dirs
];
1012 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1014 if (!dirstack
->num_dirs
) return NULL
;
1015 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1018 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1023 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1029 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1038 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1040 UINT i
= 0, len
= 0;
1044 for (p
= path
; *p
; p
++)
1046 if (*p
== '\\') len
+= 2;
1049 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1054 for (p
= path
; *p
; p
++)
1056 if (*p
!= '\\') ret
[i
++] = *p
;
1067 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1069 const WCHAR
*p
= path
, *start
;
1073 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1075 len
= strlenW( start
);
1076 p
= start
+ len
- 1;
1077 if (*p
== '\\') return NULL
;
1079 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1080 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1082 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1083 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1085 if (p
[0] == '\\' && p
[1] == '\\')
1097 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1100 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1104 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1105 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1107 const struct expr
*left
, *right
;
1109 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1111 left
= cond
->u
.expr
.left
;
1112 right
= cond
->u
.expr
.right
;
1113 if (cond
->u
.expr
.op
== OP_EQ
)
1117 const WCHAR
*str
= NULL
;
1119 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1120 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1121 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1123 str
= right
->u
.sval
;
1125 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1126 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1127 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1131 if (str
&& (path
= build_dirname( str
, &len
)))
1133 if (seen_dir( dirstack
, path
))
1138 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1143 else if (cond
->u
.expr
.op
== OP_OR
)
1145 UINT left_count
= 0, right_count
= 0;
1147 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1148 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1149 return *count
+= left_count
+ right_count
;
1154 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1156 UINT len_path
= 0, len_segment
= strlenW( segment
);
1160 if (path
) len_path
= strlenW( path
);
1161 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1162 if (path
&& len_path
)
1164 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1165 ret
[len_path
] = '\\';
1166 *len
+= len_path
+ 1;
1168 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1169 *len
+= len_segment
;
1174 static WCHAR
*get_file_version( const WCHAR
*filename
)
1176 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1177 VS_FIXEDFILEINFO
*info
;
1182 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1183 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1188 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1189 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1195 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1196 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1201 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1203 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1204 struct record_datafile
*rec
;
1205 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1206 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1207 DWORD drives
= GetLogicalDrives();
1208 WIN32_FIND_DATAW data
;
1210 struct dirstack
*dirstack
= alloc_dirstack(2);
1211 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1213 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1215 for (i
= 0; i
< sizeof(drives
); i
++)
1217 if (!(drives
& (1 << i
))) continue;
1220 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1222 num_expected_rows
= 0;
1223 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1227 path
= pop_dir( dirstack
, &len
);
1228 if (!(glob
= build_glob( root
[0], path
, len
)))
1230 status
= FILL_STATUS_FAILED
;
1233 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1237 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1239 status
= FILL_STATUS_FAILED
;
1242 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1243 new_path
= append_path( path
, data
.cFileName
, &len
);
1245 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1247 if (push_dir( dirstack
, new_path
, len
)) continue;
1248 heap_free( new_path
);
1249 status
= FILL_STATUS_FAILED
;
1252 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1253 rec
->name
= build_name( root
[0], new_path
);
1254 rec
->version
= get_file_version( rec
->name
);
1255 if (!match_row( table
, row
, cond
, &status
))
1257 free_row_values( table
, row
);
1260 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1263 FindClose( handle
);
1264 status
= FILL_STATUS_FILTERED
;
1267 offset
+= sizeof(*rec
);
1270 while (FindNextFileW( handle
, &data
));
1271 FindClose( handle
);
1273 if (!peek_dir( dirstack
)) break;
1280 free_dirstack( dirstack
);
1284 TRACE("created %u rows\n", row
);
1285 table
->num_rows
= row
;
1289 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1291 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1292 struct record_directory
*rec
;
1293 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1294 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1295 DWORD drives
= GetLogicalDrives();
1296 WIN32_FIND_DATAW data
;
1298 struct dirstack
*dirstack
;
1299 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1301 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1303 dirstack
= alloc_dirstack(2);
1305 for (i
= 0; i
< sizeof(drives
); i
++)
1307 if (!(drives
& (1 << i
))) continue;
1310 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1312 num_expected_rows
= 0;
1313 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1317 path
= pop_dir( dirstack
, &len
);
1318 if (!(glob
= build_glob( root
[0], path
, len
)))
1320 status
= FILL_STATUS_FAILED
;
1323 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1327 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1329 FindClose( handle
);
1330 status
= FILL_STATUS_FAILED
;
1333 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1334 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1337 new_path
= append_path( path
, data
.cFileName
, &len
);
1338 if (!(push_dir( dirstack
, new_path
, len
)))
1340 heap_free( new_path
);
1341 FindClose( handle
);
1342 status
= FILL_STATUS_FAILED
;
1345 rec
= (struct record_directory
*)(table
->data
+ offset
);
1346 rec
->accessmask
= FILE_ALL_ACCESS
;
1347 rec
->name
= build_name( root
[0], new_path
);
1348 if (!match_row( table
, row
, cond
, &status
))
1350 free_row_values( table
, row
);
1353 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1356 FindClose( handle
);
1357 status
= FILL_STATUS_FILTERED
;
1360 offset
+= sizeof(*rec
);
1363 while (FindNextFileW( handle
, &data
));
1364 FindClose( handle
);
1366 if (!peek_dir( dirstack
)) break;
1373 free_dirstack( dirstack
);
1377 TRACE("created %u rows\n", row
);
1378 table
->num_rows
= row
;
1382 static WCHAR
*get_filesystem( const WCHAR
*root
)
1384 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1385 WCHAR buffer
[MAX_PATH
+ 1];
1387 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1388 return heap_strdupW( buffer
);
1389 return heap_strdupW( ntfsW
);
1392 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1394 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1395 ULARGE_INTEGER free
;
1396 DISK_GEOMETRY_EX info
;
1399 free
.QuadPart
= 512 * 1024 * 1024;
1400 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1403 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1404 if (handle
!= INVALID_HANDLE_VALUE
)
1406 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), NULL
, NULL
))
1407 *disksize
= info
.DiskSize
.QuadPart
;
1408 CloseHandle( handle
);
1410 return free
.QuadPart
;
1413 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1415 static const WCHAR fmtW
[] =
1416 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1417 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1418 struct record_diskpartition
*rec
;
1419 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1420 UINT64 size
= 1024 * 1024 * 1024;
1421 DWORD drives
= GetLogicalDrives();
1422 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1424 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1426 for (i
= 0; i
< sizeof(drives
); i
++)
1428 if (drives
& (1 << i
))
1431 type
= GetDriveTypeW( root
);
1432 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1435 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1437 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1438 rec
->bootable
= (i
== 2) ? -1 : 0;
1439 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1440 sprintfW( device_id
, fmtW
, index
);
1441 rec
->device_id
= heap_strdupW( device_id
);
1442 rec
->diskindex
= index
;
1444 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1445 get_freespace( root
, &size
);
1447 rec
->startingoffset
= 0;
1448 rec
->type
= get_filesystem( root
);
1449 if (!match_row( table
, row
, cond
, &status
))
1451 free_row_values( table
, row
);
1454 offset
+= sizeof(*rec
);
1459 TRACE("created %u rows\n", row
);
1460 table
->num_rows
= row
;
1464 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1466 static const WCHAR fmtW
[] = {'%','c',':',0};
1467 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1468 struct record_logicaldisk
*rec
;
1469 UINT i
, row
= 0, offset
= 0, type
;
1470 UINT64 size
= 1024 * 1024 * 1024;
1471 DWORD drives
= GetLogicalDrives();
1472 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1474 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1476 for (i
= 0; i
< sizeof(drives
); i
++)
1478 if (drives
& (1 << i
))
1481 type
= GetDriveTypeW( root
);
1482 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1485 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1487 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1488 sprintfW( device_id
, fmtW
, 'A' + i
);
1489 rec
->device_id
= heap_strdupW( device_id
);
1490 rec
->drivetype
= type
;
1491 rec
->filesystem
= get_filesystem( root
);
1492 rec
->freespace
= get_freespace( root
, &size
);
1493 rec
->name
= heap_strdupW( device_id
);
1495 if (!match_row( table
, row
, cond
, &status
))
1497 free_row_values( table
, row
);
1500 offset
+= sizeof(*rec
);
1504 TRACE("created %u rows\n", row
);
1505 table
->num_rows
= row
;
1509 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1513 case IfOperStatusDown
:
1514 return 0; /* Disconnected */
1515 case IfOperStatusUp
:
1516 return 2; /* Connected */
1518 ERR("unhandled status %u\n", status
);
1523 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1525 static const WCHAR fmtW
[] =
1526 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1527 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1530 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1531 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1534 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1536 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1537 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1538 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1539 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1543 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1544 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1545 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1546 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1547 default: *physical
= 0; return NULL
;
1551 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1553 static const WCHAR fmtW
[] = {'%','u',0};
1554 WCHAR device_id
[11];
1555 struct record_networkadapter
*rec
;
1556 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1557 UINT row
= 0, offset
= 0, count
= 0;
1558 DWORD size
= 0, ret
;
1560 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1562 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1563 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1565 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1566 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1568 heap_free( buffer
);
1569 return FILL_STATUS_FAILED
;
1571 for (aa
= buffer
; aa
; aa
= aa
->Next
) count
++;
1572 if (!resize_table( table
, count
, sizeof(*rec
) ))
1574 heap_free( buffer
);
1575 return FILL_STATUS_FAILED
;
1577 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1579 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1580 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1581 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1582 rec
->device_id
= heap_strdupW( device_id
);
1583 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1584 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1585 rec
->manufacturer
= compsys_manufacturerW
;
1586 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1587 rec
->physicaladapter
= physical
;
1588 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1589 rec
->speed
= 1000000;
1590 if (!match_row( table
, row
, cond
, &status
))
1592 free_row_values( table
, row
);
1595 offset
+= sizeof(*rec
);
1598 TRACE("created %u rows\n", row
);
1599 table
->num_rows
= row
;
1601 heap_free( buffer
);
1605 static WCHAR
*get_cmdline( DWORD process_id
)
1607 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1608 return NULL
; /* FIXME handle different process case */
1611 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1613 static const WCHAR fmtW
[] = {'%','u',0};
1615 struct record_process
*rec
;
1616 PROCESSENTRY32W entry
;
1618 enum fill_status status
= FILL_STATUS_FAILED
;
1619 UINT row
= 0, offset
= 0;
1621 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1622 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1624 entry
.dwSize
= sizeof(entry
);
1625 if (!Process32FirstW( snap
, &entry
)) goto done
;
1626 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
1630 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
1632 rec
= (struct record_process
*)(table
->data
+ offset
);
1633 rec
->caption
= heap_strdupW( entry
.szExeFile
);
1634 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
1635 rec
->description
= heap_strdupW( entry
.szExeFile
);
1636 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
1637 rec
->handle
= heap_strdupW( handle
);
1638 rec
->name
= heap_strdupW( entry
.szExeFile
);
1639 rec
->process_id
= entry
.th32ProcessID
;
1640 rec
->pprocess_id
= entry
.th32ParentProcessID
;
1641 rec
->thread_count
= entry
.cntThreads
;
1642 rec
->get_owner
= process_get_owner
;
1643 if (!match_row( table
, row
, cond
, &status
))
1645 free_row_values( table
, row
);
1648 offset
+= sizeof(*rec
);
1650 } while (Process32NextW( snap
, &entry
));
1652 TRACE("created %u rows\n", row
);
1653 table
->num_rows
= row
;
1654 status
= FILL_STATUS_UNFILTERED
;
1657 CloseHandle( snap
);
1661 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
1664 __asm__("pushl %%ebx\n\t"
1666 "movl %%ebx, %%esi\n\t"
1668 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
1673 static void get_processor_id( WCHAR
*processor_id
)
1675 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
1676 unsigned int regs
[4] = {0, 0, 0, 0};
1678 do_cpuid( 1, regs
);
1679 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
1681 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
1684 unsigned char *p
= (unsigned char *)regs
;
1686 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
1689 static void get_processor_manufacturer( WCHAR
*manufacturer
)
1691 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
1693 do_cpuid( 0, regs
);
1694 tmp
= regs
[2]; /* swap edx and ecx */
1698 regs_to_str( regs
+ 1, 12, manufacturer
);
1700 static void get_processor_name( WCHAR
*name
)
1702 unsigned int regs
[4] = {0, 0, 0, 0};
1704 do_cpuid( 0x80000000, regs
);
1705 if (regs
[0] >= 0x80000004)
1707 do_cpuid( 0x80000002, regs
);
1708 regs_to_str( regs
, 16, name
);
1709 do_cpuid( 0x80000003, regs
);
1710 regs_to_str( regs
, 16, name
+ 16 );
1711 do_cpuid( 0x80000004, regs
);
1712 regs_to_str( regs
, 16, name
+ 32 );
1715 static UINT
get_processor_maxclockspeed( void )
1717 PROCESSOR_POWER_INFORMATION
*info
;
1718 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
1721 if ((info
= heap_alloc( size
)))
1723 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
1724 if (!status
) ret
= info
[0].MaxMhz
;
1729 static const WCHAR
*get_osarchitecture(void)
1732 GetNativeSystemInfo( &info
);
1733 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
1737 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
1739 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
1740 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
1741 struct record_processor
*rec
;
1742 UINT i
, offset
= 0, maxclockspeed
, num_cores
, num_logical_processors
, count
= get_processor_count();
1743 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1745 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1747 get_processor_id( processor_id
);
1748 get_processor_manufacturer( manufacturer
);
1749 get_processor_name( name
);
1751 maxclockspeed
= get_processor_maxclockspeed();
1752 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
1755 for (i
= 0; i
< count
; i
++)
1757 rec
= (struct record_processor
*)(table
->data
+ offset
);
1758 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
1759 rec
->cpu_status
= 1; /* CPU Enabled */
1760 sprintfW( device_id
, fmtW
, i
);
1761 rec
->device_id
= heap_strdupW( device_id
);
1762 rec
->family
= 2; /* Unknown */
1763 rec
->manufacturer
= heap_strdupW( manufacturer
);
1764 rec
->maxclockspeed
= maxclockspeed
;
1765 rec
->name
= heap_strdupW( name
);
1766 rec
->num_cores
= num_cores
;
1767 rec
->num_logical_processors
= num_logical_processors
;
1768 rec
->processor_id
= heap_strdupW( processor_id
);
1769 rec
->unique_id
= NULL
;
1770 if (!match_row( table
, i
, cond
, &status
))
1772 free_row_values( table
, i
);
1775 offset
+= sizeof(*rec
);
1778 TRACE("created %u rows\n", count
);
1779 table
->num_rows
= count
;
1783 static WCHAR
*get_lastbootuptime(void)
1785 static const WCHAR fmtW
[] =
1786 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1787 '.','%','0','6','u','+','0','0','0',0};
1788 SYSTEM_TIMEOFDAY_INFORMATION ti
;
1792 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1794 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
1795 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
1796 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
1799 static WCHAR
*get_localdatetime(void)
1801 static const WCHAR fmtW
[] =
1802 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1803 '.','%','0','6','u','%','+','0','3','d',0};
1804 TIME_ZONE_INFORMATION tzi
;
1810 Status
= GetTimeZoneInformation(&tzi
);
1812 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
1814 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
1815 Bias
+= tzi
.DaylightBias
;
1817 Bias
+= tzi
.StandardBias
;
1818 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
1821 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
1824 static WCHAR
*get_systemdirectory(void)
1829 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
1830 Wow64DisableWow64FsRedirection( &redir
);
1831 GetSystemDirectoryW( ret
, MAX_PATH
);
1832 Wow64RevertWow64FsRedirection( redir
);
1835 static WCHAR
*get_codeset(void)
1837 static const WCHAR fmtW
[] = {'%','u',0};
1838 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
1839 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
1842 static WCHAR
*get_countrycode(void)
1844 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
1845 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
1848 static WCHAR
*get_locale(void)
1850 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
1851 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
1855 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
1857 struct record_operatingsystem
*rec
;
1858 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1861 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1863 rec
= (struct record_operatingsystem
*)table
->data
;
1864 rec
->caption
= os_captionW
;
1865 rec
->codeset
= get_codeset();
1866 rec
->countrycode
= get_countrycode();
1867 rec
->csdversion
= os_csdversionW
;
1868 rec
->lastbootuptime
= get_lastbootuptime();
1869 rec
->localdatetime
= get_localdatetime();
1870 rec
->locale
= get_locale();
1871 rec
->osarchitecture
= get_osarchitecture();
1872 rec
->oslanguage
= GetSystemDefaultLangID();
1873 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
1874 rec
->ostype
= 18; /* WINNT */
1875 rec
->servicepackmajor
= 3;
1876 rec
->servicepackminor
= 0;
1877 rec
->suitemask
= 272; /* Single User + Terminal */
1878 rec
->systemdirectory
= get_systemdirectory();
1879 rec
->version
= os_versionW
;
1880 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1883 TRACE("created %u rows\n", row
);
1884 table
->num_rows
= row
;
1888 static const WCHAR
*get_service_type( DWORD type
)
1890 static const WCHAR filesystem_driverW
[] =
1891 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
1892 static const WCHAR kernel_driverW
[] =
1893 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
1894 static const WCHAR own_processW
[] =
1895 {'O','w','n',' ','P','r','o','c','e','s','s',0};
1896 static const WCHAR share_processW
[] =
1897 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
1899 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
1900 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
1901 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
1902 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
1903 else ERR("unhandled type 0x%08x\n", type
);
1906 static const WCHAR
*get_service_state( DWORD state
)
1908 static const WCHAR runningW
[] =
1909 {'R','u','n','n','i','n','g',0};
1910 static const WCHAR start_pendingW
[] =
1911 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
1912 static const WCHAR stop_pendingW
[] =
1913 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
1914 static const WCHAR stoppedW
[] =
1915 {'S','t','o','p','p','e','d',0};
1916 static const WCHAR unknownW
[] =
1917 {'U','n','k','n','o','w','n',0};
1921 case SERVICE_STOPPED
: return stoppedW
;
1922 case SERVICE_START_PENDING
: return start_pendingW
;
1923 case SERVICE_STOP_PENDING
: return stop_pendingW
;
1924 case SERVICE_RUNNING
: return runningW
;
1926 ERR("unknown state %u\n", state
);
1930 static const WCHAR
*get_service_startmode( DWORD mode
)
1932 static const WCHAR bootW
[] = {'B','o','o','t',0};
1933 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
1934 static const WCHAR autoW
[] = {'A','u','t','o',0};
1935 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
1936 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
1937 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
1941 case SERVICE_BOOT_START
: return bootW
;
1942 case SERVICE_SYSTEM_START
: return systemW
;
1943 case SERVICE_AUTO_START
: return autoW
;
1944 case SERVICE_DEMAND_START
: return manualW
;
1945 case SERVICE_DISABLED
: return disabledW
;
1947 ERR("unknown mode 0x%x\n", mode
);
1951 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
1953 QUERY_SERVICE_CONFIGW
*config
= NULL
;
1957 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
1958 QueryServiceConfigW( service
, NULL
, 0, &size
);
1959 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
1960 if (!(config
= heap_alloc( size
))) goto done
;
1961 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
1962 heap_free( config
);
1966 CloseServiceHandle( service
);
1970 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
1972 struct record_service
*rec
;
1974 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
1975 SERVICE_STATUS_PROCESS
*status
;
1976 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
1977 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
1978 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
1979 enum fill_status fill_status
= FILL_STATUS_FAILED
;
1982 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
1983 if (!(services
= heap_alloc( size
))) goto done
;
1985 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
1986 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
1987 &count
, NULL
, NULL
);
1990 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
1992 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
1994 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
1995 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
1996 &count
, NULL
, NULL
);
1997 if (!ret
) goto done
;
1999 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2001 GetComputerNameW( sysnameW
, &len
);
2002 fill_status
= FILL_STATUS_UNFILTERED
;
2004 for (i
= 0; i
< count
; i
++)
2006 QUERY_SERVICE_CONFIGW
*config
;
2008 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2010 status
= &services
[i
].ServiceStatusProcess
;
2011 rec
= (struct record_service
*)(table
->data
+ offset
);
2012 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2013 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2014 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2015 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2016 rec
->process_id
= status
->dwProcessId
;
2017 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2018 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2019 rec
->state
= get_service_state( status
->dwCurrentState
);
2020 rec
->systemname
= heap_strdupW( sysnameW
);
2021 rec
->pause_service
= service_pause_service
;
2022 rec
->resume_service
= service_resume_service
;
2023 rec
->start_service
= service_start_service
;
2024 rec
->stop_service
= service_stop_service
;
2025 heap_free( config
);
2026 if (!match_row( table
, row
, cond
, &fill_status
))
2028 free_row_values( table
, row
);
2031 offset
+= sizeof(*rec
);
2035 TRACE("created %u rows\n", row
);
2036 table
->num_rows
= row
;
2039 CloseServiceHandle( manager
);
2040 heap_free( services
);
2044 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2046 HDC hdc
= GetDC( NULL
);
2049 if (!hdc
) return 32;
2050 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2051 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2052 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2053 ReleaseDC( NULL
, hdc
);
2056 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2058 static const WCHAR fmtW
[] =
2059 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2060 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2061 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2064 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2065 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2069 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2072 struct record_videocontroller
*rec
;
2074 IDXGIFactory
*factory
= NULL
;
2075 IDXGIAdapter
*adapter
= NULL
;
2076 DXGI_ADAPTER_DESC desc
;
2077 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2078 const WCHAR
*name
= videocontroller_deviceidW
;
2079 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2082 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2084 memset (&desc
, 0, sizeof(desc
));
2085 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2086 if (FAILED(hr
)) goto done
;
2088 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2089 if (FAILED(hr
)) goto done
;
2091 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2094 vidmem
= desc
.DedicatedVideoMemory
;
2095 name
= desc
.Description
;
2099 rec
= (struct record_videocontroller
*)table
->data
;
2100 rec
->adapter_dactype
= videocontroller_dactypeW
;
2101 rec
->adapter_ram
= vidmem
;
2102 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2103 rec
->current_horizontalres
= hres
;
2104 rec
->current_verticalres
= vres
;
2105 rec
->description
= heap_strdupW( name
);
2106 rec
->device_id
= videocontroller_deviceidW
;
2107 rec
->name
= heap_strdupW( name
);
2108 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2109 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2112 TRACE("created %u rows\n", row
);
2113 table
->num_rows
= row
;
2115 if (adapter
) IDXGIAdapter_Release( adapter
);
2116 if (factory
) IDXGIFactory_Release( factory
);
2120 static struct table builtin_classes
[] =
2122 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2123 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2124 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2125 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2126 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2127 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2128 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, SIZEOF(data_diskdrive
), 0, (BYTE
*)data_diskdrive
},
2129 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2130 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2131 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2132 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2133 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2134 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2135 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2136 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2137 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2138 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2139 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2140 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2141 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2144 void init_table_list( void )
2146 static struct list tables
= LIST_INIT( tables
);
2149 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2150 table_list
= &tables
;