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
30 #define WIN32_NO_STATUS
49 #include "wine/debug.h"
50 #include "wbemprox_private.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
54 static const WCHAR class_baseboardW
[] =
55 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
56 static const WCHAR class_biosW
[] =
57 {'W','i','n','3','2','_','B','I','O','S',0};
58 static const WCHAR class_cdromdriveW
[] =
59 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
60 static const WCHAR class_compsysW
[] =
61 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
62 static const WCHAR class_compsysproductW
[] =
63 {'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};
64 static const WCHAR class_datafileW
[] =
65 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
66 static const WCHAR class_desktopmonitorW
[] =
67 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
68 static const WCHAR class_directoryW
[] =
69 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
70 static const WCHAR class_diskdriveW
[] =
71 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
72 static const WCHAR class_diskpartitionW
[] =
73 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
74 static const WCHAR class_logicaldiskW
[] =
75 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
76 static const WCHAR class_logicaldisk2W
[] =
77 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
78 static const WCHAR class_networkadapterW
[] =
79 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
80 static const WCHAR class_networkadapterconfigW
[] =
81 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
82 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
83 static const WCHAR class_osW
[] =
84 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
85 static const WCHAR class_paramsW
[] =
86 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
87 static const WCHAR class_physicalmediaW
[] =
88 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
89 static const WCHAR class_physicalmemoryW
[] =
90 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
91 static const WCHAR class_printerW
[] =
92 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
93 static const WCHAR class_process_getowner_outW
[] =
94 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
95 'N','E','R','_','O','U','T',0};
96 static const WCHAR class_processorW
[] =
97 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
98 static const WCHAR class_processor2W
[] =
99 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
100 static const WCHAR class_qualifiersW
[] =
101 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
102 static const WCHAR class_sidW
[] =
103 {'W','i','n','3','2','_','S','I','D',0};
104 static const WCHAR class_sounddeviceW
[] =
105 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
106 static const WCHAR class_systemenclosureW
[] =
107 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
108 static const WCHAR class_videocontrollerW
[] =
109 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
111 static const WCHAR prop_accountnameW
[] =
112 {'A','c','c','o','u','n','t','N','a','m','e',0};
113 static const WCHAR prop_acceptpauseW
[] =
114 {'A','c','c','e','p','t','P','a','u','s','e',0};
115 static const WCHAR prop_acceptstopW
[] =
116 {'A','c','c','e','p','t','S','t','o','p',0};
117 static const WCHAR prop_accessmaskW
[] =
118 {'A','c','c','e','s','s','M','a','s','k',0};
119 static const WCHAR prop_adapterdactypeW
[] =
120 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
121 static const WCHAR prop_adapterramW
[] =
122 {'A','d','a','p','t','e','r','R','A','M',0};
123 static const WCHAR prop_adaptertypeW
[] =
124 {'A','d','a','p','t','e','r','T','y','p','e',0};
125 static const WCHAR prop_addresswidthW
[] =
126 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
127 static const WCHAR prop_attributesW
[] =
128 {'A','t','t','r','i','b','u','t','e','s',0};
129 static const WCHAR prop_availabilityW
[] =
130 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
131 static const WCHAR prop_binaryrepresentationW
[] =
132 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
133 static const WCHAR prop_bootableW
[] =
134 {'B','o','o','t','a','b','l','e',0};
135 static const WCHAR prop_bootpartitionW
[] =
136 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
137 static const WCHAR prop_buildnumberW
[] =
138 {'B','u','i','l','d','N','u','m','b','e','r',0};
139 static const WCHAR prop_capacityW
[] =
140 {'C','a','p','a','c','i','t','y',0};
141 static const WCHAR prop_captionW
[] =
142 {'C','a','p','t','i','o','n',0};
143 static const WCHAR prop_chassistypesW
[] =
144 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
145 static const WCHAR prop_classW
[] =
146 {'C','l','a','s','s',0};
147 static const WCHAR prop_codesetW
[] =
148 {'C','o','d','e','S','e','t',0};
149 static const WCHAR prop_commandlineW
[] =
150 {'C','o','m','m','a','n','d','L','i','n','e',0};
151 static const WCHAR prop_countrycodeW
[] =
152 {'C','o','u','n','t','r','y','C','o','d','e',0};
153 static const WCHAR prop_cpustatusW
[] =
154 {'C','p','u','S','t','a','t','u','s',0};
155 static const WCHAR prop_csdversionW
[] =
156 {'C','S','D','V','e','r','s','i','o','n',0};
157 static const WCHAR prop_currentbitsperpixelW
[] =
158 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
159 static const WCHAR prop_currentclockspeedW
[] =
160 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
161 static const WCHAR prop_currenthorizontalresW
[] =
162 {'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};
163 static const WCHAR prop_currentrefreshrateW
[] =
164 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
165 static const WCHAR prop_currentscanmodeW
[] =
166 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
167 static const WCHAR prop_currentverticalresW
[] =
168 {'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};
169 static const WCHAR prop_datawidthW
[] =
170 {'D','a','t','a','W','i','d','t','h',0};
171 static const WCHAR prop_defaultipgatewayW
[] =
172 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
173 static const WCHAR prop_defaultvalueW
[] =
174 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
175 static const WCHAR prop_descriptionW
[] =
176 {'D','e','s','c','r','i','p','t','i','o','n',0};
177 static const WCHAR prop_deviceidW
[] =
178 {'D','e','v','i','c','e','I','d',0};
179 static const WCHAR prop_dhcpenabledW
[] =
180 {'D','H','C','P','E','n','a','b','l','e','d',0};
181 static const WCHAR prop_directionW
[] =
182 {'D','i','r','e','c','t','i','o','n',0};
183 static const WCHAR prop_displaynameW
[] =
184 {'D','i','s','p','l','a','y','N','a','m','e',0};
185 static const WCHAR prop_diskindexW
[] =
186 {'D','i','s','k','I','n','d','e','x',0};
187 static const WCHAR prop_dnshostnameW
[] =
188 {'D','N','S','H','o','s','t','N','a','m','e',0};
189 static const WCHAR prop_dnsserversearchorderW
[] =
190 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
191 static const WCHAR prop_domainW
[] =
192 {'D','o','m','a','i','n',0};
193 static const WCHAR prop_domainroleW
[] =
194 {'D','o','m','a','i','n','R','o','l','e',0};
195 static const WCHAR prop_driveW
[] =
196 {'D','r','i','v','e',0};
197 static const WCHAR prop_drivernameW
[] =
198 {'D','r','i','v','e','r','N','a','m','e',0};
199 static const WCHAR prop_driverversionW
[] =
200 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
201 static const WCHAR prop_drivetypeW
[] =
202 {'D','r','i','v','e','T','y','p','e',0};
203 static const WCHAR prop_familyW
[] =
204 {'F','a','m','i','l','y',0};
205 static const WCHAR prop_filesystemW
[] =
206 {'F','i','l','e','S','y','s','t','e','m',0};
207 static const WCHAR prop_flavorW
[] =
208 {'F','l','a','v','o','r',0};
209 static const WCHAR prop_freespaceW
[] =
210 {'F','r','e','e','S','p','a','c','e',0};
211 static const WCHAR prop_handleW
[] =
212 {'H','a','n','d','l','e',0};
213 static const WCHAR prop_horizontalresolutionW
[] =
214 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
215 static const WCHAR prop_idW
[] =
217 static const WCHAR prop_identificationcodeW
[] =
218 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
219 static const WCHAR prop_identifyingnumberW
[] =
220 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
221 static const WCHAR prop_indexW
[] =
222 {'I','n','d','e','x',0};
223 static const WCHAR prop_installdateW
[] =
224 {'I','n','s','t','a','l','l','D','a','t','e',0};
225 static const WCHAR prop_interfaceindexW
[] =
226 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
227 static const WCHAR prop_interfacetypeW
[] =
228 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
229 static const WCHAR prop_intvalueW
[] =
230 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
231 static const WCHAR prop_ipconnectionmetricW
[] =
232 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
233 static const WCHAR prop_ipenabledW
[] =
234 {'I','P','E','n','a','b','l','e','d',0};
235 static const WCHAR prop_lastbootuptimeW
[] =
236 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
237 static const WCHAR prop_localW
[] =
238 {'L','o','c','a','l',0};
239 static const WCHAR prop_localdatetimeW
[] =
240 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
241 static const WCHAR prop_localeW
[] =
242 {'L','o','c','a','l','e',0};
243 static const WCHAR prop_lockpresentW
[] =
244 {'L','o','c','k','P','r','e','s','e','n','t',0};
245 static const WCHAR prop_macaddressW
[] =
246 {'M','A','C','A','d','d','r','e','s','s',0};
247 static const WCHAR prop_manufacturerW
[] =
248 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
249 static const WCHAR prop_maxclockspeedW
[] =
250 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
251 static const WCHAR prop_mediatypeW
[] =
252 {'M','e','d','i','a','T','y','p','e',0};
253 static const WCHAR prop_memberW
[] =
254 {'M','e','m','b','e','r',0};
255 static const WCHAR prop_memorytypeW
[] =
256 {'M','e','m','o','r','y','T','y','p','e',0};
257 static const WCHAR prop_methodW
[] =
258 {'M','e','t','h','o','d',0};
259 static const WCHAR prop_modelW
[] =
260 {'M','o','d','e','l',0};
261 static const WCHAR prop_netconnectionstatusW
[] =
262 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
263 static const WCHAR prop_networkW
[] =
264 {'N','e','t','w','o','r','k',0};
265 static const WCHAR prop_numcoresW
[] =
266 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
267 static const WCHAR prop_numlogicalprocessorsW
[] =
268 {'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};
269 static const WCHAR prop_numprocessorsW
[] =
270 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
271 static const WCHAR prop_osarchitectureW
[] =
272 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
273 static const WCHAR prop_oslanguageW
[] =
274 {'O','S','L','a','n','g','u','a','g','e',0};
275 static const WCHAR prop_osproductsuiteW
[] =
276 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
277 static const WCHAR prop_ostypeW
[] =
278 {'O','S','T','y','p','e',0};
279 static const WCHAR prop_parameterW
[] =
280 {'P','a','r','a','m','e','t','e','r',0};
281 static const WCHAR prop_physicaladapterW
[] =
282 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
283 static const WCHAR prop_pixelsperxlogicalinchW
[] =
284 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
285 static const WCHAR prop_pnpdeviceidW
[] =
286 {'P','N','P','D','e','v','i','c','e','I','D',0};
287 static const WCHAR prop_pprocessidW
[] =
288 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
289 static const WCHAR prop_primaryW
[] =
290 {'P','r','i','m','a','r','y',0};
291 static const WCHAR prop_processidW
[] =
292 {'P','r','o','c','e','s','s','I','D',0};
293 static const WCHAR prop_processoridW
[] =
294 {'P','r','o','c','e','s','s','o','r','I','d',0};
295 static const WCHAR prop_processortypeW
[] =
296 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
297 static const WCHAR prop_productW
[] =
298 {'P','r','o','d','u','c','t',0};
299 static const WCHAR prop_productnameW
[] =
300 {'P','r','o','d','u','c','t','N','a','m','e',0};
301 static const WCHAR prop_referenceddomainnameW
[] =
302 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
303 static const WCHAR prop_releasedateW
[] =
304 {'R','e','l','e','a','s','e','D','a','t','e',0};
305 static const WCHAR prop_serialnumberW
[] =
306 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
307 static const WCHAR prop_servicepackmajorW
[] =
308 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
309 static const WCHAR prop_servicepackminorW
[] =
310 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
311 static const WCHAR prop_servicetypeW
[] =
312 {'S','e','r','v','i','c','e','T','y','p','e',0};
313 static const WCHAR prop_settingidW
[] =
314 {'S','e','t','t','i','n','g','I','D',0};
315 static const WCHAR prop_smbiosbiosversionW
[] =
316 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
317 static const WCHAR prop_startmodeW
[] =
318 {'S','t','a','r','t','M','o','d','e',0};
319 static const WCHAR prop_sidW
[] =
321 static const WCHAR prop_sidlengthW
[] =
322 {'S','i','d','L','e','n','g','t','h',0};
323 static const WCHAR prop_sizeW
[] =
325 static const WCHAR prop_speedW
[] =
326 {'S','p','e','e','d',0};
327 static const WCHAR prop_startingoffsetW
[] =
328 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
329 static const WCHAR prop_stateW
[] =
330 {'S','t','a','t','e',0};
331 static const WCHAR prop_statusinfoW
[] =
332 {'S','t','a','t','u','s','I','n','f','o',0};
333 static const WCHAR prop_strvalueW
[] =
334 {'S','t','r','i','n','g','V','a','l','u','e',0};
335 static const WCHAR prop_suitemaskW
[] =
336 {'S','u','i','t','e','M','a','s','k',0};
337 static const WCHAR prop_systemdirectoryW
[] =
338 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
339 static const WCHAR prop_systemnameW
[] =
340 {'S','y','s','t','e','m','N','a','m','e',0};
341 static const WCHAR prop_tagW
[] =
343 static const WCHAR prop_threadcountW
[] =
344 {'T','h','r','e','a','d','C','o','u','n','t',0};
345 static const WCHAR prop_totalphysicalmemoryW
[] =
346 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
347 static const WCHAR prop_totalvirtualmemorysizeW
[] =
348 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
349 static const WCHAR prop_totalvisiblememorysizeW
[] =
350 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
351 static const WCHAR prop_typeW
[] =
353 static const WCHAR prop_uniqueidW
[] =
354 {'U','n','i','q','u','e','I','d',0};
355 static const WCHAR prop_usernameW
[] =
356 {'U','s','e','r','N','a','m','e',0};
357 static const WCHAR prop_uuidW
[] =
359 static const WCHAR prop_varianttypeW
[] =
360 {'V','a','r','i','a','n','t','T','y','p','e',0};
361 static const WCHAR prop_versionW
[] =
362 {'V','e','r','s','i','o','n',0};
363 static const WCHAR prop_videoarchitectureW
[] =
364 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
365 static const WCHAR prop_videomemorytypeW
[] =
366 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
367 static const WCHAR prop_videomodedescriptionW
[] =
368 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
369 static const WCHAR prop_videoprocessorW
[] =
370 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
371 static const WCHAR prop_volumenameW
[] =
372 {'V','o','l','u','m','e','N','a','m','e',0};
373 static const WCHAR prop_volumeserialnumberW
[] =
374 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
375 static const WCHAR prop_workingsetsizeW
[] =
376 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
378 /* column definitions must be kept in sync with record structures below */
379 static const struct column col_baseboard
[] =
381 { prop_manufacturerW
, CIM_STRING
},
382 { prop_modelW
, CIM_STRING
},
383 { prop_nameW
, CIM_STRING
},
384 { prop_productW
, CIM_STRING
},
385 { prop_serialnumberW
, CIM_STRING
},
386 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
387 { prop_versionW
, CIM_STRING
}
389 static const struct column col_bios
[] =
391 { prop_descriptionW
, CIM_STRING
},
392 { prop_identificationcodeW
, CIM_STRING
},
393 { prop_manufacturerW
, CIM_STRING
},
394 { prop_nameW
, CIM_STRING
},
395 { prop_releasedateW
, CIM_DATETIME
},
396 { prop_serialnumberW
, CIM_STRING
},
397 { prop_smbiosbiosversionW
, CIM_STRING
},
398 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
400 static const struct column col_cdromdrive
[] =
402 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
403 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
404 { prop_mediatypeW
, CIM_STRING
},
405 { prop_nameW
, CIM_STRING
},
406 { prop_pnpdeviceidW
, CIM_STRING
}
408 static const struct column col_compsys
[] =
410 { prop_descriptionW
, CIM_STRING
},
411 { prop_domainW
, CIM_STRING
},
412 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
413 { prop_manufacturerW
, CIM_STRING
},
414 { prop_modelW
, CIM_STRING
},
415 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
416 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
417 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
418 { prop_totalphysicalmemoryW
, CIM_UINT64
},
419 { prop_usernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
421 static const struct column col_compsysproduct
[] =
423 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
424 { prop_uuidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
426 static const struct column col_datafile
[] =
428 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
429 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
431 static const struct column col_desktopmonitor
[] =
433 { prop_pixelsperxlogicalinchW
, CIM_UINT32
}
435 static const struct column col_directory
[] =
437 { prop_accessmaskW
, CIM_UINT32
},
438 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
440 static const struct column col_diskdrive
[] =
442 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
443 { prop_indexW
, CIM_UINT32
, VT_I4
},
444 { prop_interfacetypeW
, CIM_STRING
},
445 { prop_manufacturerW
, CIM_STRING
},
446 { prop_mediatypeW
, CIM_STRING
},
447 { prop_modelW
, CIM_STRING
},
448 { prop_pnpdeviceidW
, CIM_STRING
},
449 { prop_serialnumberW
, CIM_STRING
},
450 { prop_sizeW
, CIM_UINT64
}
452 static const struct column col_diskpartition
[] =
454 { prop_bootableW
, CIM_BOOLEAN
},
455 { prop_bootpartitionW
, CIM_BOOLEAN
},
456 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
457 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
458 { prop_indexW
, CIM_UINT32
, VT_I4
},
459 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
460 { prop_sizeW
, CIM_UINT64
},
461 { prop_startingoffsetW
, CIM_UINT64
},
462 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
464 static const struct column col_logicaldisk
[] =
466 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
467 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
468 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
469 { prop_freespaceW
, CIM_UINT64
},
470 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
471 { prop_sizeW
, CIM_UINT64
},
472 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
473 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
475 static const struct column col_networkadapter
[] =
477 { prop_adaptertypeW
, CIM_STRING
},
478 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
479 { prop_indexW
, CIM_UINT32
, VT_I4
},
480 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
481 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
482 { prop_manufacturerW
, CIM_STRING
},
483 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
484 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
485 { prop_physicaladapterW
, CIM_BOOLEAN
},
486 { prop_pnpdeviceidW
, CIM_STRING
},
487 { prop_speedW
, CIM_UINT64
}
489 static const struct column col_networkadapterconfig
[] =
491 { prop_defaultipgatewayW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
492 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
493 { prop_dhcpenabledW
, CIM_BOOLEAN
},
494 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
495 { prop_dnsserversearchorderW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
496 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
497 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
498 { prop_ipenabledW
, CIM_BOOLEAN
},
499 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
500 { prop_settingidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
502 static const struct column col_os
[] =
504 { prop_buildnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
505 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
506 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
507 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
508 { prop_csdversionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
509 { prop_installdateW
, CIM_DATETIME
},
510 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
511 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
512 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
513 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
514 { prop_osarchitectureW
, CIM_STRING
},
515 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
516 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
517 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
518 { prop_primaryW
, CIM_BOOLEAN
},
519 { prop_serialnumberW
, CIM_STRING
},
520 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
521 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
522 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
523 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
524 { prop_totalvirtualmemorysizeW
, CIM_UINT64
},
525 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
526 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
528 static const struct column col_param
[] =
530 { prop_classW
, CIM_STRING
},
531 { prop_methodW
, CIM_STRING
},
532 { prop_directionW
, CIM_SINT32
},
533 { prop_parameterW
, CIM_STRING
},
534 { prop_typeW
, CIM_UINT32
},
535 { prop_varianttypeW
, CIM_UINT32
},
536 { prop_defaultvalueW
, CIM_UINT32
}
538 static const struct column col_physicalmedia
[] =
540 { prop_serialnumberW
, CIM_STRING
},
541 { prop_tagW
, CIM_STRING
}
543 static const struct column col_physicalmemory
[] =
545 { prop_capacityW
, CIM_UINT64
},
546 { prop_memorytypeW
, CIM_UINT16
, VT_I4
}
548 static const struct column col_printer
[] =
550 { prop_attributesW
, CIM_UINT32
},
551 { prop_drivernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
552 { prop_horizontalresolutionW
, CIM_UINT32
},
553 { prop_localW
, CIM_BOOLEAN
},
554 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
555 { prop_networkW
, CIM_BOOLEAN
}
557 static const struct column col_process
[] =
559 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
560 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
561 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
562 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
563 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
564 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
565 { prop_processidW
, CIM_UINT32
, VT_I4
},
566 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
567 { prop_workingsetsizeW
, CIM_UINT64
},
569 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
571 static const struct column col_processor
[] =
573 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
574 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
575 { prop_cpustatusW
, CIM_UINT16
},
576 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
577 { prop_datawidthW
, CIM_UINT16
, VT_I4
},
578 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
579 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
580 { prop_familyW
, CIM_UINT16
, VT_I4
},
581 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
582 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
583 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
584 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
585 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
586 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
587 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
588 { prop_uniqueidW
, CIM_STRING
},
589 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
591 static const struct column col_qualifier
[] =
593 { prop_classW
, CIM_STRING
},
594 { prop_memberW
, CIM_STRING
},
595 { prop_typeW
, CIM_UINT32
},
596 { prop_flavorW
, CIM_SINT32
},
597 { prop_nameW
, CIM_STRING
},
598 { prop_intvalueW
, CIM_SINT32
},
599 { prop_strvalueW
, CIM_STRING
}
601 static const struct column col_service
[] =
603 { prop_acceptpauseW
, CIM_BOOLEAN
},
604 { prop_acceptstopW
, CIM_BOOLEAN
},
605 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
606 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
607 { prop_processidW
, CIM_UINT32
},
608 { prop_servicetypeW
, CIM_STRING
},
609 { prop_startmodeW
, CIM_STRING
},
610 { prop_stateW
, CIM_STRING
},
611 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
613 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
614 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
615 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
616 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
618 static const struct column col_sid
[] =
620 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
621 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
622 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
623 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
624 { prop_sidlengthW
, CIM_UINT32
}
626 static const struct column col_sounddevice
[] =
628 { prop_nameW
, CIM_STRING
},
629 { prop_productnameW
, CIM_STRING
},
630 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
632 static const struct column col_stdregprov
[] =
634 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
635 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
636 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
638 static const struct column col_systemenclosure
[] =
640 { prop_captionW
, CIM_STRING
},
641 { prop_chassistypesW
, CIM_UINT16
|CIM_FLAG_ARRAY
, VT_I4
|VT_ARRAY
},
642 { prop_descriptionW
, CIM_STRING
},
643 { prop_lockpresentW
, CIM_BOOLEAN
},
644 { prop_manufacturerW
, CIM_STRING
},
645 { prop_nameW
, CIM_STRING
},
646 { prop_tagW
, CIM_STRING
},
648 static const struct column col_systemsecurity
[] =
650 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
651 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
653 static const struct column col_videocontroller
[] =
655 { prop_adapterdactypeW
, CIM_STRING
},
656 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
657 { prop_availabilityW
, CIM_UINT16
},
658 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
659 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
660 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
661 { prop_currentrefreshrateW
, CIM_UINT32
, VT_I4
},
662 { prop_currentscanmodeW
, CIM_UINT16
, VT_I4
},
663 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
664 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
665 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
666 { prop_driverversionW
, CIM_STRING
},
667 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
668 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
669 { prop_videoarchitectureW
, CIM_UINT16
, VT_I4
},
670 { prop_videomemorytypeW
, CIM_UINT16
, VT_I4
},
671 { prop_videomodedescriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
672 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
675 static const WCHAR baseboard_manufacturerW
[] =
676 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
677 static const WCHAR baseboard_serialnumberW
[] =
679 static const WCHAR baseboard_tagW
[] =
680 {'B','a','s','e',' ','B','o','a','r','d',0};
681 static const WCHAR baseboard_versionW
[] =
683 static const WCHAR bios_descriptionW
[] =
684 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
685 static const WCHAR bios_manufacturerW
[] =
686 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
687 static const WCHAR bios_nameW
[] =
688 {'W','I','N','E',' ','B','I','O','S',0};
689 static const WCHAR bios_releasedateW
[] =
690 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
691 static const WCHAR bios_serialnumberW
[] =
693 static const WCHAR bios_smbiosbiosversionW
[] =
695 static const WCHAR bios_versionW
[] =
696 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
697 static const WCHAR cdromdrive_mediatypeW
[] =
698 {'C','D','-','R','O','M',0};
699 static const WCHAR cdromdrive_nameW
[] =
700 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
701 static const WCHAR cdromdrive_pnpdeviceidW
[]=
702 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
703 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
704 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
705 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
706 static const WCHAR compsys_descriptionW
[] =
707 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
708 static const WCHAR compsys_domainW
[] =
709 {'W','O','R','K','G','R','O','U','P',0};
710 static const WCHAR compsys_manufacturerW
[] =
711 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
712 static const WCHAR compsys_modelW
[] =
714 static const WCHAR compsysproduct_identifyingnumberW
[] =
716 static const WCHAR compsysproduct_uuidW
[] =
717 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
718 'd','e','a','d','d','e','a','d','d','e','a','d',0};
719 static const WCHAR diskdrive_interfacetypeW
[] =
721 static const WCHAR diskdrive_manufacturerW
[] =
722 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
723 static const WCHAR diskdrive_mediatype_fixedW
[] =
724 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
725 static const WCHAR diskdrive_mediatype_removableW
[] =
726 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
727 static const WCHAR diskdrive_modelW
[] =
728 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
729 static const WCHAR diskdrive_pnpdeviceidW
[] =
730 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
731 static const WCHAR diskdrive_serialW
[] =
732 {'W','I','N','E','H','D','I','S','K',0};
733 static const WCHAR networkadapter_pnpdeviceidW
[]=
734 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
735 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
736 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
737 static const WCHAR os_32bitW
[] =
738 {'3','2','-','b','i','t',0};
739 static const WCHAR os_64bitW
[] =
740 {'6','4','-','b','i','t',0};
741 static const WCHAR os_installdateW
[] =
742 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
743 static const WCHAR os_serialnumberW
[] =
744 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
745 static const WCHAR physicalmedia_tagW
[] =
746 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
747 static const WCHAR sounddevice_productnameW
[] =
748 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
749 static const WCHAR systemenclosure_systemenclosureW
[] =
750 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
751 static const WCHAR systemenclosure_tagW
[] =
752 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
753 static const WCHAR systemenclosure_manufacturerW
[] =
755 static const WCHAR videocontroller_dactypeW
[] =
756 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
757 static const WCHAR videocontroller_deviceidW
[] =
758 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
759 static const WCHAR videocontroller_driverversionW
[] =
762 #include "pshpack1.h"
763 struct record_baseboard
765 const WCHAR
*manufacturer
;
768 const WCHAR
*product
;
769 const WCHAR
*serialnumber
;
771 const WCHAR
*version
;
775 const WCHAR
*description
;
776 const WCHAR
*identificationcode
;
777 const WCHAR
*manufacturer
;
779 const WCHAR
*releasedate
;
780 const WCHAR
*serialnumber
;
781 const WCHAR
*smbiosbiosversion
;
782 const WCHAR
*version
;
784 struct record_cdromdrive
786 const WCHAR
*device_id
;
788 const WCHAR
*mediatype
;
790 const WCHAR
*pnpdevice_id
;
792 struct record_computersystem
794 const WCHAR
*description
;
797 const WCHAR
*manufacturer
;
800 UINT32 num_logical_processors
;
801 UINT32 num_processors
;
802 UINT64 total_physical_memory
;
803 const WCHAR
*username
;
805 struct record_computersystemproduct
807 const WCHAR
*identifyingnumber
;
810 struct record_datafile
813 const WCHAR
*version
;
815 struct record_desktopmonitor
817 UINT32 pixelsperxlogicalinch
;
819 struct record_directory
824 struct record_diskdrive
826 const WCHAR
*device_id
;
828 const WCHAR
*interfacetype
;
829 const WCHAR
*manufacturer
;
830 const WCHAR
*mediatype
;
832 const WCHAR
*pnpdevice_id
;
833 const WCHAR
*serialnumber
;
836 struct record_diskpartition
840 const WCHAR
*device_id
;
843 const WCHAR
*pnpdevice_id
;
845 UINT64 startingoffset
;
848 struct record_logicaldisk
850 const WCHAR
*device_id
;
852 const WCHAR
*filesystem
;
856 const WCHAR
*volumename
;
857 const WCHAR
*volumeserialnumber
;
859 struct record_networkadapter
861 const WCHAR
*adaptertype
;
862 const WCHAR
*device_id
;
864 UINT32 interface_index
;
865 const WCHAR
*mac_address
;
866 const WCHAR
*manufacturer
;
868 UINT16 netconnection_status
;
870 const WCHAR
*pnpdevice_id
;
873 struct record_networkadapterconfig
875 const struct array
*defaultipgateway
;
876 const WCHAR
*description
;
878 const WCHAR
*dnshostname
;
879 const struct array
*dnsserversearchorder
;
881 UINT32 ipconnectionmetric
;
883 const WCHAR
*mac_address
;
884 const WCHAR
*settingid
;
886 struct record_operatingsystem
888 const WCHAR
*buildnumber
;
889 const WCHAR
*caption
;
890 const WCHAR
*codeset
;
891 const WCHAR
*countrycode
;
892 const WCHAR
*csdversion
;
893 const WCHAR
*installdate
;
894 const WCHAR
*lastbootuptime
;
895 const WCHAR
*localdatetime
;
898 const WCHAR
*osarchitecture
;
900 UINT32 osproductsuite
;
903 const WCHAR
*serialnumber
;
904 UINT16 servicepackmajor
;
905 UINT16 servicepackminor
;
907 const WCHAR
*systemdirectory
;
908 UINT64 totalvirtualmemorysize
;
909 UINT64 totalvisiblememorysize
;
910 const WCHAR
*version
;
917 const WCHAR
*parameter
;
922 struct record_physicalmedia
924 const WCHAR
*serialnumber
;
927 struct record_physicalmemory
932 struct record_printer
935 const WCHAR
*drivername
;
936 UINT32 horizontalresolution
;
941 struct record_process
943 const WCHAR
*caption
;
944 const WCHAR
*commandline
;
945 const WCHAR
*description
;
951 UINT64 workingsetsize
;
953 class_method
*get_owner
;
955 struct record_processor
958 const WCHAR
*caption
;
960 UINT32 currentclockspeed
;
962 const WCHAR
*description
;
963 const WCHAR
*device_id
;
965 const WCHAR
*manufacturer
;
966 UINT32 maxclockspeed
;
969 UINT32 num_logical_processors
;
970 const WCHAR
*processor_id
;
971 UINT16 processortype
;
972 const WCHAR
*unique_id
;
973 const WCHAR
*version
;
975 struct record_qualifier
983 const WCHAR
*strvalue
;
985 struct record_service
989 const WCHAR
*displayname
;
992 const WCHAR
*servicetype
;
993 const WCHAR
*startmode
;
995 const WCHAR
*systemname
;
997 class_method
*pause_service
;
998 class_method
*resume_service
;
999 class_method
*start_service
;
1000 class_method
*stop_service
;
1004 const WCHAR
*accountname
;
1005 const struct array
*binaryrepresentation
;
1006 const WCHAR
*referenceddomainname
;
1010 struct record_sounddevice
1013 const WCHAR
*productname
;
1016 struct record_stdregprov
1018 class_method
*enumkey
;
1019 class_method
*enumvalues
;
1020 class_method
*getstringvalue
;
1022 struct record_systemsecurity
1024 class_method
*getsd
;
1025 class_method
*setsd
;
1027 struct record_systemenclosure
1029 const WCHAR
*caption
;
1030 const struct array
*chassistypes
;
1031 const WCHAR
*description
;
1033 const WCHAR
*manufacturer
;
1037 struct record_videocontroller
1039 const WCHAR
*adapter_dactype
;
1041 UINT16 availability
;
1042 const WCHAR
*caption
;
1043 UINT32 current_bitsperpixel
;
1044 UINT32 current_horizontalres
;
1045 UINT32 current_refreshrate
;
1046 UINT16 current_scanmode
;
1047 UINT32 current_verticalres
;
1048 const WCHAR
*description
;
1049 const WCHAR
*device_id
;
1050 const WCHAR
*driverversion
;
1052 const WCHAR
*pnpdevice_id
;
1053 UINT16 videoarchitecture
;
1054 UINT16 videomemorytype
;
1055 const WCHAR
*videomodedescription
;
1056 const WCHAR
*videoprocessor
;
1058 #include "poppack.h"
1060 static const struct record_baseboard data_baseboard
[] =
1062 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
1064 static const struct record_bios data_bios
[] =
1066 { bios_descriptionW
, NULL
, bios_manufacturerW
, bios_nameW
, bios_releasedateW
, bios_serialnumberW
,
1067 bios_smbiosbiosversionW
, bios_versionW
}
1069 static const struct record_param data_param
[] =
1071 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1072 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
1073 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
1074 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1075 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1076 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1077 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1078 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1079 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1080 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1081 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1082 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1083 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
1084 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1085 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1086 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
1087 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1088 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
1089 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
1090 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1091 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
1092 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1093 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1094 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1095 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1098 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1099 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1101 static const struct record_physicalmedia data_physicalmedia
[] =
1103 { diskdrive_serialW
, physicalmedia_tagW
}
1105 static const struct record_qualifier data_qualifier
[] =
1107 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
1108 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
1110 static const struct record_sounddevice data_sounddevice
[] =
1112 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
1114 static const struct record_stdregprov data_stdregprov
[] =
1116 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
1118 static UINT16 systemenclosure_chassistypes
[] =
1122 static const struct array systemenclosure_chassistypes_array
=
1124 SIZEOF(systemenclosure_chassistypes
),
1125 &systemenclosure_chassistypes
1127 static const struct record_systemenclosure data_systemenclosure
[] =
1130 systemenclosure_systemenclosureW
,
1131 &systemenclosure_chassistypes_array
,
1132 systemenclosure_systemenclosureW
,
1134 systemenclosure_manufacturerW
,
1135 systemenclosure_systemenclosureW
,
1136 systemenclosure_tagW
,
1139 static const struct record_systemsecurity data_systemsecurity
[] =
1141 { security_get_sd
, security_set_sd
}
1144 /* check if row matches condition and update status */
1145 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1152 *status
= FILL_STATUS_UNFILTERED
;
1155 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1157 *status
= FILL_STATUS_FAILED
;
1160 *status
= FILL_STATUS_FILTERED
;
1164 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1166 if (!table
->num_rows_allocated
)
1168 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1169 table
->num_rows_allocated
= row_count
;
1172 if (row_count
> table
->num_rows_allocated
)
1175 UINT count
= max( row_count
, table
->num_rows_allocated
* 2 );
1176 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1178 table
->num_rows_allocated
= count
;
1183 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1185 static const WCHAR fmtW
[] = {'%','c',':',0};
1186 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1187 struct record_cdromdrive
*rec
;
1188 UINT i
, row
= 0, offset
= 0;
1189 DWORD drives
= GetLogicalDrives();
1190 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1192 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1194 for (i
= 0; i
< 26; i
++)
1196 if (drives
& (1 << i
))
1199 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1202 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1204 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1205 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1206 sprintfW( drive
, fmtW
, 'A' + i
);
1207 rec
->drive
= heap_strdupW( drive
);
1208 rec
->mediatype
= cdromdrive_mediatypeW
;
1209 rec
->name
= cdromdrive_nameW
;
1210 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1211 if (!match_row( table
, row
, cond
, &status
))
1213 free_row_values( table
, row
);
1216 offset
+= sizeof(*rec
);
1220 TRACE("created %u rows\n", row
);
1221 table
->num_rows
= row
;
1225 static UINT
get_processor_count(void)
1227 SYSTEM_BASIC_INFORMATION info
;
1229 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1230 return info
.NumberOfProcessors
;
1233 static UINT
get_logical_processor_count( UINT
*num_cores
)
1235 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1236 UINT i
, j
, count
= 0;
1240 if (num_cores
) *num_cores
= get_processor_count();
1241 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1242 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1244 if (!(info
= heap_alloc( len
))) return get_processor_count();
1245 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1246 if (status
!= STATUS_SUCCESS
)
1249 return get_processor_count();
1251 if (num_cores
) *num_cores
= 0;
1252 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1254 if (info
[i
].Relationship
== RelationProcessorCore
)
1256 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1258 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1260 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1267 static UINT64
get_total_physical_memory(void)
1269 MEMORYSTATUSEX status
;
1271 status
.dwLength
= sizeof(status
);
1272 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1273 return status
.ullTotalPhys
;
1276 static WCHAR
*get_computername(void)
1279 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1281 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1282 GetComputerNameW( ret
, &size
);
1286 static WCHAR
*get_username(void)
1289 DWORD compsize
, usersize
;
1293 GetComputerNameW( NULL
, &compsize
);
1295 GetUserNameW( NULL
, &usersize
);
1296 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1297 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1298 GetComputerNameW( ret
, &compsize
);
1299 ret
[compsize
] = '\\';
1300 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1304 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1306 struct record_computersystem
*rec
;
1307 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1310 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1312 rec
= (struct record_computersystem
*)table
->data
;
1313 rec
->description
= compsys_descriptionW
;
1314 rec
->domain
= compsys_domainW
;
1315 rec
->domainrole
= 0; /* standalone workstation */
1316 rec
->manufacturer
= compsys_manufacturerW
;
1317 rec
->model
= compsys_modelW
;
1318 rec
->name
= get_computername();
1319 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1320 rec
->num_processors
= get_processor_count();
1321 rec
->total_physical_memory
= get_total_physical_memory();
1322 rec
->username
= get_username();
1323 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1326 TRACE("created %u rows\n", row
);
1327 table
->num_rows
= row
;
1331 static WCHAR
*get_compsysproduct_uuid(void)
1334 unsigned char uuid
[16];
1335 const struct timespec timeout
= {1, 0};
1336 if (!gethostuuid( uuid
, &timeout
))
1338 static const WCHAR fmtW
[] =
1339 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1340 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1341 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1342 WCHAR
*ret
= heap_alloc( 37 * sizeof(WCHAR
) );
1343 if (!ret
) return NULL
;
1344 sprintfW( ret
, fmtW
, uuid
[0], uuid
[1], uuid
[2], uuid
[3], uuid
[4], uuid
[5], uuid
[6], uuid
[7],
1345 uuid
[8], uuid
[9], uuid
[10], uuid
[11], uuid
[12], uuid
[13], uuid
[14], uuid
[15] );
1349 return heap_strdupW( compsysproduct_uuidW
);
1352 static enum fill_status
fill_compsysproduct( struct table
*table
, const struct expr
*cond
)
1354 struct record_computersystemproduct
*rec
;
1355 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1358 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1360 rec
= (struct record_computersystemproduct
*)table
->data
;
1361 rec
->identifyingnumber
= compsysproduct_identifyingnumberW
;
1362 rec
->uuid
= get_compsysproduct_uuid();
1363 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1366 TRACE("created %u rows\n", row
);
1367 table
->num_rows
= row
;
1379 static struct dirstack
*alloc_dirstack( UINT size
)
1381 struct dirstack
*dirstack
;
1383 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1384 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1386 heap_free( dirstack
);
1389 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1391 heap_free( dirstack
->dirs
);
1392 heap_free( dirstack
);
1395 dirstack
->num_dirs
= 0;
1396 dirstack
->num_allocated
= size
;
1400 static void clear_dirstack( struct dirstack
*dirstack
)
1403 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1404 dirstack
->num_dirs
= 0;
1407 static void free_dirstack( struct dirstack
*dirstack
)
1409 clear_dirstack( dirstack
);
1410 heap_free( dirstack
->dirs
);
1411 heap_free( dirstack
->len_dirs
);
1412 heap_free( dirstack
);
1415 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1417 UINT size
, i
= dirstack
->num_dirs
;
1419 if (!dir
) return FALSE
;
1421 if (i
== dirstack
->num_allocated
)
1426 size
= dirstack
->num_allocated
* 2;
1427 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1428 dirstack
->dirs
= tmp
;
1429 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1430 dirstack
->len_dirs
= len_tmp
;
1431 dirstack
->num_allocated
= size
;
1433 dirstack
->dirs
[i
] = dir
;
1434 dirstack
->len_dirs
[i
] = len
;
1435 dirstack
->num_dirs
++;
1439 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1441 if (!dirstack
->num_dirs
)
1446 dirstack
->num_dirs
--;
1447 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1448 return dirstack
->dirs
[dirstack
->num_dirs
];
1451 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1453 if (!dirstack
->num_dirs
) return NULL
;
1454 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1457 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1462 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1468 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1477 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1479 UINT i
= 0, len
= 0;
1483 for (p
= path
; *p
; p
++)
1485 if (*p
== '\\') len
+= 2;
1488 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1493 for (p
= path
; *p
; p
++)
1495 if (*p
!= '\\') ret
[i
++] = *p
;
1506 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1508 const WCHAR
*p
= path
, *start
;
1512 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1514 len
= strlenW( start
);
1515 p
= start
+ len
- 1;
1516 if (*p
== '\\') return NULL
;
1518 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1519 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1521 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1522 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1524 if (p
[0] == '\\' && p
[1] == '\\')
1536 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1539 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1543 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1544 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1546 const struct expr
*left
, *right
;
1548 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1550 left
= cond
->u
.expr
.left
;
1551 right
= cond
->u
.expr
.right
;
1552 if (cond
->u
.expr
.op
== OP_EQ
)
1556 const WCHAR
*str
= NULL
;
1558 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1559 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1560 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1562 str
= right
->u
.sval
;
1564 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1565 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1566 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1570 if (str
&& (path
= build_dirname( str
, &len
)))
1572 if (seen_dir( dirstack
, path
))
1577 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1582 else if (cond
->u
.expr
.op
== OP_OR
)
1584 UINT left_count
= 0, right_count
= 0;
1586 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1587 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1588 return *count
+= left_count
+ right_count
;
1593 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1595 UINT len_path
= 0, len_segment
= strlenW( segment
);
1599 if (path
) len_path
= strlenW( path
);
1600 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1601 if (path
&& len_path
)
1603 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1604 ret
[len_path
] = '\\';
1605 *len
+= len_path
+ 1;
1607 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1608 *len
+= len_segment
;
1613 static WCHAR
*get_file_version( const WCHAR
*filename
)
1615 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1616 VS_FIXEDFILEINFO
*info
;
1621 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1622 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1627 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1628 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1634 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1635 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1640 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1642 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1643 struct record_datafile
*rec
;
1644 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1645 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1646 DWORD drives
= GetLogicalDrives();
1647 WIN32_FIND_DATAW data
;
1649 struct dirstack
*dirstack
;
1650 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1652 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1654 dirstack
= alloc_dirstack(2);
1656 for (i
= 0; i
< 26; i
++)
1658 if (!(drives
& (1 << i
))) continue;
1661 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1663 num_expected_rows
= 0;
1664 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1670 path
= pop_dir( dirstack
, &len
);
1671 if (!(glob
= build_glob( root
[0], path
, len
)))
1673 status
= FILL_STATUS_FAILED
;
1676 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1680 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1682 status
= FILL_STATUS_FAILED
;
1683 FindClose( handle
);
1686 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1687 new_path
= append_path( path
, data
.cFileName
, &len
);
1689 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1691 if (push_dir( dirstack
, new_path
, len
)) continue;
1692 heap_free( new_path
);
1693 FindClose( handle
);
1694 status
= FILL_STATUS_FAILED
;
1697 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1698 rec
->name
= build_name( root
[0], new_path
);
1699 rec
->version
= get_file_version( rec
->name
);
1700 if (!match_row( table
, row
, cond
, &status
))
1702 free_row_values( table
, row
);
1705 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1708 FindClose( handle
);
1709 status
= FILL_STATUS_FILTERED
;
1712 offset
+= sizeof(*rec
);
1715 while (FindNextFileW( handle
, &data
));
1716 FindClose( handle
);
1718 if (!peek_dir( dirstack
)) break;
1723 free_dirstack( dirstack
);
1727 TRACE("created %u rows\n", row
);
1728 table
->num_rows
= row
;
1732 static UINT32
get_pixelsperxlogicalinch(void)
1734 HDC hdc
= GetDC( NULL
);
1737 if (!hdc
) return 96;
1738 ret
= GetDeviceCaps( hdc
, LOGPIXELSX
);
1739 ReleaseDC( NULL
, hdc
);
1743 static enum fill_status
fill_desktopmonitor( struct table
*table
, const struct expr
*cond
)
1745 struct record_desktopmonitor
*rec
;
1746 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1749 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1751 rec
= (struct record_desktopmonitor
*)table
->data
;
1752 rec
->pixelsperxlogicalinch
= get_pixelsperxlogicalinch();
1754 if (match_row( table
, row
, cond
, &status
)) row
++;
1756 TRACE("created %u rows\n", row
);
1757 table
->num_rows
= row
;
1761 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1763 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1764 struct record_directory
*rec
;
1765 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1766 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1767 DWORD drives
= GetLogicalDrives();
1768 WIN32_FIND_DATAW data
;
1770 struct dirstack
*dirstack
;
1771 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1773 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1775 dirstack
= alloc_dirstack(2);
1777 for (i
= 0; i
< 26; i
++)
1779 if (!(drives
& (1 << i
))) continue;
1782 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1784 num_expected_rows
= 0;
1785 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1791 path
= pop_dir( dirstack
, &len
);
1792 if (!(glob
= build_glob( root
[0], path
, len
)))
1794 status
= FILL_STATUS_FAILED
;
1797 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1801 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1803 FindClose( handle
);
1804 status
= FILL_STATUS_FAILED
;
1807 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1808 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1811 new_path
= append_path( path
, data
.cFileName
, &len
);
1812 if (!(push_dir( dirstack
, new_path
, len
)))
1814 heap_free( new_path
);
1815 FindClose( handle
);
1816 status
= FILL_STATUS_FAILED
;
1819 rec
= (struct record_directory
*)(table
->data
+ offset
);
1820 rec
->accessmask
= FILE_ALL_ACCESS
;
1821 rec
->name
= build_name( root
[0], new_path
);
1822 if (!match_row( table
, row
, cond
, &status
))
1824 free_row_values( table
, row
);
1827 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1830 FindClose( handle
);
1831 status
= FILL_STATUS_FILTERED
;
1834 offset
+= sizeof(*rec
);
1837 while (FindNextFileW( handle
, &data
));
1838 FindClose( handle
);
1840 if (!peek_dir( dirstack
)) break;
1845 free_dirstack( dirstack
);
1849 TRACE("created %u rows\n", row
);
1850 table
->num_rows
= row
;
1854 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1856 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1857 ULARGE_INTEGER free
;
1858 DISK_GEOMETRY_EX info
;
1860 DWORD bytes_returned
;
1862 free
.QuadPart
= 512 * 1024 * 1024;
1863 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1866 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1867 if (handle
!= INVALID_HANDLE_VALUE
)
1869 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1870 *disksize
= info
.DiskSize
.QuadPart
;
1871 CloseHandle( handle
);
1873 return free
.QuadPart
;
1876 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1878 static const WCHAR fmtW
[] =
1879 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1880 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1881 struct record_diskdrive
*rec
;
1882 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1883 UINT64 size
= 1024 * 1024 * 1024;
1884 DWORD drives
= GetLogicalDrives();
1885 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1887 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1889 for (i
= 0; i
< 26; i
++)
1891 if (drives
& (1 << i
))
1894 type
= GetDriveTypeW( root
);
1895 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1898 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1900 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1901 sprintfW( device_id
, fmtW
, index
);
1902 rec
->device_id
= heap_strdupW( device_id
);
1904 rec
->interfacetype
= diskdrive_interfacetypeW
;
1905 rec
->manufacturer
= diskdrive_manufacturerW
;
1906 if (type
== DRIVE_FIXED
)
1907 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1909 rec
->mediatype
= diskdrive_mediatype_removableW
;
1910 rec
->model
= diskdrive_modelW
;
1911 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1912 rec
->serialnumber
= diskdrive_serialW
;
1913 get_freespace( root
, &size
);
1915 if (!match_row( table
, row
, cond
, &status
))
1917 free_row_values( table
, row
);
1920 offset
+= sizeof(*rec
);
1925 TRACE("created %u rows\n", row
);
1926 table
->num_rows
= row
;
1930 static WCHAR
*get_filesystem( const WCHAR
*root
)
1932 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1933 WCHAR buffer
[MAX_PATH
+ 1];
1935 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1936 return heap_strdupW( buffer
);
1937 return heap_strdupW( ntfsW
);
1940 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1942 static const WCHAR fmtW
[] =
1943 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1944 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1945 struct record_diskpartition
*rec
;
1946 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1947 UINT64 size
= 1024 * 1024 * 1024;
1948 DWORD drives
= GetLogicalDrives();
1949 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1951 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1953 for (i
= 0; i
< 26; i
++)
1955 if (drives
& (1 << i
))
1958 type
= GetDriveTypeW( root
);
1959 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1962 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1964 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1965 rec
->bootable
= (i
== 2) ? -1 : 0;
1966 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1967 sprintfW( device_id
, fmtW
, index
);
1968 rec
->device_id
= heap_strdupW( device_id
);
1969 rec
->diskindex
= index
;
1971 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1972 get_freespace( root
, &size
);
1974 rec
->startingoffset
= 0;
1975 rec
->type
= get_filesystem( root
);
1976 if (!match_row( table
, row
, cond
, &status
))
1978 free_row_values( table
, row
);
1981 offset
+= sizeof(*rec
);
1986 TRACE("created %u rows\n", row
);
1987 table
->num_rows
= row
;
1991 static WCHAR
*get_volumename( const WCHAR
*root
)
1993 WCHAR buf
[MAX_PATH
+ 1] = {0};
1994 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1995 return heap_strdupW( buf
);
1997 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1999 static const WCHAR fmtW
[] = {'%','0','8','X',0};
2003 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
2004 sprintfW( buffer
, fmtW
, serial
);
2005 return heap_strdupW( buffer
);
2008 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
2010 static const WCHAR fmtW
[] = {'%','c',':',0};
2011 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
2012 struct record_logicaldisk
*rec
;
2013 UINT i
, row
= 0, offset
= 0, type
;
2014 UINT64 size
= 1024 * 1024 * 1024;
2015 DWORD drives
= GetLogicalDrives();
2016 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2018 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2020 for (i
= 0; i
< 26; i
++)
2022 if (drives
& (1 << i
))
2025 type
= GetDriveTypeW( root
);
2026 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
2029 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2031 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
2032 sprintfW( device_id
, fmtW
, 'A' + i
);
2033 rec
->device_id
= heap_strdupW( device_id
);
2034 rec
->drivetype
= type
;
2035 rec
->filesystem
= get_filesystem( root
);
2036 rec
->freespace
= get_freespace( root
, &size
);
2037 rec
->name
= heap_strdupW( device_id
);
2039 rec
->volumename
= get_volumename( root
);
2040 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
2041 if (!match_row( table
, row
, cond
, &status
))
2043 free_row_values( table
, row
);
2046 offset
+= sizeof(*rec
);
2050 TRACE("created %u rows\n", row
);
2051 table
->num_rows
= row
;
2055 static UINT16
get_connection_status( IF_OPER_STATUS status
)
2059 case IfOperStatusDown
:
2060 return 0; /* Disconnected */
2061 case IfOperStatusUp
:
2062 return 2; /* Connected */
2064 ERR("unhandled status %u\n", status
);
2069 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
2071 static const WCHAR fmtW
[] =
2072 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2073 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2076 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
2077 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
2080 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
2082 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2083 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
2084 static const WCHAR firewireW
[] = {'1','3','9','4',0};
2085 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
2089 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
2090 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
2091 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
2092 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
2093 default: *physical
= 0; return NULL
;
2097 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
2099 static const WCHAR fmtW
[] = {'%','u',0};
2100 WCHAR device_id
[11];
2101 struct record_networkadapter
*rec
;
2102 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2103 UINT row
= 0, offset
= 0, count
= 0;
2104 DWORD size
= 0, ret
;
2106 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2108 ret
= GetAdaptersAddresses( WS_AF_UNSPEC
, 0, NULL
, NULL
, &size
);
2109 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2111 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2112 if (GetAdaptersAddresses( WS_AF_UNSPEC
, 0, NULL
, buffer
, &size
))
2114 heap_free( buffer
);
2115 return FILL_STATUS_FAILED
;
2117 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2119 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2121 if (!resize_table( table
, count
, sizeof(*rec
) ))
2123 heap_free( buffer
);
2124 return FILL_STATUS_FAILED
;
2126 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2128 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2130 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
2131 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
2132 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
2133 rec
->device_id
= heap_strdupW( device_id
);
2134 rec
->index
= aa
->u
.s
.IfIndex
;
2135 rec
->interface_index
= aa
->u
.s
.IfIndex
;
2136 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2137 rec
->manufacturer
= compsys_manufacturerW
;
2138 rec
->name
= heap_strdupW( aa
->FriendlyName
);
2139 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
2140 rec
->physicaladapter
= physical
;
2141 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
2142 rec
->speed
= 1000000;
2143 if (!match_row( table
, row
, cond
, &status
))
2145 free_row_values( table
, row
);
2148 offset
+= sizeof(*rec
);
2151 TRACE("created %u rows\n", row
);
2152 table
->num_rows
= row
;
2154 heap_free( buffer
);
2158 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
2160 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
2161 WCHAR buf
[WS_NI_MAXHOST
];
2163 if (!addr
) return NULL
;
2164 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
2165 0, WS_NI_NAMEREQD
)) return NULL
;
2166 return heap_strdupW( buf
);
2168 static struct array
*get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS
*list
)
2170 IP_ADAPTER_GATEWAY_ADDRESS
*gateway
;
2172 ULONG buflen
, i
= 0, count
= 0;
2173 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
2175 if (!list
) return NULL
;
2176 for (gateway
= list
; gateway
; gateway
= gateway
->Next
) count
++;
2178 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2179 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2184 for (gateway
= list
; gateway
; gateway
= gateway
->Next
)
2186 buflen
= sizeof(buf
)/sizeof(buf
[0]);
2187 if (WSAAddressToStringW( gateway
->Address
.lpSockaddr
, gateway
->Address
.iSockaddrLength
,
2188 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2190 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2200 static struct array
*get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS
*list
)
2202 IP_ADAPTER_DNS_SERVER_ADDRESS
*server
;
2204 ULONG buflen
, i
= 0, count
= 0;
2205 WCHAR
**ptr
, *p
, buf
[54]; /* max IPv6 address length */
2207 if (!list
) return NULL
;
2208 for (server
= list
; server
; server
= server
->Next
) count
++;
2210 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2211 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2216 for (server
= list
; server
; server
= server
->Next
)
2218 buflen
= sizeof(buf
)/sizeof(buf
[0]);
2219 if (WSAAddressToStringW( server
->Address
.lpSockaddr
, server
->Address
.iSockaddrLength
,
2220 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2222 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2227 if ((p
= strrchrW( ptr
[i
- 1], ':' ))) *p
= 0;
2233 static WCHAR
*get_settingid( UINT32 index
)
2237 memset( &guid
, 0, sizeof(guid
) );
2239 UuidToStringW( &guid
, &str
);
2240 ret
= heap_strdupW( str
);
2241 RpcStringFreeW( &str
);
2245 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
2247 struct record_networkadapterconfig
*rec
;
2248 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2249 UINT row
= 0, offset
= 0, count
= 0;
2250 DWORD size
= 0, ret
;
2251 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2253 ret
= GetAdaptersAddresses( WS_AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, NULL
, &size
);
2254 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2256 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2257 if (GetAdaptersAddresses( WS_AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, buffer
, &size
))
2259 heap_free( buffer
);
2260 return FILL_STATUS_FAILED
;
2262 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2264 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2266 if (!resize_table( table
, count
, sizeof(*rec
) ))
2268 heap_free( buffer
);
2269 return FILL_STATUS_FAILED
;
2271 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2273 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2275 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
2276 rec
->defaultipgateway
= get_defaultipgateway( aa
->FirstGatewayAddress
);
2277 rec
->description
= heap_strdupW( aa
->Description
);
2278 rec
->dhcpenabled
= -1;
2279 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
2280 rec
->dnsserversearchorder
= get_dnsserversearchorder( aa
->FirstDnsServerAddress
);
2281 rec
->index
= aa
->u
.s
.IfIndex
;
2282 rec
->ipconnectionmetric
= 20;
2283 rec
->ipenabled
= -1;
2284 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2285 rec
->settingid
= get_settingid( rec
->index
);
2286 if (!match_row( table
, row
, cond
, &status
))
2288 free_row_values( table
, row
);
2291 offset
+= sizeof(*rec
);
2294 TRACE("created %u rows\n", row
);
2295 table
->num_rows
= row
;
2297 heap_free( buffer
);
2301 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
2303 struct record_physicalmemory
*rec
;
2304 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2307 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2309 rec
= (struct record_physicalmemory
*)table
->data
;
2310 rec
->capacity
= get_total_physical_memory();
2311 rec
->memorytype
= 9; /* RAM */
2312 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2315 TRACE("created %u rows\n", row
);
2316 table
->num_rows
= row
;
2320 static enum fill_status
fill_printer( struct table
*table
, const struct expr
*cond
)
2322 struct record_printer
*rec
;
2323 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2324 PRINTER_INFO_2W
*info
;
2325 DWORD i
, offset
= 0, count
= 0, size
= 0;
2327 EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &size
, &count
);
2328 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2330 if (!(info
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2331 if (!EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, (BYTE
*)info
, size
, &size
, &count
))
2334 return FILL_STATUS_FAILED
;
2336 if (!resize_table( table
, count
, sizeof(*rec
) ))
2339 return FILL_STATUS_FAILED
;
2342 for (i
= 0; i
< count
; i
++)
2344 rec
= (struct record_printer
*)(table
->data
+ offset
);
2345 rec
->attributes
= info
[i
].Attributes
;
2346 rec
->drivername
= heap_strdupW( info
[i
].pDriverName
);
2347 rec
->horizontalresolution
= info
[i
].pDevMode
->u1
.s1
.dmPrintQuality
;
2349 rec
->name
= heap_strdupW( info
[i
].pPrinterName
);
2351 if (!match_row( table
, i
, cond
, &status
))
2353 free_row_values( table
, i
);
2356 offset
+= sizeof(*rec
);
2358 TRACE("created %u rows\n", count
);
2359 table
->num_rows
= count
;
2365 static WCHAR
*get_cmdline( DWORD process_id
)
2367 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2368 return NULL
; /* FIXME handle different process case */
2371 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2373 static const WCHAR fmtW
[] = {'%','u',0};
2375 struct record_process
*rec
;
2376 PROCESSENTRY32W entry
;
2378 enum fill_status status
= FILL_STATUS_FAILED
;
2379 UINT row
= 0, offset
= 0;
2381 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2382 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2384 entry
.dwSize
= sizeof(entry
);
2385 if (!Process32FirstW( snap
, &entry
)) goto done
;
2386 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2390 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2392 rec
= (struct record_process
*)(table
->data
+ offset
);
2393 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2394 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2395 rec
->description
= heap_strdupW( entry
.szExeFile
);
2396 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2397 rec
->handle
= heap_strdupW( handle
);
2398 rec
->name
= heap_strdupW( entry
.szExeFile
);
2399 rec
->process_id
= entry
.th32ProcessID
;
2400 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2401 rec
->thread_count
= entry
.cntThreads
;
2402 rec
->workingsetsize
= 0;
2403 rec
->get_owner
= process_get_owner
;
2404 if (!match_row( table
, row
, cond
, &status
))
2406 free_row_values( table
, row
);
2409 offset
+= sizeof(*rec
);
2411 } while (Process32NextW( snap
, &entry
));
2413 TRACE("created %u rows\n", row
);
2414 table
->num_rows
= row
;
2415 status
= FILL_STATUS_UNFILTERED
;
2418 CloseHandle( snap
);
2422 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2428 __asm__("pushl %%ebx\n\t"
2430 "movl %%ebx, %%esi\n\t"
2432 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2437 static const WCHAR
*get_osarchitecture(void)
2440 GetNativeSystemInfo( &info
);
2441 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2444 static void get_processor_caption( WCHAR
*caption
)
2446 static const WCHAR fmtW
[] =
2447 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2448 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2449 static const WCHAR x86W
[] = {'x','8','6',0};
2450 static const WCHAR intel64W
[] = {'I','n','t','e','l','6','4',0};
2451 const WCHAR
*arch
= (get_osarchitecture() == os_32bitW
) ? x86W
: intel64W
;
2452 unsigned int regs
[4] = {0, 0, 0, 0};
2454 do_cpuid( 1, regs
);
2455 sprintfW( caption
, fmtW
, arch
, (regs
[0] & (15 << 8)) >> 8, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2457 static void get_processor_version( WCHAR
*version
)
2459 static const WCHAR fmtW
[] =
2460 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2461 unsigned int regs
[4] = {0, 0, 0, 0};
2463 do_cpuid( 1, regs
);
2464 sprintfW( version
, fmtW
, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2466 static void get_processor_id( WCHAR
*processor_id
)
2468 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2469 unsigned int regs
[4] = {0, 0, 0, 0};
2471 do_cpuid( 1, regs
);
2472 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2474 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2477 unsigned char *p
= (unsigned char *)regs
;
2479 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2482 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2484 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2486 do_cpuid( 0, regs
);
2487 tmp
= regs
[2]; /* swap edx and ecx */
2491 regs_to_str( regs
+ 1, 12, manufacturer
);
2493 static void get_processor_name( WCHAR
*name
)
2495 unsigned int regs
[4] = {0, 0, 0, 0};
2497 do_cpuid( 0x80000000, regs
);
2498 if (regs
[0] >= 0x80000004)
2500 do_cpuid( 0x80000002, regs
);
2501 regs_to_str( regs
, 16, name
);
2502 do_cpuid( 0x80000003, regs
);
2503 regs_to_str( regs
, 16, name
+ 16 );
2504 do_cpuid( 0x80000004, regs
);
2505 regs_to_str( regs
, 16, name
+ 32 );
2508 static UINT
get_processor_currentclockspeed( UINT index
)
2510 PROCESSOR_POWER_INFORMATION
*info
;
2511 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2514 if ((info
= heap_alloc( size
)))
2516 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2517 if (!status
) ret
= info
[index
].CurrentMhz
;
2522 static UINT
get_processor_maxclockspeed( UINT index
)
2524 PROCESSOR_POWER_INFORMATION
*info
;
2525 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2528 if ((info
= heap_alloc( size
)))
2530 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2531 if (!status
) ret
= info
[index
].MaxMhz
;
2537 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2539 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2540 WCHAR caption
[100], device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0}, version
[50];
2541 struct record_processor
*rec
;
2542 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2543 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2545 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2547 get_processor_caption( caption
);
2548 get_processor_id( processor_id
);
2549 get_processor_manufacturer( manufacturer
);
2550 get_processor_name( name
);
2551 get_processor_version( version
);
2553 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2556 for (i
= 0; i
< count
; i
++)
2558 rec
= (struct record_processor
*)(table
->data
+ offset
);
2559 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2560 rec
->caption
= heap_strdupW( caption
);
2561 rec
->cpu_status
= 1; /* CPU Enabled */
2562 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2563 rec
->datawidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2564 rec
->description
= heap_strdupW( caption
);
2565 sprintfW( device_id
, fmtW
, i
);
2566 rec
->device_id
= heap_strdupW( device_id
);
2567 rec
->family
= 2; /* Unknown */
2568 rec
->manufacturer
= heap_strdupW( manufacturer
);
2569 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2570 rec
->name
= heap_strdupW( name
);
2571 rec
->num_cores
= num_cores
;
2572 rec
->num_logical_processors
= num_logical_processors
;
2573 rec
->processor_id
= heap_strdupW( processor_id
);
2574 rec
->processortype
= 3; /* central processor */
2575 rec
->unique_id
= NULL
;
2576 rec
->version
= heap_strdupW( version
);
2577 if (!match_row( table
, i
, cond
, &status
))
2579 free_row_values( table
, i
);
2582 offset
+= sizeof(*rec
);
2585 TRACE("created %u rows\n", count
);
2586 table
->num_rows
= count
;
2590 static WCHAR
*get_lastbootuptime(void)
2592 static const WCHAR fmtW
[] =
2593 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2594 '.','%','0','6','u','+','0','0','0',0};
2595 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2599 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2601 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2602 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2603 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2606 static WCHAR
*get_localdatetime(void)
2608 static const WCHAR fmtW
[] =
2609 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2610 '.','%','0','6','u','%','+','0','3','d',0};
2611 TIME_ZONE_INFORMATION tzi
;
2617 Status
= GetTimeZoneInformation(&tzi
);
2619 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2621 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2622 Bias
+= tzi
.DaylightBias
;
2624 Bias
+= tzi
.StandardBias
;
2625 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2628 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2631 static WCHAR
*get_systemdirectory(void)
2636 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2637 Wow64DisableWow64FsRedirection( &redir
);
2638 GetSystemDirectoryW( ret
, MAX_PATH
);
2639 Wow64RevertWow64FsRedirection( redir
);
2642 static WCHAR
*get_codeset(void)
2644 static const WCHAR fmtW
[] = {'%','u',0};
2645 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2646 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2649 static WCHAR
*get_countrycode(void)
2651 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2652 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2655 static WCHAR
*get_locale(void)
2657 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2658 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2661 static WCHAR
*get_osbuildnumber( OSVERSIONINFOEXW
*ver
)
2663 static const WCHAR fmtW
[] = {'%','u',0};
2664 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2665 if (ret
) sprintfW( ret
, fmtW
, ver
->dwBuildNumber
);
2668 static WCHAR
*get_oscaption( OSVERSIONINFOEXW
*ver
)
2670 static const WCHAR windowsW
[] =
2671 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
2672 static const WCHAR win2000W
[] =
2673 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2674 static const WCHAR win2003W
[] =
2675 {'S','e','r','v','e','r',' ','2','0','0','3',' ','S','t','a','n','d','a','r','d',' ','E','d','i','t','i','o','n',0};
2676 static const WCHAR winxpW
[] =
2677 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2678 static const WCHAR winxp64W
[] =
2679 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',' ','x','6','4',' ','E','d','i','t','i','o','n',0};
2680 static const WCHAR vistaW
[] =
2681 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
2682 static const WCHAR win2008W
[] =
2683 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
2684 static const WCHAR win7W
[] =
2685 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2686 static const WCHAR win2008r2W
[] =
2687 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
2688 static const WCHAR win8W
[] =
2689 {'8',' ','P','r','o',0};
2690 static const WCHAR win81W
[] =
2691 {'8','.','1',' ','P','r','o',0};
2692 static const WCHAR win10W
[] =
2693 {'1','0',' ','P','r','o',0};
2694 int len
= sizeof(windowsW
)/sizeof(windowsW
[0]);
2697 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(win2003W
) ))) return NULL
;
2698 memcpy( ret
, windowsW
, sizeof(windowsW
) );
2699 if (ver
->dwMajorVersion
== 10 && ver
->dwMinorVersion
== 0) memcpy( ret
+ len
, win10W
, sizeof(win10W
) );
2700 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 3) memcpy( ret
+ len
, win8W
, sizeof(win8W
) );
2701 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 2) memcpy( ret
+ len
, win81W
, sizeof(win81W
) );
2702 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 1)
2704 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, win7W
, sizeof(win7W
) );
2705 else memcpy( ret
+ len
, win2008r2W
, sizeof(win2008r2W
) );
2707 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 0)
2709 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, vistaW
, sizeof(vistaW
) );
2710 else memcpy( ret
+ len
, win2008W
, sizeof(win2008W
) );
2712 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 2)
2714 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, winxp64W
, sizeof(winxp64W
) );
2715 else memcpy( ret
+ len
, win2003W
, sizeof(win2003W
) );
2717 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 1) memcpy( ret
+ len
, winxpW
, sizeof(winxpW
) );
2718 else memcpy( ret
+ len
, win2000W
, sizeof(win2000W
) );
2721 static WCHAR
*get_osname( const WCHAR
*caption
)
2723 static const WCHAR partitionW
[] =
2724 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
2725 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
2726 int len
= strlenW( caption
);
2729 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(partitionW
) ))) return NULL
;
2730 memcpy( ret
, caption
, len
* sizeof(WCHAR
) );
2731 memcpy( ret
+ len
, partitionW
, sizeof(partitionW
) );
2734 static WCHAR
*get_osversion( OSVERSIONINFOEXW
*ver
)
2736 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u',0};
2737 WCHAR
*ret
= heap_alloc( 33 * sizeof(WCHAR
) );
2738 if (ret
) sprintfW( ret
, fmtW
, ver
->dwMajorVersion
, ver
->dwMinorVersion
, ver
->dwBuildNumber
);
2742 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2744 struct record_operatingsystem
*rec
;
2745 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2746 OSVERSIONINFOEXW ver
;
2749 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2751 ver
.dwOSVersionInfoSize
= sizeof(ver
);
2752 GetVersionExW( (OSVERSIONINFOW
*)&ver
);
2754 rec
= (struct record_operatingsystem
*)table
->data
;
2755 rec
->buildnumber
= get_osbuildnumber( &ver
);
2756 rec
->caption
= get_oscaption( &ver
);
2757 rec
->codeset
= get_codeset();
2758 rec
->countrycode
= get_countrycode();
2759 rec
->csdversion
= ver
.szCSDVersion
[0] ? heap_strdupW( ver
.szCSDVersion
) : NULL
;
2760 rec
->installdate
= os_installdateW
;
2761 rec
->lastbootuptime
= get_lastbootuptime();
2762 rec
->localdatetime
= get_localdatetime();
2763 rec
->locale
= get_locale();
2764 rec
->name
= get_osname( rec
->caption
);
2765 rec
->osarchitecture
= get_osarchitecture();
2766 rec
->oslanguage
= GetSystemDefaultLangID();
2767 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2768 rec
->ostype
= 18; /* WINNT */
2770 rec
->serialnumber
= os_serialnumberW
;
2771 rec
->servicepackmajor
= ver
.wServicePackMajor
;
2772 rec
->servicepackminor
= ver
.wServicePackMinor
;
2773 rec
->suitemask
= 272; /* Single User + Terminal */
2774 rec
->systemdirectory
= get_systemdirectory();
2775 rec
->totalvirtualmemorysize
= get_total_physical_memory() / 1024;
2776 rec
->totalvisiblememorysize
= rec
->totalvirtualmemorysize
;
2777 rec
->version
= get_osversion( &ver
);
2778 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2781 TRACE("created %u rows\n", row
);
2782 table
->num_rows
= row
;
2786 static const WCHAR
*get_service_type( DWORD type
)
2788 static const WCHAR filesystem_driverW
[] =
2789 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2790 static const WCHAR kernel_driverW
[] =
2791 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2792 static const WCHAR own_processW
[] =
2793 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2794 static const WCHAR share_processW
[] =
2795 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2797 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2798 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2799 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2800 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2801 else ERR("unhandled type 0x%08x\n", type
);
2804 static const WCHAR
*get_service_state( DWORD state
)
2806 static const WCHAR runningW
[] =
2807 {'R','u','n','n','i','n','g',0};
2808 static const WCHAR start_pendingW
[] =
2809 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2810 static const WCHAR stop_pendingW
[] =
2811 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2812 static const WCHAR stoppedW
[] =
2813 {'S','t','o','p','p','e','d',0};
2814 static const WCHAR unknownW
[] =
2815 {'U','n','k','n','o','w','n',0};
2819 case SERVICE_STOPPED
: return stoppedW
;
2820 case SERVICE_START_PENDING
: return start_pendingW
;
2821 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2822 case SERVICE_RUNNING
: return runningW
;
2824 ERR("unknown state %u\n", state
);
2828 static const WCHAR
*get_service_startmode( DWORD mode
)
2830 static const WCHAR bootW
[] = {'B','o','o','t',0};
2831 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2832 static const WCHAR autoW
[] = {'A','u','t','o',0};
2833 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2834 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2835 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2839 case SERVICE_BOOT_START
: return bootW
;
2840 case SERVICE_SYSTEM_START
: return systemW
;
2841 case SERVICE_AUTO_START
: return autoW
;
2842 case SERVICE_DEMAND_START
: return manualW
;
2843 case SERVICE_DISABLED
: return disabledW
;
2845 ERR("unknown mode 0x%x\n", mode
);
2849 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2851 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2855 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2856 QueryServiceConfigW( service
, NULL
, 0, &size
);
2857 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2858 if (!(config
= heap_alloc( size
))) goto done
;
2859 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2860 heap_free( config
);
2864 CloseServiceHandle( service
);
2868 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2870 struct record_service
*rec
;
2872 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2873 SERVICE_STATUS_PROCESS
*status
;
2874 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2875 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2876 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2877 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2880 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2881 if (!(services
= heap_alloc( size
))) goto done
;
2883 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2884 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2885 &count
, NULL
, NULL
);
2888 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2890 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2892 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2893 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2894 &count
, NULL
, NULL
);
2895 if (!ret
) goto done
;
2897 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2899 GetComputerNameW( sysnameW
, &len
);
2900 fill_status
= FILL_STATUS_UNFILTERED
;
2902 for (i
= 0; i
< count
; i
++)
2904 QUERY_SERVICE_CONFIGW
*config
;
2906 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2908 status
= &services
[i
].ServiceStatusProcess
;
2909 rec
= (struct record_service
*)(table
->data
+ offset
);
2910 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2911 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2912 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2913 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2914 rec
->process_id
= status
->dwProcessId
;
2915 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2916 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2917 rec
->state
= get_service_state( status
->dwCurrentState
);
2918 rec
->systemname
= heap_strdupW( sysnameW
);
2919 rec
->pause_service
= service_pause_service
;
2920 rec
->resume_service
= service_resume_service
;
2921 rec
->start_service
= service_start_service
;
2922 rec
->stop_service
= service_stop_service
;
2923 heap_free( config
);
2924 if (!match_row( table
, row
, cond
, &fill_status
))
2926 free_row_values( table
, row
);
2929 offset
+= sizeof(*rec
);
2933 TRACE("created %u rows\n", row
);
2934 table
->num_rows
= row
;
2937 CloseServiceHandle( manager
);
2938 heap_free( services
);
2942 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2944 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2945 return heap_strdupW( name
->Name
.Buffer
);
2947 static struct array
*get_binaryrepresentation( PSID sid
, UINT len
)
2949 struct array
*array
= heap_alloc( sizeof(struct array
) );
2952 UINT8
*ret
= heap_alloc( len
);
2955 memcpy( ret
, sid
, len
);
2964 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2966 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2967 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2969 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2971 const struct expr
*left
, *right
;
2972 const WCHAR
*ret
= NULL
;
2974 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2976 left
= cond
->u
.expr
.left
;
2977 right
= cond
->u
.expr
.right
;
2978 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2980 ret
= right
->u
.sval
;
2982 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2989 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2992 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2993 LSA_TRANSLATED_NAME
*name
;
2995 LSA_OBJECT_ATTRIBUTES attrs
;
2997 struct record_sid
*rec
;
3000 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
3001 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3003 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
3004 len
= GetLengthSid( sid
);
3006 memset( &attrs
, 0, sizeof(attrs
) );
3007 attrs
.Length
= sizeof(attrs
);
3008 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
3011 return FILL_STATUS_FAILED
;
3013 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
3017 return FILL_STATUS_FAILED
;
3020 rec
= (struct record_sid
*)table
->data
;
3021 rec
->accountname
= get_accountname( name
);
3022 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
3023 rec
->referenceddomainname
= get_referenceddomainname( domain
);
3024 rec
->sid
= heap_strdupW( str
);
3025 rec
->sidlength
= len
;
3027 TRACE("created 1 row\n");
3028 table
->num_rows
= 1;
3030 LsaFreeMemory( domain
);
3031 LsaFreeMemory( name
);
3034 return FILL_STATUS_FILTERED
;
3037 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
3039 HDC hdc
= GetDC( NULL
);
3042 if (!hdc
) return 32;
3043 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
3044 *hres
= GetDeviceCaps( hdc
, HORZRES
);
3045 *vres
= GetDeviceCaps( hdc
, VERTRES
);
3046 ReleaseDC( NULL
, hdc
);
3049 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
3051 static const WCHAR fmtW
[] =
3052 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
3053 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
3054 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
3057 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
3058 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
3062 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
3064 static const WCHAR fmtW
[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
3065 struct record_videocontroller
*rec
;
3067 IDXGIFactory
*factory
= NULL
;
3068 IDXGIAdapter
*adapter
= NULL
;
3069 DXGI_ADAPTER_DESC desc
;
3070 UINT row
= 0, hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
3071 const WCHAR
*name
= videocontroller_deviceidW
;
3072 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3075 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3077 memset (&desc
, 0, sizeof(desc
));
3078 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
3079 if (FAILED(hr
)) goto done
;
3081 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
3082 if (FAILED(hr
)) goto done
;
3084 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
3087 vidmem
= desc
.DedicatedVideoMemory
;
3088 name
= desc
.Description
;
3092 rec
= (struct record_videocontroller
*)table
->data
;
3093 rec
->adapter_dactype
= videocontroller_dactypeW
;
3094 rec
->adapter_ram
= vidmem
;
3095 rec
->availability
= 3; /* Running or Full Power */
3096 rec
->caption
= heap_strdupW( name
);
3097 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
3098 rec
->current_horizontalres
= hres
;
3099 rec
->current_refreshrate
= 0; /* default refresh rate */
3100 rec
->current_scanmode
= 2; /* Unknown */
3101 rec
->current_verticalres
= vres
;
3102 rec
->description
= heap_strdupW( name
);
3103 rec
->device_id
= videocontroller_deviceidW
;
3104 rec
->driverversion
= videocontroller_driverversionW
;
3105 rec
->name
= heap_strdupW( name
);
3106 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
3107 rec
->videoarchitecture
= 2; /* Unknown */
3108 rec
->videomemorytype
= 2; /* Unknown */
3109 wsprintfW( mode
, fmtW
, hres
, vres
, (UINT64
)1 << rec
->current_bitsperpixel
);
3110 rec
->videomodedescription
= heap_strdupW( mode
);
3111 rec
->videoprocessor
= heap_strdupW( name
);
3112 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3115 TRACE("created %u rows\n", row
);
3116 table
->num_rows
= row
;
3118 if (adapter
) IDXGIAdapter_Release( adapter
);
3119 if (factory
) IDXGIFactory_Release( factory
);
3123 static struct table builtin_classes
[] =
3125 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
3126 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
3127 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
3128 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
3129 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, 0, 0, NULL
, fill_compsysproduct
},
3130 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
3131 { class_desktopmonitorW
, SIZEOF(col_desktopmonitor
), col_desktopmonitor
, 0, 0, NULL
, fill_desktopmonitor
},
3132 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
3133 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
3134 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
3135 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3136 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3137 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
3138 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
3139 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
3140 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
3141 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
3142 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
3143 { class_printerW
, SIZEOF(col_printer
), col_printer
, 0, 0, NULL
, fill_printer
},
3144 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
3145 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3146 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3147 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
3148 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
3149 { class_sidW
, SIZEOF(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
3150 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
3151 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
3152 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
3153 { class_systemenclosureW
, SIZEOF(col_systemenclosure
), col_systemenclosure
, SIZEOF(data_systemenclosure
), 0, (BYTE
*)data_systemenclosure
},
3154 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
3157 void init_table_list( void )
3159 static struct list tables
= LIST_INIT( tables
);
3162 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
3163 table_list
= &tables
;