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"
35 static const WCHAR class_baseboardW
[] =
36 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
37 static const WCHAR class_biosW
[] =
38 {'W','i','n','3','2','_','B','I','O','S',0};
39 static const WCHAR class_cdromdriveW
[] =
40 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
41 static const WCHAR class_compsysW
[] =
42 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
43 static const WCHAR class_compsysproductW
[] =
44 {'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};
45 static const WCHAR class_datafileW
[] =
46 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
47 static const WCHAR class_directoryW
[] =
48 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
49 static const WCHAR class_diskdriveW
[] =
50 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
51 static const WCHAR class_diskpartitionW
[] =
52 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
53 static const WCHAR class_logicaldiskW
[] =
54 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
55 static const WCHAR class_logicaldisk2W
[] =
56 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
57 static const WCHAR class_networkadapterW
[] =
58 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
59 static const WCHAR class_networkadapterconfigW
[] =
60 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
61 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
62 static const WCHAR class_osW
[] =
63 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
64 static const WCHAR class_paramsW
[] =
65 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
66 static const WCHAR class_physicalmediaW
[] =
67 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
68 static const WCHAR class_physicalmemoryW
[] =
69 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
70 static const WCHAR class_qualifiersW
[] =
71 {'_','_','Q','U','A','L','I','F','I','E','R','S',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_videocontrollerW
[] =
84 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
86 static const WCHAR prop_accountnameW
[] =
87 {'A','c','c','o','u','n','t','N','a','m','e',0};
88 static const WCHAR prop_acceptpauseW
[] =
89 {'A','c','c','e','p','t','P','a','u','s','e',0};
90 static const WCHAR prop_acceptstopW
[] =
91 {'A','c','c','e','p','t','S','t','o','p',0};
92 static const WCHAR prop_accessmaskW
[] =
93 {'A','c','c','e','s','s','M','a','s','k',0};
94 static const WCHAR prop_adapterdactypeW
[] =
95 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
96 static const WCHAR prop_adapterramW
[] =
97 {'A','d','a','p','t','e','r','R','A','M',0};
98 static const WCHAR prop_adaptertypeW
[] =
99 {'A','d','a','p','t','e','r','T','y','p','e',0};
100 static const WCHAR prop_addresswidthW
[] =
101 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
102 static const WCHAR prop_availabilityW
[] =
103 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
104 static const WCHAR prop_binaryrepresentationW
[] =
105 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
106 static const WCHAR prop_bootableW
[] =
107 {'B','o','o','t','a','b','l','e',0};
108 static const WCHAR prop_bootpartitionW
[] =
109 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
110 static const WCHAR prop_buildnumberW
[] =
111 {'B','u','i','l','d','N','u','m','b','e','r',0};
112 static const WCHAR prop_capacityW
[] =
113 {'C','a','p','a','c','i','t','y',0};
114 static const WCHAR prop_captionW
[] =
115 {'C','a','p','t','i','o','n',0};
116 static const WCHAR prop_classW
[] =
117 {'C','l','a','s','s',0};
118 static const WCHAR prop_codesetW
[] =
119 {'C','o','d','e','S','e','t',0};
120 static const WCHAR prop_commandlineW
[] =
121 {'C','o','m','m','a','n','d','L','i','n','e',0};
122 static const WCHAR prop_countrycodeW
[] =
123 {'C','o','u','n','t','r','y','C','o','d','e',0};
124 static const WCHAR prop_cpustatusW
[] =
125 {'C','p','u','S','t','a','t','u','s',0};
126 static const WCHAR prop_csdversionW
[] =
127 {'C','S','D','V','e','r','s','i','o','n',0};
128 static const WCHAR prop_currentbitsperpixelW
[] =
129 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
130 static const WCHAR prop_currentclockspeedW
[] =
131 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
132 static const WCHAR prop_currenthorizontalresW
[] =
133 {'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};
134 static const WCHAR prop_currentverticalresW
[] =
135 {'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};
136 static const WCHAR prop_defaultvalueW
[] =
137 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
138 static const WCHAR prop_descriptionW
[] =
139 {'D','e','s','c','r','i','p','t','i','o','n',0};
140 static const WCHAR prop_deviceidW
[] =
141 {'D','e','v','i','c','e','I','d',0};
142 static const WCHAR prop_directionW
[] =
143 {'D','i','r','e','c','t','i','o','n',0};
144 static const WCHAR prop_displaynameW
[] =
145 {'D','i','s','p','l','a','y','N','a','m','e',0};
146 static const WCHAR prop_diskindexW
[] =
147 {'D','i','s','k','I','n','d','e','x',0};
148 static const WCHAR prop_dnshostnameW
[] =
149 {'D','N','S','H','o','s','t','N','a','m','e',0};
150 static const WCHAR prop_domainW
[] =
151 {'D','o','m','a','i','n',0};
152 static const WCHAR prop_domainroleW
[] =
153 {'D','o','m','a','i','n','R','o','l','e',0};
154 static const WCHAR prop_driveW
[] =
155 {'D','r','i','v','e',0};
156 static const WCHAR prop_driverversionW
[] =
157 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
158 static const WCHAR prop_drivetypeW
[] =
159 {'D','r','i','v','e','T','y','p','e',0};
160 static const WCHAR prop_familyW
[] =
161 {'F','a','m','i','l','y',0};
162 static const WCHAR prop_filesystemW
[] =
163 {'F','i','l','e','S','y','s','t','e','m',0};
164 static const WCHAR prop_flavorW
[] =
165 {'F','l','a','v','o','r',0};
166 static const WCHAR prop_freespaceW
[] =
167 {'F','r','e','e','S','p','a','c','e',0};
168 static const WCHAR prop_handleW
[] =
169 {'H','a','n','d','l','e',0};
170 static const WCHAR prop_idW
[] =
172 static const WCHAR prop_identificationcodeW
[] =
173 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
174 static const WCHAR prop_identifyingnumberW
[] =
175 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
176 static const WCHAR prop_indexW
[] =
177 {'I','n','d','e','x',0};
178 static const WCHAR prop_installdateW
[] =
179 {'I','n','s','t','a','l','l','D','a','t','e',0};
180 static const WCHAR prop_interfaceindexW
[] =
181 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
182 static const WCHAR prop_interfacetypeW
[] =
183 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
184 static const WCHAR prop_intvalueW
[] =
185 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
186 static const WCHAR prop_ipconnectionmetricW
[] =
187 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
188 static const WCHAR prop_ipenabledW
[] =
189 {'I','P','E','n','a','b','l','e','d',0};
190 static const WCHAR prop_lastbootuptimeW
[] =
191 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
192 static const WCHAR prop_localdatetimeW
[] =
193 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
194 static const WCHAR prop_localeW
[] =
195 {'L','o','c','a','l','e',0};
196 static const WCHAR prop_macaddressW
[] =
197 {'M','A','C','A','d','d','r','e','s','s',0};
198 static const WCHAR prop_manufacturerW
[] =
199 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
200 static const WCHAR prop_maxclockspeedW
[] =
201 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
202 static const WCHAR prop_mediatypeW
[] =
203 {'M','e','d','i','a','T','y','p','e',0};
204 static const WCHAR prop_memberW
[] =
205 {'M','e','m','b','e','r',0};
206 static const WCHAR prop_methodW
[] =
207 {'M','e','t','h','o','d',0};
208 static const WCHAR prop_modelW
[] =
209 {'M','o','d','e','l',0};
210 static const WCHAR prop_netconnectionstatusW
[] =
211 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
212 static const WCHAR prop_numcoresW
[] =
213 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
214 static const WCHAR prop_numlogicalprocessorsW
[] =
215 {'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};
216 static const WCHAR prop_numprocessorsW
[] =
217 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
218 static const WCHAR prop_osarchitectureW
[] =
219 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
220 static const WCHAR prop_oslanguageW
[] =
221 {'O','S','L','a','n','g','u','a','g','e',0};
222 static const WCHAR prop_osproductsuiteW
[] =
223 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
224 static const WCHAR prop_ostypeW
[] =
225 {'O','S','T','y','p','e',0};
226 static const WCHAR prop_parameterW
[] =
227 {'P','a','r','a','m','e','t','e','r',0};
228 static const WCHAR prop_physicaladapterW
[] =
229 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
230 static const WCHAR prop_pnpdeviceidW
[] =
231 {'P','N','P','D','e','v','i','c','e','I','D',0};
232 static const WCHAR prop_pprocessidW
[] =
233 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
234 static const WCHAR prop_processidW
[] =
235 {'P','r','o','c','e','s','s','I','D',0};
236 static const WCHAR prop_processoridW
[] =
237 {'P','r','o','c','e','s','s','o','r','I','d',0};
238 static const WCHAR prop_processortypeW
[] =
239 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
240 static const WCHAR prop_productW
[] =
241 {'P','r','o','d','u','c','t',0};
242 static const WCHAR prop_productnameW
[] =
243 {'P','r','o','d','u','c','t','N','a','m','e',0};
244 static const WCHAR prop_referenceddomainnameW
[] =
245 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
246 static const WCHAR prop_releasedateW
[] =
247 {'R','e','l','e','a','s','e','D','a','t','e',0};
248 static const WCHAR prop_serialnumberW
[] =
249 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
250 static const WCHAR prop_servicepackmajorW
[] =
251 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
252 static const WCHAR prop_servicepackminorW
[] =
253 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
254 static const WCHAR prop_servicetypeW
[] =
255 {'S','e','r','v','i','c','e','T','y','p','e',0};
256 static const WCHAR prop_smbiosbiosversionW
[] =
257 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
258 static const WCHAR prop_startmodeW
[] =
259 {'S','t','a','r','t','M','o','d','e',0};
260 static const WCHAR prop_sidW
[] =
262 static const WCHAR prop_sidlengthW
[] =
263 {'S','i','d','L','e','n','g','t','h',0};
264 static const WCHAR prop_sizeW
[] =
266 static const WCHAR prop_speedW
[] =
267 {'S','p','e','e','d',0};
268 static const WCHAR prop_startingoffsetW
[] =
269 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
270 static const WCHAR prop_stateW
[] =
271 {'S','t','a','t','e',0};
272 static const WCHAR prop_statusinfoW
[] =
273 {'S','t','a','t','u','s','I','n','f','o',0};
274 static const WCHAR prop_strvalueW
[] =
275 {'S','t','r','i','n','g','V','a','l','u','e',0};
276 static const WCHAR prop_suitemaskW
[] =
277 {'S','u','i','t','e','M','a','s','k',0};
278 static const WCHAR prop_systemdirectoryW
[] =
279 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
280 static const WCHAR prop_systemnameW
[] =
281 {'S','y','s','t','e','m','N','a','m','e',0};
282 static const WCHAR prop_tagW
[] =
284 static const WCHAR prop_threadcountW
[] =
285 {'T','h','r','e','a','d','C','o','u','n','t',0};
286 static const WCHAR prop_totalphysicalmemoryW
[] =
287 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
288 static const WCHAR prop_totalvisiblememorysizeW
[] =
289 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
290 static const WCHAR prop_typeW
[] =
292 static const WCHAR prop_uniqueidW
[] =
293 {'U','n','i','q','u','e','I','d',0};
294 static const WCHAR prop_usernameW
[] =
295 {'U','s','e','r','N','a','m','e',0};
296 static const WCHAR prop_uuidW
[] =
298 static const WCHAR prop_varianttypeW
[] =
299 {'V','a','r','i','a','n','t','T','y','p','e',0};
300 static const WCHAR prop_versionW
[] =
301 {'V','e','r','s','i','o','n',0};
302 static const WCHAR prop_videoprocessorW
[] =
303 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
304 static const WCHAR prop_volumenameW
[] =
305 {'V','o','l','u','m','e','N','a','m','e',0};
306 static const WCHAR prop_volumeserialnumberW
[] =
307 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
309 /* column definitions must be kept in sync with record structures below */
310 static const struct column col_baseboard
[] =
312 { prop_manufacturerW
, CIM_STRING
},
313 { prop_modelW
, CIM_STRING
},
314 { prop_nameW
, CIM_STRING
},
315 { prop_productW
, CIM_STRING
},
316 { prop_serialnumberW
, CIM_STRING
},
317 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
318 { prop_versionW
, CIM_STRING
}
320 static const struct column col_bios
[] =
322 { prop_descriptionW
, CIM_STRING
},
323 { prop_identificationcodeW
, CIM_STRING
},
324 { prop_manufacturerW
, CIM_STRING
},
325 { prop_releasedateW
, CIM_DATETIME
},
326 { prop_serialnumberW
, CIM_STRING
},
327 { prop_smbiosbiosversionW
, CIM_STRING
},
328 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
330 static const struct column col_cdromdrive
[] =
332 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
333 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
334 { prop_mediatypeW
, CIM_STRING
},
335 { prop_nameW
, CIM_STRING
},
336 { prop_pnpdeviceidW
, CIM_STRING
}
338 static const struct column col_compsys
[] =
340 { prop_descriptionW
, CIM_STRING
},
341 { prop_domainW
, CIM_STRING
},
342 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
343 { prop_manufacturerW
, CIM_STRING
},
344 { prop_modelW
, CIM_STRING
},
345 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
346 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
347 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
348 { prop_totalphysicalmemoryW
, CIM_UINT64
},
349 { prop_usernameW
, CIM_STRING
}
351 static const struct column col_compsysproduct
[] =
353 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
354 { prop_uuidW
, CIM_STRING
}
356 static const struct column col_datafile
[] =
358 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
359 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
361 static const struct column col_directory
[] =
363 { prop_accessmaskW
, CIM_UINT32
},
364 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
366 static const struct column col_diskdrive
[] =
368 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
369 { prop_indexW
, CIM_UINT32
, VT_I4
},
370 { prop_interfacetypeW
, CIM_STRING
},
371 { prop_manufacturerW
, CIM_STRING
},
372 { prop_mediatypeW
, CIM_STRING
},
373 { prop_modelW
, CIM_STRING
},
374 { prop_pnpdeviceidW
, CIM_STRING
},
375 { prop_serialnumberW
, CIM_STRING
},
376 { prop_sizeW
, CIM_UINT64
}
378 static const struct column col_diskpartition
[] =
380 { prop_bootableW
, CIM_BOOLEAN
},
381 { prop_bootpartitionW
, CIM_BOOLEAN
},
382 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
383 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
384 { prop_indexW
, CIM_UINT32
, VT_I4
},
385 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
386 { prop_sizeW
, CIM_UINT64
},
387 { prop_startingoffsetW
, CIM_UINT64
},
388 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
390 static const struct column col_logicaldisk
[] =
392 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
393 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
394 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
395 { prop_freespaceW
, CIM_UINT64
},
396 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
397 { prop_sizeW
, CIM_UINT64
},
398 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
399 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
401 static const struct column col_networkadapter
[] =
403 { prop_adaptertypeW
, CIM_STRING
},
404 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
405 { prop_indexW
, CIM_UINT32
, VT_I4
},
406 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
407 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
408 { prop_manufacturerW
, CIM_STRING
},
409 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
410 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
411 { prop_physicaladapterW
, CIM_BOOLEAN
},
412 { prop_pnpdeviceidW
, CIM_STRING
},
413 { prop_speedW
, CIM_UINT64
}
415 static const struct column col_networkadapterconfig
[] =
417 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
418 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
419 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
420 { prop_ipenabledW
, CIM_BOOLEAN
},
421 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
423 static const struct column col_os
[] =
425 { prop_buildnumberW
, CIM_STRING
},
426 { prop_captionW
, CIM_STRING
},
427 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
428 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
429 { prop_csdversionW
, CIM_STRING
},
430 { prop_installdateW
, CIM_DATETIME
},
431 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
432 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
433 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
434 { prop_nameW
, CIM_STRING
},
435 { prop_osarchitectureW
, CIM_STRING
},
436 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
437 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
438 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
439 { prop_serialnumberW
, CIM_STRING
},
440 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
441 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
442 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
443 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
444 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
445 { prop_versionW
, CIM_STRING
}
447 static const struct column col_param
[] =
449 { prop_classW
, CIM_STRING
},
450 { prop_methodW
, CIM_STRING
},
451 { prop_directionW
, CIM_SINT32
},
452 { prop_parameterW
, CIM_STRING
},
453 { prop_typeW
, CIM_UINT32
},
454 { prop_varianttypeW
, CIM_UINT32
},
455 { prop_defaultvalueW
, CIM_UINT32
}
457 static const struct column col_physicalmedia
[] =
459 { prop_serialnumberW
, CIM_STRING
},
460 { prop_tagW
, CIM_STRING
}
462 static const struct column col_physicalmemory
[] =
464 { prop_capacityW
, CIM_UINT64
}
466 static const struct column col_process
[] =
468 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
469 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
470 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
471 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
472 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
473 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
474 { prop_processidW
, CIM_UINT32
, VT_I4
},
475 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
477 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
479 static const struct column col_processor
[] =
481 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
482 { prop_cpustatusW
, CIM_UINT16
},
483 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
484 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
485 { prop_familyW
, CIM_UINT16
, VT_I4
},
486 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
487 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
488 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
489 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
490 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
491 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
492 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
493 { prop_uniqueidW
, CIM_STRING
}
495 static const struct column col_qualifier
[] =
497 { prop_classW
, CIM_STRING
},
498 { prop_memberW
, CIM_STRING
},
499 { prop_typeW
, CIM_UINT32
},
500 { prop_flavorW
, CIM_SINT32
},
501 { prop_nameW
, CIM_STRING
},
502 { prop_intvalueW
, CIM_SINT32
},
503 { prop_strvalueW
, CIM_STRING
}
505 static const struct column col_service
[] =
507 { prop_acceptpauseW
, CIM_BOOLEAN
},
508 { prop_acceptstopW
, CIM_BOOLEAN
},
509 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
510 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
511 { prop_processidW
, CIM_UINT32
},
512 { prop_servicetypeW
, CIM_STRING
},
513 { prop_startmodeW
, CIM_STRING
},
514 { prop_stateW
, CIM_STRING
},
515 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
517 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
518 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
519 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
520 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
522 static const struct column col_sid
[] =
524 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
525 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
526 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
527 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
528 { prop_sidlengthW
, CIM_UINT32
}
530 static const struct column col_sounddevice
[] =
532 { prop_nameW
, CIM_STRING
},
533 { prop_productnameW
, CIM_STRING
},
534 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
536 static const struct column col_stdregprov
[] =
538 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
539 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
540 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
542 static const struct column col_systemsecurity
[] =
544 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
545 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
547 static const struct column col_videocontroller
[] =
549 { prop_adapterdactypeW
, CIM_STRING
},
550 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
551 { prop_availabilityW
, CIM_UINT16
},
552 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
553 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
554 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
555 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
556 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
557 { prop_driverversionW
, CIM_STRING
},
558 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
559 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
560 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
563 static const WCHAR baseboard_manufacturerW
[] =
564 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
565 static const WCHAR baseboard_serialnumberW
[] =
567 static const WCHAR baseboard_tagW
[] =
568 {'B','a','s','e',' ','B','o','a','r','d',0};
569 static const WCHAR baseboard_versionW
[] =
571 static const WCHAR bios_descriptionW
[] =
572 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
573 static const WCHAR bios_manufacturerW
[] =
574 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
575 static const WCHAR bios_releasedateW
[] =
576 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
577 static const WCHAR bios_serialnumberW
[] =
579 static const WCHAR bios_smbiosbiosversionW
[] =
581 static const WCHAR bios_versionW
[] =
582 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
583 static const WCHAR cdromdrive_mediatypeW
[] =
584 {'C','D','-','R','O','M',0};
585 static const WCHAR cdromdrive_nameW
[] =
586 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
587 static const WCHAR cdromdrive_pnpdeviceidW
[]=
588 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
589 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
590 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
591 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
592 static const WCHAR compsys_descriptionW
[] =
593 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
594 static const WCHAR compsys_domainW
[] =
595 {'W','O','R','K','G','R','O','U','P',0};
596 static const WCHAR compsys_manufacturerW
[] =
597 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
598 static const WCHAR compsys_modelW
[] =
600 static const WCHAR compsysproduct_identifyingnumberW
[] =
602 static const WCHAR compsysproduct_uuidW
[] =
603 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
604 '0','0','0','0','0','0','0','0','0','0','0','0',0};
605 static const WCHAR diskdrive_interfacetypeW
[] =
607 static const WCHAR diskdrive_manufacturerW
[] =
608 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
609 static const WCHAR diskdrive_mediatype_fixedW
[] =
610 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
611 static const WCHAR diskdrive_mediatype_removableW
[] =
612 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
613 static const WCHAR diskdrive_modelW
[] =
614 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
615 static const WCHAR diskdrive_pnpdeviceidW
[] =
616 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
617 static const WCHAR diskdrive_serialW
[] =
618 {'W','I','N','E','H','D','I','S','K',0};
619 static const WCHAR networkadapter_pnpdeviceidW
[]=
620 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
621 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
622 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
623 static const WCHAR os_32bitW
[] =
624 {'3','2','-','b','i','t',0};
625 static const WCHAR os_64bitW
[] =
626 {'6','4','-','b','i','t',0};
627 static const WCHAR os_buildnumberW
[] =
629 static const WCHAR os_captionW
[] =
630 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
631 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
632 static const WCHAR os_csdversionW
[] =
633 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
634 static const WCHAR os_installdateW
[] =
635 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
636 static const WCHAR os_nameW
[] =
637 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
638 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
639 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
640 '\\','P','a','r','t','i','t','i','o','n','1',0};
641 static const WCHAR os_serialnumberW
[] =
642 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
643 static const WCHAR os_versionW
[] =
644 {'5','.','1','.','2','6','0','0',0};
645 static const WCHAR physicalmedia_tagW
[] =
646 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
647 static const WCHAR sounddevice_productnameW
[] =
648 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
649 static const WCHAR videocontroller_dactypeW
[] =
650 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
651 static const WCHAR videocontroller_deviceidW
[] =
652 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
653 static const WCHAR videocontroller_driverversionW
[] =
656 #include "pshpack1.h"
657 struct record_baseboard
659 const WCHAR
*manufacturer
;
662 const WCHAR
*product
;
663 const WCHAR
*serialnumber
;
665 const WCHAR
*version
;
669 const WCHAR
*description
;
670 const WCHAR
*identificationcode
;
671 const WCHAR
*manufacturer
;
672 const WCHAR
*releasedate
;
673 const WCHAR
*serialnumber
;
674 const WCHAR
*smbiosbiosversion
;
675 const WCHAR
*version
;
677 struct record_cdromdrive
679 const WCHAR
*device_id
;
681 const WCHAR
*mediatype
;
683 const WCHAR
*pnpdevice_id
;
685 struct record_computersystem
687 const WCHAR
*description
;
690 const WCHAR
*manufacturer
;
693 UINT32 num_logical_processors
;
694 UINT32 num_processors
;
695 UINT64 total_physical_memory
;
696 const WCHAR
*username
;
698 struct record_computersystemproduct
700 const WCHAR
*identifyingnumber
;
703 struct record_datafile
706 const WCHAR
*version
;
708 struct record_directory
713 struct record_diskdrive
715 const WCHAR
*device_id
;
717 const WCHAR
*interfacetype
;
718 const WCHAR
*manufacturer
;
719 const WCHAR
*mediatype
;
721 const WCHAR
*pnpdevice_id
;
722 const WCHAR
*serialnumber
;
725 struct record_diskpartition
729 const WCHAR
*device_id
;
732 const WCHAR
*pnpdevice_id
;
734 UINT64 startingoffset
;
737 struct record_logicaldisk
739 const WCHAR
*device_id
;
741 const WCHAR
*filesystem
;
745 const WCHAR
*volumename
;
746 const WCHAR
*volumeserialnumber
;
748 struct record_networkadapter
750 const WCHAR
*adaptertype
;
751 const WCHAR
*device_id
;
753 UINT32 interface_index
;
754 const WCHAR
*mac_address
;
755 const WCHAR
*manufacturer
;
757 UINT16 netconnection_status
;
759 const WCHAR
*pnpdevice_id
;
762 struct record_networkadapterconfig
764 const WCHAR
*dnshostname
;
766 UINT32 ipconnectionmetric
;
768 const WCHAR
*mac_address
;
770 struct record_operatingsystem
772 const WCHAR
*buildnumber
;
773 const WCHAR
*caption
;
774 const WCHAR
*codeset
;
775 const WCHAR
*countrycode
;
776 const WCHAR
*csdversion
;
777 const WCHAR
*installdate
;
778 const WCHAR
*lastbootuptime
;
779 const WCHAR
*localdatetime
;
782 const WCHAR
*osarchitecture
;
784 UINT32 osproductsuite
;
786 const WCHAR
*serialnumber
;
787 UINT16 servicepackmajor
;
788 UINT16 servicepackminor
;
790 const WCHAR
*systemdirectory
;
791 UINT64 totalvisiblememorysize
;
792 const WCHAR
*version
;
799 const WCHAR
*parameter
;
804 struct record_physicalmedia
806 const WCHAR
*serialnumber
;
809 struct record_physicalmemory
813 struct record_process
815 const WCHAR
*caption
;
816 const WCHAR
*commandline
;
817 const WCHAR
*description
;
824 class_method
*get_owner
;
826 struct record_processor
830 UINT32 currentclockspeed
;
831 const WCHAR
*device_id
;
833 const WCHAR
*manufacturer
;
834 UINT32 maxclockspeed
;
837 UINT32 num_logical_processors
;
838 const WCHAR
*processor_id
;
839 UINT16 processortype
;
840 const WCHAR
*unique_id
;
842 struct record_qualifier
850 const WCHAR
*strvalue
;
852 struct record_service
856 const WCHAR
*displayname
;
859 const WCHAR
*servicetype
;
860 const WCHAR
*startmode
;
862 const WCHAR
*systemname
;
864 class_method
*pause_service
;
865 class_method
*resume_service
;
866 class_method
*start_service
;
867 class_method
*stop_service
;
871 const WCHAR
*accountname
;
872 const UINT8
*binaryrepresentation
;
873 const WCHAR
*referenceddomainname
;
877 struct record_sounddevice
880 const WCHAR
*productname
;
883 struct record_stdregprov
885 class_method
*enumkey
;
886 class_method
*enumvalues
;
887 class_method
*getstringvalue
;
889 struct record_systemsecurity
894 struct record_videocontroller
896 const WCHAR
*adapter_dactype
;
899 UINT32 current_bitsperpixel
;
900 UINT32 current_horizontalres
;
901 UINT32 current_verticalres
;
902 const WCHAR
*description
;
903 const WCHAR
*device_id
;
904 const WCHAR
*driverversion
;
906 const WCHAR
*pnpdevice_id
;
907 const WCHAR
*videoprocessor
;
911 static const struct record_baseboard data_baseboard
[] =
913 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
915 static const struct record_bios data_bios
[] =
917 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
918 bios_smbiosbiosversionW
, bios_versionW
}
920 static const struct record_computersystemproduct data_compsysproduct
[] =
922 { compsysproduct_identifyingnumberW
, compsysproduct_uuidW
}
924 static const struct record_param data_param
[] =
926 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
927 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
928 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
929 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
930 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
931 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
932 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
933 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
934 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
935 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
936 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
937 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
938 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
939 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
940 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
941 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
942 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
943 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
944 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
945 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
946 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
947 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
948 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
949 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
950 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
953 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
954 WBEM_FLAVOR_ORIGIN_PROPAGATED)
956 static const struct record_physicalmedia data_physicalmedia
[] =
958 { diskdrive_serialW
, physicalmedia_tagW
}
960 static const struct record_qualifier data_qualifier
[] =
962 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
963 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
965 static const struct record_sounddevice data_sounddevice
[] =
967 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
969 static const struct record_stdregprov data_stdregprov
[] =
971 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
973 static const struct record_systemsecurity data_systemsecurity
[] =
975 { security_get_sd
, security_set_sd
}
978 /* check if row matches condition and update status */
979 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
986 *status
= FILL_STATUS_UNFILTERED
;
989 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
991 *status
= FILL_STATUS_FAILED
;
994 *status
= FILL_STATUS_FILTERED
;
998 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1000 if (!table
->num_rows_allocated
)
1002 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1003 table
->num_rows_allocated
= row_count
;
1006 if (row_count
>= table
->num_rows_allocated
)
1009 UINT count
= table
->num_rows_allocated
* 2;
1010 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1012 table
->num_rows_allocated
= count
;
1017 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1019 static const WCHAR fmtW
[] = {'%','c',':',0};
1020 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1021 struct record_cdromdrive
*rec
;
1022 UINT i
, row
= 0, offset
= 0;
1023 DWORD drives
= GetLogicalDrives();
1024 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1026 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1028 for (i
= 0; i
< sizeof(drives
); i
++)
1030 if (drives
& (1 << i
))
1033 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1036 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1038 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1039 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1040 sprintfW( drive
, fmtW
, 'A' + i
);
1041 rec
->drive
= heap_strdupW( drive
);
1042 rec
->mediatype
= cdromdrive_mediatypeW
;
1043 rec
->name
= cdromdrive_nameW
;
1044 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1045 if (!match_row( table
, row
, cond
, &status
))
1047 free_row_values( table
, row
);
1050 offset
+= sizeof(*rec
);
1054 TRACE("created %u rows\n", row
);
1055 table
->num_rows
= row
;
1059 static UINT
get_processor_count(void)
1061 SYSTEM_BASIC_INFORMATION info
;
1063 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1064 return info
.NumberOfProcessors
;
1067 static UINT
get_logical_processor_count( UINT
*num_cores
)
1069 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1070 UINT i
, j
, count
= 0;
1074 if (num_cores
) *num_cores
= get_processor_count();
1075 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1076 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1078 if (!(info
= heap_alloc( len
))) return get_processor_count();
1079 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1080 if (status
!= STATUS_SUCCESS
)
1083 return get_processor_count();
1085 if (num_cores
) *num_cores
= 0;
1086 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1088 if (info
[i
].Relationship
== RelationProcessorCore
)
1090 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1092 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1094 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1101 static UINT64
get_total_physical_memory(void)
1103 MEMORYSTATUSEX status
;
1105 status
.dwLength
= sizeof(status
);
1106 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1107 return status
.ullTotalPhys
;
1110 static WCHAR
*get_computername(void)
1113 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1115 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1116 GetComputerNameW( ret
, &size
);
1120 static WCHAR
*get_username(void)
1123 DWORD compsize
, usersize
;
1127 GetComputerNameW( NULL
, &compsize
);
1129 GetUserNameW( NULL
, &usersize
);
1130 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1131 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1132 GetComputerNameW( ret
, &compsize
);
1133 ret
[compsize
] = '\\';
1134 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1138 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1140 struct record_computersystem
*rec
;
1141 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1144 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1146 rec
= (struct record_computersystem
*)table
->data
;
1147 rec
->description
= compsys_descriptionW
;
1148 rec
->domain
= compsys_domainW
;
1149 rec
->domainrole
= 0; /* standalone workstation */
1150 rec
->manufacturer
= compsys_manufacturerW
;
1151 rec
->model
= compsys_modelW
;
1152 rec
->name
= get_computername();
1153 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1154 rec
->num_processors
= get_processor_count();
1155 rec
->total_physical_memory
= get_total_physical_memory();
1156 rec
->username
= get_username();
1157 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1160 TRACE("created %u rows\n", row
);
1161 table
->num_rows
= row
;
1173 static struct dirstack
*alloc_dirstack( UINT size
)
1175 struct dirstack
*dirstack
;
1177 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1178 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1180 heap_free( dirstack
);
1183 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1185 heap_free( dirstack
->dirs
);
1186 heap_free( dirstack
);
1189 dirstack
->num_dirs
= 0;
1190 dirstack
->num_allocated
= size
;
1194 static void clear_dirstack( struct dirstack
*dirstack
)
1197 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1198 dirstack
->num_dirs
= 0;
1201 static void free_dirstack( struct dirstack
*dirstack
)
1203 clear_dirstack( dirstack
);
1204 heap_free( dirstack
->dirs
);
1205 heap_free( dirstack
->len_dirs
);
1206 heap_free( dirstack
);
1209 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1211 UINT size
, i
= dirstack
->num_dirs
;
1213 if (!dir
) return FALSE
;
1215 if (i
== dirstack
->num_allocated
)
1220 size
= dirstack
->num_allocated
* 2;
1221 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1222 dirstack
->dirs
= tmp
;
1223 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1224 dirstack
->len_dirs
= len_tmp
;
1225 dirstack
->num_allocated
= size
;
1227 dirstack
->dirs
[i
] = dir
;
1228 dirstack
->len_dirs
[i
] = len
;
1229 dirstack
->num_dirs
++;
1233 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1235 if (!dirstack
->num_dirs
)
1240 dirstack
->num_dirs
--;
1241 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1242 return dirstack
->dirs
[dirstack
->num_dirs
];
1245 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1247 if (!dirstack
->num_dirs
) return NULL
;
1248 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1251 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1256 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1262 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1271 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1273 UINT i
= 0, len
= 0;
1277 for (p
= path
; *p
; p
++)
1279 if (*p
== '\\') len
+= 2;
1282 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1287 for (p
= path
; *p
; p
++)
1289 if (*p
!= '\\') ret
[i
++] = *p
;
1300 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1302 const WCHAR
*p
= path
, *start
;
1306 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1308 len
= strlenW( start
);
1309 p
= start
+ len
- 1;
1310 if (*p
== '\\') return NULL
;
1312 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1313 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1315 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1316 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1318 if (p
[0] == '\\' && p
[1] == '\\')
1330 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1333 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1337 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1338 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1340 const struct expr
*left
, *right
;
1342 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1344 left
= cond
->u
.expr
.left
;
1345 right
= cond
->u
.expr
.right
;
1346 if (cond
->u
.expr
.op
== OP_EQ
)
1350 const WCHAR
*str
= NULL
;
1352 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1353 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1354 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1356 str
= right
->u
.sval
;
1358 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1359 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1360 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1364 if (str
&& (path
= build_dirname( str
, &len
)))
1366 if (seen_dir( dirstack
, path
))
1371 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1376 else if (cond
->u
.expr
.op
== OP_OR
)
1378 UINT left_count
= 0, right_count
= 0;
1380 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1381 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1382 return *count
+= left_count
+ right_count
;
1387 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1389 UINT len_path
= 0, len_segment
= strlenW( segment
);
1393 if (path
) len_path
= strlenW( path
);
1394 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1395 if (path
&& len_path
)
1397 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1398 ret
[len_path
] = '\\';
1399 *len
+= len_path
+ 1;
1401 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1402 *len
+= len_segment
;
1407 static WCHAR
*get_file_version( const WCHAR
*filename
)
1409 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1410 VS_FIXEDFILEINFO
*info
;
1415 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1416 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1421 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1422 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1428 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1429 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1434 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1436 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1437 struct record_datafile
*rec
;
1438 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1439 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1440 DWORD drives
= GetLogicalDrives();
1441 WIN32_FIND_DATAW data
;
1443 struct dirstack
*dirstack
;
1444 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1446 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1448 dirstack
= alloc_dirstack(2);
1450 for (i
= 0; i
< sizeof(drives
); i
++)
1452 if (!(drives
& (1 << i
))) continue;
1455 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1457 num_expected_rows
= 0;
1458 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1462 path
= pop_dir( dirstack
, &len
);
1463 if (!(glob
= build_glob( root
[0], path
, len
)))
1465 status
= FILL_STATUS_FAILED
;
1468 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1472 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1474 status
= FILL_STATUS_FAILED
;
1475 FindClose( handle
);
1478 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1479 new_path
= append_path( path
, data
.cFileName
, &len
);
1481 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1483 if (push_dir( dirstack
, new_path
, len
)) continue;
1484 heap_free( new_path
);
1485 FindClose( handle
);
1486 status
= FILL_STATUS_FAILED
;
1489 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1490 rec
->name
= build_name( root
[0], new_path
);
1491 rec
->version
= get_file_version( rec
->name
);
1492 if (!match_row( table
, row
, cond
, &status
))
1494 free_row_values( table
, row
);
1497 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1500 FindClose( handle
);
1501 status
= FILL_STATUS_FILTERED
;
1504 offset
+= sizeof(*rec
);
1507 while (FindNextFileW( handle
, &data
));
1508 FindClose( handle
);
1510 if (!peek_dir( dirstack
)) break;
1517 free_dirstack( dirstack
);
1521 TRACE("created %u rows\n", row
);
1522 table
->num_rows
= row
;
1526 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1528 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1529 struct record_directory
*rec
;
1530 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1531 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1532 DWORD drives
= GetLogicalDrives();
1533 WIN32_FIND_DATAW data
;
1535 struct dirstack
*dirstack
;
1536 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1538 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1540 dirstack
= alloc_dirstack(2);
1542 for (i
= 0; i
< sizeof(drives
); i
++)
1544 if (!(drives
& (1 << i
))) continue;
1547 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1549 num_expected_rows
= 0;
1550 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1554 path
= pop_dir( dirstack
, &len
);
1555 if (!(glob
= build_glob( root
[0], path
, len
)))
1557 status
= FILL_STATUS_FAILED
;
1560 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1564 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1566 FindClose( handle
);
1567 status
= FILL_STATUS_FAILED
;
1570 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1571 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1574 new_path
= append_path( path
, data
.cFileName
, &len
);
1575 if (!(push_dir( dirstack
, new_path
, len
)))
1577 heap_free( new_path
);
1578 FindClose( handle
);
1579 status
= FILL_STATUS_FAILED
;
1582 rec
= (struct record_directory
*)(table
->data
+ offset
);
1583 rec
->accessmask
= FILE_ALL_ACCESS
;
1584 rec
->name
= build_name( root
[0], new_path
);
1585 if (!match_row( table
, row
, cond
, &status
))
1587 free_row_values( table
, row
);
1590 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1593 FindClose( handle
);
1594 status
= FILL_STATUS_FILTERED
;
1597 offset
+= sizeof(*rec
);
1600 while (FindNextFileW( handle
, &data
));
1601 FindClose( handle
);
1603 if (!peek_dir( dirstack
)) break;
1610 free_dirstack( dirstack
);
1614 TRACE("created %u rows\n", row
);
1615 table
->num_rows
= row
;
1619 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1621 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1622 ULARGE_INTEGER free
;
1623 DISK_GEOMETRY_EX info
;
1625 DWORD bytes_returned
;
1627 free
.QuadPart
= 512 * 1024 * 1024;
1628 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1631 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1632 if (handle
!= INVALID_HANDLE_VALUE
)
1634 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1635 *disksize
= info
.DiskSize
.QuadPart
;
1636 CloseHandle( handle
);
1638 return free
.QuadPart
;
1641 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1643 static const WCHAR fmtW
[] =
1644 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1645 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1646 struct record_diskdrive
*rec
;
1647 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1648 UINT64 size
= 1024 * 1024 * 1024;
1649 DWORD drives
= GetLogicalDrives();
1650 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1652 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1654 for (i
= 0; i
< sizeof(drives
); i
++)
1656 if (drives
& (1 << i
))
1659 type
= GetDriveTypeW( root
);
1660 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1663 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1665 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1666 sprintfW( device_id
, fmtW
, index
);
1667 rec
->device_id
= heap_strdupW( device_id
);
1669 rec
->interfacetype
= diskdrive_interfacetypeW
;
1670 rec
->manufacturer
= diskdrive_manufacturerW
;
1671 if (type
== DRIVE_FIXED
)
1672 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1674 rec
->mediatype
= diskdrive_mediatype_removableW
;
1675 rec
->model
= diskdrive_modelW
;
1676 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1677 rec
->serialnumber
= diskdrive_serialW
;
1678 get_freespace( root
, &size
);
1680 if (!match_row( table
, row
, cond
, &status
))
1682 free_row_values( table
, row
);
1685 offset
+= sizeof(*rec
);
1690 TRACE("created %u rows\n", row
);
1691 table
->num_rows
= row
;
1695 static WCHAR
*get_filesystem( const WCHAR
*root
)
1697 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1698 WCHAR buffer
[MAX_PATH
+ 1];
1700 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1701 return heap_strdupW( buffer
);
1702 return heap_strdupW( ntfsW
);
1705 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1707 static const WCHAR fmtW
[] =
1708 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1709 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1710 struct record_diskpartition
*rec
;
1711 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1712 UINT64 size
= 1024 * 1024 * 1024;
1713 DWORD drives
= GetLogicalDrives();
1714 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1716 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1718 for (i
= 0; i
< sizeof(drives
); i
++)
1720 if (drives
& (1 << i
))
1723 type
= GetDriveTypeW( root
);
1724 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1727 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1729 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1730 rec
->bootable
= (i
== 2) ? -1 : 0;
1731 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1732 sprintfW( device_id
, fmtW
, index
);
1733 rec
->device_id
= heap_strdupW( device_id
);
1734 rec
->diskindex
= index
;
1736 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1737 get_freespace( root
, &size
);
1739 rec
->startingoffset
= 0;
1740 rec
->type
= get_filesystem( root
);
1741 if (!match_row( table
, row
, cond
, &status
))
1743 free_row_values( table
, row
);
1746 offset
+= sizeof(*rec
);
1751 TRACE("created %u rows\n", row
);
1752 table
->num_rows
= row
;
1756 static WCHAR
*get_volumename( const WCHAR
*root
)
1758 WCHAR buf
[MAX_PATH
+ 1] = {0};
1759 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1760 return heap_strdupW( buf
);
1762 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1764 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1768 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1769 sprintfW( buffer
, fmtW
, serial
);
1770 return heap_strdupW( buffer
);
1773 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1775 static const WCHAR fmtW
[] = {'%','c',':',0};
1776 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1777 struct record_logicaldisk
*rec
;
1778 UINT i
, row
= 0, offset
= 0, type
;
1779 UINT64 size
= 1024 * 1024 * 1024;
1780 DWORD drives
= GetLogicalDrives();
1781 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1783 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1785 for (i
= 0; i
< sizeof(drives
); i
++)
1787 if (drives
& (1 << i
))
1790 type
= GetDriveTypeW( root
);
1791 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1794 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1796 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1797 sprintfW( device_id
, fmtW
, 'A' + i
);
1798 rec
->device_id
= heap_strdupW( device_id
);
1799 rec
->drivetype
= type
;
1800 rec
->filesystem
= get_filesystem( root
);
1801 rec
->freespace
= get_freespace( root
, &size
);
1802 rec
->name
= heap_strdupW( device_id
);
1804 rec
->volumename
= get_volumename( root
);
1805 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1806 if (!match_row( table
, row
, cond
, &status
))
1808 free_row_values( table
, row
);
1811 offset
+= sizeof(*rec
);
1815 TRACE("created %u rows\n", row
);
1816 table
->num_rows
= row
;
1820 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1824 case IfOperStatusDown
:
1825 return 0; /* Disconnected */
1826 case IfOperStatusUp
:
1827 return 2; /* Connected */
1829 ERR("unhandled status %u\n", status
);
1834 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1836 static const WCHAR fmtW
[] =
1837 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1838 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1841 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1842 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1845 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1847 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1848 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1849 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1850 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1854 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1855 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1856 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1857 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1858 default: *physical
= 0; return NULL
;
1862 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1864 static const WCHAR fmtW
[] = {'%','u',0};
1865 WCHAR device_id
[11];
1866 struct record_networkadapter
*rec
;
1867 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1868 UINT row
= 0, offset
= 0, count
= 0;
1869 DWORD size
= 0, ret
;
1871 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1873 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1874 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1876 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1877 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1879 heap_free( buffer
);
1880 return FILL_STATUS_FAILED
;
1882 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1884 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1886 if (!resize_table( table
, count
, sizeof(*rec
) ))
1888 heap_free( buffer
);
1889 return FILL_STATUS_FAILED
;
1891 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1893 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1895 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1896 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1897 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1898 rec
->device_id
= heap_strdupW( device_id
);
1899 rec
->index
= aa
->u
.s
.IfIndex
;
1900 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1901 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1902 rec
->manufacturer
= compsys_manufacturerW
;
1903 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1904 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1905 rec
->physicaladapter
= physical
;
1906 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1907 rec
->speed
= 1000000;
1908 if (!match_row( table
, row
, cond
, &status
))
1910 free_row_values( table
, row
);
1913 offset
+= sizeof(*rec
);
1916 TRACE("created %u rows\n", row
);
1917 table
->num_rows
= row
;
1919 heap_free( buffer
);
1923 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
1925 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
1926 WCHAR buf
[NI_MAXHOST
];
1928 if (!addr
) return NULL
;
1929 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
1930 0, NI_NAMEREQD
)) return NULL
;
1931 return heap_strdupW( buf
);
1934 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1936 struct record_networkadapterconfig
*rec
;
1937 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1938 UINT row
= 0, offset
= 0, count
= 0;
1939 DWORD size
= 0, ret
;
1940 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1942 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1943 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1945 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1946 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1948 heap_free( buffer
);
1949 return FILL_STATUS_FAILED
;
1951 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1953 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1955 if (!resize_table( table
, count
, sizeof(*rec
) ))
1957 heap_free( buffer
);
1958 return FILL_STATUS_FAILED
;
1960 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1962 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1964 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1965 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
1966 rec
->index
= aa
->u
.s
.IfIndex
;
1967 rec
->ipconnectionmetric
= 20;
1968 rec
->ipenabled
= -1;
1969 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1970 if (!match_row( table
, row
, cond
, &status
))
1972 free_row_values( table
, row
);
1975 offset
+= sizeof(*rec
);
1978 TRACE("created %u rows\n", row
);
1979 table
->num_rows
= row
;
1981 heap_free( buffer
);
1985 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
1987 struct record_physicalmemory
*rec
;
1988 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1991 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1993 rec
= (struct record_physicalmemory
*)table
->data
;
1994 rec
->capacity
= get_total_physical_memory();
1995 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1998 TRACE("created %u rows\n", row
);
1999 table
->num_rows
= row
;
2003 static WCHAR
*get_cmdline( DWORD process_id
)
2005 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2006 return NULL
; /* FIXME handle different process case */
2009 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2011 static const WCHAR fmtW
[] = {'%','u',0};
2013 struct record_process
*rec
;
2014 PROCESSENTRY32W entry
;
2016 enum fill_status status
= FILL_STATUS_FAILED
;
2017 UINT row
= 0, offset
= 0;
2019 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2020 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2022 entry
.dwSize
= sizeof(entry
);
2023 if (!Process32FirstW( snap
, &entry
)) goto done
;
2024 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2028 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2030 rec
= (struct record_process
*)(table
->data
+ offset
);
2031 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2032 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2033 rec
->description
= heap_strdupW( entry
.szExeFile
);
2034 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2035 rec
->handle
= heap_strdupW( handle
);
2036 rec
->name
= heap_strdupW( entry
.szExeFile
);
2037 rec
->process_id
= entry
.th32ProcessID
;
2038 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2039 rec
->thread_count
= entry
.cntThreads
;
2040 rec
->get_owner
= process_get_owner
;
2041 if (!match_row( table
, row
, cond
, &status
))
2043 free_row_values( table
, row
);
2046 offset
+= sizeof(*rec
);
2048 } while (Process32NextW( snap
, &entry
));
2050 TRACE("created %u rows\n", row
);
2051 table
->num_rows
= row
;
2052 status
= FILL_STATUS_UNFILTERED
;
2055 CloseHandle( snap
);
2059 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2065 __asm__("pushl %%ebx\n\t"
2067 "movl %%ebx, %%esi\n\t"
2069 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2075 static void get_processor_id( WCHAR
*processor_id
)
2077 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2078 unsigned int regs
[4] = {0, 0, 0, 0};
2080 do_cpuid( 1, regs
);
2081 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2083 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2086 unsigned char *p
= (unsigned char *)regs
;
2088 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2091 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2093 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2095 do_cpuid( 0, regs
);
2096 tmp
= regs
[2]; /* swap edx and ecx */
2100 regs_to_str( regs
+ 1, 12, manufacturer
);
2102 static void get_processor_name( WCHAR
*name
)
2104 unsigned int regs
[4] = {0, 0, 0, 0};
2106 do_cpuid( 0x80000000, regs
);
2107 if (regs
[0] >= 0x80000004)
2109 do_cpuid( 0x80000002, regs
);
2110 regs_to_str( regs
, 16, name
);
2111 do_cpuid( 0x80000003, regs
);
2112 regs_to_str( regs
, 16, name
+ 16 );
2113 do_cpuid( 0x80000004, regs
);
2114 regs_to_str( regs
, 16, name
+ 32 );
2117 static UINT
get_processor_currentclockspeed( UINT index
)
2119 PROCESSOR_POWER_INFORMATION
*info
;
2120 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2123 if ((info
= heap_alloc( size
)))
2125 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2126 if (!status
) ret
= info
[index
].CurrentMhz
;
2131 static UINT
get_processor_maxclockspeed( UINT index
)
2133 PROCESSOR_POWER_INFORMATION
*info
;
2134 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2137 if ((info
= heap_alloc( size
)))
2139 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2140 if (!status
) ret
= info
[index
].MaxMhz
;
2145 static const WCHAR
*get_osarchitecture(void)
2148 GetNativeSystemInfo( &info
);
2149 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2153 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2155 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2156 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2157 struct record_processor
*rec
;
2158 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2159 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2161 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2163 get_processor_id( processor_id
);
2164 get_processor_manufacturer( manufacturer
);
2165 get_processor_name( name
);
2167 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2170 for (i
= 0; i
< count
; i
++)
2172 rec
= (struct record_processor
*)(table
->data
+ offset
);
2173 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2174 rec
->cpu_status
= 1; /* CPU Enabled */
2175 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2176 sprintfW( device_id
, fmtW
, i
);
2177 rec
->device_id
= heap_strdupW( device_id
);
2178 rec
->family
= 2; /* Unknown */
2179 rec
->manufacturer
= heap_strdupW( manufacturer
);
2180 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2181 rec
->name
= heap_strdupW( name
);
2182 rec
->num_cores
= num_cores
;
2183 rec
->num_logical_processors
= num_logical_processors
;
2184 rec
->processor_id
= heap_strdupW( processor_id
);
2185 rec
->processortype
= 3; /* central processor */
2186 rec
->unique_id
= NULL
;
2187 if (!match_row( table
, i
, cond
, &status
))
2189 free_row_values( table
, i
);
2192 offset
+= sizeof(*rec
);
2195 TRACE("created %u rows\n", count
);
2196 table
->num_rows
= count
;
2200 static WCHAR
*get_lastbootuptime(void)
2202 static const WCHAR fmtW
[] =
2203 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2204 '.','%','0','6','u','+','0','0','0',0};
2205 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2209 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2211 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2212 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2213 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2216 static WCHAR
*get_localdatetime(void)
2218 static const WCHAR fmtW
[] =
2219 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2220 '.','%','0','6','u','%','+','0','3','d',0};
2221 TIME_ZONE_INFORMATION tzi
;
2227 Status
= GetTimeZoneInformation(&tzi
);
2229 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2231 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2232 Bias
+= tzi
.DaylightBias
;
2234 Bias
+= tzi
.StandardBias
;
2235 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2238 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2241 static WCHAR
*get_systemdirectory(void)
2246 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2247 Wow64DisableWow64FsRedirection( &redir
);
2248 GetSystemDirectoryW( ret
, MAX_PATH
);
2249 Wow64RevertWow64FsRedirection( redir
);
2252 static WCHAR
*get_codeset(void)
2254 static const WCHAR fmtW
[] = {'%','u',0};
2255 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2256 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2259 static WCHAR
*get_countrycode(void)
2261 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2262 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2265 static WCHAR
*get_locale(void)
2267 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2268 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2272 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2274 struct record_operatingsystem
*rec
;
2275 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2278 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2280 rec
= (struct record_operatingsystem
*)table
->data
;
2281 rec
->buildnumber
= os_buildnumberW
;
2282 rec
->caption
= os_captionW
;
2283 rec
->codeset
= get_codeset();
2284 rec
->countrycode
= get_countrycode();
2285 rec
->csdversion
= os_csdversionW
;
2286 rec
->installdate
= os_installdateW
;
2287 rec
->lastbootuptime
= get_lastbootuptime();
2288 rec
->localdatetime
= get_localdatetime();
2289 rec
->locale
= get_locale();
2290 rec
->name
= os_nameW
;
2291 rec
->osarchitecture
= get_osarchitecture();
2292 rec
->oslanguage
= GetSystemDefaultLangID();
2293 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2294 rec
->ostype
= 18; /* WINNT */
2295 rec
->serialnumber
= os_serialnumberW
;
2296 rec
->servicepackmajor
= 3;
2297 rec
->servicepackminor
= 0;
2298 rec
->suitemask
= 272; /* Single User + Terminal */
2299 rec
->systemdirectory
= get_systemdirectory();
2300 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2301 rec
->version
= os_versionW
;
2302 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2305 TRACE("created %u rows\n", row
);
2306 table
->num_rows
= row
;
2310 static const WCHAR
*get_service_type( DWORD type
)
2312 static const WCHAR filesystem_driverW
[] =
2313 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2314 static const WCHAR kernel_driverW
[] =
2315 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2316 static const WCHAR own_processW
[] =
2317 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2318 static const WCHAR share_processW
[] =
2319 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2321 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2322 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2323 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2324 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2325 else ERR("unhandled type 0x%08x\n", type
);
2328 static const WCHAR
*get_service_state( DWORD state
)
2330 static const WCHAR runningW
[] =
2331 {'R','u','n','n','i','n','g',0};
2332 static const WCHAR start_pendingW
[] =
2333 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2334 static const WCHAR stop_pendingW
[] =
2335 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2336 static const WCHAR stoppedW
[] =
2337 {'S','t','o','p','p','e','d',0};
2338 static const WCHAR unknownW
[] =
2339 {'U','n','k','n','o','w','n',0};
2343 case SERVICE_STOPPED
: return stoppedW
;
2344 case SERVICE_START_PENDING
: return start_pendingW
;
2345 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2346 case SERVICE_RUNNING
: return runningW
;
2348 ERR("unknown state %u\n", state
);
2352 static const WCHAR
*get_service_startmode( DWORD mode
)
2354 static const WCHAR bootW
[] = {'B','o','o','t',0};
2355 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2356 static const WCHAR autoW
[] = {'A','u','t','o',0};
2357 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2358 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2359 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2363 case SERVICE_BOOT_START
: return bootW
;
2364 case SERVICE_SYSTEM_START
: return systemW
;
2365 case SERVICE_AUTO_START
: return autoW
;
2366 case SERVICE_DEMAND_START
: return manualW
;
2367 case SERVICE_DISABLED
: return disabledW
;
2369 ERR("unknown mode 0x%x\n", mode
);
2373 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2375 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2379 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2380 QueryServiceConfigW( service
, NULL
, 0, &size
);
2381 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2382 if (!(config
= heap_alloc( size
))) goto done
;
2383 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2384 heap_free( config
);
2388 CloseServiceHandle( service
);
2392 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2394 struct record_service
*rec
;
2396 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2397 SERVICE_STATUS_PROCESS
*status
;
2398 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2399 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2400 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2401 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2404 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2405 if (!(services
= heap_alloc( size
))) goto done
;
2407 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2408 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2409 &count
, NULL
, NULL
);
2412 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2414 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2416 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2417 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2418 &count
, NULL
, NULL
);
2419 if (!ret
) goto done
;
2421 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2423 GetComputerNameW( sysnameW
, &len
);
2424 fill_status
= FILL_STATUS_UNFILTERED
;
2426 for (i
= 0; i
< count
; i
++)
2428 QUERY_SERVICE_CONFIGW
*config
;
2430 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2432 status
= &services
[i
].ServiceStatusProcess
;
2433 rec
= (struct record_service
*)(table
->data
+ offset
);
2434 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2435 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2436 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2437 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2438 rec
->process_id
= status
->dwProcessId
;
2439 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2440 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2441 rec
->state
= get_service_state( status
->dwCurrentState
);
2442 rec
->systemname
= heap_strdupW( sysnameW
);
2443 rec
->pause_service
= service_pause_service
;
2444 rec
->resume_service
= service_resume_service
;
2445 rec
->start_service
= service_start_service
;
2446 rec
->stop_service
= service_stop_service
;
2447 heap_free( config
);
2448 if (!match_row( table
, row
, cond
, &fill_status
))
2450 free_row_values( table
, row
);
2453 offset
+= sizeof(*rec
);
2457 TRACE("created %u rows\n", row
);
2458 table
->num_rows
= row
;
2461 CloseServiceHandle( manager
);
2462 heap_free( services
);
2466 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2468 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2469 return heap_strdupW( name
->Name
.Buffer
);
2471 static UINT8
*get_binaryrepresentation( PSID sid
, UINT len
)
2473 UINT8
*ret
= heap_alloc( len
);
2474 if (!ret
) return NULL
;
2475 memcpy( ret
, sid
, len
);
2478 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2480 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2481 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2483 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2485 const struct expr
*left
, *right
;
2486 const WCHAR
*ret
= NULL
;
2488 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2490 left
= cond
->u
.expr
.left
;
2491 right
= cond
->u
.expr
.right
;
2492 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2494 ret
= right
->u
.sval
;
2496 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2503 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2506 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2507 LSA_TRANSLATED_NAME
*name
;
2509 LSA_OBJECT_ATTRIBUTES attrs
;
2511 struct record_sid
*rec
;
2514 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
2515 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2517 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
2518 len
= GetLengthSid( sid
);
2520 memset( &attrs
, 0, sizeof(attrs
) );
2521 attrs
.Length
= sizeof(attrs
);
2522 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
2525 return FILL_STATUS_FAILED
;
2527 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
2531 return FILL_STATUS_FAILED
;
2534 rec
= (struct record_sid
*)table
->data
;
2535 rec
->accountname
= get_accountname( name
);
2536 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
2537 rec
->referenceddomainname
= get_referenceddomainname( domain
);
2538 rec
->sid
= heap_strdupW( str
);
2539 rec
->sidlength
= len
;
2541 TRACE("created 1 row\n");
2542 table
->num_rows
= 1;
2544 LsaFreeMemory( domain
);
2545 LsaFreeMemory( name
);
2548 return FILL_STATUS_FILTERED
;
2551 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2553 HDC hdc
= GetDC( NULL
);
2556 if (!hdc
) return 32;
2557 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2558 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2559 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2560 ReleaseDC( NULL
, hdc
);
2563 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2565 static const WCHAR fmtW
[] =
2566 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2567 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2568 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2571 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2572 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2576 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2579 struct record_videocontroller
*rec
;
2581 IDXGIFactory
*factory
= NULL
;
2582 IDXGIAdapter
*adapter
= NULL
;
2583 DXGI_ADAPTER_DESC desc
;
2584 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2585 const WCHAR
*name
= videocontroller_deviceidW
;
2586 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2589 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2591 memset (&desc
, 0, sizeof(desc
));
2592 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2593 if (FAILED(hr
)) goto done
;
2595 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2596 if (FAILED(hr
)) goto done
;
2598 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2601 vidmem
= desc
.DedicatedVideoMemory
;
2602 name
= desc
.Description
;
2606 rec
= (struct record_videocontroller
*)table
->data
;
2607 rec
->adapter_dactype
= videocontroller_dactypeW
;
2608 rec
->adapter_ram
= vidmem
;
2609 rec
->availability
= 3; /* Running or Full Power */
2610 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2611 rec
->current_horizontalres
= hres
;
2612 rec
->current_verticalres
= vres
;
2613 rec
->description
= heap_strdupW( name
);
2614 rec
->device_id
= videocontroller_deviceidW
;
2615 rec
->driverversion
= videocontroller_driverversionW
;
2616 rec
->name
= heap_strdupW( name
);
2617 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2618 rec
->videoprocessor
= heap_strdupW( name
);
2619 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2622 TRACE("created %u rows\n", row
);
2623 table
->num_rows
= row
;
2625 if (adapter
) IDXGIAdapter_Release( adapter
);
2626 if (factory
) IDXGIFactory_Release( factory
);
2630 static struct table builtin_classes
[] =
2632 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2633 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2634 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2635 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2636 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, SIZEOF(data_compsysproduct
), 0, (BYTE
*)data_compsysproduct
},
2637 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2638 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2639 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2640 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2641 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2642 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2643 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2644 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
2645 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2646 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2647 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2648 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2649 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2650 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2651 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2652 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2653 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2654 { class_sidW
, SIZEOF(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
2655 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2656 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2657 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2658 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2661 void init_table_list( void )
2663 static struct list tables
= LIST_INIT( tables
);
2666 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2667 table_list
= &tables
;