2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wbemprox_private.h"
33 static const WCHAR class_baseboardW
[] =
34 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
35 static const WCHAR class_biosW
[] =
36 {'W','i','n','3','2','_','B','I','O','S',0};
37 static const WCHAR class_cdromdriveW
[] =
38 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
39 static const WCHAR class_compsysW
[] =
40 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
41 static const WCHAR class_compsysproductW
[] =
42 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
43 static const WCHAR class_datafileW
[] =
44 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
45 static const WCHAR class_directoryW
[] =
46 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
47 static const WCHAR class_diskdriveW
[] =
48 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
49 static const WCHAR class_diskpartitionW
[] =
50 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
51 static const WCHAR class_logicaldiskW
[] =
52 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
53 static const WCHAR class_logicaldisk2W
[] =
54 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
55 static const WCHAR class_networkadapterW
[] =
56 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
57 static const WCHAR class_networkadapterconfigW
[] =
58 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
59 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
60 static const WCHAR class_osW
[] =
61 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
62 static const WCHAR class_paramsW
[] =
63 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
64 static const WCHAR class_physicalmediaW
[] =
65 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
66 static const WCHAR class_physicalmemoryW
[] =
67 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
68 static const WCHAR class_qualifiersW
[] =
69 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
70 static const WCHAR class_printerW
[] =
71 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
72 static const WCHAR class_process_getowner_outW
[] =
73 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
74 'N','E','R','_','O','U','T',0};
75 static const WCHAR class_processorW
[] =
76 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
77 static const WCHAR class_processor2W
[] =
78 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
79 static const WCHAR class_sidW
[] =
80 {'W','i','n','3','2','_','S','I','D',0};
81 static const WCHAR class_sounddeviceW
[] =
82 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
83 static const WCHAR class_systemenclosureW
[] =
84 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
85 static const WCHAR class_videocontrollerW
[] =
86 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
88 static const WCHAR prop_accountnameW
[] =
89 {'A','c','c','o','u','n','t','N','a','m','e',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_attributesW
[] =
105 {'A','t','t','r','i','b','u','t','e','s',0};
106 static const WCHAR prop_availabilityW
[] =
107 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
108 static const WCHAR prop_binaryrepresentationW
[] =
109 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
110 static const WCHAR prop_bootableW
[] =
111 {'B','o','o','t','a','b','l','e',0};
112 static const WCHAR prop_bootpartitionW
[] =
113 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
114 static const WCHAR prop_buildnumberW
[] =
115 {'B','u','i','l','d','N','u','m','b','e','r',0};
116 static const WCHAR prop_capacityW
[] =
117 {'C','a','p','a','c','i','t','y',0};
118 static const WCHAR prop_captionW
[] =
119 {'C','a','p','t','i','o','n',0};
120 static const WCHAR prop_chassistypesW
[] =
121 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
122 static const WCHAR prop_classW
[] =
123 {'C','l','a','s','s',0};
124 static const WCHAR prop_codesetW
[] =
125 {'C','o','d','e','S','e','t',0};
126 static const WCHAR prop_commandlineW
[] =
127 {'C','o','m','m','a','n','d','L','i','n','e',0};
128 static const WCHAR prop_countrycodeW
[] =
129 {'C','o','u','n','t','r','y','C','o','d','e',0};
130 static const WCHAR prop_cpustatusW
[] =
131 {'C','p','u','S','t','a','t','u','s',0};
132 static const WCHAR prop_csdversionW
[] =
133 {'C','S','D','V','e','r','s','i','o','n',0};
134 static const WCHAR prop_currentbitsperpixelW
[] =
135 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
136 static const WCHAR prop_currentclockspeedW
[] =
137 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
138 static const WCHAR prop_currenthorizontalresW
[] =
139 {'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};
140 static const WCHAR prop_currentrefreshrateW
[] =
141 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
142 static const WCHAR prop_currentscanmodeW
[] =
143 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
144 static const WCHAR prop_currentverticalresW
[] =
145 {'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};
146 static const WCHAR prop_datawidthW
[] =
147 {'D','a','t','a','W','i','d','t','h',0};
148 static const WCHAR prop_defaultvalueW
[] =
149 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
150 static const WCHAR prop_descriptionW
[] =
151 {'D','e','s','c','r','i','p','t','i','o','n',0};
152 static const WCHAR prop_deviceidW
[] =
153 {'D','e','v','i','c','e','I','d',0};
154 static const WCHAR prop_directionW
[] =
155 {'D','i','r','e','c','t','i','o','n',0};
156 static const WCHAR prop_displaynameW
[] =
157 {'D','i','s','p','l','a','y','N','a','m','e',0};
158 static const WCHAR prop_diskindexW
[] =
159 {'D','i','s','k','I','n','d','e','x',0};
160 static const WCHAR prop_dnshostnameW
[] =
161 {'D','N','S','H','o','s','t','N','a','m','e',0};
162 static const WCHAR prop_domainW
[] =
163 {'D','o','m','a','i','n',0};
164 static const WCHAR prop_domainroleW
[] =
165 {'D','o','m','a','i','n','R','o','l','e',0};
166 static const WCHAR prop_driveW
[] =
167 {'D','r','i','v','e',0};
168 static const WCHAR prop_drivernameW
[] =
169 {'D','r','i','v','e','r','N','a','m','e',0};
170 static const WCHAR prop_driverversionW
[] =
171 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
172 static const WCHAR prop_drivetypeW
[] =
173 {'D','r','i','v','e','T','y','p','e',0};
174 static const WCHAR prop_familyW
[] =
175 {'F','a','m','i','l','y',0};
176 static const WCHAR prop_filesystemW
[] =
177 {'F','i','l','e','S','y','s','t','e','m',0};
178 static const WCHAR prop_flavorW
[] =
179 {'F','l','a','v','o','r',0};
180 static const WCHAR prop_freespaceW
[] =
181 {'F','r','e','e','S','p','a','c','e',0};
182 static const WCHAR prop_handleW
[] =
183 {'H','a','n','d','l','e',0};
184 static const WCHAR prop_horizontalresolutionW
[] =
185 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
186 static const WCHAR prop_idW
[] =
188 static const WCHAR prop_identificationcodeW
[] =
189 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
190 static const WCHAR prop_identifyingnumberW
[] =
191 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
192 static const WCHAR prop_indexW
[] =
193 {'I','n','d','e','x',0};
194 static const WCHAR prop_installdateW
[] =
195 {'I','n','s','t','a','l','l','D','a','t','e',0};
196 static const WCHAR prop_interfaceindexW
[] =
197 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
198 static const WCHAR prop_interfacetypeW
[] =
199 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
200 static const WCHAR prop_intvalueW
[] =
201 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
202 static const WCHAR prop_ipconnectionmetricW
[] =
203 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
204 static const WCHAR prop_ipenabledW
[] =
205 {'I','P','E','n','a','b','l','e','d',0};
206 static const WCHAR prop_lastbootuptimeW
[] =
207 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
208 static const WCHAR prop_localW
[] =
209 {'L','o','c','a','l',0};
210 static const WCHAR prop_localdatetimeW
[] =
211 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
212 static const WCHAR prop_localeW
[] =
213 {'L','o','c','a','l','e',0};
214 static const WCHAR prop_lockpresentW
[] =
215 {'L','o','c','k','P','r','e','s','e','n','t',0};
216 static const WCHAR prop_macaddressW
[] =
217 {'M','A','C','A','d','d','r','e','s','s',0};
218 static const WCHAR prop_manufacturerW
[] =
219 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
220 static const WCHAR prop_maxclockspeedW
[] =
221 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
222 static const WCHAR prop_mediatypeW
[] =
223 {'M','e','d','i','a','T','y','p','e',0};
224 static const WCHAR prop_memberW
[] =
225 {'M','e','m','b','e','r',0};
226 static const WCHAR prop_methodW
[] =
227 {'M','e','t','h','o','d',0};
228 static const WCHAR prop_modelW
[] =
229 {'M','o','d','e','l',0};
230 static const WCHAR prop_netconnectionstatusW
[] =
231 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
232 static const WCHAR prop_networkW
[] =
233 {'N','e','t','w','o','r','k',0};
234 static const WCHAR prop_numcoresW
[] =
235 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
236 static const WCHAR prop_numlogicalprocessorsW
[] =
237 {'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};
238 static const WCHAR prop_numprocessorsW
[] =
239 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
240 static const WCHAR prop_osarchitectureW
[] =
241 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
242 static const WCHAR prop_oslanguageW
[] =
243 {'O','S','L','a','n','g','u','a','g','e',0};
244 static const WCHAR prop_osproductsuiteW
[] =
245 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
246 static const WCHAR prop_ostypeW
[] =
247 {'O','S','T','y','p','e',0};
248 static const WCHAR prop_parameterW
[] =
249 {'P','a','r','a','m','e','t','e','r',0};
250 static const WCHAR prop_physicaladapterW
[] =
251 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
252 static const WCHAR prop_pnpdeviceidW
[] =
253 {'P','N','P','D','e','v','i','c','e','I','D',0};
254 static const WCHAR prop_pprocessidW
[] =
255 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
256 static const WCHAR prop_primaryW
[] =
257 {'P','r','i','m','a','r','y',0};
258 static const WCHAR prop_processidW
[] =
259 {'P','r','o','c','e','s','s','I','D',0};
260 static const WCHAR prop_processoridW
[] =
261 {'P','r','o','c','e','s','s','o','r','I','d',0};
262 static const WCHAR prop_processortypeW
[] =
263 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
264 static const WCHAR prop_productW
[] =
265 {'P','r','o','d','u','c','t',0};
266 static const WCHAR prop_productnameW
[] =
267 {'P','r','o','d','u','c','t','N','a','m','e',0};
268 static const WCHAR prop_referenceddomainnameW
[] =
269 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
270 static const WCHAR prop_releasedateW
[] =
271 {'R','e','l','e','a','s','e','D','a','t','e',0};
272 static const WCHAR prop_serialnumberW
[] =
273 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
274 static const WCHAR prop_servicepackmajorW
[] =
275 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
276 static const WCHAR prop_servicepackminorW
[] =
277 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
278 static const WCHAR prop_servicetypeW
[] =
279 {'S','e','r','v','i','c','e','T','y','p','e',0};
280 static const WCHAR prop_smbiosbiosversionW
[] =
281 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
282 static const WCHAR prop_startmodeW
[] =
283 {'S','t','a','r','t','M','o','d','e',0};
284 static const WCHAR prop_sidW
[] =
286 static const WCHAR prop_sidlengthW
[] =
287 {'S','i','d','L','e','n','g','t','h',0};
288 static const WCHAR prop_sizeW
[] =
290 static const WCHAR prop_speedW
[] =
291 {'S','p','e','e','d',0};
292 static const WCHAR prop_startingoffsetW
[] =
293 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
294 static const WCHAR prop_stateW
[] =
295 {'S','t','a','t','e',0};
296 static const WCHAR prop_statusinfoW
[] =
297 {'S','t','a','t','u','s','I','n','f','o',0};
298 static const WCHAR prop_strvalueW
[] =
299 {'S','t','r','i','n','g','V','a','l','u','e',0};
300 static const WCHAR prop_suitemaskW
[] =
301 {'S','u','i','t','e','M','a','s','k',0};
302 static const WCHAR prop_systemdirectoryW
[] =
303 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
304 static const WCHAR prop_systemnameW
[] =
305 {'S','y','s','t','e','m','N','a','m','e',0};
306 static const WCHAR prop_tagW
[] =
308 static const WCHAR prop_threadcountW
[] =
309 {'T','h','r','e','a','d','C','o','u','n','t',0};
310 static const WCHAR prop_totalphysicalmemoryW
[] =
311 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
312 static const WCHAR prop_totalvisiblememorysizeW
[] =
313 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
314 static const WCHAR prop_typeW
[] =
316 static const WCHAR prop_uniqueidW
[] =
317 {'U','n','i','q','u','e','I','d',0};
318 static const WCHAR prop_usernameW
[] =
319 {'U','s','e','r','N','a','m','e',0};
320 static const WCHAR prop_uuidW
[] =
322 static const WCHAR prop_varianttypeW
[] =
323 {'V','a','r','i','a','n','t','T','y','p','e',0};
324 static const WCHAR prop_versionW
[] =
325 {'V','e','r','s','i','o','n',0};
326 static const WCHAR prop_videoarchitectureW
[] =
327 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
328 static const WCHAR prop_videomemorytypeW
[] =
329 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
330 static const WCHAR prop_videoprocessorW
[] =
331 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
332 static const WCHAR prop_volumenameW
[] =
333 {'V','o','l','u','m','e','N','a','m','e',0};
334 static const WCHAR prop_volumeserialnumberW
[] =
335 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
336 static const WCHAR prop_workingsetsizeW
[] =
337 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
339 /* column definitions must be kept in sync with record structures below */
340 static const struct column col_baseboard
[] =
342 { prop_manufacturerW
, CIM_STRING
},
343 { prop_modelW
, CIM_STRING
},
344 { prop_nameW
, CIM_STRING
},
345 { prop_productW
, CIM_STRING
},
346 { prop_serialnumberW
, CIM_STRING
},
347 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
348 { prop_versionW
, CIM_STRING
}
350 static const struct column col_bios
[] =
352 { prop_descriptionW
, CIM_STRING
},
353 { prop_identificationcodeW
, CIM_STRING
},
354 { prop_manufacturerW
, CIM_STRING
},
355 { prop_releasedateW
, CIM_DATETIME
},
356 { prop_serialnumberW
, CIM_STRING
},
357 { prop_smbiosbiosversionW
, CIM_STRING
},
358 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
360 static const struct column col_cdromdrive
[] =
362 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
363 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
364 { prop_mediatypeW
, CIM_STRING
},
365 { prop_nameW
, CIM_STRING
},
366 { prop_pnpdeviceidW
, CIM_STRING
}
368 static const struct column col_compsys
[] =
370 { prop_descriptionW
, CIM_STRING
},
371 { prop_domainW
, CIM_STRING
},
372 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
373 { prop_manufacturerW
, CIM_STRING
},
374 { prop_modelW
, CIM_STRING
},
375 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
376 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
377 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
378 { prop_totalphysicalmemoryW
, CIM_UINT64
},
379 { prop_usernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
381 static const struct column col_compsysproduct
[] =
383 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
384 { prop_uuidW
, CIM_STRING
}
386 static const struct column col_datafile
[] =
388 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
389 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
391 static const struct column col_directory
[] =
393 { prop_accessmaskW
, CIM_UINT32
},
394 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
396 static const struct column col_diskdrive
[] =
398 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
399 { prop_indexW
, CIM_UINT32
, VT_I4
},
400 { prop_interfacetypeW
, CIM_STRING
},
401 { prop_manufacturerW
, CIM_STRING
},
402 { prop_mediatypeW
, CIM_STRING
},
403 { prop_modelW
, CIM_STRING
},
404 { prop_pnpdeviceidW
, CIM_STRING
},
405 { prop_serialnumberW
, CIM_STRING
},
406 { prop_sizeW
, CIM_UINT64
}
408 static const struct column col_diskpartition
[] =
410 { prop_bootableW
, CIM_BOOLEAN
},
411 { prop_bootpartitionW
, CIM_BOOLEAN
},
412 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
413 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
414 { prop_indexW
, CIM_UINT32
, VT_I4
},
415 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
416 { prop_sizeW
, CIM_UINT64
},
417 { prop_startingoffsetW
, CIM_UINT64
},
418 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
420 static const struct column col_logicaldisk
[] =
422 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
423 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
424 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
425 { prop_freespaceW
, CIM_UINT64
},
426 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
427 { prop_sizeW
, CIM_UINT64
},
428 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
429 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
431 static const struct column col_networkadapter
[] =
433 { prop_adaptertypeW
, CIM_STRING
},
434 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
435 { prop_indexW
, CIM_UINT32
, VT_I4
},
436 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
437 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
438 { prop_manufacturerW
, CIM_STRING
},
439 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
440 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
441 { prop_physicaladapterW
, CIM_BOOLEAN
},
442 { prop_pnpdeviceidW
, CIM_STRING
},
443 { prop_speedW
, CIM_UINT64
}
445 static const struct column col_networkadapterconfig
[] =
447 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
448 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
449 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
450 { prop_ipenabledW
, CIM_BOOLEAN
},
451 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
453 static const struct column col_os
[] =
455 { prop_buildnumberW
, CIM_STRING
},
456 { prop_captionW
, CIM_STRING
},
457 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
458 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
459 { prop_csdversionW
, CIM_STRING
},
460 { prop_installdateW
, CIM_DATETIME
},
461 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
462 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
463 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
464 { prop_nameW
, CIM_STRING
},
465 { prop_osarchitectureW
, CIM_STRING
},
466 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
467 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
468 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
469 { prop_primaryW
, CIM_BOOLEAN
},
470 { prop_serialnumberW
, CIM_STRING
},
471 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
472 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
473 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
474 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
475 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
476 { prop_versionW
, CIM_STRING
}
478 static const struct column col_param
[] =
480 { prop_classW
, CIM_STRING
},
481 { prop_methodW
, CIM_STRING
},
482 { prop_directionW
, CIM_SINT32
},
483 { prop_parameterW
, CIM_STRING
},
484 { prop_typeW
, CIM_UINT32
},
485 { prop_varianttypeW
, CIM_UINT32
},
486 { prop_defaultvalueW
, CIM_UINT32
}
488 static const struct column col_physicalmedia
[] =
490 { prop_serialnumberW
, CIM_STRING
},
491 { prop_tagW
, CIM_STRING
}
493 static const struct column col_physicalmemory
[] =
495 { prop_capacityW
, CIM_UINT64
}
497 static const struct column col_printer
[] =
499 { prop_attributesW
, CIM_UINT32
},
500 { prop_drivernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
501 { prop_horizontalresolutionW
, CIM_UINT32
},
502 { prop_localW
, CIM_BOOLEAN
},
503 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
504 { prop_networkW
, CIM_BOOLEAN
}
506 static const struct column col_process
[] =
508 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
509 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
510 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
511 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
512 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
513 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
514 { prop_processidW
, CIM_UINT32
, VT_I4
},
515 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
516 { prop_workingsetsizeW
, CIM_UINT64
},
518 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
520 static const struct column col_processor
[] =
522 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
523 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
524 { prop_cpustatusW
, CIM_UINT16
},
525 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
526 { prop_datawidthW
, CIM_UINT16
, VT_I4
},
527 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
528 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
529 { prop_familyW
, CIM_UINT16
, VT_I4
},
530 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
531 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
532 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
533 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
534 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
535 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
536 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
537 { prop_uniqueidW
, CIM_STRING
},
538 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
540 static const struct column col_qualifier
[] =
542 { prop_classW
, CIM_STRING
},
543 { prop_memberW
, CIM_STRING
},
544 { prop_typeW
, CIM_UINT32
},
545 { prop_flavorW
, CIM_SINT32
},
546 { prop_nameW
, CIM_STRING
},
547 { prop_intvalueW
, CIM_SINT32
},
548 { prop_strvalueW
, CIM_STRING
}
550 static const struct column col_service
[] =
552 { prop_acceptpauseW
, CIM_BOOLEAN
},
553 { prop_acceptstopW
, CIM_BOOLEAN
},
554 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
555 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
556 { prop_processidW
, CIM_UINT32
},
557 { prop_servicetypeW
, CIM_STRING
},
558 { prop_startmodeW
, CIM_STRING
},
559 { prop_stateW
, CIM_STRING
},
560 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
562 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
563 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
564 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
565 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
567 static const struct column col_sid
[] =
569 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
570 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
571 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
572 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
573 { prop_sidlengthW
, CIM_UINT32
}
575 static const struct column col_sounddevice
[] =
577 { prop_nameW
, CIM_STRING
},
578 { prop_productnameW
, CIM_STRING
},
579 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
581 static const struct column col_stdregprov
[] =
583 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
584 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
585 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
587 static const struct column col_systemenclosure
[] =
589 { prop_captionW
, CIM_STRING
},
590 { prop_chassistypesW
, CIM_UINT16
|CIM_FLAG_ARRAY
},
591 { prop_descriptionW
, CIM_STRING
},
592 { prop_lockpresentW
, CIM_BOOLEAN
},
593 { prop_manufacturerW
, CIM_STRING
},
594 { prop_nameW
, CIM_STRING
},
595 { prop_tagW
, CIM_STRING
},
597 static const struct column col_systemsecurity
[] =
599 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
600 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
602 static const struct column col_videocontroller
[] =
604 { prop_adapterdactypeW
, CIM_STRING
},
605 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
606 { prop_availabilityW
, CIM_UINT16
},
607 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
608 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
609 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
610 { prop_currentrefreshrateW
, CIM_UINT32
, VT_I4
},
611 { prop_currentscanmodeW
, CIM_UINT16
, VT_I4
},
612 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
613 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
614 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
615 { prop_driverversionW
, CIM_STRING
},
616 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
617 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
618 { prop_videoarchitectureW
, CIM_UINT16
, VT_I4
},
619 { prop_videomemorytypeW
, CIM_UINT16
, VT_I4
},
620 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
623 static const WCHAR baseboard_manufacturerW
[] =
624 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
625 static const WCHAR baseboard_serialnumberW
[] =
627 static const WCHAR baseboard_tagW
[] =
628 {'B','a','s','e',' ','B','o','a','r','d',0};
629 static const WCHAR baseboard_versionW
[] =
631 static const WCHAR bios_descriptionW
[] =
632 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
633 static const WCHAR bios_manufacturerW
[] =
634 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
635 static const WCHAR bios_releasedateW
[] =
636 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
637 static const WCHAR bios_serialnumberW
[] =
639 static const WCHAR bios_smbiosbiosversionW
[] =
641 static const WCHAR bios_versionW
[] =
642 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
643 static const WCHAR cdromdrive_mediatypeW
[] =
644 {'C','D','-','R','O','M',0};
645 static const WCHAR cdromdrive_nameW
[] =
646 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
647 static const WCHAR cdromdrive_pnpdeviceidW
[]=
648 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
649 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
650 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
651 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
652 static const WCHAR compsys_descriptionW
[] =
653 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
654 static const WCHAR compsys_domainW
[] =
655 {'W','O','R','K','G','R','O','U','P',0};
656 static const WCHAR compsys_manufacturerW
[] =
657 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
658 static const WCHAR compsys_modelW
[] =
660 static const WCHAR compsysproduct_identifyingnumberW
[] =
662 static const WCHAR compsysproduct_uuidW
[] =
663 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
664 '0','0','0','0','0','0','0','0','0','0','0','0',0};
665 static const WCHAR diskdrive_interfacetypeW
[] =
667 static const WCHAR diskdrive_manufacturerW
[] =
668 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
669 static const WCHAR diskdrive_mediatype_fixedW
[] =
670 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
671 static const WCHAR diskdrive_mediatype_removableW
[] =
672 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
673 static const WCHAR diskdrive_modelW
[] =
674 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
675 static const WCHAR diskdrive_pnpdeviceidW
[] =
676 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
677 static const WCHAR diskdrive_serialW
[] =
678 {'W','I','N','E','H','D','I','S','K',0};
679 static const WCHAR networkadapter_pnpdeviceidW
[]=
680 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
681 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
682 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
683 static const WCHAR os_32bitW
[] =
684 {'3','2','-','b','i','t',0};
685 static const WCHAR os_64bitW
[] =
686 {'6','4','-','b','i','t',0};
687 static const WCHAR os_buildnumberW
[] =
689 static const WCHAR os_captionW
[] =
690 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
691 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
692 static const WCHAR os_csdversionW
[] =
693 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
694 static const WCHAR os_installdateW
[] =
695 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
696 static const WCHAR os_nameW
[] =
697 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
698 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
699 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
700 '\\','P','a','r','t','i','t','i','o','n','1',0};
701 static const WCHAR os_serialnumberW
[] =
702 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
703 static const WCHAR os_versionW
[] =
704 {'5','.','1','.','2','6','0','0',0};
705 static const WCHAR physicalmedia_tagW
[] =
706 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
707 static const WCHAR sounddevice_productnameW
[] =
708 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
709 static const WCHAR systemenclosure_systemenclosureW
[] =
710 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
711 static const WCHAR systemenclosure_tagW
[] =
712 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
713 static const WCHAR systemenclosure_manufacturerW
[] =
715 static const WCHAR videocontroller_dactypeW
[] =
716 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
717 static const WCHAR videocontroller_deviceidW
[] =
718 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
719 static const WCHAR videocontroller_driverversionW
[] =
722 #include "pshpack1.h"
723 struct record_baseboard
725 const WCHAR
*manufacturer
;
728 const WCHAR
*product
;
729 const WCHAR
*serialnumber
;
731 const WCHAR
*version
;
735 const WCHAR
*description
;
736 const WCHAR
*identificationcode
;
737 const WCHAR
*manufacturer
;
738 const WCHAR
*releasedate
;
739 const WCHAR
*serialnumber
;
740 const WCHAR
*smbiosbiosversion
;
741 const WCHAR
*version
;
743 struct record_cdromdrive
745 const WCHAR
*device_id
;
747 const WCHAR
*mediatype
;
749 const WCHAR
*pnpdevice_id
;
751 struct record_computersystem
753 const WCHAR
*description
;
756 const WCHAR
*manufacturer
;
759 UINT32 num_logical_processors
;
760 UINT32 num_processors
;
761 UINT64 total_physical_memory
;
762 const WCHAR
*username
;
764 struct record_computersystemproduct
766 const WCHAR
*identifyingnumber
;
769 struct record_datafile
772 const WCHAR
*version
;
774 struct record_directory
779 struct record_diskdrive
781 const WCHAR
*device_id
;
783 const WCHAR
*interfacetype
;
784 const WCHAR
*manufacturer
;
785 const WCHAR
*mediatype
;
787 const WCHAR
*pnpdevice_id
;
788 const WCHAR
*serialnumber
;
791 struct record_diskpartition
795 const WCHAR
*device_id
;
798 const WCHAR
*pnpdevice_id
;
800 UINT64 startingoffset
;
803 struct record_logicaldisk
805 const WCHAR
*device_id
;
807 const WCHAR
*filesystem
;
811 const WCHAR
*volumename
;
812 const WCHAR
*volumeserialnumber
;
814 struct record_networkadapter
816 const WCHAR
*adaptertype
;
817 const WCHAR
*device_id
;
819 UINT32 interface_index
;
820 const WCHAR
*mac_address
;
821 const WCHAR
*manufacturer
;
823 UINT16 netconnection_status
;
825 const WCHAR
*pnpdevice_id
;
828 struct record_networkadapterconfig
830 const WCHAR
*dnshostname
;
832 UINT32 ipconnectionmetric
;
834 const WCHAR
*mac_address
;
836 struct record_operatingsystem
838 const WCHAR
*buildnumber
;
839 const WCHAR
*caption
;
840 const WCHAR
*codeset
;
841 const WCHAR
*countrycode
;
842 const WCHAR
*csdversion
;
843 const WCHAR
*installdate
;
844 const WCHAR
*lastbootuptime
;
845 const WCHAR
*localdatetime
;
848 const WCHAR
*osarchitecture
;
850 UINT32 osproductsuite
;
853 const WCHAR
*serialnumber
;
854 UINT16 servicepackmajor
;
855 UINT16 servicepackminor
;
857 const WCHAR
*systemdirectory
;
858 UINT64 totalvisiblememorysize
;
859 const WCHAR
*version
;
866 const WCHAR
*parameter
;
871 struct record_physicalmedia
873 const WCHAR
*serialnumber
;
876 struct record_physicalmemory
880 struct record_printer
883 const WCHAR
*drivername
;
884 UINT32 horizontalresolution
;
889 struct record_process
891 const WCHAR
*caption
;
892 const WCHAR
*commandline
;
893 const WCHAR
*description
;
899 UINT64 workingsetsize
;
901 class_method
*get_owner
;
903 struct record_processor
906 const WCHAR
*caption
;
908 UINT32 currentclockspeed
;
910 const WCHAR
*description
;
911 const WCHAR
*device_id
;
913 const WCHAR
*manufacturer
;
914 UINT32 maxclockspeed
;
917 UINT32 num_logical_processors
;
918 const WCHAR
*processor_id
;
919 UINT16 processortype
;
920 const WCHAR
*unique_id
;
921 const WCHAR
*version
;
923 struct record_qualifier
931 const WCHAR
*strvalue
;
933 struct record_service
937 const WCHAR
*displayname
;
940 const WCHAR
*servicetype
;
941 const WCHAR
*startmode
;
943 const WCHAR
*systemname
;
945 class_method
*pause_service
;
946 class_method
*resume_service
;
947 class_method
*start_service
;
948 class_method
*stop_service
;
952 const WCHAR
*accountname
;
953 const struct array
*binaryrepresentation
;
954 const WCHAR
*referenceddomainname
;
958 struct record_sounddevice
961 const WCHAR
*productname
;
964 struct record_stdregprov
966 class_method
*enumkey
;
967 class_method
*enumvalues
;
968 class_method
*getstringvalue
;
970 struct record_systemsecurity
975 struct record_systemenclosure
977 const WCHAR
*caption
;
978 const struct array
*chassistypes
;
979 const WCHAR
*description
;
981 const WCHAR
*manufacturer
;
985 struct record_videocontroller
987 const WCHAR
*adapter_dactype
;
990 const WCHAR
*caption
;
991 UINT32 current_bitsperpixel
;
992 UINT32 current_horizontalres
;
993 UINT32 current_refreshrate
;
994 UINT16 current_scanmode
;
995 UINT32 current_verticalres
;
996 const WCHAR
*description
;
997 const WCHAR
*device_id
;
998 const WCHAR
*driverversion
;
1000 const WCHAR
*pnpdevice_id
;
1001 UINT16 videoarchitecture
;
1002 UINT16 videomemorytype
;
1003 const WCHAR
*videoprocessor
;
1005 #include "poppack.h"
1007 static const struct record_baseboard data_baseboard
[] =
1009 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
1011 static const struct record_bios data_bios
[] =
1013 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
1014 bios_smbiosbiosversionW
, bios_versionW
}
1016 static const struct record_computersystemproduct data_compsysproduct
[] =
1018 { compsysproduct_identifyingnumberW
, compsysproduct_uuidW
}
1020 static const struct record_param data_param
[] =
1022 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1023 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
1024 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
1025 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1026 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1027 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1028 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1029 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1030 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1031 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1032 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1033 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1034 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
1035 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1036 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1037 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
1038 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1039 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
1040 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
1041 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1042 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
1043 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1044 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1045 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1046 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1049 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1050 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1052 static const struct record_physicalmedia data_physicalmedia
[] =
1054 { diskdrive_serialW
, physicalmedia_tagW
}
1056 static const struct record_qualifier data_qualifier
[] =
1058 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
1059 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
1061 static const struct record_sounddevice data_sounddevice
[] =
1063 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
1065 static const struct record_stdregprov data_stdregprov
[] =
1067 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
1069 static UINT16 systemenclosure_chassistypes
[] =
1073 static const struct array systemenclosure_chassistypes_array
=
1075 SIZEOF(systemenclosure_chassistypes
),
1076 &systemenclosure_chassistypes
1078 static const struct record_systemenclosure data_systemenclosure
[] =
1081 systemenclosure_systemenclosureW
,
1082 &systemenclosure_chassistypes_array
,
1083 systemenclosure_systemenclosureW
,
1085 systemenclosure_manufacturerW
,
1086 systemenclosure_systemenclosureW
,
1087 systemenclosure_tagW
,
1090 static const struct record_systemsecurity data_systemsecurity
[] =
1092 { security_get_sd
, security_set_sd
}
1095 /* check if row matches condition and update status */
1096 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1103 *status
= FILL_STATUS_UNFILTERED
;
1106 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1108 *status
= FILL_STATUS_FAILED
;
1111 *status
= FILL_STATUS_FILTERED
;
1115 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1117 if (!table
->num_rows_allocated
)
1119 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1120 table
->num_rows_allocated
= row_count
;
1123 if (row_count
> table
->num_rows_allocated
)
1126 UINT count
= max( row_count
, table
->num_rows_allocated
* 2 );
1127 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1129 table
->num_rows_allocated
= count
;
1134 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1136 static const WCHAR fmtW
[] = {'%','c',':',0};
1137 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1138 struct record_cdromdrive
*rec
;
1139 UINT i
, row
= 0, offset
= 0;
1140 DWORD drives
= GetLogicalDrives();
1141 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1143 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1145 for (i
= 0; i
< sizeof(drives
); i
++)
1147 if (drives
& (1 << i
))
1150 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1153 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1155 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1156 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1157 sprintfW( drive
, fmtW
, 'A' + i
);
1158 rec
->drive
= heap_strdupW( drive
);
1159 rec
->mediatype
= cdromdrive_mediatypeW
;
1160 rec
->name
= cdromdrive_nameW
;
1161 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1162 if (!match_row( table
, row
, cond
, &status
))
1164 free_row_values( table
, row
);
1167 offset
+= sizeof(*rec
);
1171 TRACE("created %u rows\n", row
);
1172 table
->num_rows
= row
;
1176 static UINT
get_processor_count(void)
1178 SYSTEM_BASIC_INFORMATION info
;
1180 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1181 return info
.NumberOfProcessors
;
1184 static UINT
get_logical_processor_count( UINT
*num_cores
)
1186 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1187 UINT i
, j
, count
= 0;
1191 if (num_cores
) *num_cores
= get_processor_count();
1192 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1193 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1195 if (!(info
= heap_alloc( len
))) return get_processor_count();
1196 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1197 if (status
!= STATUS_SUCCESS
)
1200 return get_processor_count();
1202 if (num_cores
) *num_cores
= 0;
1203 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1205 if (info
[i
].Relationship
== RelationProcessorCore
)
1207 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1209 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1211 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1218 static UINT64
get_total_physical_memory(void)
1220 MEMORYSTATUSEX status
;
1222 status
.dwLength
= sizeof(status
);
1223 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1224 return status
.ullTotalPhys
;
1227 static WCHAR
*get_computername(void)
1230 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1232 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1233 GetComputerNameW( ret
, &size
);
1237 static WCHAR
*get_username(void)
1240 DWORD compsize
, usersize
;
1244 GetComputerNameW( NULL
, &compsize
);
1246 GetUserNameW( NULL
, &usersize
);
1247 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1248 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1249 GetComputerNameW( ret
, &compsize
);
1250 ret
[compsize
] = '\\';
1251 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1255 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1257 struct record_computersystem
*rec
;
1258 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1261 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1263 rec
= (struct record_computersystem
*)table
->data
;
1264 rec
->description
= compsys_descriptionW
;
1265 rec
->domain
= compsys_domainW
;
1266 rec
->domainrole
= 0; /* standalone workstation */
1267 rec
->manufacturer
= compsys_manufacturerW
;
1268 rec
->model
= compsys_modelW
;
1269 rec
->name
= get_computername();
1270 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1271 rec
->num_processors
= get_processor_count();
1272 rec
->total_physical_memory
= get_total_physical_memory();
1273 rec
->username
= get_username();
1274 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1277 TRACE("created %u rows\n", row
);
1278 table
->num_rows
= row
;
1290 static struct dirstack
*alloc_dirstack( UINT size
)
1292 struct dirstack
*dirstack
;
1294 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1295 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1297 heap_free( dirstack
);
1300 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1302 heap_free( dirstack
->dirs
);
1303 heap_free( dirstack
);
1306 dirstack
->num_dirs
= 0;
1307 dirstack
->num_allocated
= size
;
1311 static void clear_dirstack( struct dirstack
*dirstack
)
1314 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1315 dirstack
->num_dirs
= 0;
1318 static void free_dirstack( struct dirstack
*dirstack
)
1320 clear_dirstack( dirstack
);
1321 heap_free( dirstack
->dirs
);
1322 heap_free( dirstack
->len_dirs
);
1323 heap_free( dirstack
);
1326 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1328 UINT size
, i
= dirstack
->num_dirs
;
1330 if (!dir
) return FALSE
;
1332 if (i
== dirstack
->num_allocated
)
1337 size
= dirstack
->num_allocated
* 2;
1338 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1339 dirstack
->dirs
= tmp
;
1340 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1341 dirstack
->len_dirs
= len_tmp
;
1342 dirstack
->num_allocated
= size
;
1344 dirstack
->dirs
[i
] = dir
;
1345 dirstack
->len_dirs
[i
] = len
;
1346 dirstack
->num_dirs
++;
1350 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1352 if (!dirstack
->num_dirs
)
1357 dirstack
->num_dirs
--;
1358 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1359 return dirstack
->dirs
[dirstack
->num_dirs
];
1362 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1364 if (!dirstack
->num_dirs
) return NULL
;
1365 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1368 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1373 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1379 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1388 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1390 UINT i
= 0, len
= 0;
1394 for (p
= path
; *p
; p
++)
1396 if (*p
== '\\') len
+= 2;
1399 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1404 for (p
= path
; *p
; p
++)
1406 if (*p
!= '\\') ret
[i
++] = *p
;
1417 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1419 const WCHAR
*p
= path
, *start
;
1423 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1425 len
= strlenW( start
);
1426 p
= start
+ len
- 1;
1427 if (*p
== '\\') return NULL
;
1429 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1430 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1432 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1433 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1435 if (p
[0] == '\\' && p
[1] == '\\')
1447 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1450 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1454 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1455 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1457 const struct expr
*left
, *right
;
1459 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1461 left
= cond
->u
.expr
.left
;
1462 right
= cond
->u
.expr
.right
;
1463 if (cond
->u
.expr
.op
== OP_EQ
)
1467 const WCHAR
*str
= NULL
;
1469 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1470 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1471 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1473 str
= right
->u
.sval
;
1475 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1476 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1477 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1481 if (str
&& (path
= build_dirname( str
, &len
)))
1483 if (seen_dir( dirstack
, path
))
1488 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1493 else if (cond
->u
.expr
.op
== OP_OR
)
1495 UINT left_count
= 0, right_count
= 0;
1497 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1498 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1499 return *count
+= left_count
+ right_count
;
1504 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1506 UINT len_path
= 0, len_segment
= strlenW( segment
);
1510 if (path
) len_path
= strlenW( path
);
1511 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1512 if (path
&& len_path
)
1514 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1515 ret
[len_path
] = '\\';
1516 *len
+= len_path
+ 1;
1518 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1519 *len
+= len_segment
;
1524 static WCHAR
*get_file_version( const WCHAR
*filename
)
1526 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1527 VS_FIXEDFILEINFO
*info
;
1532 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1533 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1538 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1539 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1545 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1546 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1551 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1553 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1554 struct record_datafile
*rec
;
1555 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1556 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1557 DWORD drives
= GetLogicalDrives();
1558 WIN32_FIND_DATAW data
;
1560 struct dirstack
*dirstack
;
1561 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1563 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1565 dirstack
= alloc_dirstack(2);
1567 for (i
= 0; i
< sizeof(drives
); i
++)
1569 if (!(drives
& (1 << i
))) continue;
1572 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1574 num_expected_rows
= 0;
1575 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1581 path
= pop_dir( dirstack
, &len
);
1582 if (!(glob
= build_glob( root
[0], path
, len
)))
1584 status
= FILL_STATUS_FAILED
;
1587 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1591 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1593 status
= FILL_STATUS_FAILED
;
1594 FindClose( handle
);
1597 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1598 new_path
= append_path( path
, data
.cFileName
, &len
);
1600 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1602 if (push_dir( dirstack
, new_path
, len
)) continue;
1603 heap_free( new_path
);
1604 FindClose( handle
);
1605 status
= FILL_STATUS_FAILED
;
1608 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1609 rec
->name
= build_name( root
[0], new_path
);
1610 rec
->version
= get_file_version( rec
->name
);
1611 if (!match_row( table
, row
, cond
, &status
))
1613 free_row_values( table
, row
);
1616 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1619 FindClose( handle
);
1620 status
= FILL_STATUS_FILTERED
;
1623 offset
+= sizeof(*rec
);
1626 while (FindNextFileW( handle
, &data
));
1627 FindClose( handle
);
1629 if (!peek_dir( dirstack
)) break;
1634 free_dirstack( dirstack
);
1638 TRACE("created %u rows\n", row
);
1639 table
->num_rows
= row
;
1643 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1645 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1646 struct record_directory
*rec
;
1647 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1648 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1649 DWORD drives
= GetLogicalDrives();
1650 WIN32_FIND_DATAW data
;
1652 struct dirstack
*dirstack
;
1653 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1655 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1657 dirstack
= alloc_dirstack(2);
1659 for (i
= 0; i
< sizeof(drives
); i
++)
1661 if (!(drives
& (1 << i
))) continue;
1664 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1666 num_expected_rows
= 0;
1667 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1673 path
= pop_dir( dirstack
, &len
);
1674 if (!(glob
= build_glob( root
[0], path
, len
)))
1676 status
= FILL_STATUS_FAILED
;
1679 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1683 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1685 FindClose( handle
);
1686 status
= FILL_STATUS_FAILED
;
1689 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1690 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1693 new_path
= append_path( path
, data
.cFileName
, &len
);
1694 if (!(push_dir( dirstack
, new_path
, len
)))
1696 heap_free( new_path
);
1697 FindClose( handle
);
1698 status
= FILL_STATUS_FAILED
;
1701 rec
= (struct record_directory
*)(table
->data
+ offset
);
1702 rec
->accessmask
= FILE_ALL_ACCESS
;
1703 rec
->name
= build_name( root
[0], new_path
);
1704 if (!match_row( table
, row
, cond
, &status
))
1706 free_row_values( table
, row
);
1709 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1712 FindClose( handle
);
1713 status
= FILL_STATUS_FILTERED
;
1716 offset
+= sizeof(*rec
);
1719 while (FindNextFileW( handle
, &data
));
1720 FindClose( handle
);
1722 if (!peek_dir( dirstack
)) break;
1727 free_dirstack( dirstack
);
1731 TRACE("created %u rows\n", row
);
1732 table
->num_rows
= row
;
1736 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1738 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1739 ULARGE_INTEGER free
;
1740 DISK_GEOMETRY_EX info
;
1742 DWORD bytes_returned
;
1744 free
.QuadPart
= 512 * 1024 * 1024;
1745 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1748 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1749 if (handle
!= INVALID_HANDLE_VALUE
)
1751 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1752 *disksize
= info
.DiskSize
.QuadPart
;
1753 CloseHandle( handle
);
1755 return free
.QuadPart
;
1758 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1760 static const WCHAR fmtW
[] =
1761 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1762 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1763 struct record_diskdrive
*rec
;
1764 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1765 UINT64 size
= 1024 * 1024 * 1024;
1766 DWORD drives
= GetLogicalDrives();
1767 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1769 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1771 for (i
= 0; i
< sizeof(drives
); i
++)
1773 if (drives
& (1 << i
))
1776 type
= GetDriveTypeW( root
);
1777 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1780 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1782 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1783 sprintfW( device_id
, fmtW
, index
);
1784 rec
->device_id
= heap_strdupW( device_id
);
1786 rec
->interfacetype
= diskdrive_interfacetypeW
;
1787 rec
->manufacturer
= diskdrive_manufacturerW
;
1788 if (type
== DRIVE_FIXED
)
1789 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1791 rec
->mediatype
= diskdrive_mediatype_removableW
;
1792 rec
->model
= diskdrive_modelW
;
1793 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1794 rec
->serialnumber
= diskdrive_serialW
;
1795 get_freespace( root
, &size
);
1797 if (!match_row( table
, row
, cond
, &status
))
1799 free_row_values( table
, row
);
1802 offset
+= sizeof(*rec
);
1807 TRACE("created %u rows\n", row
);
1808 table
->num_rows
= row
;
1812 static WCHAR
*get_filesystem( const WCHAR
*root
)
1814 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1815 WCHAR buffer
[MAX_PATH
+ 1];
1817 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1818 return heap_strdupW( buffer
);
1819 return heap_strdupW( ntfsW
);
1822 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1824 static const WCHAR fmtW
[] =
1825 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1826 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1827 struct record_diskpartition
*rec
;
1828 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1829 UINT64 size
= 1024 * 1024 * 1024;
1830 DWORD drives
= GetLogicalDrives();
1831 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1833 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1835 for (i
= 0; i
< sizeof(drives
); i
++)
1837 if (drives
& (1 << i
))
1840 type
= GetDriveTypeW( root
);
1841 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1844 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1846 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1847 rec
->bootable
= (i
== 2) ? -1 : 0;
1848 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1849 sprintfW( device_id
, fmtW
, index
);
1850 rec
->device_id
= heap_strdupW( device_id
);
1851 rec
->diskindex
= index
;
1853 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1854 get_freespace( root
, &size
);
1856 rec
->startingoffset
= 0;
1857 rec
->type
= get_filesystem( root
);
1858 if (!match_row( table
, row
, cond
, &status
))
1860 free_row_values( table
, row
);
1863 offset
+= sizeof(*rec
);
1868 TRACE("created %u rows\n", row
);
1869 table
->num_rows
= row
;
1873 static WCHAR
*get_volumename( const WCHAR
*root
)
1875 WCHAR buf
[MAX_PATH
+ 1] = {0};
1876 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1877 return heap_strdupW( buf
);
1879 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1881 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1885 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1886 sprintfW( buffer
, fmtW
, serial
);
1887 return heap_strdupW( buffer
);
1890 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1892 static const WCHAR fmtW
[] = {'%','c',':',0};
1893 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1894 struct record_logicaldisk
*rec
;
1895 UINT i
, row
= 0, offset
= 0, type
;
1896 UINT64 size
= 1024 * 1024 * 1024;
1897 DWORD drives
= GetLogicalDrives();
1898 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1900 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1902 for (i
= 0; i
< sizeof(drives
); i
++)
1904 if (drives
& (1 << i
))
1907 type
= GetDriveTypeW( root
);
1908 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1911 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1913 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1914 sprintfW( device_id
, fmtW
, 'A' + i
);
1915 rec
->device_id
= heap_strdupW( device_id
);
1916 rec
->drivetype
= type
;
1917 rec
->filesystem
= get_filesystem( root
);
1918 rec
->freespace
= get_freespace( root
, &size
);
1919 rec
->name
= heap_strdupW( device_id
);
1921 rec
->volumename
= get_volumename( root
);
1922 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1923 if (!match_row( table
, row
, cond
, &status
))
1925 free_row_values( table
, row
);
1928 offset
+= sizeof(*rec
);
1932 TRACE("created %u rows\n", row
);
1933 table
->num_rows
= row
;
1937 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1941 case IfOperStatusDown
:
1942 return 0; /* Disconnected */
1943 case IfOperStatusUp
:
1944 return 2; /* Connected */
1946 ERR("unhandled status %u\n", status
);
1951 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1953 static const WCHAR fmtW
[] =
1954 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1955 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1958 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1959 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1962 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1964 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1965 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1966 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1967 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1971 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1972 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1973 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1974 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1975 default: *physical
= 0; return NULL
;
1979 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1981 static const WCHAR fmtW
[] = {'%','u',0};
1982 WCHAR device_id
[11];
1983 struct record_networkadapter
*rec
;
1984 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1985 UINT row
= 0, offset
= 0, count
= 0;
1986 DWORD size
= 0, ret
;
1988 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1990 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1991 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1993 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1994 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1996 heap_free( buffer
);
1997 return FILL_STATUS_FAILED
;
1999 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2001 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2003 if (!resize_table( table
, count
, sizeof(*rec
) ))
2005 heap_free( buffer
);
2006 return FILL_STATUS_FAILED
;
2008 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2010 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2012 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
2013 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
2014 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
2015 rec
->device_id
= heap_strdupW( device_id
);
2016 rec
->index
= aa
->u
.s
.IfIndex
;
2017 rec
->interface_index
= aa
->u
.s
.IfIndex
;
2018 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2019 rec
->manufacturer
= compsys_manufacturerW
;
2020 rec
->name
= heap_strdupW( aa
->FriendlyName
);
2021 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
2022 rec
->physicaladapter
= physical
;
2023 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
2024 rec
->speed
= 1000000;
2025 if (!match_row( table
, row
, cond
, &status
))
2027 free_row_values( table
, row
);
2030 offset
+= sizeof(*rec
);
2033 TRACE("created %u rows\n", row
);
2034 table
->num_rows
= row
;
2036 heap_free( buffer
);
2040 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
2042 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
2043 WCHAR buf
[NI_MAXHOST
];
2045 if (!addr
) return NULL
;
2046 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
2047 0, NI_NAMEREQD
)) return NULL
;
2048 return heap_strdupW( buf
);
2051 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
2053 struct record_networkadapterconfig
*rec
;
2054 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2055 UINT row
= 0, offset
= 0, count
= 0;
2056 DWORD size
= 0, ret
;
2057 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2059 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
2060 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2062 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2063 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
2065 heap_free( buffer
);
2066 return FILL_STATUS_FAILED
;
2068 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2070 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2072 if (!resize_table( table
, count
, sizeof(*rec
) ))
2074 heap_free( buffer
);
2075 return FILL_STATUS_FAILED
;
2077 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2079 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2081 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
2082 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
2083 rec
->index
= aa
->u
.s
.IfIndex
;
2084 rec
->ipconnectionmetric
= 20;
2085 rec
->ipenabled
= -1;
2086 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2087 if (!match_row( table
, row
, cond
, &status
))
2089 free_row_values( table
, row
);
2092 offset
+= sizeof(*rec
);
2095 TRACE("created %u rows\n", row
);
2096 table
->num_rows
= row
;
2098 heap_free( buffer
);
2102 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
2104 struct record_physicalmemory
*rec
;
2105 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2108 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2110 rec
= (struct record_physicalmemory
*)table
->data
;
2111 rec
->capacity
= get_total_physical_memory();
2112 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2115 TRACE("created %u rows\n", row
);
2116 table
->num_rows
= row
;
2120 static enum fill_status
fill_printer( struct table
*table
, const struct expr
*cond
)
2122 struct record_printer
*rec
;
2123 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2124 PRINTER_INFO_2W
*info
;
2125 DWORD i
, offset
= 0, count
= 0, size
= 0;
2127 EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &size
, &count
);
2128 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2130 if (!(info
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2131 if (!EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, (BYTE
*)info
, size
, &size
, &count
))
2134 return FILL_STATUS_FAILED
;
2136 if (!resize_table( table
, count
, sizeof(*rec
) ))
2139 return FILL_STATUS_FAILED
;
2142 for (i
= 0; i
< count
; i
++)
2144 rec
= (struct record_printer
*)(table
->data
+ offset
);
2145 rec
->attributes
= info
[i
].Attributes
;
2146 rec
->drivername
= heap_strdupW( info
[i
].pDriverName
);
2147 rec
->horizontalresolution
= info
[i
].pDevMode
->u1
.s1
.dmPrintQuality
;
2149 rec
->name
= heap_strdupW( info
[i
].pPrinterName
);
2151 if (!match_row( table
, i
, cond
, &status
))
2153 free_row_values( table
, i
);
2156 offset
+= sizeof(*rec
);
2158 TRACE("created %u rows\n", count
);
2159 table
->num_rows
= count
;
2165 static WCHAR
*get_cmdline( DWORD process_id
)
2167 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2168 return NULL
; /* FIXME handle different process case */
2171 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2173 static const WCHAR fmtW
[] = {'%','u',0};
2175 struct record_process
*rec
;
2176 PROCESSENTRY32W entry
;
2178 enum fill_status status
= FILL_STATUS_FAILED
;
2179 UINT row
= 0, offset
= 0;
2181 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2182 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2184 entry
.dwSize
= sizeof(entry
);
2185 if (!Process32FirstW( snap
, &entry
)) goto done
;
2186 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2190 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2192 rec
= (struct record_process
*)(table
->data
+ offset
);
2193 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2194 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2195 rec
->description
= heap_strdupW( entry
.szExeFile
);
2196 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2197 rec
->handle
= heap_strdupW( handle
);
2198 rec
->name
= heap_strdupW( entry
.szExeFile
);
2199 rec
->process_id
= entry
.th32ProcessID
;
2200 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2201 rec
->thread_count
= entry
.cntThreads
;
2202 rec
->workingsetsize
= 0;
2203 rec
->get_owner
= process_get_owner
;
2204 if (!match_row( table
, row
, cond
, &status
))
2206 free_row_values( table
, row
);
2209 offset
+= sizeof(*rec
);
2211 } while (Process32NextW( snap
, &entry
));
2213 TRACE("created %u rows\n", row
);
2214 table
->num_rows
= row
;
2215 status
= FILL_STATUS_UNFILTERED
;
2218 CloseHandle( snap
);
2222 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2228 __asm__("pushl %%ebx\n\t"
2230 "movl %%ebx, %%esi\n\t"
2232 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2237 static const WCHAR
*get_osarchitecture(void)
2240 GetNativeSystemInfo( &info
);
2241 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2244 static void get_processor_caption( WCHAR
*caption
)
2246 static const WCHAR fmtW
[] =
2247 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2248 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2249 static const WCHAR x86W
[] = {'x','8','6',0};
2250 static const WCHAR intel64W
[] = {'I','n','t','e','l','6','4',0};
2251 const WCHAR
*arch
= (get_osarchitecture() == os_32bitW
) ? x86W
: intel64W
;
2252 unsigned int regs
[4] = {0, 0, 0, 0};
2254 do_cpuid( 1, regs
);
2255 sprintfW( caption
, fmtW
, arch
, (regs
[0] & (15 << 8)) >> 8, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2257 static void get_processor_version( WCHAR
*version
)
2259 static const WCHAR fmtW
[] =
2260 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2261 unsigned int regs
[4] = {0, 0, 0, 0};
2263 do_cpuid( 1, regs
);
2264 sprintfW( version
, fmtW
, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2266 static void get_processor_id( WCHAR
*processor_id
)
2268 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2269 unsigned int regs
[4] = {0, 0, 0, 0};
2271 do_cpuid( 1, regs
);
2272 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2274 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2277 unsigned char *p
= (unsigned char *)regs
;
2279 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2282 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2284 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2286 do_cpuid( 0, regs
);
2287 tmp
= regs
[2]; /* swap edx and ecx */
2291 regs_to_str( regs
+ 1, 12, manufacturer
);
2293 static void get_processor_name( WCHAR
*name
)
2295 unsigned int regs
[4] = {0, 0, 0, 0};
2297 do_cpuid( 0x80000000, regs
);
2298 if (regs
[0] >= 0x80000004)
2300 do_cpuid( 0x80000002, regs
);
2301 regs_to_str( regs
, 16, name
);
2302 do_cpuid( 0x80000003, regs
);
2303 regs_to_str( regs
, 16, name
+ 16 );
2304 do_cpuid( 0x80000004, regs
);
2305 regs_to_str( regs
, 16, name
+ 32 );
2308 static UINT
get_processor_currentclockspeed( UINT index
)
2310 PROCESSOR_POWER_INFORMATION
*info
;
2311 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2314 if ((info
= heap_alloc( size
)))
2316 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2317 if (!status
) ret
= info
[index
].CurrentMhz
;
2322 static UINT
get_processor_maxclockspeed( UINT index
)
2324 PROCESSOR_POWER_INFORMATION
*info
;
2325 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2328 if ((info
= heap_alloc( size
)))
2330 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2331 if (!status
) ret
= info
[index
].MaxMhz
;
2337 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2339 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2340 WCHAR caption
[100], device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0}, version
[50];
2341 struct record_processor
*rec
;
2342 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2343 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2345 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2347 get_processor_caption( caption
);
2348 get_processor_id( processor_id
);
2349 get_processor_manufacturer( manufacturer
);
2350 get_processor_name( name
);
2351 get_processor_version( version
);
2353 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2356 for (i
= 0; i
< count
; i
++)
2358 rec
= (struct record_processor
*)(table
->data
+ offset
);
2359 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2360 rec
->caption
= heap_strdupW( caption
);
2361 rec
->cpu_status
= 1; /* CPU Enabled */
2362 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2363 rec
->datawidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2364 rec
->description
= heap_strdupW( caption
);
2365 sprintfW( device_id
, fmtW
, i
);
2366 rec
->device_id
= heap_strdupW( device_id
);
2367 rec
->family
= 2; /* Unknown */
2368 rec
->manufacturer
= heap_strdupW( manufacturer
);
2369 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2370 rec
->name
= heap_strdupW( name
);
2371 rec
->num_cores
= num_cores
;
2372 rec
->num_logical_processors
= num_logical_processors
;
2373 rec
->processor_id
= heap_strdupW( processor_id
);
2374 rec
->processortype
= 3; /* central processor */
2375 rec
->unique_id
= NULL
;
2376 rec
->version
= heap_strdupW( version
);
2377 if (!match_row( table
, i
, cond
, &status
))
2379 free_row_values( table
, i
);
2382 offset
+= sizeof(*rec
);
2385 TRACE("created %u rows\n", count
);
2386 table
->num_rows
= count
;
2390 static WCHAR
*get_lastbootuptime(void)
2392 static const WCHAR fmtW
[] =
2393 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2394 '.','%','0','6','u','+','0','0','0',0};
2395 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2399 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2401 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2402 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2403 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2406 static WCHAR
*get_localdatetime(void)
2408 static const WCHAR fmtW
[] =
2409 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2410 '.','%','0','6','u','%','+','0','3','d',0};
2411 TIME_ZONE_INFORMATION tzi
;
2417 Status
= GetTimeZoneInformation(&tzi
);
2419 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2421 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2422 Bias
+= tzi
.DaylightBias
;
2424 Bias
+= tzi
.StandardBias
;
2425 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2428 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2431 static WCHAR
*get_systemdirectory(void)
2436 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2437 Wow64DisableWow64FsRedirection( &redir
);
2438 GetSystemDirectoryW( ret
, MAX_PATH
);
2439 Wow64RevertWow64FsRedirection( redir
);
2442 static WCHAR
*get_codeset(void)
2444 static const WCHAR fmtW
[] = {'%','u',0};
2445 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2446 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2449 static WCHAR
*get_countrycode(void)
2451 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2452 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2455 static WCHAR
*get_locale(void)
2457 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2458 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2462 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2464 struct record_operatingsystem
*rec
;
2465 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2468 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2470 rec
= (struct record_operatingsystem
*)table
->data
;
2471 rec
->buildnumber
= os_buildnumberW
;
2472 rec
->caption
= os_captionW
;
2473 rec
->codeset
= get_codeset();
2474 rec
->countrycode
= get_countrycode();
2475 rec
->csdversion
= os_csdversionW
;
2476 rec
->installdate
= os_installdateW
;
2477 rec
->lastbootuptime
= get_lastbootuptime();
2478 rec
->localdatetime
= get_localdatetime();
2479 rec
->locale
= get_locale();
2480 rec
->name
= os_nameW
;
2481 rec
->osarchitecture
= get_osarchitecture();
2482 rec
->oslanguage
= GetSystemDefaultLangID();
2483 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2484 rec
->ostype
= 18; /* WINNT */
2486 rec
->serialnumber
= os_serialnumberW
;
2487 rec
->servicepackmajor
= 3;
2488 rec
->servicepackminor
= 0;
2489 rec
->suitemask
= 272; /* Single User + Terminal */
2490 rec
->systemdirectory
= get_systemdirectory();
2491 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2492 rec
->version
= os_versionW
;
2493 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2496 TRACE("created %u rows\n", row
);
2497 table
->num_rows
= row
;
2501 static const WCHAR
*get_service_type( DWORD type
)
2503 static const WCHAR filesystem_driverW
[] =
2504 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2505 static const WCHAR kernel_driverW
[] =
2506 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2507 static const WCHAR own_processW
[] =
2508 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2509 static const WCHAR share_processW
[] =
2510 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2512 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2513 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2514 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2515 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2516 else ERR("unhandled type 0x%08x\n", type
);
2519 static const WCHAR
*get_service_state( DWORD state
)
2521 static const WCHAR runningW
[] =
2522 {'R','u','n','n','i','n','g',0};
2523 static const WCHAR start_pendingW
[] =
2524 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2525 static const WCHAR stop_pendingW
[] =
2526 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2527 static const WCHAR stoppedW
[] =
2528 {'S','t','o','p','p','e','d',0};
2529 static const WCHAR unknownW
[] =
2530 {'U','n','k','n','o','w','n',0};
2534 case SERVICE_STOPPED
: return stoppedW
;
2535 case SERVICE_START_PENDING
: return start_pendingW
;
2536 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2537 case SERVICE_RUNNING
: return runningW
;
2539 ERR("unknown state %u\n", state
);
2543 static const WCHAR
*get_service_startmode( DWORD mode
)
2545 static const WCHAR bootW
[] = {'B','o','o','t',0};
2546 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2547 static const WCHAR autoW
[] = {'A','u','t','o',0};
2548 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2549 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2550 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2554 case SERVICE_BOOT_START
: return bootW
;
2555 case SERVICE_SYSTEM_START
: return systemW
;
2556 case SERVICE_AUTO_START
: return autoW
;
2557 case SERVICE_DEMAND_START
: return manualW
;
2558 case SERVICE_DISABLED
: return disabledW
;
2560 ERR("unknown mode 0x%x\n", mode
);
2564 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2566 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2570 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2571 QueryServiceConfigW( service
, NULL
, 0, &size
);
2572 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2573 if (!(config
= heap_alloc( size
))) goto done
;
2574 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2575 heap_free( config
);
2579 CloseServiceHandle( service
);
2583 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2585 struct record_service
*rec
;
2587 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2588 SERVICE_STATUS_PROCESS
*status
;
2589 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2590 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2591 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2592 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2595 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2596 if (!(services
= heap_alloc( size
))) goto done
;
2598 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2599 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2600 &count
, NULL
, NULL
);
2603 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2605 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2607 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2608 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2609 &count
, NULL
, NULL
);
2610 if (!ret
) goto done
;
2612 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2614 GetComputerNameW( sysnameW
, &len
);
2615 fill_status
= FILL_STATUS_UNFILTERED
;
2617 for (i
= 0; i
< count
; i
++)
2619 QUERY_SERVICE_CONFIGW
*config
;
2621 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2623 status
= &services
[i
].ServiceStatusProcess
;
2624 rec
= (struct record_service
*)(table
->data
+ offset
);
2625 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2626 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2627 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2628 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2629 rec
->process_id
= status
->dwProcessId
;
2630 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2631 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2632 rec
->state
= get_service_state( status
->dwCurrentState
);
2633 rec
->systemname
= heap_strdupW( sysnameW
);
2634 rec
->pause_service
= service_pause_service
;
2635 rec
->resume_service
= service_resume_service
;
2636 rec
->start_service
= service_start_service
;
2637 rec
->stop_service
= service_stop_service
;
2638 heap_free( config
);
2639 if (!match_row( table
, row
, cond
, &fill_status
))
2641 free_row_values( table
, row
);
2644 offset
+= sizeof(*rec
);
2648 TRACE("created %u rows\n", row
);
2649 table
->num_rows
= row
;
2652 CloseServiceHandle( manager
);
2653 heap_free( services
);
2657 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2659 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2660 return heap_strdupW( name
->Name
.Buffer
);
2662 static struct array
*get_binaryrepresentation( PSID sid
, UINT len
)
2664 struct array
*array
= heap_alloc( sizeof(struct array
) );
2667 UINT8
*ret
= heap_alloc( len
);
2670 memcpy( ret
, sid
, len
);
2679 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2681 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2682 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2684 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2686 const struct expr
*left
, *right
;
2687 const WCHAR
*ret
= NULL
;
2689 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2691 left
= cond
->u
.expr
.left
;
2692 right
= cond
->u
.expr
.right
;
2693 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2695 ret
= right
->u
.sval
;
2697 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2704 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2707 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2708 LSA_TRANSLATED_NAME
*name
;
2710 LSA_OBJECT_ATTRIBUTES attrs
;
2712 struct record_sid
*rec
;
2715 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
2716 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2718 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
2719 len
= GetLengthSid( sid
);
2721 memset( &attrs
, 0, sizeof(attrs
) );
2722 attrs
.Length
= sizeof(attrs
);
2723 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
2726 return FILL_STATUS_FAILED
;
2728 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
2732 return FILL_STATUS_FAILED
;
2735 rec
= (struct record_sid
*)table
->data
;
2736 rec
->accountname
= get_accountname( name
);
2737 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);