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_uuidW
[] =
296 static const WCHAR prop_varianttypeW
[] =
297 {'V','a','r','i','a','n','t','T','y','p','e',0};
298 static const WCHAR prop_versionW
[] =
299 {'V','e','r','s','i','o','n',0};
300 static const WCHAR prop_videoprocessorW
[] =
301 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
302 static const WCHAR prop_volumenameW
[] =
303 {'V','o','l','u','m','e','N','a','m','e',0};
304 static const WCHAR prop_volumeserialnumberW
[] =
305 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
307 /* column definitions must be kept in sync with record structures below */
308 static const struct column col_baseboard
[] =
310 { prop_manufacturerW
, CIM_STRING
},
311 { prop_modelW
, CIM_STRING
},
312 { prop_nameW
, CIM_STRING
},
313 { prop_productW
, CIM_STRING
},
314 { prop_serialnumberW
, CIM_STRING
},
315 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
316 { prop_versionW
, CIM_STRING
}
318 static const struct column col_bios
[] =
320 { prop_descriptionW
, CIM_STRING
},
321 { prop_identificationcodeW
, CIM_STRING
},
322 { prop_manufacturerW
, CIM_STRING
},
323 { prop_releasedateW
, CIM_DATETIME
},
324 { prop_serialnumberW
, CIM_STRING
},
325 { prop_smbiosbiosversionW
, CIM_STRING
},
326 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
328 static const struct column col_cdromdrive
[] =
330 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
331 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
332 { prop_mediatypeW
, CIM_STRING
},
333 { prop_nameW
, CIM_STRING
},
334 { prop_pnpdeviceidW
, CIM_STRING
}
336 static const struct column col_compsys
[] =
338 { prop_descriptionW
, CIM_STRING
},
339 { prop_domainW
, CIM_STRING
},
340 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
341 { prop_manufacturerW
, CIM_STRING
},
342 { prop_modelW
, CIM_STRING
},
343 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
344 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
345 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
346 { prop_totalphysicalmemoryW
, CIM_UINT64
}
348 static const struct column col_compsysproduct
[] =
350 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
351 { prop_uuidW
, CIM_STRING
}
353 static const struct column col_datafile
[] =
355 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
356 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
358 static const struct column col_directory
[] =
360 { prop_accessmaskW
, CIM_UINT32
},
361 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
363 static const struct column col_diskdrive
[] =
365 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
366 { prop_indexW
, CIM_UINT32
, VT_I4
},
367 { prop_interfacetypeW
, CIM_STRING
},
368 { prop_manufacturerW
, CIM_STRING
},
369 { prop_mediatypeW
, CIM_STRING
},
370 { prop_modelW
, CIM_STRING
},
371 { prop_pnpdeviceidW
, CIM_STRING
},
372 { prop_serialnumberW
, CIM_STRING
},
373 { prop_sizeW
, CIM_UINT64
}
375 static const struct column col_diskpartition
[] =
377 { prop_bootableW
, CIM_BOOLEAN
},
378 { prop_bootpartitionW
, CIM_BOOLEAN
},
379 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
380 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
381 { prop_indexW
, CIM_UINT32
, VT_I4
},
382 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
383 { prop_sizeW
, CIM_UINT64
},
384 { prop_startingoffsetW
, CIM_UINT64
},
385 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
387 static const struct column col_logicaldisk
[] =
389 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
390 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
391 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
392 { prop_freespaceW
, CIM_UINT64
},
393 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
394 { prop_sizeW
, CIM_UINT64
},
395 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
396 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
398 static const struct column col_networkadapter
[] =
400 { prop_adaptertypeW
, CIM_STRING
},
401 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
402 { prop_indexW
, CIM_UINT32
, VT_I4
},
403 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
404 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
405 { prop_manufacturerW
, CIM_STRING
},
406 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
407 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
408 { prop_physicaladapterW
, CIM_BOOLEAN
},
409 { prop_pnpdeviceidW
, CIM_STRING
},
410 { prop_speedW
, CIM_UINT64
}
412 static const struct column col_networkadapterconfig
[] =
414 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
415 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
416 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
417 { prop_ipenabledW
, CIM_BOOLEAN
},
418 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
420 static const struct column col_os
[] =
422 { prop_buildnumberW
, CIM_STRING
},
423 { prop_captionW
, CIM_STRING
},
424 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
425 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
426 { prop_csdversionW
, CIM_STRING
},
427 { prop_installdateW
, CIM_DATETIME
},
428 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
429 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
430 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
431 { prop_nameW
, CIM_STRING
},
432 { prop_osarchitectureW
, CIM_STRING
},
433 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
434 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
435 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
436 { prop_serialnumberW
, CIM_STRING
},
437 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
438 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
439 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
440 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
441 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
442 { prop_versionW
, CIM_STRING
}
444 static const struct column col_param
[] =
446 { prop_classW
, CIM_STRING
},
447 { prop_methodW
, CIM_STRING
},
448 { prop_directionW
, CIM_SINT32
},
449 { prop_parameterW
, CIM_STRING
},
450 { prop_typeW
, CIM_UINT32
},
451 { prop_varianttypeW
, CIM_UINT32
},
452 { prop_defaultvalueW
, CIM_UINT32
}
454 static const struct column col_physicalmedia
[] =
456 { prop_serialnumberW
, CIM_STRING
},
457 { prop_tagW
, CIM_STRING
}
459 static const struct column col_physicalmemory
[] =
461 { prop_capacityW
, CIM_UINT64
}
463 static const struct column col_process
[] =
465 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
466 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
467 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
468 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
469 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
470 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
471 { prop_processidW
, CIM_UINT32
, VT_I4
},
472 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
474 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
476 static const struct column col_processor
[] =
478 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
479 { prop_cpustatusW
, CIM_UINT16
},
480 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
481 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
482 { prop_familyW
, CIM_UINT16
, VT_I4
},
483 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
484 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
485 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
486 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
487 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
488 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
489 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
490 { prop_uniqueidW
, CIM_STRING
}
492 static const struct column col_qualifier
[] =
494 { prop_classW
, CIM_STRING
},
495 { prop_memberW
, CIM_STRING
},
496 { prop_typeW
, CIM_UINT32
},
497 { prop_flavorW
, CIM_SINT32
},
498 { prop_nameW
, CIM_STRING
},
499 { prop_intvalueW
, CIM_SINT32
},
500 { prop_strvalueW
, CIM_STRING
}
502 static const struct column col_service
[] =
504 { prop_acceptpauseW
, CIM_BOOLEAN
},
505 { prop_acceptstopW
, CIM_BOOLEAN
},
506 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
507 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
508 { prop_processidW
, CIM_UINT32
},
509 { prop_servicetypeW
, CIM_STRING
},
510 { prop_startmodeW
, CIM_STRING
},
511 { prop_stateW
, CIM_STRING
},
512 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
514 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
515 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
516 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
517 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
519 static const struct column col_sid
[] =
521 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
522 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
523 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
524 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
525 { prop_sidlengthW
, CIM_UINT32
}
527 static const struct column col_sounddevice
[] =
529 { prop_nameW
, CIM_STRING
},
530 { prop_productnameW
, CIM_STRING
},
531 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
533 static const struct column col_stdregprov
[] =
535 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
536 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
537 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
539 static const struct column col_systemsecurity
[] =
541 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
542 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
544 static const struct column col_videocontroller
[] =
546 { prop_adapterdactypeW
, CIM_STRING
},
547 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
548 { prop_availabilityW
, CIM_UINT16
},
549 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
550 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
551 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
552 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
553 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
554 { prop_driverversionW
, CIM_STRING
},
555 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
556 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
557 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
560 static const WCHAR baseboard_manufacturerW
[] =
561 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
562 static const WCHAR baseboard_serialnumberW
[] =
564 static const WCHAR baseboard_tagW
[] =
565 {'B','a','s','e',' ','B','o','a','r','d',0};
566 static const WCHAR baseboard_versionW
[] =
568 static const WCHAR bios_descriptionW
[] =
569 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
570 static const WCHAR bios_manufacturerW
[] =
571 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
572 static const WCHAR bios_releasedateW
[] =
573 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
574 static const WCHAR bios_serialnumberW
[] =
576 static const WCHAR bios_smbiosbiosversionW
[] =
578 static const WCHAR bios_versionW
[] =
579 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
580 static const WCHAR cdromdrive_mediatypeW
[] =
581 {'C','D','-','R','O','M',0};
582 static const WCHAR cdromdrive_nameW
[] =
583 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
584 static const WCHAR cdromdrive_pnpdeviceidW
[]=
585 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
586 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
587 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
588 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
589 static const WCHAR compsys_descriptionW
[] =
590 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
591 static const WCHAR compsys_domainW
[] =
592 {'W','O','R','K','G','R','O','U','P',0};
593 static const WCHAR compsys_manufacturerW
[] =
594 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
595 static const WCHAR compsys_modelW
[] =
597 static const WCHAR compsysproduct_identifyingnumberW
[] =
599 static const WCHAR compsysproduct_uuidW
[] =
600 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
601 '0','0','0','0','0','0','0','0','0','0','0','0',0};
602 static const WCHAR diskdrive_interfacetypeW
[] =
604 static const WCHAR diskdrive_manufacturerW
[] =
605 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
606 static const WCHAR diskdrive_mediatype_fixedW
[] =
607 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
608 static const WCHAR diskdrive_mediatype_removableW
[] =
609 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
610 static const WCHAR diskdrive_modelW
[] =
611 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
612 static const WCHAR diskdrive_pnpdeviceidW
[] =
613 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
614 static const WCHAR diskdrive_serialW
[] =
615 {'W','I','N','E','H','D','I','S','K',0};
616 static const WCHAR networkadapter_pnpdeviceidW
[]=
617 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
618 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
619 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
620 static const WCHAR os_32bitW
[] =
621 {'3','2','-','b','i','t',0};
622 static const WCHAR os_64bitW
[] =
623 {'6','4','-','b','i','t',0};
624 static const WCHAR os_buildnumberW
[] =
626 static const WCHAR os_captionW
[] =
627 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
628 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
629 static const WCHAR os_csdversionW
[] =
630 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
631 static const WCHAR os_installdateW
[] =
632 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
633 static const WCHAR os_nameW
[] =
634 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
635 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
636 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
637 '\\','P','a','r','t','i','t','i','o','n','1',0};
638 static const WCHAR os_serialnumberW
[] =
639 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
640 static const WCHAR os_versionW
[] =
641 {'5','.','1','.','2','6','0','0',0};
642 static const WCHAR physicalmedia_tagW
[] =
643 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
644 static const WCHAR sounddevice_productnameW
[] =
645 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
646 static const WCHAR videocontroller_dactypeW
[] =
647 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
648 static const WCHAR videocontroller_deviceidW
[] =
649 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
650 static const WCHAR videocontroller_driverversionW
[] =
653 #include "pshpack1.h"
654 struct record_baseboard
656 const WCHAR
*manufacturer
;
659 const WCHAR
*product
;
660 const WCHAR
*serialnumber
;
662 const WCHAR
*version
;
666 const WCHAR
*description
;
667 const WCHAR
*identificationcode
;
668 const WCHAR
*manufacturer
;
669 const WCHAR
*releasedate
;
670 const WCHAR
*serialnumber
;
671 const WCHAR
*smbiosbiosversion
;
672 const WCHAR
*version
;
674 struct record_cdromdrive
676 const WCHAR
*device_id
;
678 const WCHAR
*mediatype
;
680 const WCHAR
*pnpdevice_id
;
682 struct record_computersystem
684 const WCHAR
*description
;
687 const WCHAR
*manufacturer
;
690 UINT32 num_logical_processors
;
691 UINT32 num_processors
;
692 UINT64 total_physical_memory
;
694 struct record_computersystemproduct
696 const WCHAR
*identifyingnumber
;
699 struct record_datafile
702 const WCHAR
*version
;
704 struct record_directory
709 struct record_diskdrive
711 const WCHAR
*device_id
;
713 const WCHAR
*interfacetype
;
714 const WCHAR
*manufacturer
;
715 const WCHAR
*mediatype
;
717 const WCHAR
*pnpdevice_id
;
718 const WCHAR
*serialnumber
;
721 struct record_diskpartition
725 const WCHAR
*device_id
;
728 const WCHAR
*pnpdevice_id
;
730 UINT64 startingoffset
;
733 struct record_logicaldisk
735 const WCHAR
*device_id
;
737 const WCHAR
*filesystem
;
741 const WCHAR
*volumename
;
742 const WCHAR
*volumeserialnumber
;
744 struct record_networkadapter
746 const WCHAR
*adaptertype
;
747 const WCHAR
*device_id
;
749 UINT32 interface_index
;
750 const WCHAR
*mac_address
;
751 const WCHAR
*manufacturer
;
753 UINT16 netconnection_status
;
755 const WCHAR
*pnpdevice_id
;
758 struct record_networkadapterconfig
760 const WCHAR
*dnshostname
;
762 UINT32 ipconnectionmetric
;
764 const WCHAR
*mac_address
;
766 struct record_operatingsystem
768 const WCHAR
*buildnumber
;
769 const WCHAR
*caption
;
770 const WCHAR
*codeset
;
771 const WCHAR
*countrycode
;
772 const WCHAR
*csdversion
;
773 const WCHAR
*installdate
;
774 const WCHAR
*lastbootuptime
;
775 const WCHAR
*localdatetime
;
778 const WCHAR
*osarchitecture
;
780 UINT32 osproductsuite
;
782 const WCHAR
*serialnumber
;
783 UINT16 servicepackmajor
;
784 UINT16 servicepackminor
;
786 const WCHAR
*systemdirectory
;
787 UINT64 totalvisiblememorysize
;
788 const WCHAR
*version
;
795 const WCHAR
*parameter
;
800 struct record_physicalmedia
802 const WCHAR
*serialnumber
;
805 struct record_physicalmemory
809 struct record_process
811 const WCHAR
*caption
;
812 const WCHAR
*commandline
;
813 const WCHAR
*description
;
820 class_method
*get_owner
;
822 struct record_processor
826 UINT32 currentclockspeed
;
827 const WCHAR
*device_id
;
829 const WCHAR
*manufacturer
;
830 UINT32 maxclockspeed
;
833 UINT32 num_logical_processors
;
834 const WCHAR
*processor_id
;
835 UINT16 processortype
;
836 const WCHAR
*unique_id
;
838 struct record_qualifier
846 const WCHAR
*strvalue
;
848 struct record_service
852 const WCHAR
*displayname
;
855 const WCHAR
*servicetype
;
856 const WCHAR
*startmode
;
858 const WCHAR
*systemname
;
860 class_method
*pause_service
;
861 class_method
*resume_service
;
862 class_method
*start_service
;
863 class_method
*stop_service
;
867 const WCHAR
*accountname
;
868 const UINT8
*binaryrepresentation
;
869 const WCHAR
*referenceddomainname
;
873 struct record_sounddevice
876 const WCHAR
*productname
;
879 struct record_stdregprov
881 class_method
*enumkey
;
882 class_method
*enumvalues
;
883 class_method
*getstringvalue
;
885 struct record_systemsecurity
890 struct record_videocontroller
892 const WCHAR
*adapter_dactype
;
895 UINT32 current_bitsperpixel
;
896 UINT32 current_horizontalres
;
897 UINT32 current_verticalres
;
898 const WCHAR
*description
;
899 const WCHAR
*device_id
;
900 const WCHAR
*driverversion
;
902 const WCHAR
*pnpdevice_id
;
903 const WCHAR
*videoprocessor
;
907 static const struct record_baseboard data_baseboard
[] =
909 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
911 static const struct record_bios data_bios
[] =
913 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
914 bios_smbiosbiosversionW
, bios_versionW
}
916 static const struct record_computersystemproduct data_compsysproduct
[] =
918 { compsysproduct_identifyingnumberW
, compsysproduct_uuidW
}
920 static const struct record_param data_param
[] =
922 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
923 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
924 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
925 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
926 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
927 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
928 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
929 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
930 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
931 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
932 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
933 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
934 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
935 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
936 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
937 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
938 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
939 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
940 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
941 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
942 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
943 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
944 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
945 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
946 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
949 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
950 WBEM_FLAVOR_ORIGIN_PROPAGATED)
952 static const struct record_physicalmedia data_physicalmedia
[] =
954 { diskdrive_serialW
, physicalmedia_tagW
}
956 static const struct record_qualifier data_qualifier
[] =
958 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
959 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
961 static const struct record_sounddevice data_sounddevice
[] =
963 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
965 static const struct record_stdregprov data_stdregprov
[] =
967 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
969 static const struct record_systemsecurity data_systemsecurity
[] =
971 { security_get_sd
, security_set_sd
}
974 /* check if row matches condition and update status */
975 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
982 *status
= FILL_STATUS_UNFILTERED
;
985 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
987 *status
= FILL_STATUS_FAILED
;
990 *status
= FILL_STATUS_FILTERED
;
994 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
996 if (!table
->num_rows_allocated
)
998 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
999 table
->num_rows_allocated
= row_count
;
1002 if (row_count
>= table
->num_rows_allocated
)
1005 UINT count
= table
->num_rows_allocated
* 2;
1006 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1008 table
->num_rows_allocated
= count
;
1013 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1015 static const WCHAR fmtW
[] = {'%','c',':',0};
1016 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1017 struct record_cdromdrive
*rec
;
1018 UINT i
, row
= 0, offset
= 0;
1019 DWORD drives
= GetLogicalDrives();
1020 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1022 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1024 for (i
= 0; i
< sizeof(drives
); i
++)
1026 if (drives
& (1 << i
))
1029 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1032 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1034 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1035 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1036 sprintfW( drive
, fmtW
, 'A' + i
);
1037 rec
->drive
= heap_strdupW( drive
);
1038 rec
->mediatype
= cdromdrive_mediatypeW
;
1039 rec
->name
= cdromdrive_nameW
;
1040 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1041 if (!match_row( table
, row
, cond
, &status
))
1043 free_row_values( table
, row
);
1046 offset
+= sizeof(*rec
);
1050 TRACE("created %u rows\n", row
);
1051 table
->num_rows
= row
;
1055 static UINT
get_processor_count(void)
1057 SYSTEM_BASIC_INFORMATION info
;
1059 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1060 return info
.NumberOfProcessors
;
1063 static UINT
get_logical_processor_count( UINT
*num_cores
)
1065 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1066 UINT i
, j
, count
= 0;
1070 if (num_cores
) *num_cores
= get_processor_count();
1071 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1072 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1074 if (!(info
= heap_alloc( len
))) return get_processor_count();
1075 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1076 if (status
!= STATUS_SUCCESS
)
1079 return get_processor_count();
1081 if (num_cores
) *num_cores
= 0;
1082 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1084 if (info
[i
].Relationship
== RelationProcessorCore
)
1086 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1088 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1090 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1097 static UINT64
get_total_physical_memory(void)
1099 MEMORYSTATUSEX status
;
1101 status
.dwLength
= sizeof(status
);
1102 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1103 return status
.ullTotalPhys
;
1106 static WCHAR
*get_computername(void)
1109 DWORD size
= MAX_COMPUTERNAME_LENGTH
;
1111 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1112 GetComputerNameW( ret
, &size
);
1116 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1118 struct record_computersystem
*rec
;
1119 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1122 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1124 rec
= (struct record_computersystem
*)table
->data
;
1125 rec
->description
= compsys_descriptionW
;
1126 rec
->domain
= compsys_domainW
;
1127 rec
->domainrole
= 0; /* standalone workstation */
1128 rec
->manufacturer
= compsys_manufacturerW
;
1129 rec
->model
= compsys_modelW
;
1130 rec
->name
= get_computername();
1131 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1132 rec
->num_processors
= get_processor_count();
1133 rec
->total_physical_memory
= get_total_physical_memory();
1134 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1137 TRACE("created %u rows\n", row
);
1138 table
->num_rows
= row
;
1150 static struct dirstack
*alloc_dirstack( UINT size
)
1152 struct dirstack
*dirstack
;
1154 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1155 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1157 heap_free( dirstack
);
1160 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1162 heap_free( dirstack
->dirs
);
1163 heap_free( dirstack
);
1166 dirstack
->num_dirs
= 0;
1167 dirstack
->num_allocated
= size
;
1171 static void clear_dirstack( struct dirstack
*dirstack
)
1174 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1175 dirstack
->num_dirs
= 0;
1178 static void free_dirstack( struct dirstack
*dirstack
)
1180 clear_dirstack( dirstack
);
1181 heap_free( dirstack
->dirs
);
1182 heap_free( dirstack
->len_dirs
);
1183 heap_free( dirstack
);
1186 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1188 UINT size
, i
= dirstack
->num_dirs
;
1190 if (!dir
) return FALSE
;
1192 if (i
== dirstack
->num_allocated
)
1197 size
= dirstack
->num_allocated
* 2;
1198 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1199 dirstack
->dirs
= tmp
;
1200 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1201 dirstack
->len_dirs
= len_tmp
;
1202 dirstack
->num_allocated
= size
;
1204 dirstack
->dirs
[i
] = dir
;
1205 dirstack
->len_dirs
[i
] = len
;
1206 dirstack
->num_dirs
++;
1210 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1212 if (!dirstack
->num_dirs
)
1217 dirstack
->num_dirs
--;
1218 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1219 return dirstack
->dirs
[dirstack
->num_dirs
];
1222 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1224 if (!dirstack
->num_dirs
) return NULL
;
1225 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1228 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1233 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1239 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1248 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1250 UINT i
= 0, len
= 0;
1254 for (p
= path
; *p
; p
++)
1256 if (*p
== '\\') len
+= 2;
1259 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1264 for (p
= path
; *p
; p
++)
1266 if (*p
!= '\\') ret
[i
++] = *p
;
1277 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1279 const WCHAR
*p
= path
, *start
;
1283 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1285 len
= strlenW( start
);
1286 p
= start
+ len
- 1;
1287 if (*p
== '\\') return NULL
;
1289 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1290 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1292 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1293 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1295 if (p
[0] == '\\' && p
[1] == '\\')
1307 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1310 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1314 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1315 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1317 const struct expr
*left
, *right
;
1319 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1321 left
= cond
->u
.expr
.left
;
1322 right
= cond
->u
.expr
.right
;
1323 if (cond
->u
.expr
.op
== OP_EQ
)
1327 const WCHAR
*str
= NULL
;
1329 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1330 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1331 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1333 str
= right
->u
.sval
;
1335 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1336 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1337 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1341 if (str
&& (path
= build_dirname( str
, &len
)))
1343 if (seen_dir( dirstack
, path
))
1348 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1353 else if (cond
->u
.expr
.op
== OP_OR
)
1355 UINT left_count
= 0, right_count
= 0;
1357 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1358 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1359 return *count
+= left_count
+ right_count
;
1364 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1366 UINT len_path
= 0, len_segment
= strlenW( segment
);
1370 if (path
) len_path
= strlenW( path
);
1371 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1372 if (path
&& len_path
)
1374 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1375 ret
[len_path
] = '\\';
1376 *len
+= len_path
+ 1;
1378 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1379 *len
+= len_segment
;
1384 static WCHAR
*get_file_version( const WCHAR
*filename
)
1386 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1387 VS_FIXEDFILEINFO
*info
;
1392 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1393 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1398 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1399 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1405 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1406 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1411 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1413 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1414 struct record_datafile
*rec
;
1415 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1416 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1417 DWORD drives
= GetLogicalDrives();
1418 WIN32_FIND_DATAW data
;
1420 struct dirstack
*dirstack
;
1421 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1423 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1425 dirstack
= alloc_dirstack(2);
1427 for (i
= 0; i
< sizeof(drives
); i
++)
1429 if (!(drives
& (1 << i
))) continue;
1432 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1434 num_expected_rows
= 0;
1435 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1439 path
= pop_dir( dirstack
, &len
);
1440 if (!(glob
= build_glob( root
[0], path
, len
)))
1442 status
= FILL_STATUS_FAILED
;
1445 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1449 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1451 status
= FILL_STATUS_FAILED
;
1452 FindClose( handle
);
1455 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1456 new_path
= append_path( path
, data
.cFileName
, &len
);
1458 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1460 if (push_dir( dirstack
, new_path
, len
)) continue;
1461 heap_free( new_path
);
1462 FindClose( handle
);
1463 status
= FILL_STATUS_FAILED
;
1466 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1467 rec
->name
= build_name( root
[0], new_path
);
1468 rec
->version
= get_file_version( rec
->name
);
1469 if (!match_row( table
, row
, cond
, &status
))
1471 free_row_values( table
, row
);
1474 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1477 FindClose( handle
);
1478 status
= FILL_STATUS_FILTERED
;
1481 offset
+= sizeof(*rec
);
1484 while (FindNextFileW( handle
, &data
));
1485 FindClose( handle
);
1487 if (!peek_dir( dirstack
)) break;
1494 free_dirstack( dirstack
);
1498 TRACE("created %u rows\n", row
);
1499 table
->num_rows
= row
;
1503 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1505 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1506 struct record_directory
*rec
;
1507 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1508 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1509 DWORD drives
= GetLogicalDrives();
1510 WIN32_FIND_DATAW data
;
1512 struct dirstack
*dirstack
;
1513 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1515 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1517 dirstack
= alloc_dirstack(2);
1519 for (i
= 0; i
< sizeof(drives
); i
++)
1521 if (!(drives
& (1 << i
))) continue;
1524 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1526 num_expected_rows
= 0;
1527 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1531 path
= pop_dir( dirstack
, &len
);
1532 if (!(glob
= build_glob( root
[0], path
, len
)))
1534 status
= FILL_STATUS_FAILED
;
1537 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1541 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1543 FindClose( handle
);
1544 status
= FILL_STATUS_FAILED
;
1547 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1548 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1551 new_path
= append_path( path
, data
.cFileName
, &len
);
1552 if (!(push_dir( dirstack
, new_path
, len
)))
1554 heap_free( new_path
);
1555 FindClose( handle
);
1556 status
= FILL_STATUS_FAILED
;
1559 rec
= (struct record_directory
*)(table
->data
+ offset
);
1560 rec
->accessmask
= FILE_ALL_ACCESS
;
1561 rec
->name
= build_name( root
[0], new_path
);
1562 if (!match_row( table
, row
, cond
, &status
))
1564 free_row_values( table
, row
);
1567 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1570 FindClose( handle
);
1571 status
= FILL_STATUS_FILTERED
;
1574 offset
+= sizeof(*rec
);
1577 while (FindNextFileW( handle
, &data
));
1578 FindClose( handle
);
1580 if (!peek_dir( dirstack
)) break;
1587 free_dirstack( dirstack
);
1591 TRACE("created %u rows\n", row
);
1592 table
->num_rows
= row
;
1596 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1598 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1599 ULARGE_INTEGER free
;
1600 DISK_GEOMETRY_EX info
;
1602 DWORD bytes_returned
;
1604 free
.QuadPart
= 512 * 1024 * 1024;
1605 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1608 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1609 if (handle
!= INVALID_HANDLE_VALUE
)
1611 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1612 *disksize
= info
.DiskSize
.QuadPart
;
1613 CloseHandle( handle
);
1615 return free
.QuadPart
;
1618 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1620 static const WCHAR fmtW
[] =
1621 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1622 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1623 struct record_diskdrive
*rec
;
1624 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1625 UINT64 size
= 1024 * 1024 * 1024;
1626 DWORD drives
= GetLogicalDrives();
1627 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1629 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1631 for (i
= 0; i
< sizeof(drives
); i
++)
1633 if (drives
& (1 << i
))
1636 type
= GetDriveTypeW( root
);
1637 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1640 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1642 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1643 sprintfW( device_id
, fmtW
, index
);
1644 rec
->device_id
= heap_strdupW( device_id
);
1646 rec
->interfacetype
= diskdrive_interfacetypeW
;
1647 rec
->manufacturer
= diskdrive_manufacturerW
;
1648 if (type
== DRIVE_FIXED
)
1649 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1651 rec
->mediatype
= diskdrive_mediatype_removableW
;
1652 rec
->model
= diskdrive_modelW
;
1653 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1654 rec
->serialnumber
= diskdrive_serialW
;
1655 get_freespace( root
, &size
);
1657 if (!match_row( table
, row
, cond
, &status
))
1659 free_row_values( table
, row
);
1662 offset
+= sizeof(*rec
);
1667 TRACE("created %u rows\n", row
);
1668 table
->num_rows
= row
;
1672 static WCHAR
*get_filesystem( const WCHAR
*root
)
1674 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1675 WCHAR buffer
[MAX_PATH
+ 1];
1677 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1678 return heap_strdupW( buffer
);
1679 return heap_strdupW( ntfsW
);
1682 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1684 static const WCHAR fmtW
[] =
1685 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1686 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1687 struct record_diskpartition
*rec
;
1688 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1689 UINT64 size
= 1024 * 1024 * 1024;
1690 DWORD drives
= GetLogicalDrives();
1691 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1693 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1695 for (i
= 0; i
< sizeof(drives
); i
++)
1697 if (drives
& (1 << i
))
1700 type
= GetDriveTypeW( root
);
1701 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1704 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1706 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1707 rec
->bootable
= (i
== 2) ? -1 : 0;
1708 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1709 sprintfW( device_id
, fmtW
, index
);
1710 rec
->device_id
= heap_strdupW( device_id
);
1711 rec
->diskindex
= index
;
1713 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1714 get_freespace( root
, &size
);
1716 rec
->startingoffset
= 0;
1717 rec
->type
= get_filesystem( root
);
1718 if (!match_row( table
, row
, cond
, &status
))
1720 free_row_values( table
, row
);
1723 offset
+= sizeof(*rec
);
1728 TRACE("created %u rows\n", row
);
1729 table
->num_rows
= row
;
1733 static WCHAR
*get_volumename( const WCHAR
*root
)
1735 WCHAR buf
[MAX_PATH
+ 1] = {0};
1736 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1737 return heap_strdupW( buf
);
1739 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1741 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1745 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1746 sprintfW( buffer
, fmtW
, serial
);
1747 return heap_strdupW( buffer
);
1750 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1752 static const WCHAR fmtW
[] = {'%','c',':',0};
1753 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1754 struct record_logicaldisk
*rec
;
1755 UINT i
, row
= 0, offset
= 0, type
;
1756 UINT64 size
= 1024 * 1024 * 1024;
1757 DWORD drives
= GetLogicalDrives();
1758 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1760 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1762 for (i
= 0; i
< sizeof(drives
); i
++)
1764 if (drives
& (1 << i
))
1767 type
= GetDriveTypeW( root
);
1768 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1771 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1773 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1774 sprintfW( device_id
, fmtW
, 'A' + i
);
1775 rec
->device_id
= heap_strdupW( device_id
);
1776 rec
->drivetype
= type
;
1777 rec
->filesystem
= get_filesystem( root
);
1778 rec
->freespace
= get_freespace( root
, &size
);
1779 rec
->name
= heap_strdupW( device_id
);
1781 rec
->volumename
= get_volumename( root
);
1782 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1783 if (!match_row( table
, row
, cond
, &status
))
1785 free_row_values( table
, row
);
1788 offset
+= sizeof(*rec
);
1792 TRACE("created %u rows\n", row
);
1793 table
->num_rows
= row
;
1797 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1801 case IfOperStatusDown
:
1802 return 0; /* Disconnected */
1803 case IfOperStatusUp
:
1804 return 2; /* Connected */
1806 ERR("unhandled status %u\n", status
);
1811 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1813 static const WCHAR fmtW
[] =
1814 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1815 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1818 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1819 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1822 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1824 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1825 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1826 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1827 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1831 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1832 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1833 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1834 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1835 default: *physical
= 0; return NULL
;
1839 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1841 static const WCHAR fmtW
[] = {'%','u',0};
1842 WCHAR device_id
[11];
1843 struct record_networkadapter
*rec
;
1844 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1845 UINT row
= 0, offset
= 0, count
= 0;
1846 DWORD size
= 0, ret
;
1848 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1850 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1851 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1853 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1854 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1856 heap_free( buffer
);
1857 return FILL_STATUS_FAILED
;
1859 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1861 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1863 if (!resize_table( table
, count
, sizeof(*rec
) ))
1865 heap_free( buffer
);
1866 return FILL_STATUS_FAILED
;
1868 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1870 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1872 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1873 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1874 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1875 rec
->device_id
= heap_strdupW( device_id
);
1876 rec
->index
= aa
->u
.s
.IfIndex
;
1877 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1878 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1879 rec
->manufacturer
= compsys_manufacturerW
;
1880 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1881 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1882 rec
->physicaladapter
= physical
;
1883 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1884 rec
->speed
= 1000000;
1885 if (!match_row( table
, row
, cond
, &status
))
1887 free_row_values( table
, row
);
1890 offset
+= sizeof(*rec
);
1893 TRACE("created %u rows\n", row
);
1894 table
->num_rows
= row
;
1896 heap_free( buffer
);
1900 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
1902 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
1903 WCHAR buf
[NI_MAXHOST
];
1905 if (!addr
) return NULL
;
1906 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
1907 0, NI_NAMEREQD
)) return NULL
;
1908 return heap_strdupW( buf
);
1911 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1913 struct record_networkadapterconfig
*rec
;
1914 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1915 UINT row
= 0, offset
= 0, count
= 0;
1916 DWORD size
= 0, ret
;
1917 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1919 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1920 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1922 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1923 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1925 heap_free( buffer
);
1926 return FILL_STATUS_FAILED
;
1928 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1930 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1932 if (!resize_table( table
, count
, sizeof(*rec
) ))
1934 heap_free( buffer
);
1935 return FILL_STATUS_FAILED
;
1937 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1939 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1941 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1942 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
1943 rec
->index
= aa
->u
.s
.IfIndex
;
1944 rec
->ipconnectionmetric
= 20;
1945 rec
->ipenabled
= -1;
1946 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1947 if (!match_row( table
, row
, cond
, &status
))
1949 free_row_values( table
, row
);
1952 offset
+= sizeof(*rec
);
1955 TRACE("created %u rows\n", row
);
1956 table
->num_rows
= row
;
1958 heap_free( buffer
);
1962 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
1964 struct record_physicalmemory
*rec
;
1965 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1968 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1970 rec
= (struct record_physicalmemory
*)table
->data
;
1971 rec
->capacity
= get_total_physical_memory();
1972 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1975 TRACE("created %u rows\n", row
);
1976 table
->num_rows
= row
;
1980 static WCHAR
*get_cmdline( DWORD process_id
)
1982 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1983 return NULL
; /* FIXME handle different process case */
1986 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
1988 static const WCHAR fmtW
[] = {'%','u',0};
1990 struct record_process
*rec
;
1991 PROCESSENTRY32W entry
;
1993 enum fill_status status
= FILL_STATUS_FAILED
;
1994 UINT row
= 0, offset
= 0;
1996 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
1997 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
1999 entry
.dwSize
= sizeof(entry
);
2000 if (!Process32FirstW( snap
, &entry
)) goto done
;
2001 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2005 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2007 rec
= (struct record_process
*)(table
->data
+ offset
);
2008 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2009 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2010 rec
->description
= heap_strdupW( entry
.szExeFile
);
2011 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2012 rec
->handle
= heap_strdupW( handle
);
2013 rec
->name
= heap_strdupW( entry
.szExeFile
);
2014 rec
->process_id
= entry
.th32ProcessID
;
2015 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2016 rec
->thread_count
= entry
.cntThreads
;
2017 rec
->get_owner
= process_get_owner
;
2018 if (!match_row( table
, row
, cond
, &status
))
2020 free_row_values( table
, row
);
2023 offset
+= sizeof(*rec
);
2025 } while (Process32NextW( snap
, &entry
));
2027 TRACE("created %u rows\n", row
);
2028 table
->num_rows
= row
;
2029 status
= FILL_STATUS_UNFILTERED
;
2032 CloseHandle( snap
);
2036 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2042 __asm__("pushl %%ebx\n\t"
2044 "movl %%ebx, %%esi\n\t"
2046 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2052 static void get_processor_id( WCHAR
*processor_id
)
2054 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2055 unsigned int regs
[4] = {0, 0, 0, 0};
2057 do_cpuid( 1, regs
);
2058 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2060 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2063 unsigned char *p
= (unsigned char *)regs
;
2065 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2068 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2070 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2072 do_cpuid( 0, regs
);
2073 tmp
= regs
[2]; /* swap edx and ecx */
2077 regs_to_str( regs
+ 1, 12, manufacturer
);
2079 static void get_processor_name( WCHAR
*name
)
2081 unsigned int regs
[4] = {0, 0, 0, 0};
2083 do_cpuid( 0x80000000, regs
);
2084 if (regs
[0] >= 0x80000004)
2086 do_cpuid( 0x80000002, regs
);
2087 regs_to_str( regs
, 16, name
);
2088 do_cpuid( 0x80000003, regs
);
2089 regs_to_str( regs
, 16, name
+ 16 );
2090 do_cpuid( 0x80000004, regs
);
2091 regs_to_str( regs
, 16, name
+ 32 );
2094 static UINT
get_processor_currentclockspeed( UINT index
)
2096 PROCESSOR_POWER_INFORMATION
*info
;
2097 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2100 if ((info
= heap_alloc( size
)))
2102 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2103 if (!status
) ret
= info
[index
].CurrentMhz
;
2108 static UINT
get_processor_maxclockspeed( UINT index
)
2110 PROCESSOR_POWER_INFORMATION
*info
;
2111 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2114 if ((info
= heap_alloc( size
)))
2116 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2117 if (!status
) ret
= info
[index
].MaxMhz
;
2122 static const WCHAR
*get_osarchitecture(void)
2125 GetNativeSystemInfo( &info
);
2126 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2130 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2132 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2133 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2134 struct record_processor
*rec
;
2135 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2136 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2138 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2140 get_processor_id( processor_id
);
2141 get_processor_manufacturer( manufacturer
);
2142 get_processor_name( name
);
2144 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2147 for (i
= 0; i
< count
; i
++)
2149 rec
= (struct record_processor
*)(table
->data
+ offset
);
2150 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2151 rec
->cpu_status
= 1; /* CPU Enabled */
2152 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2153 sprintfW( device_id
, fmtW
, i
);
2154 rec
->device_id
= heap_strdupW( device_id
);
2155 rec
->family
= 2; /* Unknown */
2156 rec
->manufacturer
= heap_strdupW( manufacturer
);
2157 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2158 rec
->name
= heap_strdupW( name
);
2159 rec
->num_cores
= num_cores
;
2160 rec
->num_logical_processors
= num_logical_processors
;
2161 rec
->processor_id
= heap_strdupW( processor_id
);
2162 rec
->processortype
= 3; /* central processor */
2163 rec
->unique_id
= NULL
;
2164 if (!match_row( table
, i
, cond
, &status
))
2166 free_row_values( table
, i
);
2169 offset
+= sizeof(*rec
);
2172 TRACE("created %u rows\n", count
);
2173 table
->num_rows
= count
;
2177 static WCHAR
*get_lastbootuptime(void)
2179 static const WCHAR fmtW
[] =
2180 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2181 '.','%','0','6','u','+','0','0','0',0};
2182 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2186 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2188 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2189 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2190 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2193 static WCHAR
*get_localdatetime(void)
2195 static const WCHAR fmtW
[] =
2196 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2197 '.','%','0','6','u','%','+','0','3','d',0};
2198 TIME_ZONE_INFORMATION tzi
;
2204 Status
= GetTimeZoneInformation(&tzi
);
2206 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2208 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2209 Bias
+= tzi
.DaylightBias
;
2211 Bias
+= tzi
.StandardBias
;
2212 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2215 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2218 static WCHAR
*get_systemdirectory(void)
2223 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2224 Wow64DisableWow64FsRedirection( &redir
);
2225 GetSystemDirectoryW( ret
, MAX_PATH
);
2226 Wow64RevertWow64FsRedirection( redir
);
2229 static WCHAR
*get_codeset(void)
2231 static const WCHAR fmtW
[] = {'%','u',0};
2232 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2233 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2236 static WCHAR
*get_countrycode(void)
2238 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2239 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2242 static WCHAR
*get_locale(void)
2244 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2245 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2249 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2251 struct record_operatingsystem
*rec
;
2252 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2255 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2257 rec
= (struct record_operatingsystem
*)table
->data
;
2258 rec
->buildnumber
= os_buildnumberW
;
2259 rec
->caption
= os_captionW
;
2260 rec
->codeset
= get_codeset();
2261 rec
->countrycode
= get_countrycode();
2262 rec
->csdversion
= os_csdversionW
;
2263 rec
->installdate
= os_installdateW
;
2264 rec
->lastbootuptime
= get_lastbootuptime();
2265 rec
->localdatetime
= get_localdatetime();
2266 rec
->locale
= get_locale();
2267 rec
->name
= os_nameW
;
2268 rec
->osarchitecture
= get_osarchitecture();
2269 rec
->oslanguage
= GetSystemDefaultLangID();
2270 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2271 rec
->ostype
= 18; /* WINNT */
2272 rec
->serialnumber
= os_serialnumberW
;
2273 rec
->servicepackmajor
= 3;
2274 rec
->servicepackminor
= 0;
2275 rec
->suitemask
= 272; /* Single User + Terminal */
2276 rec
->systemdirectory
= get_systemdirectory();
2277 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2278 rec
->version
= os_versionW
;
2279 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2282 TRACE("created %u rows\n", row
);
2283 table
->num_rows
= row
;
2287 static const WCHAR
*get_service_type( DWORD type
)
2289 static const WCHAR filesystem_driverW
[] =
2290 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2291 static const WCHAR kernel_driverW
[] =
2292 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2293 static const WCHAR own_processW
[] =
2294 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2295 static const WCHAR share_processW
[] =
2296 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2298 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2299 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2300 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2301 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2302 else ERR("unhandled type 0x%08x\n", type
);
2305 static const WCHAR
*get_service_state( DWORD state
)
2307 static const WCHAR runningW
[] =
2308 {'R','u','n','n','i','n','g',0};
2309 static const WCHAR start_pendingW
[] =
2310 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2311 static const WCHAR stop_pendingW
[] =
2312 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2313 static const WCHAR stoppedW
[] =
2314 {'S','t','o','p','p','e','d',0};
2315 static const WCHAR unknownW
[] =
2316 {'U','n','k','n','o','w','n',0};
2320 case SERVICE_STOPPED
: return stoppedW
;
2321 case SERVICE_START_PENDING
: return start_pendingW
;
2322 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2323 case SERVICE_RUNNING
: return runningW
;
2325 ERR("unknown state %u\n", state
);
2329 static const WCHAR
*get_service_startmode( DWORD mode
)
2331 static const WCHAR bootW
[] = {'B','o','o','t',0};
2332 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2333 static const WCHAR autoW
[] = {'A','u','t','o',0};
2334 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2335 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2336 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2340 case SERVICE_BOOT_START
: return bootW
;
2341 case SERVICE_SYSTEM_START
: return systemW
;
2342 case SERVICE_AUTO_START
: return autoW
;
2343 case SERVICE_DEMAND_START
: return manualW
;
2344 case SERVICE_DISABLED
: return disabledW
;
2346 ERR("unknown mode 0x%x\n", mode
);
2350 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2352 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2356 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2357 QueryServiceConfigW( service
, NULL
, 0, &size
);
2358 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2359 if (!(config
= heap_alloc( size
))) goto done
;
2360 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2361 heap_free( config
);
2365 CloseServiceHandle( service
);
2369 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2371 struct record_service
*rec
;
2373 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2374 SERVICE_STATUS_PROCESS
*status
;
2375 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2376 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2377 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2378 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2381 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2382 if (!(services
= heap_alloc( size
))) goto done
;
2384 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2385 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2386 &count
, NULL
, NULL
);
2389 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2391 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2393 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2394 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2395 &count
, NULL
, NULL
);
2396 if (!ret
) goto done
;
2398 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2400 GetComputerNameW( sysnameW
, &len
);
2401 fill_status
= FILL_STATUS_UNFILTERED
;
2403 for (i
= 0; i
< count
; i
++)
2405 QUERY_SERVICE_CONFIGW
*config
;
2407 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2409 status
= &services
[i
].ServiceStatusProcess
;
2410 rec
= (struct record_service
*)(table
->data
+ offset
);
2411 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2412 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2413 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2414 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2415 rec
->process_id
= status
->dwProcessId
;
2416 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2417 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2418 rec
->state
= get_service_state( status
->dwCurrentState
);
2419 rec
->systemname
= heap_strdupW( sysnameW
);
2420 rec
->pause_service
= service_pause_service
;
2421 rec
->resume_service
= service_resume_service
;
2422 rec
->start_service
= service_start_service
;
2423 rec
->stop_service
= service_stop_service
;
2424 heap_free( config
);
2425 if (!match_row( table
, row
, cond
, &fill_status
))
2427 free_row_values( table
, row
);
2430 offset
+= sizeof(*rec
);
2434 TRACE("created %u rows\n", row
);
2435 table
->num_rows
= row
;
2438 CloseServiceHandle( manager
);
2439 heap_free( services
);
2443 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2445 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2446 return heap_strdupW( name
->Name
.Buffer
);
2448 static UINT8
*get_binaryrepresentation( PSID sid
, UINT len
)
2450 UINT8
*ret
= heap_alloc( len
);
2451 if (!ret
) return NULL
;
2452 memcpy( ret
, sid
, len
);
2455 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2457 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2458 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2460 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2462 const struct expr
*left
, *right
;
2463 const WCHAR
*ret
= NULL
;
2465 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2467 left
= cond
->u
.expr
.left
;
2468 right
= cond
->u
.expr
.right
;
2469 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2471 ret
= right
->u
.sval
;
2473 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2480 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2483 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2484 LSA_TRANSLATED_NAME
*name
;
2486 LSA_OBJECT_ATTRIBUTES attrs
;
2488 struct record_sid
*rec
;
2491 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
2492 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2494 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
2495 len
= GetLengthSid( sid
);
2497 memset( &attrs
, 0, sizeof(attrs
) );
2498 attrs
.Length
= sizeof(attrs
);
2499 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
2502 return FILL_STATUS_FAILED
;
2504 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
2508 return FILL_STATUS_FAILED
;
2511 rec
= (struct record_sid
*)table
->data
;
2512 rec
->accountname
= get_accountname( name
);
2513 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
2514 rec
->referenceddomainname
= get_referenceddomainname( domain
);
2515 rec
->sid
= heap_strdupW( str
);
2516 rec
->sidlength
= len
;
2518 TRACE("created 1 row\n");
2519 table
->num_rows
= 1;
2521 LsaFreeMemory( domain
);
2522 LsaFreeMemory( name
);
2525 return FILL_STATUS_FILTERED
;
2528 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2530 HDC hdc
= GetDC( NULL
);
2533 if (!hdc
) return 32;
2534 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2535 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2536 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2537 ReleaseDC( NULL
, hdc
);
2540 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2542 static const WCHAR fmtW
[] =
2543 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2544 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2545 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2548 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2549 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2553 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2556 struct record_videocontroller
*rec
;
2558 IDXGIFactory
*factory
= NULL
;
2559 IDXGIAdapter
*adapter
= NULL
;
2560 DXGI_ADAPTER_DESC desc
;
2561 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2562 const WCHAR
*name
= videocontroller_deviceidW
;
2563 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2566 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2568 memset (&desc
, 0, sizeof(desc
));
2569 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2570 if (FAILED(hr
)) goto done
;
2572 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2573 if (FAILED(hr
)) goto done
;
2575 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2578 vidmem
= desc
.DedicatedVideoMemory
;
2579 name
= desc
.Description
;
2583 rec
= (struct record_videocontroller
*)table
->data
;
2584 rec
->adapter_dactype
= videocontroller_dactypeW
;
2585 rec
->adapter_ram
= vidmem
;
2586 rec
->availability
= 3; /* Running or Full Power */
2587 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2588 rec
->current_horizontalres
= hres
;
2589 rec
->current_verticalres
= vres
;
2590 rec
->description
= heap_strdupW( name
);
2591 rec
->device_id
= videocontroller_deviceidW
;
2592 rec
->driverversion
= videocontroller_driverversionW
;
2593 rec
->name
= heap_strdupW( name
);
2594 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2595 rec
->videoprocessor
= heap_strdupW( name
);
2596 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2599 TRACE("created %u rows\n", row
);
2600 table
->num_rows
= row
;
2602 if (adapter
) IDXGIAdapter_Release( adapter
);
2603 if (factory
) IDXGIFactory_Release( factory
);
2607 static struct table builtin_classes
[] =
2609 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2610 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2611 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2612 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2613 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, SIZEOF(data_compsysproduct
), 0, (BYTE
*)data_compsysproduct
},
2614 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2615 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2616 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2617 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2618 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2619 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2620 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2621 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
2622 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2623 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2624 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2625 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2626 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2627 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2628 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2629 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2630 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2631 { class_sidW
, SIZEOF(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
2632 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2633 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2634 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2635 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2638 void init_table_list( void )
2640 static struct list tables
= LIST_INIT( tables
);
2643 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2644 table_list
= &tables
;