2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
27 #define WIN32_NO_STATUS
45 #include "wine/debug.h"
46 #include "wbemprox_private.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
50 static const WCHAR class_baseboardW
[] =
51 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
52 static const WCHAR class_biosW
[] =
53 {'W','i','n','3','2','_','B','I','O','S',0};
54 static const WCHAR class_cdromdriveW
[] =
55 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
56 static const WCHAR class_compsysW
[] =
57 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
58 static const WCHAR class_compsysproductW
[] =
59 {'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};
60 static const WCHAR class_datafileW
[] =
61 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
62 static const WCHAR class_directoryW
[] =
63 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
64 static const WCHAR class_diskdriveW
[] =
65 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
66 static const WCHAR class_diskpartitionW
[] =
67 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
68 static const WCHAR class_logicaldiskW
[] =
69 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
70 static const WCHAR class_logicaldisk2W
[] =
71 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
72 static const WCHAR class_networkadapterW
[] =
73 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
74 static const WCHAR class_networkadapterconfigW
[] =
75 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
76 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
77 static const WCHAR class_osW
[] =
78 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
79 static const WCHAR class_paramsW
[] =
80 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
81 static const WCHAR class_physicalmediaW
[] =
82 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
83 static const WCHAR class_physicalmemoryW
[] =
84 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
85 static const WCHAR class_qualifiersW
[] =
86 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
87 static const WCHAR class_process_getowner_outW
[] =
88 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
89 'N','E','R','_','O','U','T',0};
90 static const WCHAR class_processorW
[] =
91 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
92 static const WCHAR class_processor2W
[] =
93 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
94 static const WCHAR class_sidW
[] =
95 {'W','i','n','3','2','_','S','I','D',0};
96 static const WCHAR class_sounddeviceW
[] =
97 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
98 static const WCHAR class_videocontrollerW
[] =
99 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
101 static const WCHAR prop_accountnameW
[] =
102 {'A','c','c','o','u','n','t','N','a','m','e',0};
103 static const WCHAR prop_acceptpauseW
[] =
104 {'A','c','c','e','p','t','P','a','u','s','e',0};
105 static const WCHAR prop_acceptstopW
[] =
106 {'A','c','c','e','p','t','S','t','o','p',0};
107 static const WCHAR prop_accessmaskW
[] =
108 {'A','c','c','e','s','s','M','a','s','k',0};
109 static const WCHAR prop_adapterdactypeW
[] =
110 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
111 static const WCHAR prop_adapterramW
[] =
112 {'A','d','a','p','t','e','r','R','A','M',0};
113 static const WCHAR prop_adaptertypeW
[] =
114 {'A','d','a','p','t','e','r','T','y','p','e',0};
115 static const WCHAR prop_addresswidthW
[] =
116 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
117 static const WCHAR prop_availabilityW
[] =
118 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
119 static const WCHAR prop_binaryrepresentationW
[] =
120 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
121 static const WCHAR prop_bootableW
[] =
122 {'B','o','o','t','a','b','l','e',0};
123 static const WCHAR prop_bootpartitionW
[] =
124 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
125 static const WCHAR prop_buildnumberW
[] =
126 {'B','u','i','l','d','N','u','m','b','e','r',0};
127 static const WCHAR prop_capacityW
[] =
128 {'C','a','p','a','c','i','t','y',0};
129 static const WCHAR prop_captionW
[] =
130 {'C','a','p','t','i','o','n',0};
131 static const WCHAR prop_classW
[] =
132 {'C','l','a','s','s',0};
133 static const WCHAR prop_codesetW
[] =
134 {'C','o','d','e','S','e','t',0};
135 static const WCHAR prop_commandlineW
[] =
136 {'C','o','m','m','a','n','d','L','i','n','e',0};
137 static const WCHAR prop_countrycodeW
[] =
138 {'C','o','u','n','t','r','y','C','o','d','e',0};
139 static const WCHAR prop_cpustatusW
[] =
140 {'C','p','u','S','t','a','t','u','s',0};
141 static const WCHAR prop_csdversionW
[] =
142 {'C','S','D','V','e','r','s','i','o','n',0};
143 static const WCHAR prop_currentbitsperpixelW
[] =
144 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
145 static const WCHAR prop_currentclockspeedW
[] =
146 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
147 static const WCHAR prop_currenthorizontalresW
[] =
148 {'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};
149 static const WCHAR prop_currentverticalresW
[] =
150 {'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};
151 static const WCHAR prop_defaultvalueW
[] =
152 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
153 static const WCHAR prop_descriptionW
[] =
154 {'D','e','s','c','r','i','p','t','i','o','n',0};
155 static const WCHAR prop_deviceidW
[] =
156 {'D','e','v','i','c','e','I','d',0};
157 static const WCHAR prop_directionW
[] =
158 {'D','i','r','e','c','t','i','o','n',0};
159 static const WCHAR prop_displaynameW
[] =
160 {'D','i','s','p','l','a','y','N','a','m','e',0};
161 static const WCHAR prop_diskindexW
[] =
162 {'D','i','s','k','I','n','d','e','x',0};
163 static const WCHAR prop_dnshostnameW
[] =
164 {'D','N','S','H','o','s','t','N','a','m','e',0};
165 static const WCHAR prop_domainW
[] =
166 {'D','o','m','a','i','n',0};
167 static const WCHAR prop_domainroleW
[] =
168 {'D','o','m','a','i','n','R','o','l','e',0};
169 static const WCHAR prop_driveW
[] =
170 {'D','r','i','v','e',0};
171 static const WCHAR prop_driverversionW
[] =
172 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
173 static const WCHAR prop_drivetypeW
[] =
174 {'D','r','i','v','e','T','y','p','e',0};
175 static const WCHAR prop_familyW
[] =
176 {'F','a','m','i','l','y',0};
177 static const WCHAR prop_filesystemW
[] =
178 {'F','i','l','e','S','y','s','t','e','m',0};
179 static const WCHAR prop_flavorW
[] =
180 {'F','l','a','v','o','r',0};
181 static const WCHAR prop_freespaceW
[] =
182 {'F','r','e','e','S','p','a','c','e',0};
183 static const WCHAR prop_handleW
[] =
184 {'H','a','n','d','l','e',0};
185 static const WCHAR prop_idW
[] =
187 static const WCHAR prop_identificationcodeW
[] =
188 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
189 static const WCHAR prop_identifyingnumberW
[] =
190 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
191 static const WCHAR prop_indexW
[] =
192 {'I','n','d','e','x',0};
193 static const WCHAR prop_installdateW
[] =
194 {'I','n','s','t','a','l','l','D','a','t','e',0};
195 static const WCHAR prop_interfaceindexW
[] =
196 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
197 static const WCHAR prop_interfacetypeW
[] =
198 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
199 static const WCHAR prop_intvalueW
[] =
200 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
201 static const WCHAR prop_ipconnectionmetricW
[] =
202 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
203 static const WCHAR prop_ipenabledW
[] =
204 {'I','P','E','n','a','b','l','e','d',0};
205 static const WCHAR prop_lastbootuptimeW
[] =
206 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
207 static const WCHAR prop_localdatetimeW
[] =
208 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
209 static const WCHAR prop_localeW
[] =
210 {'L','o','c','a','l','e',0};
211 static const WCHAR prop_macaddressW
[] =
212 {'M','A','C','A','d','d','r','e','s','s',0};
213 static const WCHAR prop_manufacturerW
[] =
214 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
215 static const WCHAR prop_maxclockspeedW
[] =
216 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
217 static const WCHAR prop_mediatypeW
[] =
218 {'M','e','d','i','a','T','y','p','e',0};
219 static const WCHAR prop_memberW
[] =
220 {'M','e','m','b','e','r',0};
221 static const WCHAR prop_methodW
[] =
222 {'M','e','t','h','o','d',0};
223 static const WCHAR prop_modelW
[] =
224 {'M','o','d','e','l',0};
225 static const WCHAR prop_netconnectionstatusW
[] =
226 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
227 static const WCHAR prop_numcoresW
[] =
228 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
229 static const WCHAR prop_numlogicalprocessorsW
[] =
230 {'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};
231 static const WCHAR prop_numprocessorsW
[] =
232 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
233 static const WCHAR prop_osarchitectureW
[] =
234 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
235 static const WCHAR prop_oslanguageW
[] =
236 {'O','S','L','a','n','g','u','a','g','e',0};
237 static const WCHAR prop_osproductsuiteW
[] =
238 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
239 static const WCHAR prop_ostypeW
[] =
240 {'O','S','T','y','p','e',0};
241 static const WCHAR prop_parameterW
[] =
242 {'P','a','r','a','m','e','t','e','r',0};
243 static const WCHAR prop_physicaladapterW
[] =
244 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
245 static const WCHAR prop_pnpdeviceidW
[] =
246 {'P','N','P','D','e','v','i','c','e','I','D',0};
247 static const WCHAR prop_pprocessidW
[] =
248 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
249 static const WCHAR prop_processidW
[] =
250 {'P','r','o','c','e','s','s','I','D',0};
251 static const WCHAR prop_processoridW
[] =
252 {'P','r','o','c','e','s','s','o','r','I','d',0};
253 static const WCHAR prop_processortypeW
[] =
254 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
255 static const WCHAR prop_productW
[] =
256 {'P','r','o','d','u','c','t',0};
257 static const WCHAR prop_productnameW
[] =
258 {'P','r','o','d','u','c','t','N','a','m','e',0};
259 static const WCHAR prop_referenceddomainnameW
[] =
260 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
261 static const WCHAR prop_releasedateW
[] =
262 {'R','e','l','e','a','s','e','D','a','t','e',0};
263 static const WCHAR prop_serialnumberW
[] =
264 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
265 static const WCHAR prop_servicepackmajorW
[] =
266 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
267 static const WCHAR prop_servicepackminorW
[] =
268 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
269 static const WCHAR prop_servicetypeW
[] =
270 {'S','e','r','v','i','c','e','T','y','p','e',0};
271 static const WCHAR prop_smbiosbiosversionW
[] =
272 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
273 static const WCHAR prop_startmodeW
[] =
274 {'S','t','a','r','t','M','o','d','e',0};
275 static const WCHAR prop_sidW
[] =
277 static const WCHAR prop_sidlengthW
[] =
278 {'S','i','d','L','e','n','g','t','h',0};
279 static const WCHAR prop_sizeW
[] =
281 static const WCHAR prop_speedW
[] =
282 {'S','p','e','e','d',0};
283 static const WCHAR prop_startingoffsetW
[] =
284 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
285 static const WCHAR prop_stateW
[] =
286 {'S','t','a','t','e',0};
287 static const WCHAR prop_statusinfoW
[] =
288 {'S','t','a','t','u','s','I','n','f','o',0};
289 static const WCHAR prop_strvalueW
[] =
290 {'S','t','r','i','n','g','V','a','l','u','e',0};
291 static const WCHAR prop_suitemaskW
[] =
292 {'S','u','i','t','e','M','a','s','k',0};
293 static const WCHAR prop_systemdirectoryW
[] =
294 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
295 static const WCHAR prop_systemnameW
[] =
296 {'S','y','s','t','e','m','N','a','m','e',0};
297 static const WCHAR prop_tagW
[] =
299 static const WCHAR prop_threadcountW
[] =
300 {'T','h','r','e','a','d','C','o','u','n','t',0};
301 static const WCHAR prop_totalphysicalmemoryW
[] =
302 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
303 static const WCHAR prop_totalvisiblememorysizeW
[] =
304 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
305 static const WCHAR prop_typeW
[] =
307 static const WCHAR prop_uniqueidW
[] =
308 {'U','n','i','q','u','e','I','d',0};
309 static const WCHAR prop_usernameW
[] =
310 {'U','s','e','r','N','a','m','e',0};
311 static const WCHAR prop_uuidW
[] =
313 static const WCHAR prop_varianttypeW
[] =
314 {'V','a','r','i','a','n','t','T','y','p','e',0};
315 static const WCHAR prop_versionW
[] =
316 {'V','e','r','s','i','o','n',0};
317 static const WCHAR prop_videoprocessorW
[] =
318 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
319 static const WCHAR prop_volumenameW
[] =
320 {'V','o','l','u','m','e','N','a','m','e',0};
321 static const WCHAR prop_volumeserialnumberW
[] =
322 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
324 /* column definitions must be kept in sync with record structures below */
325 static const struct column col_baseboard
[] =
327 { prop_manufacturerW
, CIM_STRING
},
328 { prop_modelW
, CIM_STRING
},
329 { prop_nameW
, CIM_STRING
},
330 { prop_productW
, CIM_STRING
},
331 { prop_serialnumberW
, CIM_STRING
},
332 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
333 { prop_versionW
, CIM_STRING
}
335 static const struct column col_bios
[] =
337 { prop_descriptionW
, CIM_STRING
},
338 { prop_identificationcodeW
, CIM_STRING
},
339 { prop_manufacturerW
, CIM_STRING
},
340 { prop_releasedateW
, CIM_DATETIME
},
341 { prop_serialnumberW
, CIM_STRING
},
342 { prop_smbiosbiosversionW
, CIM_STRING
},
343 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
345 static const struct column col_cdromdrive
[] =
347 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
348 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
349 { prop_mediatypeW
, CIM_STRING
},
350 { prop_nameW
, CIM_STRING
},
351 { prop_pnpdeviceidW
, CIM_STRING
}
353 static const struct column col_compsys
[] =
355 { prop_descriptionW
, CIM_STRING
},
356 { prop_domainW
, CIM_STRING
},
357 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
358 { prop_manufacturerW
, CIM_STRING
},
359 { prop_modelW
, CIM_STRING
},
360 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
361 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
362 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
363 { prop_totalphysicalmemoryW
, CIM_UINT64
},
364 { prop_usernameW
, CIM_STRING
}
366 static const struct column col_compsysproduct
[] =
368 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
369 { prop_uuidW
, CIM_STRING
}
371 static const struct column col_datafile
[] =
373 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
374 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
376 static const struct column col_directory
[] =
378 { prop_accessmaskW
, CIM_UINT32
},
379 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
381 static const struct column col_diskdrive
[] =
383 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
384 { prop_indexW
, CIM_UINT32
, VT_I4
},
385 { prop_interfacetypeW
, CIM_STRING
},
386 { prop_manufacturerW
, CIM_STRING
},
387 { prop_mediatypeW
, CIM_STRING
},
388 { prop_modelW
, CIM_STRING
},
389 { prop_pnpdeviceidW
, CIM_STRING
},
390 { prop_serialnumberW
, CIM_STRING
},
391 { prop_sizeW
, CIM_UINT64
}
393 static const struct column col_diskpartition
[] =
395 { prop_bootableW
, CIM_BOOLEAN
},
396 { prop_bootpartitionW
, CIM_BOOLEAN
},
397 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
398 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
399 { prop_indexW
, CIM_UINT32
, VT_I4
},
400 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
401 { prop_sizeW
, CIM_UINT64
},
402 { prop_startingoffsetW
, CIM_UINT64
},
403 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
405 static const struct column col_logicaldisk
[] =
407 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
408 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
409 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
410 { prop_freespaceW
, CIM_UINT64
},
411 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
412 { prop_sizeW
, CIM_UINT64
},
413 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
414 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
416 static const struct column col_networkadapter
[] =
418 { prop_adaptertypeW
, CIM_STRING
},
419 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
420 { prop_indexW
, CIM_UINT32
, VT_I4
},
421 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
422 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
423 { prop_manufacturerW
, CIM_STRING
},
424 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
425 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
426 { prop_physicaladapterW
, CIM_BOOLEAN
},
427 { prop_pnpdeviceidW
, CIM_STRING
},
428 { prop_speedW
, CIM_UINT64
}
430 static const struct column col_networkadapterconfig
[] =
432 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
433 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
434 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
435 { prop_ipenabledW
, CIM_BOOLEAN
},
436 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
438 static const struct column col_os
[] =
440 { prop_buildnumberW
, CIM_STRING
},
441 { prop_captionW
, CIM_STRING
},
442 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
443 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
444 { prop_csdversionW
, CIM_STRING
},
445 { prop_installdateW
, CIM_DATETIME
},
446 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
447 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
448 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
449 { prop_nameW
, CIM_STRING
},
450 { prop_osarchitectureW
, CIM_STRING
},
451 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
452 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
453 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
454 { prop_serialnumberW
, CIM_STRING
},
455 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
456 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
457 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
458 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
459 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
460 { prop_versionW
, CIM_STRING
}
462 static const struct column col_param
[] =
464 { prop_classW
, CIM_STRING
},
465 { prop_methodW
, CIM_STRING
},
466 { prop_directionW
, CIM_SINT32
},
467 { prop_parameterW
, CIM_STRING
},
468 { prop_typeW
, CIM_UINT32
},
469 { prop_varianttypeW
, CIM_UINT32
},
470 { prop_defaultvalueW
, CIM_UINT32
}
472 static const struct column col_physicalmedia
[] =
474 { prop_serialnumberW
, CIM_STRING
},
475 { prop_tagW
, CIM_STRING
}
477 static const struct column col_physicalmemory
[] =
479 { prop_capacityW
, CIM_UINT64
}
481 static const struct column col_process
[] =
483 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
484 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
485 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
486 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
487 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
488 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
489 { prop_processidW
, CIM_UINT32
, VT_I4
},
490 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
492 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
494 static const struct column col_processor
[] =
496 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
497 { prop_cpustatusW
, CIM_UINT16
},
498 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
499 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
500 { prop_familyW
, CIM_UINT16
, VT_I4
},
501 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
502 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
503 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
504 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
505 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
506 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
507 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
508 { prop_uniqueidW
, CIM_STRING
}
510 static const struct column col_qualifier
[] =
512 { prop_classW
, CIM_STRING
},
513 { prop_memberW
, CIM_STRING
},
514 { prop_typeW
, CIM_UINT32
},
515 { prop_flavorW
, CIM_SINT32
},
516 { prop_nameW
, CIM_STRING
},
517 { prop_intvalueW
, CIM_SINT32
},
518 { prop_strvalueW
, CIM_STRING
}
520 static const struct column col_service
[] =
522 { prop_acceptpauseW
, CIM_BOOLEAN
},
523 { prop_acceptstopW
, CIM_BOOLEAN
},
524 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
525 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
526 { prop_processidW
, CIM_UINT32
},
527 { prop_servicetypeW
, CIM_STRING
},
528 { prop_startmodeW
, CIM_STRING
},
529 { prop_stateW
, CIM_STRING
},
530 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
532 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
533 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
534 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
535 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
537 static const struct column col_sid
[] =
539 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
540 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
541 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
542 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
543 { prop_sidlengthW
, CIM_UINT32
}
545 static const struct column col_sounddevice
[] =
547 { prop_nameW
, CIM_STRING
},
548 { prop_productnameW
, CIM_STRING
},
549 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
551 static const struct column col_stdregprov
[] =
553 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
554 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
555 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
557 static const struct column col_systemsecurity
[] =
559 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
560 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
562 static const struct column col_videocontroller
[] =
564 { prop_adapterdactypeW
, CIM_STRING
},
565 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
566 { prop_availabilityW
, CIM_UINT16
},
567 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
568 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
569 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
570 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
571 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
572 { prop_driverversionW
, CIM_STRING
},
573 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
574 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
575 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
578 static const WCHAR baseboard_manufacturerW
[] =
579 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
580 static const WCHAR baseboard_serialnumberW
[] =
582 static const WCHAR baseboard_tagW
[] =
583 {'B','a','s','e',' ','B','o','a','r','d',0};
584 static const WCHAR baseboard_versionW
[] =
586 static const WCHAR bios_descriptionW
[] =
587 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
588 static const WCHAR bios_manufacturerW
[] =
589 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
590 static const WCHAR bios_releasedateW
[] =
591 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
592 static const WCHAR bios_serialnumberW
[] =
594 static const WCHAR bios_smbiosbiosversionW
[] =
596 static const WCHAR bios_versionW
[] =
597 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
598 static const WCHAR cdromdrive_mediatypeW
[] =
599 {'C','D','-','R','O','M',0};
600 static const WCHAR cdromdrive_nameW
[] =
601 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
602 static const WCHAR cdromdrive_pnpdeviceidW
[]=
603 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
604 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
605 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
606 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
607 static const WCHAR compsys_descriptionW
[] =
608 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
609 static const WCHAR compsys_domainW
[] =
610 {'W','O','R','K','G','R','O','U','P',0};
611 static const WCHAR compsys_manufacturerW
[] =
612 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
613 static const WCHAR compsys_modelW
[] =
615 static const WCHAR compsysproduct_identifyingnumberW
[] =
617 static const WCHAR compsysproduct_uuidW
[] =
618 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
619 '0','0','0','0','0','0','0','0','0','0','0','0',0};
620 static const WCHAR diskdrive_interfacetypeW
[] =
622 static const WCHAR diskdrive_manufacturerW
[] =
623 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
624 static const WCHAR diskdrive_mediatype_fixedW
[] =
625 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
626 static const WCHAR diskdrive_mediatype_removableW
[] =
627 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
628 static const WCHAR diskdrive_modelW
[] =
629 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
630 static const WCHAR diskdrive_pnpdeviceidW
[] =
631 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
632 static const WCHAR diskdrive_serialW
[] =
633 {'W','I','N','E','H','D','I','S','K',0};
634 static const WCHAR networkadapter_pnpdeviceidW
[]=
635 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
636 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
637 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
638 static const WCHAR os_32bitW
[] =
639 {'3','2','-','b','i','t',0};
640 static const WCHAR os_64bitW
[] =
641 {'6','4','-','b','i','t',0};
642 static const WCHAR os_buildnumberW
[] =
644 static const WCHAR os_captionW
[] =
645 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
646 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
647 static const WCHAR os_csdversionW
[] =
648 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
649 static const WCHAR os_installdateW
[] =
650 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
651 static const WCHAR os_nameW
[] =
652 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
653 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
654 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
655 '\\','P','a','r','t','i','t','i','o','n','1',0};
656 static const WCHAR os_serialnumberW
[] =
657 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
658 static const WCHAR os_versionW
[] =
659 {'5','.','1','.','2','6','0','0',0};
660 static const WCHAR physicalmedia_tagW
[] =
661 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
662 static const WCHAR sounddevice_productnameW
[] =
663 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
664 static const WCHAR videocontroller_dactypeW
[] =
665 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
666 static const WCHAR videocontroller_deviceidW
[] =
667 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
668 static const WCHAR videocontroller_driverversionW
[] =
671 #include "pshpack1.h"
672 struct record_baseboard
674 const WCHAR
*manufacturer
;
677 const WCHAR
*product
;
678 const WCHAR
*serialnumber
;
680 const WCHAR
*version
;
684 const WCHAR
*description
;
685 const WCHAR
*identificationcode
;
686 const WCHAR
*manufacturer
;
687 const WCHAR
*releasedate
;
688 const WCHAR
*serialnumber
;
689 const WCHAR
*smbiosbiosversion
;
690 const WCHAR
*version
;
692 struct record_cdromdrive
694 const WCHAR
*device_id
;
696 const WCHAR
*mediatype
;
698 const WCHAR
*pnpdevice_id
;
700 struct record_computersystem
702 const WCHAR
*description
;
705 const WCHAR
*manufacturer
;
708 UINT32 num_logical_processors
;
709 UINT32 num_processors
;
710 UINT64 total_physical_memory
;
711 const WCHAR
*username
;
713 struct record_computersystemproduct
715 const WCHAR
*identifyingnumber
;
718 struct record_datafile
721 const WCHAR
*version
;
723 struct record_directory
728 struct record_diskdrive
730 const WCHAR
*device_id
;
732 const WCHAR
*interfacetype
;
733 const WCHAR
*manufacturer
;
734 const WCHAR
*mediatype
;
736 const WCHAR
*pnpdevice_id
;
737 const WCHAR
*serialnumber
;
740 struct record_diskpartition
744 const WCHAR
*device_id
;
747 const WCHAR
*pnpdevice_id
;
749 UINT64 startingoffset
;
752 struct record_logicaldisk
754 const WCHAR
*device_id
;
756 const WCHAR
*filesystem
;
760 const WCHAR
*volumename
;
761 const WCHAR
*volumeserialnumber
;
763 struct record_networkadapter
765 const WCHAR
*adaptertype
;
766 const WCHAR
*device_id
;
768 UINT32 interface_index
;
769 const WCHAR
*mac_address
;
770 const WCHAR
*manufacturer
;
772 UINT16 netconnection_status
;
774 const WCHAR
*pnpdevice_id
;
777 struct record_networkadapterconfig
779 const WCHAR
*dnshostname
;
781 UINT32 ipconnectionmetric
;
783 const WCHAR
*mac_address
;
785 struct record_operatingsystem
787 const WCHAR
*buildnumber
;
788 const WCHAR
*caption
;
789 const WCHAR
*codeset
;
790 const WCHAR
*countrycode
;
791 const WCHAR
*csdversion
;
792 const WCHAR
*installdate
;
793 const WCHAR
*lastbootuptime
;
794 const WCHAR
*localdatetime
;
797 const WCHAR
*osarchitecture
;
799 UINT32 osproductsuite
;
801 const WCHAR
*serialnumber
;
802 UINT16 servicepackmajor
;
803 UINT16 servicepackminor
;
805 const WCHAR
*systemdirectory
;
806 UINT64 totalvisiblememorysize
;
807 const WCHAR
*version
;
814 const WCHAR
*parameter
;
819 struct record_physicalmedia
821 const WCHAR
*serialnumber
;
824 struct record_physicalmemory
828 struct record_process
830 const WCHAR
*caption
;
831 const WCHAR
*commandline
;
832 const WCHAR
*description
;
839 class_method
*get_owner
;
841 struct record_processor
845 UINT32 currentclockspeed
;
846 const WCHAR
*device_id
;
848 const WCHAR
*manufacturer
;
849 UINT32 maxclockspeed
;
852 UINT32 num_logical_processors
;
853 const WCHAR
*processor_id
;
854 UINT16 processortype
;
855 const WCHAR
*unique_id
;
857 struct record_qualifier
865 const WCHAR
*strvalue
;
867 struct record_service
871 const WCHAR
*displayname
;
874 const WCHAR
*servicetype
;
875 const WCHAR
*startmode
;
877 const WCHAR
*systemname
;
879 class_method
*pause_service
;
880 class_method
*resume_service
;
881 class_method
*start_service
;
882 class_method
*stop_service
;
886 const WCHAR
*accountname
;
887 const UINT8
*binaryrepresentation
;
888 const WCHAR
*referenceddomainname
;
892 struct record_sounddevice
895 const WCHAR
*productname
;
898 struct record_stdregprov
900 class_method
*enumkey
;
901 class_method
*enumvalues
;
902 class_method
*getstringvalue
;
904 struct record_systemsecurity
909 struct record_videocontroller
911 const WCHAR
*adapter_dactype
;
914 UINT32 current_bitsperpixel
;
915 UINT32 current_horizontalres
;
916 UINT32 current_verticalres
;
917 const WCHAR
*description
;
918 const WCHAR
*device_id
;
919 const WCHAR
*driverversion
;
921 const WCHAR
*pnpdevice_id
;
922 const WCHAR
*videoprocessor
;
926 static const struct record_baseboard data_baseboard
[] =
928 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
930 static const struct record_bios data_bios
[] =
932 { bios_descriptionW
, bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
,
933 bios_smbiosbiosversionW
, bios_versionW
}
935 static const struct record_computersystemproduct data_compsysproduct
[] =
937 { compsysproduct_identifyingnumberW
, compsysproduct_uuidW
}
939 static const struct record_param data_param
[] =
941 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
942 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
943 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
944 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
945 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
946 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
947 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
948 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
949 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
950 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
951 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
952 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
953 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
954 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
955 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
956 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
957 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
958 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
959 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
960 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
961 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
962 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
963 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
964 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
965 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
968 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
969 WBEM_FLAVOR_ORIGIN_PROPAGATED)
971 static const struct record_physicalmedia data_physicalmedia
[] =
973 { diskdrive_serialW
, physicalmedia_tagW
}
975 static const struct record_qualifier data_qualifier
[] =
977 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
978 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
980 static const struct record_sounddevice data_sounddevice
[] =
982 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
984 static const struct record_stdregprov data_stdregprov
[] =
986 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
988 static const struct record_systemsecurity data_systemsecurity
[] =
990 { security_get_sd
, security_set_sd
}
993 /* check if row matches condition and update status */
994 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1001 *status
= FILL_STATUS_UNFILTERED
;
1004 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1006 *status
= FILL_STATUS_FAILED
;
1009 *status
= FILL_STATUS_FILTERED
;
1013 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1015 if (!table
->num_rows_allocated
)
1017 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1018 table
->num_rows_allocated
= row_count
;
1021 if (row_count
>= table
->num_rows_allocated
)
1024 UINT count
= table
->num_rows_allocated
* 2;
1025 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1027 table
->num_rows_allocated
= count
;
1032 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1034 static const WCHAR fmtW
[] = {'%','c',':',0};
1035 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1036 struct record_cdromdrive
*rec
;
1037 UINT i
, row
= 0, offset
= 0;
1038 DWORD drives
= GetLogicalDrives();
1039 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1041 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1043 for (i
= 0; i
< sizeof(drives
); i
++)
1045 if (drives
& (1 << i
))
1048 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1051 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1053 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1054 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1055 sprintfW( drive
, fmtW
, 'A' + i
);
1056 rec
->drive
= heap_strdupW( drive
);
1057 rec
->mediatype
= cdromdrive_mediatypeW
;
1058 rec
->name
= cdromdrive_nameW
;
1059 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1060 if (!match_row( table
, row
, cond
, &status
))
1062 free_row_values( table
, row
);
1065 offset
+= sizeof(*rec
);
1069 TRACE("created %u rows\n", row
);
1070 table
->num_rows
= row
;
1074 static UINT
get_processor_count(void)
1076 SYSTEM_BASIC_INFORMATION info
;
1078 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1079 return info
.NumberOfProcessors
;
1082 static UINT
get_logical_processor_count( UINT
*num_cores
)
1084 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1085 UINT i
, j
, count
= 0;
1089 if (num_cores
) *num_cores
= get_processor_count();
1090 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1091 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1093 if (!(info
= heap_alloc( len
))) return get_processor_count();
1094 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1095 if (status
!= STATUS_SUCCESS
)
1098 return get_processor_count();
1100 if (num_cores
) *num_cores
= 0;
1101 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1103 if (info
[i
].Relationship
== RelationProcessorCore
)
1105 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1107 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1109 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1116 static UINT64
get_total_physical_memory(void)
1118 MEMORYSTATUSEX status
;
1120 status
.dwLength
= sizeof(status
);
1121 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1122 return status
.ullTotalPhys
;
1125 static WCHAR
*get_computername(void)
1128 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1130 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1131 GetComputerNameW( ret
, &size
);
1135 static WCHAR
*get_username(void)
1138 DWORD compsize
, usersize
;
1142 GetComputerNameW( NULL
, &compsize
);
1144 GetUserNameW( NULL
, &usersize
);
1145 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1146 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1147 GetComputerNameW( ret
, &compsize
);
1148 ret
[compsize
] = '\\';
1149 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1153 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1155 struct record_computersystem
*rec
;
1156 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1159 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1161 rec
= (struct record_computersystem
*)table
->data
;
1162 rec
->description
= compsys_descriptionW
;
1163 rec
->domain
= compsys_domainW
;
1164 rec
->domainrole
= 0; /* standalone workstation */
1165 rec
->manufacturer
= compsys_manufacturerW
;
1166 rec
->model
= compsys_modelW
;
1167 rec
->name
= get_computername();
1168 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1169 rec
->num_processors
= get_processor_count();
1170 rec
->total_physical_memory
= get_total_physical_memory();
1171 rec
->username
= get_username();
1172 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1175 TRACE("created %u rows\n", row
);
1176 table
->num_rows
= row
;
1188 static struct dirstack
*alloc_dirstack( UINT size
)
1190 struct dirstack
*dirstack
;
1192 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1193 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1195 heap_free( dirstack
);
1198 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1200 heap_free( dirstack
->dirs
);
1201 heap_free( dirstack
);
1204 dirstack
->num_dirs
= 0;
1205 dirstack
->num_allocated
= size
;
1209 static void clear_dirstack( struct dirstack
*dirstack
)
1212 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1213 dirstack
->num_dirs
= 0;
1216 static void free_dirstack( struct dirstack
*dirstack
)
1218 clear_dirstack( dirstack
);
1219 heap_free( dirstack
->dirs
);
1220 heap_free( dirstack
->len_dirs
);
1221 heap_free( dirstack
);
1224 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1226 UINT size
, i
= dirstack
->num_dirs
;
1228 if (!dir
) return FALSE
;
1230 if (i
== dirstack
->num_allocated
)
1235 size
= dirstack
->num_allocated
* 2;
1236 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1237 dirstack
->dirs
= tmp
;
1238 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1239 dirstack
->len_dirs
= len_tmp
;
1240 dirstack
->num_allocated
= size
;
1242 dirstack
->dirs
[i
] = dir
;
1243 dirstack
->len_dirs
[i
] = len
;
1244 dirstack
->num_dirs
++;
1248 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1250 if (!dirstack
->num_dirs
)
1255 dirstack
->num_dirs
--;
1256 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1257 return dirstack
->dirs
[dirstack
->num_dirs
];
1260 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1262 if (!dirstack
->num_dirs
) return NULL
;
1263 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1266 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1271 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1277 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1286 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1288 UINT i
= 0, len
= 0;
1292 for (p
= path
; *p
; p
++)
1294 if (*p
== '\\') len
+= 2;
1297 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1302 for (p
= path
; *p
; p
++)
1304 if (*p
!= '\\') ret
[i
++] = *p
;
1315 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1317 const WCHAR
*p
= path
, *start
;
1321 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1323 len
= strlenW( start
);
1324 p
= start
+ len
- 1;
1325 if (*p
== '\\') return NULL
;
1327 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1328 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1330 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1331 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1333 if (p
[0] == '\\' && p
[1] == '\\')
1345 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1348 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1352 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1353 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1355 const struct expr
*left
, *right
;
1357 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1359 left
= cond
->u
.expr
.left
;
1360 right
= cond
->u
.expr
.right
;
1361 if (cond
->u
.expr
.op
== OP_EQ
)
1365 const WCHAR
*str
= NULL
;
1367 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1368 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1369 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1371 str
= right
->u
.sval
;
1373 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1374 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1375 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1379 if (str
&& (path
= build_dirname( str
, &len
)))
1381 if (seen_dir( dirstack
, path
))
1386 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1391 else if (cond
->u
.expr
.op
== OP_OR
)
1393 UINT left_count
= 0, right_count
= 0;
1395 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1396 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1397 return *count
+= left_count
+ right_count
;
1402 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1404 UINT len_path
= 0, len_segment
= strlenW( segment
);
1408 if (path
) len_path
= strlenW( path
);
1409 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1410 if (path
&& len_path
)
1412 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1413 ret
[len_path
] = '\\';
1414 *len
+= len_path
+ 1;
1416 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1417 *len
+= len_segment
;
1422 static WCHAR
*get_file_version( const WCHAR
*filename
)
1424 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1425 VS_FIXEDFILEINFO
*info
;
1430 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1431 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1436 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1437 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1443 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1444 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1449 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1451 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1452 struct record_datafile
*rec
;
1453 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1454 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1455 DWORD drives
= GetLogicalDrives();
1456 WIN32_FIND_DATAW data
;
1458 struct dirstack
*dirstack
;
1459 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1461 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1463 dirstack
= alloc_dirstack(2);
1465 for (i
= 0; i
< sizeof(drives
); i
++)
1467 if (!(drives
& (1 << i
))) continue;
1470 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1472 num_expected_rows
= 0;
1473 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1477 path
= pop_dir( dirstack
, &len
);
1478 if (!(glob
= build_glob( root
[0], path
, len
)))
1480 status
= FILL_STATUS_FAILED
;
1483 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1487 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1489 status
= FILL_STATUS_FAILED
;
1490 FindClose( handle
);
1493 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1494 new_path
= append_path( path
, data
.cFileName
, &len
);
1496 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1498 if (push_dir( dirstack
, new_path
, len
)) continue;
1499 heap_free( new_path
);
1500 FindClose( handle
);
1501 status
= FILL_STATUS_FAILED
;
1504 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1505 rec
->name
= build_name( root
[0], new_path
);
1506 rec
->version
= get_file_version( rec
->name
);
1507 if (!match_row( table
, row
, cond
, &status
))
1509 free_row_values( table
, row
);
1512 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1515 FindClose( handle
);
1516 status
= FILL_STATUS_FILTERED
;
1519 offset
+= sizeof(*rec
);
1522 while (FindNextFileW( handle
, &data
));
1523 FindClose( handle
);
1525 if (!peek_dir( dirstack
)) break;
1532 free_dirstack( dirstack
);
1536 TRACE("created %u rows\n", row
);
1537 table
->num_rows
= row
;
1541 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1543 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1544 struct record_directory
*rec
;
1545 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1546 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1547 DWORD drives
= GetLogicalDrives();
1548 WIN32_FIND_DATAW data
;
1550 struct dirstack
*dirstack
;
1551 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1553 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1555 dirstack
= alloc_dirstack(2);
1557 for (i
= 0; i
< sizeof(drives
); i
++)
1559 if (!(drives
& (1 << i
))) continue;
1562 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1564 num_expected_rows
= 0;
1565 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1569 path
= pop_dir( dirstack
, &len
);
1570 if (!(glob
= build_glob( root
[0], path
, len
)))
1572 status
= FILL_STATUS_FAILED
;
1575 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1579 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1581 FindClose( handle
);
1582 status
= FILL_STATUS_FAILED
;
1585 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1586 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1589 new_path
= append_path( path
, data
.cFileName
, &len
);
1590 if (!(push_dir( dirstack
, new_path
, len
)))
1592 heap_free( new_path
);
1593 FindClose( handle
);
1594 status
= FILL_STATUS_FAILED
;
1597 rec
= (struct record_directory
*)(table
->data
+ offset
);
1598 rec
->accessmask
= FILE_ALL_ACCESS
;
1599 rec
->name
= build_name( root
[0], new_path
);
1600 if (!match_row( table
, row
, cond
, &status
))
1602 free_row_values( table
, row
);
1605 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1608 FindClose( handle
);
1609 status
= FILL_STATUS_FILTERED
;
1612 offset
+= sizeof(*rec
);
1615 while (FindNextFileW( handle
, &data
));
1616 FindClose( handle
);
1618 if (!peek_dir( dirstack
)) break;
1625 free_dirstack( dirstack
);
1629 TRACE("created %u rows\n", row
);
1630 table
->num_rows
= row
;
1634 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1636 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1637 ULARGE_INTEGER free
;
1638 DISK_GEOMETRY_EX info
;
1640 DWORD bytes_returned
;
1642 free
.QuadPart
= 512 * 1024 * 1024;
1643 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1646 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1647 if (handle
!= INVALID_HANDLE_VALUE
)
1649 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1650 *disksize
= info
.DiskSize
.QuadPart
;
1651 CloseHandle( handle
);
1653 return free
.QuadPart
;
1656 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1658 static const WCHAR fmtW
[] =
1659 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1660 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1661 struct record_diskdrive
*rec
;
1662 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1663 UINT64 size
= 1024 * 1024 * 1024;
1664 DWORD drives
= GetLogicalDrives();
1665 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1667 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1669 for (i
= 0; i
< sizeof(drives
); i
++)
1671 if (drives
& (1 << i
))
1674 type
= GetDriveTypeW( root
);
1675 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1678 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1680 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1681 sprintfW( device_id
, fmtW
, index
);
1682 rec
->device_id
= heap_strdupW( device_id
);
1684 rec
->interfacetype
= diskdrive_interfacetypeW
;
1685 rec
->manufacturer
= diskdrive_manufacturerW
;
1686 if (type
== DRIVE_FIXED
)
1687 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1689 rec
->mediatype
= diskdrive_mediatype_removableW
;
1690 rec
->model
= diskdrive_modelW
;
1691 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1692 rec
->serialnumber
= diskdrive_serialW
;
1693 get_freespace( root
, &size
);
1695 if (!match_row( table
, row
, cond
, &status
))
1697 free_row_values( table
, row
);
1700 offset
+= sizeof(*rec
);
1705 TRACE("created %u rows\n", row
);
1706 table
->num_rows
= row
;
1710 static WCHAR
*get_filesystem( const WCHAR
*root
)
1712 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1713 WCHAR buffer
[MAX_PATH
+ 1];
1715 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1716 return heap_strdupW( buffer
);
1717 return heap_strdupW( ntfsW
);
1720 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1722 static const WCHAR fmtW
[] =
1723 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1724 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1725 struct record_diskpartition
*rec
;
1726 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1727 UINT64 size
= 1024 * 1024 * 1024;
1728 DWORD drives
= GetLogicalDrives();
1729 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1731 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1733 for (i
= 0; i
< sizeof(drives
); i
++)
1735 if (drives
& (1 << i
))
1738 type
= GetDriveTypeW( root
);
1739 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1742 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1744 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1745 rec
->bootable
= (i
== 2) ? -1 : 0;
1746 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1747 sprintfW( device_id
, fmtW
, index
);
1748 rec
->device_id
= heap_strdupW( device_id
);
1749 rec
->diskindex
= index
;
1751 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1752 get_freespace( root
, &size
);
1754 rec
->startingoffset
= 0;
1755 rec
->type
= get_filesystem( root
);
1756 if (!match_row( table
, row
, cond
, &status
))
1758 free_row_values( table
, row
);
1761 offset
+= sizeof(*rec
);
1766 TRACE("created %u rows\n", row
);
1767 table
->num_rows
= row
;
1771 static WCHAR
*get_volumename( const WCHAR
*root
)
1773 WCHAR buf
[MAX_PATH
+ 1] = {0};
1774 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1775 return heap_strdupW( buf
);
1777 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1779 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1783 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1784 sprintfW( buffer
, fmtW
, serial
);
1785 return heap_strdupW( buffer
);
1788 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1790 static const WCHAR fmtW
[] = {'%','c',':',0};
1791 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1792 struct record_logicaldisk
*rec
;
1793 UINT i
, row
= 0, offset
= 0, type
;
1794 UINT64 size
= 1024 * 1024 * 1024;
1795 DWORD drives
= GetLogicalDrives();
1796 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1798 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1800 for (i
= 0; i
< sizeof(drives
); i
++)
1802 if (drives
& (1 << i
))
1805 type
= GetDriveTypeW( root
);
1806 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
1809 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1811 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
1812 sprintfW( device_id
, fmtW
, 'A' + i
);
1813 rec
->device_id
= heap_strdupW( device_id
);
1814 rec
->drivetype
= type
;
1815 rec
->filesystem
= get_filesystem( root
);
1816 rec
->freespace
= get_freespace( root
, &size
);
1817 rec
->name
= heap_strdupW( device_id
);
1819 rec
->volumename
= get_volumename( root
);
1820 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
1821 if (!match_row( table
, row
, cond
, &status
))
1823 free_row_values( table
, row
);
1826 offset
+= sizeof(*rec
);
1830 TRACE("created %u rows\n", row
);
1831 table
->num_rows
= row
;
1835 static UINT16
get_connection_status( IF_OPER_STATUS status
)
1839 case IfOperStatusDown
:
1840 return 0; /* Disconnected */
1841 case IfOperStatusUp
:
1842 return 2; /* Connected */
1844 ERR("unhandled status %u\n", status
);
1849 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
1851 static const WCHAR fmtW
[] =
1852 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1853 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1856 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
1857 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
1860 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
1862 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1863 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
1864 static const WCHAR firewireW
[] = {'1','3','9','4',0};
1865 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
1869 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
1870 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
1871 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
1872 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
1873 default: *physical
= 0; return NULL
;
1877 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
1879 static const WCHAR fmtW
[] = {'%','u',0};
1880 WCHAR device_id
[11];
1881 struct record_networkadapter
*rec
;
1882 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1883 UINT row
= 0, offset
= 0, count
= 0;
1884 DWORD size
= 0, ret
;
1886 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1888 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1889 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1891 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1892 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1894 heap_free( buffer
);
1895 return FILL_STATUS_FAILED
;
1897 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1899 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1901 if (!resize_table( table
, count
, sizeof(*rec
) ))
1903 heap_free( buffer
);
1904 return FILL_STATUS_FAILED
;
1906 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1908 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1910 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
1911 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
1912 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
1913 rec
->device_id
= heap_strdupW( device_id
);
1914 rec
->index
= aa
->u
.s
.IfIndex
;
1915 rec
->interface_index
= aa
->u
.s
.IfIndex
;
1916 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1917 rec
->manufacturer
= compsys_manufacturerW
;
1918 rec
->name
= heap_strdupW( aa
->FriendlyName
);
1919 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
1920 rec
->physicaladapter
= physical
;
1921 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
1922 rec
->speed
= 1000000;
1923 if (!match_row( table
, row
, cond
, &status
))
1925 free_row_values( table
, row
);
1928 offset
+= sizeof(*rec
);
1931 TRACE("created %u rows\n", row
);
1932 table
->num_rows
= row
;
1934 heap_free( buffer
);
1938 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
1940 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
1941 WCHAR buf
[NI_MAXHOST
];
1943 if (!addr
) return NULL
;
1944 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
1945 0, NI_NAMEREQD
)) return NULL
;
1946 return heap_strdupW( buf
);
1949 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
1951 struct record_networkadapterconfig
*rec
;
1952 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
1953 UINT row
= 0, offset
= 0, count
= 0;
1954 DWORD size
= 0, ret
;
1955 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1957 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
1958 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
1960 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
1961 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
1963 heap_free( buffer
);
1964 return FILL_STATUS_FAILED
;
1966 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1968 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
1970 if (!resize_table( table
, count
, sizeof(*rec
) ))
1972 heap_free( buffer
);
1973 return FILL_STATUS_FAILED
;
1975 for (aa
= buffer
; aa
; aa
= aa
->Next
)
1977 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
1979 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
1980 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
1981 rec
->index
= aa
->u
.s
.IfIndex
;
1982 rec
->ipconnectionmetric
= 20;
1983 rec
->ipenabled
= -1;
1984 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
1985 if (!match_row( table
, row
, cond
, &status
))
1987 free_row_values( table
, row
);
1990 offset
+= sizeof(*rec
);
1993 TRACE("created %u rows\n", row
);
1994 table
->num_rows
= row
;
1996 heap_free( buffer
);
2000 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
2002 struct record_physicalmemory
*rec
;
2003 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2006 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2008 rec
= (struct record_physicalmemory
*)table
->data
;
2009 rec
->capacity
= get_total_physical_memory();
2010 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2013 TRACE("created %u rows\n", row
);
2014 table
->num_rows
= row
;
2018 static WCHAR
*get_cmdline( DWORD process_id
)
2020 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2021 return NULL
; /* FIXME handle different process case */
2024 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2026 static const WCHAR fmtW
[] = {'%','u',0};
2028 struct record_process
*rec
;
2029 PROCESSENTRY32W entry
;
2031 enum fill_status status
= FILL_STATUS_FAILED
;
2032 UINT row
= 0, offset
= 0;
2034 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2035 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2037 entry
.dwSize
= sizeof(entry
);
2038 if (!Process32FirstW( snap
, &entry
)) goto done
;
2039 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2043 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2045 rec
= (struct record_process
*)(table
->data
+ offset
);
2046 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2047 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2048 rec
->description
= heap_strdupW( entry
.szExeFile
);
2049 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2050 rec
->handle
= heap_strdupW( handle
);
2051 rec
->name
= heap_strdupW( entry
.szExeFile
);
2052 rec
->process_id
= entry
.th32ProcessID
;
2053 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2054 rec
->thread_count
= entry
.cntThreads
;
2055 rec
->get_owner
= process_get_owner
;
2056 if (!match_row( table
, row
, cond
, &status
))
2058 free_row_values( table
, row
);
2061 offset
+= sizeof(*rec
);
2063 } while (Process32NextW( snap
, &entry
));
2065 TRACE("created %u rows\n", row
);
2066 table
->num_rows
= row
;
2067 status
= FILL_STATUS_UNFILTERED
;
2070 CloseHandle( snap
);
2074 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2077 __asm__("pushl %%ebx\n\t"
2079 "movl %%ebx, %%esi\n\t"
2081 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2086 static void get_processor_id( WCHAR
*processor_id
)
2088 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2089 unsigned int regs
[4] = {0, 0, 0, 0};
2091 do_cpuid( 1, regs
);
2092 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2094 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2097 unsigned char *p
= (unsigned char *)regs
;
2099 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2102 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2104 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2106 do_cpuid( 0, regs
);
2107 tmp
= regs
[2]; /* swap edx and ecx */
2111 regs_to_str( regs
+ 1, 12, manufacturer
);
2113 static void get_processor_name( WCHAR
*name
)
2115 unsigned int regs
[4] = {0, 0, 0, 0};
2117 do_cpuid( 0x80000000, regs
);
2118 if (regs
[0] >= 0x80000004)
2120 do_cpuid( 0x80000002, regs
);
2121 regs_to_str( regs
, 16, name
);
2122 do_cpuid( 0x80000003, regs
);
2123 regs_to_str( regs
, 16, name
+ 16 );
2124 do_cpuid( 0x80000004, regs
);
2125 regs_to_str( regs
, 16, name
+ 32 );
2128 static UINT
get_processor_currentclockspeed( UINT index
)
2130 PROCESSOR_POWER_INFORMATION
*info
;
2131 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2134 if ((info
= heap_alloc( size
)))
2136 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2137 if (!status
) ret
= info
[index
].CurrentMhz
;
2142 static UINT
get_processor_maxclockspeed( UINT index
)
2144 PROCESSOR_POWER_INFORMATION
*info
;
2145 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2148 if ((info
= heap_alloc( size
)))
2150 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2151 if (!status
) ret
= info
[index
].MaxMhz
;
2156 static const WCHAR
*get_osarchitecture(void)
2159 GetNativeSystemInfo( &info
);
2160 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2164 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2166 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2167 WCHAR device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0};
2168 struct record_processor
*rec
;
2169 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2170 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2172 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2174 get_processor_id( processor_id
);
2175 get_processor_manufacturer( manufacturer
);
2176 get_processor_name( name
);
2178 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2181 for (i
= 0; i
< count
; i
++)
2183 rec
= (struct record_processor
*)(table
->data
+ offset
);
2184 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2185 rec
->cpu_status
= 1; /* CPU Enabled */
2186 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2187 sprintfW( device_id
, fmtW
, i
);
2188 rec
->device_id
= heap_strdupW( device_id
);
2189 rec
->family
= 2; /* Unknown */
2190 rec
->manufacturer
= heap_strdupW( manufacturer
);
2191 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2192 rec
->name
= heap_strdupW( name
);
2193 rec
->num_cores
= num_cores
;
2194 rec
->num_logical_processors
= num_logical_processors
;
2195 rec
->processor_id
= heap_strdupW( processor_id
);
2196 rec
->processortype
= 3; /* central processor */
2197 rec
->unique_id
= NULL
;
2198 if (!match_row( table
, i
, cond
, &status
))
2200 free_row_values( table
, i
);
2203 offset
+= sizeof(*rec
);
2206 TRACE("created %u rows\n", count
);
2207 table
->num_rows
= count
;
2211 static WCHAR
*get_lastbootuptime(void)
2213 static const WCHAR fmtW
[] =
2214 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2215 '.','%','0','6','u','+','0','0','0',0};
2216 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2220 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2222 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2223 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2224 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2227 static WCHAR
*get_localdatetime(void)
2229 static const WCHAR fmtW
[] =
2230 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2231 '.','%','0','6','u','%','+','0','3','d',0};
2232 TIME_ZONE_INFORMATION tzi
;
2238 Status
= GetTimeZoneInformation(&tzi
);
2240 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2242 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2243 Bias
+= tzi
.DaylightBias
;
2245 Bias
+= tzi
.StandardBias
;
2246 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2249 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2252 static WCHAR
*get_systemdirectory(void)
2257 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2258 Wow64DisableWow64FsRedirection( &redir
);
2259 GetSystemDirectoryW( ret
, MAX_PATH
);
2260 Wow64RevertWow64FsRedirection( redir
);
2263 static WCHAR
*get_codeset(void)
2265 static const WCHAR fmtW
[] = {'%','u',0};
2266 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2267 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2270 static WCHAR
*get_countrycode(void)
2272 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2273 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2276 static WCHAR
*get_locale(void)
2278 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2279 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2283 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2285 struct record_operatingsystem
*rec
;
2286 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2289 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2291 rec
= (struct record_operatingsystem
*)table
->data
;
2292 rec
->buildnumber
= os_buildnumberW
;
2293 rec
->caption
= os_captionW
;
2294 rec
->codeset
= get_codeset();
2295 rec
->countrycode
= get_countrycode();
2296 rec
->csdversion
= os_csdversionW
;
2297 rec
->installdate
= os_installdateW
;
2298 rec
->lastbootuptime
= get_lastbootuptime();
2299 rec
->localdatetime
= get_localdatetime();
2300 rec
->locale
= get_locale();
2301 rec
->name
= os_nameW
;
2302 rec
->osarchitecture
= get_osarchitecture();
2303 rec
->oslanguage
= GetSystemDefaultLangID();
2304 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2305 rec
->ostype
= 18; /* WINNT */
2306 rec
->serialnumber
= os_serialnumberW
;
2307 rec
->servicepackmajor
= 3;
2308 rec
->servicepackminor
= 0;
2309 rec
->suitemask
= 272; /* Single User + Terminal */
2310 rec
->systemdirectory
= get_systemdirectory();
2311 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2312 rec
->version
= os_versionW
;
2313 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2316 TRACE("created %u rows\n", row
);
2317 table
->num_rows
= row
;
2321 static const WCHAR
*get_service_type( DWORD type
)
2323 static const WCHAR filesystem_driverW
[] =
2324 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2325 static const WCHAR kernel_driverW
[] =
2326 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2327 static const WCHAR own_processW
[] =
2328 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2329 static const WCHAR share_processW
[] =
2330 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2332 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2333 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2334 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2335 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2336 else ERR("unhandled type 0x%08x\n", type
);
2339 static const WCHAR
*get_service_state( DWORD state
)
2341 static const WCHAR runningW
[] =
2342 {'R','u','n','n','i','n','g',0};
2343 static const WCHAR start_pendingW
[] =
2344 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2345 static const WCHAR stop_pendingW
[] =
2346 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2347 static const WCHAR stoppedW
[] =
2348 {'S','t','o','p','p','e','d',0};
2349 static const WCHAR unknownW
[] =
2350 {'U','n','k','n','o','w','n',0};
2354 case SERVICE_STOPPED
: return stoppedW
;
2355 case SERVICE_START_PENDING
: return start_pendingW
;
2356 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2357 case SERVICE_RUNNING
: return runningW
;
2359 ERR("unknown state %u\n", state
);
2363 static const WCHAR
*get_service_startmode( DWORD mode
)
2365 static const WCHAR bootW
[] = {'B','o','o','t',0};
2366 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2367 static const WCHAR autoW
[] = {'A','u','t','o',0};
2368 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2369 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2370 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2374 case SERVICE_BOOT_START
: return bootW
;
2375 case SERVICE_SYSTEM_START
: return systemW
;
2376 case SERVICE_AUTO_START
: return autoW
;
2377 case SERVICE_DEMAND_START
: return manualW
;
2378 case SERVICE_DISABLED
: return disabledW
;
2380 ERR("unknown mode 0x%x\n", mode
);
2384 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2386 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2390 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2391 QueryServiceConfigW( service
, NULL
, 0, &size
);
2392 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2393 if (!(config
= heap_alloc( size
))) goto done
;
2394 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2395 heap_free( config
);
2399 CloseServiceHandle( service
);
2403 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2405 struct record_service
*rec
;
2407 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2408 SERVICE_STATUS_PROCESS
*status
;
2409 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2410 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2411 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2412 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2415 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2416 if (!(services
= heap_alloc( size
))) goto done
;
2418 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2419 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2420 &count
, NULL
, NULL
);
2423 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2425 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2427 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2428 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2429 &count
, NULL
, NULL
);
2430 if (!ret
) goto done
;
2432 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2434 GetComputerNameW( sysnameW
, &len
);
2435 fill_status
= FILL_STATUS_UNFILTERED
;
2437 for (i
= 0; i
< count
; i
++)
2439 QUERY_SERVICE_CONFIGW
*config
;
2441 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2443 status
= &services
[i
].ServiceStatusProcess
;
2444 rec
= (struct record_service
*)(table
->data
+ offset
);
2445 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2446 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2447 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2448 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2449 rec
->process_id
= status
->dwProcessId
;
2450 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2451 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2452 rec
->state
= get_service_state( status
->dwCurrentState
);
2453 rec
->systemname
= heap_strdupW( sysnameW
);
2454 rec
->pause_service
= service_pause_service
;
2455 rec
->resume_service
= service_resume_service
;
2456 rec
->start_service
= service_start_service
;
2457 rec
->stop_service
= service_stop_service
;
2458 heap_free( config
);
2459 if (!match_row( table
, row
, cond
, &fill_status
))
2461 free_row_values( table
, row
);
2464 offset
+= sizeof(*rec
);
2468 TRACE("created %u rows\n", row
);
2469 table
->num_rows
= row
;
2472 CloseServiceHandle( manager
);
2473 heap_free( services
);
2477 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2479 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2480 return heap_strdupW( name
->Name
.Buffer
);
2482 static UINT8
*get_binaryrepresentation( PSID sid
, UINT len
)
2484 UINT8
*ret
= heap_alloc( len
);
2485 if (!ret
) return NULL
;
2486 memcpy( ret
, sid
, len
);
2489 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2491 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2492 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2494 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2496 const struct expr
*left
, *right
;
2497 const WCHAR
*ret
= NULL
;
2499 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2501 left
= cond
->u
.expr
.left
;
2502 right
= cond
->u
.expr
.right
;
2503 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2505 ret
= right
->u
.sval
;
2507 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2514 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2517 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2518 LSA_TRANSLATED_NAME
*name
;
2520 LSA_OBJECT_ATTRIBUTES attrs
;
2522 struct record_sid
*rec
;
2525 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
2526 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2528 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
2529 len
= GetLengthSid( sid
);
2531 memset( &attrs
, 0, sizeof(attrs
) );
2532 attrs
.Length
= sizeof(attrs
);
2533 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
2536 return FILL_STATUS_FAILED
;
2538 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
2542 return FILL_STATUS_FAILED
;
2545 rec
= (struct record_sid
*)table
->data
;
2546 rec
->accountname
= get_accountname( name
);
2547 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
2548 rec
->referenceddomainname
= get_referenceddomainname( domain
);
2549 rec
->sid
= heap_strdupW( str
);
2550 rec
->sidlength
= len
;
2552 TRACE("created 1 row\n");
2553 table
->num_rows
= 1;
2555 LsaFreeMemory( domain
);
2556 LsaFreeMemory( name
);
2559 return FILL_STATUS_FILTERED
;
2562 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
2564 HDC hdc
= GetDC( NULL
);
2567 if (!hdc
) return 32;
2568 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
2569 *hres
= GetDeviceCaps( hdc
, HORZRES
);
2570 *vres
= GetDeviceCaps( hdc
, VERTRES
);
2571 ReleaseDC( NULL
, hdc
);
2574 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
2576 static const WCHAR fmtW
[] =
2577 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2578 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2579 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2582 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
2583 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
2587 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
2590 struct record_videocontroller
*rec
;
2592 IDXGIFactory
*factory
= NULL
;
2593 IDXGIAdapter
*adapter
= NULL
;
2594 DXGI_ADAPTER_DESC desc
;
2595 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
2596 const WCHAR
*name
= videocontroller_deviceidW
;
2597 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2600 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2602 memset (&desc
, 0, sizeof(desc
));
2603 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
2604 if (FAILED(hr
)) goto done
;
2606 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
2607 if (FAILED(hr
)) goto done
;
2609 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
2612 vidmem
= desc
.DedicatedVideoMemory
;
2613 name
= desc
.Description
;
2617 rec
= (struct record_videocontroller
*)table
->data
;
2618 rec
->adapter_dactype
= videocontroller_dactypeW
;
2619 rec
->adapter_ram
= vidmem
;
2620 rec
->availability
= 3; /* Running or Full Power */
2621 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
2622 rec
->current_horizontalres
= hres
;
2623 rec
->current_verticalres
= vres
;
2624 rec
->description
= heap_strdupW( name
);
2625 rec
->device_id
= videocontroller_deviceidW
;
2626 rec
->driverversion
= videocontroller_driverversionW
;
2627 rec
->name
= heap_strdupW( name
);
2628 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
2629 rec
->videoprocessor
= heap_strdupW( name
);
2630 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2633 TRACE("created %u rows\n", row
);
2634 table
->num_rows
= row
;
2636 if (adapter
) IDXGIAdapter_Release( adapter
);
2637 if (factory
) IDXGIFactory_Release( factory
);
2641 static struct table builtin_classes
[] =
2643 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
2644 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
2645 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
2646 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
2647 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, SIZEOF(data_compsysproduct
), 0, (BYTE
*)data_compsysproduct
},
2648 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
2649 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
2650 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
2651 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
2652 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2653 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
2654 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
2655 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
2656 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
2657 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
2658 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
2659 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
2660 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
2661 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2662 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
2663 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
2664 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
2665 { class_sidW
, SIZEOF(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
2666 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
2667 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
2668 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
2669 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
2672 void init_table_list( void )
2674 static struct list tables
= LIST_INIT( tables
);
2677 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
2678 table_list
= &tables
;