2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wbemprox_private.h"
34 static const WCHAR class_baseboardW
[] =
35 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
36 static const WCHAR class_biosW
[] =
37 {'W','i','n','3','2','_','B','I','O','S',0};
38 static const WCHAR class_cdromdriveW
[] =
39 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
40 static const WCHAR class_compsysW
[] =
41 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
42 static const WCHAR class_compsysproductW
[] =
43 {'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};
44 static const WCHAR class_datafileW
[] =
45 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
46 static const WCHAR class_desktopmonitorW
[] =
47 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
48 static const WCHAR class_directoryW
[] =
49 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
50 static const WCHAR class_diskdriveW
[] =
51 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
52 static const WCHAR class_diskpartitionW
[] =
53 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
54 static const WCHAR class_logicaldiskW
[] =
55 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
56 static const WCHAR class_logicaldisk2W
[] =
57 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
58 static const WCHAR class_networkadapterW
[] =
59 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
60 static const WCHAR class_networkadapterconfigW
[] =
61 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
62 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
63 static const WCHAR class_osW
[] =
64 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
65 static const WCHAR class_paramsW
[] =
66 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
67 static const WCHAR class_physicalmediaW
[] =
68 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
69 static const WCHAR class_physicalmemoryW
[] =
70 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
71 static const WCHAR class_printerW
[] =
72 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
73 static const WCHAR class_process_getowner_outW
[] =
74 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
75 'N','E','R','_','O','U','T',0};
76 static const WCHAR class_processorW
[] =
77 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
78 static const WCHAR class_processor2W
[] =
79 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
80 static const WCHAR class_qualifiersW
[] =
81 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
82 static const WCHAR class_sidW
[] =
83 {'W','i','n','3','2','_','S','I','D',0};
84 static const WCHAR class_sounddeviceW
[] =
85 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
86 static const WCHAR class_systemenclosureW
[] =
87 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
88 static const WCHAR class_videocontrollerW
[] =
89 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
91 static const WCHAR prop_accountnameW
[] =
92 {'A','c','c','o','u','n','t','N','a','m','e',0};
93 static const WCHAR prop_acceptpauseW
[] =
94 {'A','c','c','e','p','t','P','a','u','s','e',0};
95 static const WCHAR prop_acceptstopW
[] =
96 {'A','c','c','e','p','t','S','t','o','p',0};
97 static const WCHAR prop_accessmaskW
[] =
98 {'A','c','c','e','s','s','M','a','s','k',0};
99 static const WCHAR prop_adapterdactypeW
[] =
100 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
101 static const WCHAR prop_adapterramW
[] =
102 {'A','d','a','p','t','e','r','R','A','M',0};
103 static const WCHAR prop_adaptertypeW
[] =
104 {'A','d','a','p','t','e','r','T','y','p','e',0};
105 static const WCHAR prop_addresswidthW
[] =
106 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
107 static const WCHAR prop_attributesW
[] =
108 {'A','t','t','r','i','b','u','t','e','s',0};
109 static const WCHAR prop_availabilityW
[] =
110 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
111 static const WCHAR prop_binaryrepresentationW
[] =
112 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
113 static const WCHAR prop_bootableW
[] =
114 {'B','o','o','t','a','b','l','e',0};
115 static const WCHAR prop_bootpartitionW
[] =
116 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
117 static const WCHAR prop_buildnumberW
[] =
118 {'B','u','i','l','d','N','u','m','b','e','r',0};
119 static const WCHAR prop_capacityW
[] =
120 {'C','a','p','a','c','i','t','y',0};
121 static const WCHAR prop_captionW
[] =
122 {'C','a','p','t','i','o','n',0};
123 static const WCHAR prop_chassistypesW
[] =
124 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
125 static const WCHAR prop_classW
[] =
126 {'C','l','a','s','s',0};
127 static const WCHAR prop_codesetW
[] =
128 {'C','o','d','e','S','e','t',0};
129 static const WCHAR prop_commandlineW
[] =
130 {'C','o','m','m','a','n','d','L','i','n','e',0};
131 static const WCHAR prop_countrycodeW
[] =
132 {'C','o','u','n','t','r','y','C','o','d','e',0};
133 static const WCHAR prop_cpustatusW
[] =
134 {'C','p','u','S','t','a','t','u','s',0};
135 static const WCHAR prop_csdversionW
[] =
136 {'C','S','D','V','e','r','s','i','o','n',0};
137 static const WCHAR prop_currentbitsperpixelW
[] =
138 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
139 static const WCHAR prop_currentclockspeedW
[] =
140 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
141 static const WCHAR prop_currenthorizontalresW
[] =
142 {'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};
143 static const WCHAR prop_currentrefreshrateW
[] =
144 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
145 static const WCHAR prop_currentscanmodeW
[] =
146 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
147 static const WCHAR prop_currentverticalresW
[] =
148 {'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};
149 static const WCHAR prop_datawidthW
[] =
150 {'D','a','t','a','W','i','d','t','h',0};
151 static const WCHAR prop_defaultipgatewayW
[] =
152 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
153 static const WCHAR prop_defaultvalueW
[] =
154 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
155 static const WCHAR prop_descriptionW
[] =
156 {'D','e','s','c','r','i','p','t','i','o','n',0};
157 static const WCHAR prop_deviceidW
[] =
158 {'D','e','v','i','c','e','I','d',0};
159 static const WCHAR prop_dhcpenabledW
[] =
160 {'D','H','C','P','E','n','a','b','l','e','d',0};
161 static const WCHAR prop_directionW
[] =
162 {'D','i','r','e','c','t','i','o','n',0};
163 static const WCHAR prop_displaynameW
[] =
164 {'D','i','s','p','l','a','y','N','a','m','e',0};
165 static const WCHAR prop_diskindexW
[] =
166 {'D','i','s','k','I','n','d','e','x',0};
167 static const WCHAR prop_dnshostnameW
[] =
168 {'D','N','S','H','o','s','t','N','a','m','e',0};
169 static const WCHAR prop_dnsserversearchorderW
[] =
170 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
171 static const WCHAR prop_domainW
[] =
172 {'D','o','m','a','i','n',0};
173 static const WCHAR prop_domainroleW
[] =
174 {'D','o','m','a','i','n','R','o','l','e',0};
175 static const WCHAR prop_driveW
[] =
176 {'D','r','i','v','e',0};
177 static const WCHAR prop_drivernameW
[] =
178 {'D','r','i','v','e','r','N','a','m','e',0};
179 static const WCHAR prop_driverversionW
[] =
180 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
181 static const WCHAR prop_drivetypeW
[] =
182 {'D','r','i','v','e','T','y','p','e',0};
183 static const WCHAR prop_familyW
[] =
184 {'F','a','m','i','l','y',0};
185 static const WCHAR prop_filesystemW
[] =
186 {'F','i','l','e','S','y','s','t','e','m',0};
187 static const WCHAR prop_flavorW
[] =
188 {'F','l','a','v','o','r',0};
189 static const WCHAR prop_freespaceW
[] =
190 {'F','r','e','e','S','p','a','c','e',0};
191 static const WCHAR prop_handleW
[] =
192 {'H','a','n','d','l','e',0};
193 static const WCHAR prop_horizontalresolutionW
[] =
194 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
195 static const WCHAR prop_idW
[] =
197 static const WCHAR prop_identificationcodeW
[] =
198 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
199 static const WCHAR prop_identifyingnumberW
[] =
200 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
201 static const WCHAR prop_indexW
[] =
202 {'I','n','d','e','x',0};
203 static const WCHAR prop_installdateW
[] =
204 {'I','n','s','t','a','l','l','D','a','t','e',0};
205 static const WCHAR prop_interfaceindexW
[] =
206 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
207 static const WCHAR prop_interfacetypeW
[] =
208 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
209 static const WCHAR prop_intvalueW
[] =
210 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
211 static const WCHAR prop_ipconnectionmetricW
[] =
212 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
213 static const WCHAR prop_ipenabledW
[] =
214 {'I','P','E','n','a','b','l','e','d',0};
215 static const WCHAR prop_lastbootuptimeW
[] =
216 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
217 static const WCHAR prop_localW
[] =
218 {'L','o','c','a','l',0};
219 static const WCHAR prop_localdatetimeW
[] =
220 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
221 static const WCHAR prop_localeW
[] =
222 {'L','o','c','a','l','e',0};
223 static const WCHAR prop_locationW
[] =
224 {'L','o','c','a','t','i','o','n',0};
225 static const WCHAR prop_lockpresentW
[] =
226 {'L','o','c','k','P','r','e','s','e','n','t',0};
227 static const WCHAR prop_macaddressW
[] =
228 {'M','A','C','A','d','d','r','e','s','s',0};
229 static const WCHAR prop_manufacturerW
[] =
230 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
231 static const WCHAR prop_maxclockspeedW
[] =
232 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
233 static const WCHAR prop_mediatypeW
[] =
234 {'M','e','d','i','a','T','y','p','e',0};
235 static const WCHAR prop_memberW
[] =
236 {'M','e','m','b','e','r',0};
237 static const WCHAR prop_methodW
[] =
238 {'M','e','t','h','o','d',0};
239 static const WCHAR prop_modelW
[] =
240 {'M','o','d','e','l',0};
241 static const WCHAR prop_netconnectionstatusW
[] =
242 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
243 static const WCHAR prop_networkW
[] =
244 {'N','e','t','w','o','r','k',0};
245 static const WCHAR prop_numcoresW
[] =
246 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
247 static const WCHAR prop_numlogicalprocessorsW
[] =
248 {'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};
249 static const WCHAR prop_numprocessorsW
[] =
250 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
251 static const WCHAR prop_osarchitectureW
[] =
252 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
253 static const WCHAR prop_oslanguageW
[] =
254 {'O','S','L','a','n','g','u','a','g','e',0};
255 static const WCHAR prop_osproductsuiteW
[] =
256 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
257 static const WCHAR prop_ostypeW
[] =
258 {'O','S','T','y','p','e',0};
259 static const WCHAR prop_parameterW
[] =
260 {'P','a','r','a','m','e','t','e','r',0};
261 static const WCHAR prop_physicaladapterW
[] =
262 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
263 static const WCHAR prop_pixelsperxlogicalinchW
[] =
264 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
265 static const WCHAR prop_pnpdeviceidW
[] =
266 {'P','N','P','D','e','v','i','c','e','I','D',0};
267 static const WCHAR prop_portnameW
[] =
268 {'P','o','r','t','N','a','m','e',0};
269 static const WCHAR prop_pprocessidW
[] =
270 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
271 static const WCHAR prop_primaryW
[] =
272 {'P','r','i','m','a','r','y',0};
273 static const WCHAR prop_processidW
[] =
274 {'P','r','o','c','e','s','s','I','D',0};
275 static const WCHAR prop_processoridW
[] =
276 {'P','r','o','c','e','s','s','o','r','I','d',0};
277 static const WCHAR prop_processortypeW
[] =
278 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
279 static const WCHAR prop_productW
[] =
280 {'P','r','o','d','u','c','t',0};
281 static const WCHAR prop_productnameW
[] =
282 {'P','r','o','d','u','c','t','N','a','m','e',0};
283 static const WCHAR prop_referenceddomainnameW
[] =
284 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
285 static const WCHAR prop_releasedateW
[] =
286 {'R','e','l','e','a','s','e','D','a','t','e',0};
287 static const WCHAR prop_serialnumberW
[] =
288 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
289 static const WCHAR prop_servicepackmajorW
[] =
290 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
291 static const WCHAR prop_servicepackminorW
[] =
292 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
293 static const WCHAR prop_servicetypeW
[] =
294 {'S','e','r','v','i','c','e','T','y','p','e',0};
295 static const WCHAR prop_settingidW
[] =
296 {'S','e','t','t','i','n','g','I','D',0};
297 static const WCHAR prop_smbiosbiosversionW
[] =
298 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
299 static const WCHAR prop_startmodeW
[] =
300 {'S','t','a','r','t','M','o','d','e',0};
301 static const WCHAR prop_sidW
[] =
303 static const WCHAR prop_sidlengthW
[] =
304 {'S','i','d','L','e','n','g','t','h',0};
305 static const WCHAR prop_sizeW
[] =
307 static const WCHAR prop_speedW
[] =
308 {'S','p','e','e','d',0};
309 static const WCHAR prop_startingoffsetW
[] =
310 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
311 static const WCHAR prop_stateW
[] =
312 {'S','t','a','t','e',0};
313 static const WCHAR prop_statusinfoW
[] =
314 {'S','t','a','t','u','s','I','n','f','o',0};
315 static const WCHAR prop_strvalueW
[] =
316 {'S','t','r','i','n','g','V','a','l','u','e',0};
317 static const WCHAR prop_suitemaskW
[] =
318 {'S','u','i','t','e','M','a','s','k',0};
319 static const WCHAR prop_systemdirectoryW
[] =
320 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
321 static const WCHAR prop_systemnameW
[] =
322 {'S','y','s','t','e','m','N','a','m','e',0};
323 static const WCHAR prop_tagW
[] =
325 static const WCHAR prop_threadcountW
[] =
326 {'T','h','r','e','a','d','C','o','u','n','t',0};
327 static const WCHAR prop_totalphysicalmemoryW
[] =
328 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
329 static const WCHAR prop_totalvisiblememorysizeW
[] =
330 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
331 static const WCHAR prop_typeW
[] =
333 static const WCHAR prop_uniqueidW
[] =
334 {'U','n','i','q','u','e','I','d',0};
335 static const WCHAR prop_usernameW
[] =
336 {'U','s','e','r','N','a','m','e',0};
337 static const WCHAR prop_uuidW
[] =
339 static const WCHAR prop_varianttypeW
[] =
340 {'V','a','r','i','a','n','t','T','y','p','e',0};
341 static const WCHAR prop_versionW
[] =
342 {'V','e','r','s','i','o','n',0};
343 static const WCHAR prop_videoarchitectureW
[] =
344 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
345 static const WCHAR prop_videomemorytypeW
[] =
346 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
347 static const WCHAR prop_videomodedescriptionW
[] =
348 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
349 static const WCHAR prop_videoprocessorW
[] =
350 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
351 static const WCHAR prop_volumenameW
[] =
352 {'V','o','l','u','m','e','N','a','m','e',0};
353 static const WCHAR prop_volumeserialnumberW
[] =
354 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
355 static const WCHAR prop_workingsetsizeW
[] =
356 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
358 /* column definitions must be kept in sync with record structures below */
359 static const struct column col_baseboard
[] =
361 { prop_manufacturerW
, CIM_STRING
},
362 { prop_modelW
, CIM_STRING
},
363 { prop_nameW
, CIM_STRING
},
364 { prop_productW
, CIM_STRING
},
365 { prop_serialnumberW
, CIM_STRING
},
366 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
},
367 { prop_versionW
, CIM_STRING
}
369 static const struct column col_bios
[] =
371 { prop_descriptionW
, CIM_STRING
},
372 { prop_identificationcodeW
, CIM_STRING
},
373 { prop_manufacturerW
, CIM_STRING
},
374 { prop_nameW
, CIM_STRING
},
375 { prop_releasedateW
, CIM_DATETIME
},
376 { prop_serialnumberW
, CIM_STRING
},
377 { prop_smbiosbiosversionW
, CIM_STRING
},
378 { prop_versionW
, CIM_STRING
|COL_FLAG_KEY
}
380 static const struct column col_cdromdrive
[] =
382 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
383 { prop_driveW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
384 { prop_mediatypeW
, CIM_STRING
},
385 { prop_nameW
, CIM_STRING
},
386 { prop_pnpdeviceidW
, CIM_STRING
}
388 static const struct column col_compsys
[] =
390 { prop_descriptionW
, CIM_STRING
},
391 { prop_domainW
, CIM_STRING
},
392 { prop_domainroleW
, CIM_UINT16
, VT_I4
},
393 { prop_manufacturerW
, CIM_STRING
},
394 { prop_modelW
, CIM_STRING
},
395 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
396 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
397 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
398 { prop_totalphysicalmemoryW
, CIM_UINT64
},
399 { prop_usernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
401 static const struct column col_compsysproduct
[] =
403 { prop_identifyingnumberW
, CIM_STRING
|COL_FLAG_KEY
},
404 { prop_uuidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
406 static const struct column col_datafile
[] =
408 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
409 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
411 static const struct column col_desktopmonitor
[] =
413 { prop_pixelsperxlogicalinchW
, CIM_UINT32
}
415 static const struct column col_directory
[] =
417 { prop_accessmaskW
, CIM_UINT32
},
418 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
}
420 static const struct column col_diskdrive
[] =
422 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
423 { prop_indexW
, CIM_UINT32
, VT_I4
},
424 { prop_interfacetypeW
, CIM_STRING
},
425 { prop_manufacturerW
, CIM_STRING
},
426 { prop_mediatypeW
, CIM_STRING
},
427 { prop_modelW
, CIM_STRING
},
428 { prop_pnpdeviceidW
, CIM_STRING
},
429 { prop_serialnumberW
, CIM_STRING
},
430 { prop_sizeW
, CIM_UINT64
}
432 static const struct column col_diskpartition
[] =
434 { prop_bootableW
, CIM_BOOLEAN
},
435 { prop_bootpartitionW
, CIM_BOOLEAN
},
436 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
437 { prop_diskindexW
, CIM_UINT32
, VT_I4
},
438 { prop_indexW
, CIM_UINT32
, VT_I4
},
439 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
440 { prop_sizeW
, CIM_UINT64
},
441 { prop_startingoffsetW
, CIM_UINT64
},
442 { prop_typeW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
444 static const struct column col_logicaldisk
[] =
446 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
447 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
448 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
449 { prop_freespaceW
, CIM_UINT64
},
450 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
451 { prop_sizeW
, CIM_UINT64
},
452 { prop_volumenameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
453 { prop_volumeserialnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
455 static const struct column col_networkadapter
[] =
457 { prop_adaptertypeW
, CIM_STRING
},
458 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
459 { prop_indexW
, CIM_UINT32
, VT_I4
},
460 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
461 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
462 { prop_manufacturerW
, CIM_STRING
},
463 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
464 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
465 { prop_physicaladapterW
, CIM_BOOLEAN
},
466 { prop_pnpdeviceidW
, CIM_STRING
},
467 { prop_speedW
, CIM_UINT64
}
469 static const struct column col_networkadapterconfig
[] =
471 { prop_defaultipgatewayW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
472 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
473 { prop_dhcpenabledW
, CIM_BOOLEAN
},
474 { prop_dnshostnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
475 { prop_dnsserversearchorderW
, CIM_STRING
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
476 { prop_indexW
, CIM_UINT32
|COL_FLAG_KEY
, VT_I4
},
477 { prop_ipconnectionmetricW
, CIM_UINT32
, VT_I4
},
478 { prop_ipenabledW
, CIM_BOOLEAN
},
479 { prop_macaddressW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
480 { prop_settingidW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
482 static const struct column col_os
[] =
484 { prop_buildnumberW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
485 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
486 { prop_codesetW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
487 { prop_countrycodeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
488 { prop_csdversionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
489 { prop_installdateW
, CIM_DATETIME
},
490 { prop_lastbootuptimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
491 { prop_localdatetimeW
, CIM_DATETIME
|COL_FLAG_DYNAMIC
},
492 { prop_localeW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
493 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
494 { prop_osarchitectureW
, CIM_STRING
},
495 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
496 { prop_osproductsuiteW
, CIM_UINT32
, VT_I4
},
497 { prop_ostypeW
, CIM_UINT16
, VT_I4
},
498 { prop_primaryW
, CIM_BOOLEAN
},
499 { prop_serialnumberW
, CIM_STRING
},
500 { prop_servicepackmajorW
, CIM_UINT16
, VT_I4
},
501 { prop_servicepackminorW
, CIM_UINT16
, VT_I4
},
502 { prop_suitemaskW
, CIM_UINT32
, VT_I4
},
503 { prop_systemdirectoryW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
504 { prop_totalvisiblememorysizeW
, CIM_UINT64
},
505 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
507 static const struct column col_param
[] =
509 { prop_classW
, CIM_STRING
},
510 { prop_methodW
, CIM_STRING
},
511 { prop_directionW
, CIM_SINT32
},
512 { prop_parameterW
, CIM_STRING
},
513 { prop_typeW
, CIM_UINT32
},
514 { prop_varianttypeW
, CIM_UINT32
},
515 { prop_defaultvalueW
, CIM_UINT32
}
517 static const struct column col_physicalmedia
[] =
519 { prop_serialnumberW
, CIM_STRING
},
520 { prop_tagW
, CIM_STRING
}
522 static const struct column col_physicalmemory
[] =
524 { prop_capacityW
, CIM_UINT64
}
526 static const struct column col_printer
[] =
528 { prop_attributesW
, CIM_UINT32
},
529 { prop_drivernameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
530 { prop_horizontalresolutionW
, CIM_UINT32
},
531 { prop_localW
, CIM_BOOLEAN
},
532 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
533 { prop_networkW
, CIM_BOOLEAN
},
534 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
535 { prop_portnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
536 { prop_locationW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
538 static const struct column col_process
[] =
540 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
541 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
542 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
543 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
544 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
545 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
546 { prop_processidW
, CIM_UINT32
, VT_I4
},
547 { prop_threadcountW
, CIM_UINT32
, VT_I4
},
548 { prop_workingsetsizeW
, CIM_UINT64
},
550 { method_getownerW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
552 static const struct column col_processor
[] =
554 { prop_addresswidthW
, CIM_UINT16
, VT_I4
},
555 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
556 { prop_cpustatusW
, CIM_UINT16
},
557 { prop_currentclockspeedW
, CIM_UINT32
, VT_I4
},
558 { prop_datawidthW
, CIM_UINT16
, VT_I4
},
559 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
560 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
561 { prop_familyW
, CIM_UINT16
, VT_I4
},
562 { prop_manufacturerW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
563 { prop_maxclockspeedW
, CIM_UINT32
, VT_I4
},
564 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
565 { prop_numcoresW
, CIM_UINT32
, VT_I4
},
566 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
567 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
568 { prop_processortypeW
, CIM_UINT16
, VT_I4
},
569 { prop_uniqueidW
, CIM_STRING
},
570 { prop_versionW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
572 static const struct column col_qualifier
[] =
574 { prop_classW
, CIM_STRING
},
575 { prop_memberW
, CIM_STRING
},
576 { prop_typeW
, CIM_UINT32
},
577 { prop_flavorW
, CIM_SINT32
},
578 { prop_nameW
, CIM_STRING
},
579 { prop_intvalueW
, CIM_SINT32
},
580 { prop_strvalueW
, CIM_STRING
}
582 static const struct column col_service
[] =
584 { prop_acceptpauseW
, CIM_BOOLEAN
},
585 { prop_acceptstopW
, CIM_BOOLEAN
},
586 { prop_displaynameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
587 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
588 { prop_processidW
, CIM_UINT32
},
589 { prop_servicetypeW
, CIM_STRING
},
590 { prop_startmodeW
, CIM_STRING
},
591 { prop_stateW
, CIM_STRING
},
592 { prop_systemnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
594 { method_pauseserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
595 { method_resumeserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
596 { method_startserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
597 { method_stopserviceW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
599 static const struct column col_sid
[] =
601 { prop_accountnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
602 { prop_binaryrepresentationW
, CIM_UINT8
|CIM_FLAG_ARRAY
|COL_FLAG_DYNAMIC
},
603 { prop_referenceddomainnameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
604 { prop_sidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
605 { prop_sidlengthW
, CIM_UINT32
}
607 static const struct column col_sounddevice
[] =
609 { prop_nameW
, CIM_STRING
},
610 { prop_productnameW
, CIM_STRING
},
611 { prop_statusinfoW
, CIM_UINT16
, VT_I4
}
613 static const struct column col_stdregprov
[] =
615 { method_enumkeyW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
616 { method_enumvaluesW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
617 { method_getstringvalueW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
}
619 static const struct column col_systemenclosure
[] =
621 { prop_captionW
, CIM_STRING
},
622 { prop_chassistypesW
, CIM_UINT16
|CIM_FLAG_ARRAY
, VT_I4
|VT_ARRAY
},
623 { prop_descriptionW
, CIM_STRING
},
624 { prop_lockpresentW
, CIM_BOOLEAN
},
625 { prop_manufacturerW
, CIM_STRING
},
626 { prop_nameW
, CIM_STRING
},
627 { prop_tagW
, CIM_STRING
},
629 static const struct column col_systemsecurity
[] =
631 { method_getsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
632 { method_setsdW
, CIM_FLAG_ARRAY
|COL_FLAG_METHOD
},
634 static const struct column col_videocontroller
[] =
636 { prop_adapterdactypeW
, CIM_STRING
},
637 { prop_adapterramW
, CIM_UINT32
, VT_I4
},
638 { prop_availabilityW
, CIM_UINT16
},
639 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
640 { prop_currentbitsperpixelW
, CIM_UINT32
, VT_I4
},
641 { prop_currenthorizontalresW
, CIM_UINT32
, VT_I4
},
642 { prop_currentrefreshrateW
, CIM_UINT32
, VT_I4
},
643 { prop_currentscanmodeW
, CIM_UINT16
, VT_I4
},
644 { prop_currentverticalresW
, CIM_UINT32
, VT_I4
},
645 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
646 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
647 { prop_driverversionW
, CIM_STRING
},
648 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
649 { prop_pnpdeviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
650 { prop_videoarchitectureW
, CIM_UINT16
, VT_I4
},
651 { prop_videomemorytypeW
, CIM_UINT16
, VT_I4
},
652 { prop_videomodedescriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
653 { prop_videoprocessorW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
656 static const WCHAR baseboard_manufacturerW
[] =
657 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
658 static const WCHAR baseboard_serialnumberW
[] =
660 static const WCHAR baseboard_tagW
[] =
661 {'B','a','s','e',' ','B','o','a','r','d',0};
662 static const WCHAR baseboard_versionW
[] =
664 static const WCHAR bios_descriptionW
[] =
665 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
666 static const WCHAR bios_manufacturerW
[] =
667 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
668 static const WCHAR bios_nameW
[] =
669 {'W','I','N','E',' ','B','I','O','S',0};
670 static const WCHAR bios_releasedateW
[] =
671 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
672 static const WCHAR bios_serialnumberW
[] =
674 static const WCHAR bios_smbiosbiosversionW
[] =
676 static const WCHAR bios_versionW
[] =
677 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
678 static const WCHAR cdromdrive_mediatypeW
[] =
679 {'C','D','-','R','O','M',0};
680 static const WCHAR cdromdrive_nameW
[] =
681 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
682 static const WCHAR cdromdrive_pnpdeviceidW
[]=
683 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
684 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
685 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
686 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
687 static const WCHAR compsys_descriptionW
[] =
688 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
689 static const WCHAR compsys_domainW
[] =
690 {'W','O','R','K','G','R','O','U','P',0};
691 static const WCHAR compsys_manufacturerW
[] =
692 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
693 static const WCHAR compsys_modelW
[] =
695 static const WCHAR compsysproduct_identifyingnumberW
[] =
697 static const WCHAR compsysproduct_uuidW
[] =
698 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
699 '0','0','0','0','0','0','0','0','0','0','0','0',0};
700 static const WCHAR diskdrive_interfacetypeW
[] =
702 static const WCHAR diskdrive_manufacturerW
[] =
703 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
704 static const WCHAR diskdrive_mediatype_fixedW
[] =
705 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
706 static const WCHAR diskdrive_mediatype_removableW
[] =
707 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
708 static const WCHAR diskdrive_modelW
[] =
709 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
710 static const WCHAR diskdrive_pnpdeviceidW
[] =
711 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
712 static const WCHAR diskdrive_serialW
[] =
713 {'W','I','N','E','H','D','I','S','K',0};
714 static const WCHAR networkadapter_pnpdeviceidW
[]=
715 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
716 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
717 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
718 static const WCHAR os_32bitW
[] =
719 {'3','2','-','b','i','t',0};
720 static const WCHAR os_64bitW
[] =
721 {'6','4','-','b','i','t',0};
722 static const WCHAR os_installdateW
[] =
723 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
724 static const WCHAR os_serialnumberW
[] =
725 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
726 static const WCHAR physicalmedia_tagW
[] =
727 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
728 static const WCHAR sounddevice_productnameW
[] =
729 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
730 static const WCHAR systemenclosure_systemenclosureW
[] =
731 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
732 static const WCHAR systemenclosure_tagW
[] =
733 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
734 static const WCHAR systemenclosure_manufacturerW
[] =
736 static const WCHAR videocontroller_dactypeW
[] =
737 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
738 static const WCHAR videocontroller_deviceidW
[] =
739 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
740 static const WCHAR videocontroller_driverversionW
[] =
743 #include "pshpack1.h"
744 struct record_baseboard
746 const WCHAR
*manufacturer
;
749 const WCHAR
*product
;
750 const WCHAR
*serialnumber
;
752 const WCHAR
*version
;
756 const WCHAR
*description
;
757 const WCHAR
*identificationcode
;
758 const WCHAR
*manufacturer
;
760 const WCHAR
*releasedate
;
761 const WCHAR
*serialnumber
;
762 const WCHAR
*smbiosbiosversion
;
763 const WCHAR
*version
;
765 struct record_cdromdrive
767 const WCHAR
*device_id
;
769 const WCHAR
*mediatype
;
771 const WCHAR
*pnpdevice_id
;
773 struct record_computersystem
775 const WCHAR
*description
;
778 const WCHAR
*manufacturer
;
781 UINT32 num_logical_processors
;
782 UINT32 num_processors
;
783 UINT64 total_physical_memory
;
784 const WCHAR
*username
;
786 struct record_computersystemproduct
788 const WCHAR
*identifyingnumber
;
791 struct record_datafile
794 const WCHAR
*version
;
796 struct record_desktopmonitor
798 UINT32 pixelsperxlogicalinch
;
800 struct record_directory
805 struct record_diskdrive
807 const WCHAR
*device_id
;
809 const WCHAR
*interfacetype
;
810 const WCHAR
*manufacturer
;
811 const WCHAR
*mediatype
;
813 const WCHAR
*pnpdevice_id
;
814 const WCHAR
*serialnumber
;
817 struct record_diskpartition
821 const WCHAR
*device_id
;
824 const WCHAR
*pnpdevice_id
;
826 UINT64 startingoffset
;
829 struct record_logicaldisk
831 const WCHAR
*device_id
;
833 const WCHAR
*filesystem
;
837 const WCHAR
*volumename
;
838 const WCHAR
*volumeserialnumber
;
840 struct record_networkadapter
842 const WCHAR
*adaptertype
;
843 const WCHAR
*device_id
;
845 UINT32 interface_index
;
846 const WCHAR
*mac_address
;
847 const WCHAR
*manufacturer
;
849 UINT16 netconnection_status
;
851 const WCHAR
*pnpdevice_id
;
854 struct record_networkadapterconfig
856 const struct array
*defaultipgateway
;
857 const WCHAR
*description
;
859 const WCHAR
*dnshostname
;
860 const struct array
*dnsserversearchorder
;
862 UINT32 ipconnectionmetric
;
864 const WCHAR
*mac_address
;
865 const WCHAR
*settingid
;
867 struct record_operatingsystem
869 const WCHAR
*buildnumber
;
870 const WCHAR
*caption
;
871 const WCHAR
*codeset
;
872 const WCHAR
*countrycode
;
873 const WCHAR
*csdversion
;
874 const WCHAR
*installdate
;
875 const WCHAR
*lastbootuptime
;
876 const WCHAR
*localdatetime
;
879 const WCHAR
*osarchitecture
;
881 UINT32 osproductsuite
;
884 const WCHAR
*serialnumber
;
885 UINT16 servicepackmajor
;
886 UINT16 servicepackminor
;
888 const WCHAR
*systemdirectory
;
889 UINT64 totalvisiblememorysize
;
890 const WCHAR
*version
;
897 const WCHAR
*parameter
;
902 struct record_physicalmedia
904 const WCHAR
*serialnumber
;
907 struct record_physicalmemory
911 struct record_printer
914 const WCHAR
*drivername
;
915 UINT32 horizontalresolution
;
919 const WCHAR
*device_id
;
920 const WCHAR
*portname
;
921 const WCHAR
*location
;
923 struct record_process
925 const WCHAR
*caption
;
926 const WCHAR
*commandline
;
927 const WCHAR
*description
;
933 UINT64 workingsetsize
;
935 class_method
*get_owner
;
937 struct record_processor
940 const WCHAR
*caption
;
942 UINT32 currentclockspeed
;
944 const WCHAR
*description
;
945 const WCHAR
*device_id
;
947 const WCHAR
*manufacturer
;
948 UINT32 maxclockspeed
;
951 UINT32 num_logical_processors
;
952 const WCHAR
*processor_id
;
953 UINT16 processortype
;
954 const WCHAR
*unique_id
;
955 const WCHAR
*version
;
957 struct record_qualifier
965 const WCHAR
*strvalue
;
967 struct record_service
971 const WCHAR
*displayname
;
974 const WCHAR
*servicetype
;
975 const WCHAR
*startmode
;
977 const WCHAR
*systemname
;
979 class_method
*pause_service
;
980 class_method
*resume_service
;
981 class_method
*start_service
;
982 class_method
*stop_service
;
986 const WCHAR
*accountname
;
987 const struct array
*binaryrepresentation
;
988 const WCHAR
*referenceddomainname
;
992 struct record_sounddevice
995 const WCHAR
*productname
;
998 struct record_stdregprov
1000 class_method
*enumkey
;
1001 class_method
*enumvalues
;
1002 class_method
*getstringvalue
;
1004 struct record_systemsecurity
1006 class_method
*getsd
;
1007 class_method
*setsd
;
1009 struct record_systemenclosure
1011 const WCHAR
*caption
;
1012 const struct array
*chassistypes
;
1013 const WCHAR
*description
;
1015 const WCHAR
*manufacturer
;
1019 struct record_videocontroller
1021 const WCHAR
*adapter_dactype
;
1023 UINT16 availability
;
1024 const WCHAR
*caption
;
1025 UINT32 current_bitsperpixel
;
1026 UINT32 current_horizontalres
;
1027 UINT32 current_refreshrate
;
1028 UINT16 current_scanmode
;
1029 UINT32 current_verticalres
;
1030 const WCHAR
*description
;
1031 const WCHAR
*device_id
;
1032 const WCHAR
*driverversion
;
1034 const WCHAR
*pnpdevice_id
;
1035 UINT16 videoarchitecture
;
1036 UINT16 videomemorytype
;
1037 const WCHAR
*videomodedescription
;
1038 const WCHAR
*videoprocessor
;
1040 #include "poppack.h"
1042 static const struct record_baseboard data_baseboard
[] =
1044 { baseboard_manufacturerW
, baseboard_tagW
, baseboard_tagW
, baseboard_tagW
, baseboard_serialnumberW
, baseboard_versionW
}
1046 static const struct record_bios data_bios
[] =
1048 { bios_descriptionW
, NULL
, bios_manufacturerW
, bios_nameW
, bios_releasedateW
, bios_serialnumberW
,
1049 bios_smbiosbiosversionW
, bios_versionW
}
1051 static const struct record_param data_param
[] =
1053 { class_processW
, method_getownerW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1054 { class_processW
, method_getownerW
, -1, param_userW
, CIM_STRING
},
1055 { class_processW
, method_getownerW
, -1, param_domainW
, CIM_STRING
},
1056 { class_serviceW
, method_pauseserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1057 { class_serviceW
, method_resumeserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1058 { class_serviceW
, method_startserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1059 { class_serviceW
, method_stopserviceW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1060 { class_stdregprovW
, method_enumkeyW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1061 { class_stdregprovW
, method_enumkeyW
, 1, param_subkeynameW
, CIM_STRING
},
1062 { class_stdregprovW
, method_enumkeyW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1063 { class_stdregprovW
, method_enumkeyW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1064 { class_stdregprovW
, method_enumvaluesW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1065 { class_stdregprovW
, method_enumvaluesW
, 1, param_subkeynameW
, CIM_STRING
},
1066 { class_stdregprovW
, method_enumvaluesW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1067 { class_stdregprovW
, method_enumvaluesW
, -1, param_namesW
, CIM_STRING
|CIM_FLAG_ARRAY
},
1068 { class_stdregprovW
, method_enumvaluesW
, -1, param_typesW
, CIM_SINT32
|CIM_FLAG_ARRAY
},
1069 { class_stdregprovW
, method_getstringvalueW
, 1, param_defkeyW
, CIM_SINT32
, 0, 0x80000002 },
1070 { class_stdregprovW
, method_getstringvalueW
, 1, param_subkeynameW
, CIM_STRING
},
1071 { class_stdregprovW
, method_getstringvalueW
, 1, param_valuenameW
, CIM_STRING
},
1072 { class_stdregprovW
, method_getstringvalueW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1073 { class_stdregprovW
, method_getstringvalueW
, -1, param_valueW
, CIM_STRING
},
1074 { class_systemsecurityW
, method_getsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1075 { class_systemsecurityW
, method_getsdW
, -1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1076 { class_systemsecurityW
, method_setsdW
, 1, param_sdW
, CIM_UINT8
|CIM_FLAG_ARRAY
},
1077 { class_systemsecurityW
, method_setsdW
, -1, param_returnvalueW
, CIM_UINT32
, VT_I4
},
1080 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1081 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1083 static const struct record_physicalmedia data_physicalmedia
[] =
1085 { diskdrive_serialW
, physicalmedia_tagW
}
1087 static const struct record_qualifier data_qualifier
[] =
1089 { class_process_getowner_outW
, param_userW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 0 },
1090 { class_process_getowner_outW
, param_domainW
, CIM_SINT32
, FLAVOR_ID
, prop_idW
, 1 }
1092 static const struct record_sounddevice data_sounddevice
[] =
1094 { sounddevice_productnameW
, sounddevice_productnameW
, 3 /* enabled */ }
1096 static const struct record_stdregprov data_stdregprov
[] =
1098 { reg_enum_key
, reg_enum_values
, reg_get_stringvalue
}
1100 static UINT16 systemenclosure_chassistypes
[] =
1104 static const struct array systemenclosure_chassistypes_array
=
1106 SIZEOF(systemenclosure_chassistypes
),
1107 &systemenclosure_chassistypes
1109 static const struct record_systemenclosure data_systemenclosure
[] =
1112 systemenclosure_systemenclosureW
,
1113 &systemenclosure_chassistypes_array
,
1114 systemenclosure_systemenclosureW
,
1116 systemenclosure_manufacturerW
,
1117 systemenclosure_systemenclosureW
,
1118 systemenclosure_tagW
,
1121 static const struct record_systemsecurity data_systemsecurity
[] =
1123 { security_get_sd
, security_set_sd
}
1126 /* check if row matches condition and update status */
1127 static BOOL
match_row( const struct table
*table
, UINT row
, const struct expr
*cond
, enum fill_status
*status
)
1134 *status
= FILL_STATUS_UNFILTERED
;
1137 if (eval_cond( table
, row
, cond
, &val
, &type
) != S_OK
)
1139 *status
= FILL_STATUS_FAILED
;
1142 *status
= FILL_STATUS_FILTERED
;
1146 static BOOL
resize_table( struct table
*table
, UINT row_count
, UINT row_size
)
1148 if (!table
->num_rows_allocated
)
1150 if (!(table
->data
= heap_alloc( row_count
* row_size
))) return FALSE
;
1151 table
->num_rows_allocated
= row_count
;
1154 if (row_count
> table
->num_rows_allocated
)
1157 UINT count
= max( row_count
, table
->num_rows_allocated
* 2 );
1158 if (!(data
= heap_realloc( table
->data
, count
* row_size
))) return FALSE
;
1160 table
->num_rows_allocated
= count
;
1165 static enum fill_status
fill_cdromdrive( struct table
*table
, const struct expr
*cond
)
1167 static const WCHAR fmtW
[] = {'%','c',':',0};
1168 WCHAR drive
[3], root
[] = {'A',':','\\',0};
1169 struct record_cdromdrive
*rec
;
1170 UINT i
, row
= 0, offset
= 0;
1171 DWORD drives
= GetLogicalDrives();
1172 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1174 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1176 for (i
= 0; i
< 26; i
++)
1178 if (drives
& (1 << i
))
1181 if (GetDriveTypeW( root
) != DRIVE_CDROM
)
1184 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1186 rec
= (struct record_cdromdrive
*)(table
->data
+ offset
);
1187 rec
->device_id
= cdromdrive_pnpdeviceidW
;
1188 sprintfW( drive
, fmtW
, 'A' + i
);
1189 rec
->drive
= heap_strdupW( drive
);
1190 rec
->mediatype
= cdromdrive_mediatypeW
;
1191 rec
->name
= cdromdrive_nameW
;
1192 rec
->pnpdevice_id
= cdromdrive_pnpdeviceidW
;
1193 if (!match_row( table
, row
, cond
, &status
))
1195 free_row_values( table
, row
);
1198 offset
+= sizeof(*rec
);
1202 TRACE("created %u rows\n", row
);
1203 table
->num_rows
= row
;
1207 static UINT
get_processor_count(void)
1209 SYSTEM_BASIC_INFORMATION info
;
1211 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
1212 return info
.NumberOfProcessors
;
1215 static UINT
get_logical_processor_count( UINT
*num_cores
)
1217 SYSTEM_LOGICAL_PROCESSOR_INFORMATION
*info
;
1218 UINT i
, j
, count
= 0;
1222 if (num_cores
) *num_cores
= get_processor_count();
1223 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, NULL
, 0, &len
);
1224 if (status
!= STATUS_INFO_LENGTH_MISMATCH
) return get_processor_count();
1226 if (!(info
= heap_alloc( len
))) return get_processor_count();
1227 status
= NtQuerySystemInformation( SystemLogicalProcessorInformation
, info
, len
, &len
);
1228 if (status
!= STATUS_SUCCESS
)
1231 return get_processor_count();
1233 if (num_cores
) *num_cores
= 0;
1234 for (i
= 0; i
< len
/ sizeof(*info
); i
++)
1236 if (info
[i
].Relationship
== RelationProcessorCore
)
1238 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) count
++;
1240 else if (info
[i
].Relationship
== RelationProcessorPackage
&& num_cores
)
1242 for (j
= 0; j
< sizeof(ULONG_PTR
); j
++) if (info
[i
].ProcessorMask
& (1 << j
)) (*num_cores
)++;
1249 static UINT64
get_total_physical_memory(void)
1251 MEMORYSTATUSEX status
;
1253 status
.dwLength
= sizeof(status
);
1254 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
1255 return status
.ullTotalPhys
;
1258 static WCHAR
*get_computername(void)
1261 DWORD size
= MAX_COMPUTERNAME_LENGTH
+ 1;
1263 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1264 GetComputerNameW( ret
, &size
);
1268 static WCHAR
*get_username(void)
1271 DWORD compsize
, usersize
;
1275 GetComputerNameW( NULL
, &compsize
);
1277 GetUserNameW( NULL
, &usersize
);
1278 size
= compsize
+ usersize
; /* two null terminators account for the \ */
1279 if (!(ret
= heap_alloc( size
* sizeof(WCHAR
) ))) return NULL
;
1280 GetComputerNameW( ret
, &compsize
);
1281 ret
[compsize
] = '\\';
1282 GetUserNameW( ret
+ compsize
+ 1, &usersize
);
1286 static enum fill_status
fill_compsys( struct table
*table
, const struct expr
*cond
)
1288 struct record_computersystem
*rec
;
1289 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1292 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1294 rec
= (struct record_computersystem
*)table
->data
;
1295 rec
->description
= compsys_descriptionW
;
1296 rec
->domain
= compsys_domainW
;
1297 rec
->domainrole
= 0; /* standalone workstation */
1298 rec
->manufacturer
= compsys_manufacturerW
;
1299 rec
->model
= compsys_modelW
;
1300 rec
->name
= get_computername();
1301 rec
->num_logical_processors
= get_logical_processor_count( NULL
);
1302 rec
->num_processors
= get_processor_count();
1303 rec
->total_physical_memory
= get_total_physical_memory();
1304 rec
->username
= get_username();
1305 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1308 TRACE("created %u rows\n", row
);
1309 table
->num_rows
= row
;
1313 static WCHAR
*get_compsysproduct_uuid(void)
1316 unsigned char uuid
[16];
1317 const struct timespec timeout
= {1, 0};
1318 if (!gethostuuid( uuid
, &timeout
))
1320 static const WCHAR fmtW
[] =
1321 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1322 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1323 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1324 WCHAR
*ret
= heap_alloc( 37 * sizeof(WCHAR
) );
1325 if (!ret
) return NULL
;
1326 sprintfW( ret
, fmtW
, uuid
[0], uuid
[1], uuid
[2], uuid
[3], uuid
[4], uuid
[5], uuid
[6], uuid
[7],
1327 uuid
[8], uuid
[9], uuid
[10], uuid
[11], uuid
[12], uuid
[13], uuid
[14], uuid
[15] );
1331 return heap_strdupW( compsysproduct_uuidW
);
1334 static enum fill_status
fill_compsysproduct( struct table
*table
, const struct expr
*cond
)
1336 struct record_computersystemproduct
*rec
;
1337 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1340 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1342 rec
= (struct record_computersystemproduct
*)table
->data
;
1343 rec
->identifyingnumber
= compsysproduct_identifyingnumberW
;
1344 rec
->uuid
= get_compsysproduct_uuid();
1345 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
1348 TRACE("created %u rows\n", row
);
1349 table
->num_rows
= row
;
1361 static struct dirstack
*alloc_dirstack( UINT size
)
1363 struct dirstack
*dirstack
;
1365 if (!(dirstack
= heap_alloc( sizeof(*dirstack
) ))) return NULL
;
1366 if (!(dirstack
->dirs
= heap_alloc( sizeof(WCHAR
*) * size
)))
1368 heap_free( dirstack
);
1371 if (!(dirstack
->len_dirs
= heap_alloc( sizeof(UINT
) * size
)))
1373 heap_free( dirstack
->dirs
);
1374 heap_free( dirstack
);
1377 dirstack
->num_dirs
= 0;
1378 dirstack
->num_allocated
= size
;
1382 static void clear_dirstack( struct dirstack
*dirstack
)
1385 for (i
= 0; i
< dirstack
->num_dirs
; i
++) heap_free( dirstack
->dirs
[i
] );
1386 dirstack
->num_dirs
= 0;
1389 static void free_dirstack( struct dirstack
*dirstack
)
1391 clear_dirstack( dirstack
);
1392 heap_free( dirstack
->dirs
);
1393 heap_free( dirstack
->len_dirs
);
1394 heap_free( dirstack
);
1397 static BOOL
push_dir( struct dirstack
*dirstack
, WCHAR
*dir
, UINT len
)
1399 UINT size
, i
= dirstack
->num_dirs
;
1401 if (!dir
) return FALSE
;
1403 if (i
== dirstack
->num_allocated
)
1408 size
= dirstack
->num_allocated
* 2;
1409 if (!(tmp
= heap_realloc( dirstack
->dirs
, size
* sizeof(WCHAR
*) ))) return FALSE
;
1410 dirstack
->dirs
= tmp
;
1411 if (!(len_tmp
= heap_realloc( dirstack
->len_dirs
, size
* sizeof(UINT
) ))) return FALSE
;
1412 dirstack
->len_dirs
= len_tmp
;
1413 dirstack
->num_allocated
= size
;
1415 dirstack
->dirs
[i
] = dir
;
1416 dirstack
->len_dirs
[i
] = len
;
1417 dirstack
->num_dirs
++;
1421 static WCHAR
*pop_dir( struct dirstack
*dirstack
, UINT
*len
)
1423 if (!dirstack
->num_dirs
)
1428 dirstack
->num_dirs
--;
1429 *len
= dirstack
->len_dirs
[dirstack
->num_dirs
];
1430 return dirstack
->dirs
[dirstack
->num_dirs
];
1433 static const WCHAR
*peek_dir( struct dirstack
*dirstack
)
1435 if (!dirstack
->num_dirs
) return NULL
;
1436 return dirstack
->dirs
[dirstack
->num_dirs
- 1];
1439 static WCHAR
*build_glob( WCHAR drive
, const WCHAR
*path
, UINT len
)
1444 if (!(ret
= heap_alloc( (len
+ 6) * sizeof(WCHAR
) ))) return NULL
;
1450 memcpy( ret
+ i
, path
, len
* sizeof(WCHAR
) );
1459 static WCHAR
*build_name( WCHAR drive
, const WCHAR
*path
)
1461 UINT i
= 0, len
= 0;
1465 for (p
= path
; *p
; p
++)
1467 if (*p
== '\\') len
+= 2;
1470 if (!(ret
= heap_alloc( (len
+ 5) * sizeof(WCHAR
) ))) return NULL
;
1475 for (p
= path
; *p
; p
++)
1477 if (*p
!= '\\') ret
[i
++] = *p
;
1488 static WCHAR
*build_dirname( const WCHAR
*path
, UINT
*ret_len
)
1490 const WCHAR
*p
= path
, *start
;
1494 if (!isalphaW( p
[0] ) || p
[1] != ':' || p
[2] != '\\' || p
[3] != '\\' || !p
[4]) return NULL
;
1496 len
= strlenW( start
);
1497 p
= start
+ len
- 1;
1498 if (*p
== '\\') return NULL
;
1500 while (p
>= start
&& *p
!= '\\') { len
--; p
--; };
1501 while (p
>= start
&& *p
== '\\') { len
--; p
--; };
1503 if (!(ret
= heap_alloc( (len
+ 1) * sizeof(WCHAR
) ))) return NULL
;
1504 for (i
= 0, p
= start
; p
< start
+ len
; p
++)
1506 if (p
[0] == '\\' && p
[1] == '\\')
1518 static BOOL
seen_dir( struct dirstack
*dirstack
, const WCHAR
*path
)
1521 for (i
= 0; i
< dirstack
->num_dirs
; i
++) if (!strcmpW( dirstack
->dirs
[i
], path
)) return TRUE
;
1525 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1526 static UINT
seed_dirs( struct dirstack
*dirstack
, const struct expr
*cond
, WCHAR root
, UINT
*count
)
1528 const struct expr
*left
, *right
;
1530 if (!cond
|| cond
->type
!= EXPR_COMPLEX
) return *count
= 0;
1532 left
= cond
->u
.expr
.left
;
1533 right
= cond
->u
.expr
.right
;
1534 if (cond
->u
.expr
.op
== OP_EQ
)
1538 const WCHAR
*str
= NULL
;
1540 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&&
1541 !strcmpW( left
->u
.propval
->name
, prop_nameW
) &&
1542 toupperW( right
->u
.sval
[0] ) == toupperW( root
))
1544 str
= right
->u
.sval
;
1546 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&&
1547 !strcmpW( right
->u
.propval
->name
, prop_nameW
) &&
1548 toupperW( left
->u
.sval
[0] ) == toupperW( root
))
1552 if (str
&& (path
= build_dirname( str
, &len
)))
1554 if (seen_dir( dirstack
, path
))
1559 else if (push_dir( dirstack
, path
, len
)) return ++*count
;
1564 else if (cond
->u
.expr
.op
== OP_OR
)
1566 UINT left_count
= 0, right_count
= 0;
1568 if (!(seed_dirs( dirstack
, left
, root
, &left_count
))) return *count
= 0;
1569 if (!(seed_dirs( dirstack
, right
, root
, &right_count
))) return *count
= 0;
1570 return *count
+= left_count
+ right_count
;
1575 static WCHAR
*append_path( const WCHAR
*path
, const WCHAR
*segment
, UINT
*len
)
1577 UINT len_path
= 0, len_segment
= strlenW( segment
);
1581 if (path
) len_path
= strlenW( path
);
1582 if (!(ret
= heap_alloc( (len_path
+ len_segment
+ 2) * sizeof(WCHAR
) ))) return NULL
;
1583 if (path
&& len_path
)
1585 memcpy( ret
, path
, len_path
* sizeof(WCHAR
) );
1586 ret
[len_path
] = '\\';
1587 *len
+= len_path
+ 1;
1589 memcpy( ret
+ *len
, segment
, len_segment
* sizeof(WCHAR
) );
1590 *len
+= len_segment
;
1595 static WCHAR
*get_file_version( const WCHAR
*filename
)
1597 static const WCHAR slashW
[] = {'\\',0}, fmtW
[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1598 VS_FIXEDFILEINFO
*info
;
1603 if (!(ret
= heap_alloc( (4 * 5 + sizeof(fmtW
) / sizeof(fmtW
[0])) * sizeof(WCHAR
) ))) return NULL
;
1604 if (!(size
= GetFileVersionInfoSizeW( filename
, NULL
)) || !(block
= heap_alloc( size
)))
1609 if (!GetFileVersionInfoW( filename
, 0, size
, block
) ||
1610 !VerQueryValueW( block
, slashW
, (void **)&info
, &size
))
1616 sprintfW( ret
, fmtW
, info
->dwFileVersionMS
>> 16, info
->dwFileVersionMS
& 0xffff,
1617 info
->dwFileVersionLS
>> 16, info
->dwFileVersionLS
& 0xffff );
1622 static enum fill_status
fill_datafile( struct table
*table
, const struct expr
*cond
)
1624 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1625 struct record_datafile
*rec
;
1626 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1627 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1628 DWORD drives
= GetLogicalDrives();
1629 WIN32_FIND_DATAW data
;
1631 struct dirstack
*dirstack
;
1632 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1634 if (!resize_table( table
, 8, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1636 dirstack
= alloc_dirstack(2);
1638 for (i
= 0; i
< 26; i
++)
1640 if (!(drives
& (1 << i
))) continue;
1643 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1645 num_expected_rows
= 0;
1646 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1652 path
= pop_dir( dirstack
, &len
);
1653 if (!(glob
= build_glob( root
[0], path
, len
)))
1655 status
= FILL_STATUS_FAILED
;
1658 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1662 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1664 status
= FILL_STATUS_FAILED
;
1665 FindClose( handle
);
1668 if (!strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
)) continue;
1669 new_path
= append_path( path
, data
.cFileName
, &len
);
1671 if (data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1673 if (push_dir( dirstack
, new_path
, len
)) continue;
1674 heap_free( new_path
);
1675 FindClose( handle
);
1676 status
= FILL_STATUS_FAILED
;
1679 rec
= (struct record_datafile
*)(table
->data
+ offset
);
1680 rec
->name
= build_name( root
[0], new_path
);
1681 rec
->version
= get_file_version( rec
->name
);
1682 if (!match_row( table
, row
, cond
, &status
))
1684 free_row_values( table
, row
);
1687 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1690 FindClose( handle
);
1691 status
= FILL_STATUS_FILTERED
;
1694 offset
+= sizeof(*rec
);
1697 while (FindNextFileW( handle
, &data
));
1698 FindClose( handle
);
1700 if (!peek_dir( dirstack
)) break;
1705 free_dirstack( dirstack
);
1709 TRACE("created %u rows\n", row
);
1710 table
->num_rows
= row
;
1714 static UINT32
get_pixelsperxlogicalinch(void)
1716 HDC hdc
= GetDC( NULL
);
1719 if (!hdc
) return 96;
1720 ret
= GetDeviceCaps( hdc
, LOGPIXELSX
);
1721 ReleaseDC( NULL
, hdc
);
1725 static enum fill_status
fill_desktopmonitor( struct table
*table
, const struct expr
*cond
)
1727 struct record_desktopmonitor
*rec
;
1728 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1731 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1733 rec
= (struct record_desktopmonitor
*)table
->data
;
1734 rec
->pixelsperxlogicalinch
= get_pixelsperxlogicalinch();
1736 if (match_row( table
, row
, cond
, &status
)) row
++;
1738 TRACE("created %u rows\n", row
);
1739 table
->num_rows
= row
;
1743 static enum fill_status
fill_directory( struct table
*table
, const struct expr
*cond
)
1745 static const WCHAR dotW
[] = {'.',0}, dotdotW
[] = {'.','.',0};
1746 struct record_directory
*rec
;
1747 UINT i
, len
, row
= 0, offset
= 0, num_expected_rows
;
1748 WCHAR
*glob
= NULL
, *path
= NULL
, *new_path
, root
[] = {'A',':','\\',0};
1749 DWORD drives
= GetLogicalDrives();
1750 WIN32_FIND_DATAW data
;
1752 struct dirstack
*dirstack
;
1753 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1755 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1757 dirstack
= alloc_dirstack(2);
1759 for (i
= 0; i
< 26; i
++)
1761 if (!(drives
& (1 << i
))) continue;
1764 if (GetDriveTypeW( root
) != DRIVE_FIXED
) continue;
1766 num_expected_rows
= 0;
1767 if (!seed_dirs( dirstack
, cond
, root
[0], &num_expected_rows
)) clear_dirstack( dirstack
);
1773 path
= pop_dir( dirstack
, &len
);
1774 if (!(glob
= build_glob( root
[0], path
, len
)))
1776 status
= FILL_STATUS_FAILED
;
1779 if ((handle
= FindFirstFileW( glob
, &data
)) != INVALID_HANDLE_VALUE
)
1783 if (!resize_table( table
, row
+ 1, sizeof(*rec
) ))
1785 FindClose( handle
);
1786 status
= FILL_STATUS_FAILED
;
1789 if (!(data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) ||
1790 !strcmpW( data
.cFileName
, dotW
) || !strcmpW( data
.cFileName
, dotdotW
))
1793 new_path
= append_path( path
, data
.cFileName
, &len
);
1794 if (!(push_dir( dirstack
, new_path
, len
)))
1796 heap_free( new_path
);
1797 FindClose( handle
);
1798 status
= FILL_STATUS_FAILED
;
1801 rec
= (struct record_directory
*)(table
->data
+ offset
);
1802 rec
->accessmask
= FILE_ALL_ACCESS
;
1803 rec
->name
= build_name( root
[0], new_path
);
1804 if (!match_row( table
, row
, cond
, &status
))
1806 free_row_values( table
, row
);
1809 else if (num_expected_rows
&& row
== num_expected_rows
- 1)
1812 FindClose( handle
);
1813 status
= FILL_STATUS_FILTERED
;
1816 offset
+= sizeof(*rec
);
1819 while (FindNextFileW( handle
, &data
));
1820 FindClose( handle
);
1822 if (!peek_dir( dirstack
)) break;
1827 free_dirstack( dirstack
);
1831 TRACE("created %u rows\n", row
);
1832 table
->num_rows
= row
;
1836 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
1838 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
1839 ULARGE_INTEGER free
;
1840 DISK_GEOMETRY_EX info
;
1842 DWORD bytes_returned
;
1844 free
.QuadPart
= 512 * 1024 * 1024;
1845 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
1848 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
1849 if (handle
!= INVALID_HANDLE_VALUE
)
1851 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), &bytes_returned
, NULL
))
1852 *disksize
= info
.DiskSize
.QuadPart
;
1853 CloseHandle( handle
);
1855 return free
.QuadPart
;
1858 static enum fill_status
fill_diskdrive( struct table
*table
, const struct expr
*cond
)
1860 static const WCHAR fmtW
[] =
1861 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1862 WCHAR device_id
[sizeof(fmtW
)/sizeof(fmtW
[0]) + 10], root
[] = {'A',':','\\',0};
1863 struct record_diskdrive
*rec
;
1864 UINT i
, row
= 0, offset
= 0, index
= 0, type
;
1865 UINT64 size
= 1024 * 1024 * 1024;
1866 DWORD drives
= GetLogicalDrives();
1867 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1869 if (!resize_table( table
, 2, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1871 for (i
= 0; i
< 26; i
++)
1873 if (drives
& (1 << i
))
1876 type
= GetDriveTypeW( root
);
1877 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1880 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1882 rec
= (struct record_diskdrive
*)(table
->data
+ offset
);
1883 sprintfW( device_id
, fmtW
, index
);
1884 rec
->device_id
= heap_strdupW( device_id
);
1886 rec
->interfacetype
= diskdrive_interfacetypeW
;
1887 rec
->manufacturer
= diskdrive_manufacturerW
;
1888 if (type
== DRIVE_FIXED
)
1889 rec
->mediatype
= diskdrive_mediatype_fixedW
;
1891 rec
->mediatype
= diskdrive_mediatype_removableW
;
1892 rec
->model
= diskdrive_modelW
;
1893 rec
->pnpdevice_id
= diskdrive_pnpdeviceidW
;
1894 rec
->serialnumber
= diskdrive_serialW
;
1895 get_freespace( root
, &size
);
1897 if (!match_row( table
, row
, cond
, &status
))
1899 free_row_values( table
, row
);
1902 offset
+= sizeof(*rec
);
1907 TRACE("created %u rows\n", row
);
1908 table
->num_rows
= row
;
1912 static WCHAR
*get_filesystem( const WCHAR
*root
)
1914 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
1915 WCHAR buffer
[MAX_PATH
+ 1];
1917 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
1918 return heap_strdupW( buffer
);
1919 return heap_strdupW( ntfsW
);
1922 static enum fill_status
fill_diskpartition( struct table
*table
, const struct expr
*cond
)
1924 static const WCHAR fmtW
[] =
1925 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1926 WCHAR device_id
[32], root
[] = {'A',':','\\',0};
1927 struct record_diskpartition
*rec
;
1928 UINT i
, row
= 0, offset
= 0, type
, index
= 0;
1929 UINT64 size
= 1024 * 1024 * 1024;
1930 DWORD drives
= GetLogicalDrives();
1931 enum fill_status status
= FILL_STATUS_UNFILTERED
;
1933 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1935 for (i
= 0; i
< 26; i
++)
1937 if (drives
& (1 << i
))
1940 type
= GetDriveTypeW( root
);
1941 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_REMOVABLE
)
1944 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
1946 rec
= (struct record_diskpartition
*)(table
->data
+ offset
);
1947 rec
->bootable
= (i
== 2) ? -1 : 0;
1948 rec
->bootpartition
= (i
== 2) ? -1 : 0;
1949 sprintfW( device_id
, fmtW
, index
);
1950 rec
->device_id
= heap_strdupW( device_id
);
1951 rec
->diskindex
= index
;
1953 rec
->pnpdevice_id
= heap_strdupW( device_id
);
1954 get_freespace( root
, &size
);
1956 rec
->startingoffset
= 0;
1957 rec
->type
= get_filesystem( root
);
1958 if (!match_row( table
, row
, cond
, &status
))
1960 free_row_values( table
, row
);
1963 offset
+= sizeof(*rec
);
1968 TRACE("created %u rows\n", row
);
1969 table
->num_rows
= row
;
1973 static WCHAR
*get_volumename( const WCHAR
*root
)
1975 WCHAR buf
[MAX_PATH
+ 1] = {0};
1976 GetVolumeInformationW( root
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
, NULL
, NULL
, NULL
, 0 );
1977 return heap_strdupW( buf
);
1979 static WCHAR
*get_volumeserialnumber( const WCHAR
*root
)
1981 static const WCHAR fmtW
[] = {'%','0','8','X',0};
1985 GetVolumeInformationW( root
, NULL
, 0, &serial
, NULL
, NULL
, NULL
, 0 );
1986 sprintfW( buffer
, fmtW
, serial
);
1987 return heap_strdupW( buffer
);
1990 static enum fill_status
fill_logicaldisk( struct table
*table
, const struct expr
*cond
)
1992 static const WCHAR fmtW
[] = {'%','c',':',0};
1993 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
1994 struct record_logicaldisk
*rec
;
1995 UINT i
, row
= 0, offset
= 0, type
;
1996 UINT64 size
= 1024 * 1024 * 1024;
1997 DWORD drives
= GetLogicalDrives();
1998 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2000 if (!resize_table( table
, 4, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2002 for (i
= 0; i
< 26; i
++)
2004 if (drives
& (1 << i
))
2007 type
= GetDriveTypeW( root
);
2008 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
2011 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2013 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
2014 sprintfW( device_id
, fmtW
, 'A' + i
);
2015 rec
->device_id
= heap_strdupW( device_id
);
2016 rec
->drivetype
= type
;
2017 rec
->filesystem
= get_filesystem( root
);
2018 rec
->freespace
= get_freespace( root
, &size
);
2019 rec
->name
= heap_strdupW( device_id
);
2021 rec
->volumename
= get_volumename( root
);
2022 rec
->volumeserialnumber
= get_volumeserialnumber( root
);
2023 if (!match_row( table
, row
, cond
, &status
))
2025 free_row_values( table
, row
);
2028 offset
+= sizeof(*rec
);
2032 TRACE("created %u rows\n", row
);
2033 table
->num_rows
= row
;
2037 static UINT16
get_connection_status( IF_OPER_STATUS status
)
2041 case IfOperStatusDown
:
2042 return 0; /* Disconnected */
2043 case IfOperStatusUp
:
2044 return 2; /* Connected */
2046 ERR("unhandled status %u\n", status
);
2051 static WCHAR
*get_mac_address( const BYTE
*addr
, DWORD len
)
2053 static const WCHAR fmtW
[] =
2054 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2055 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2058 if (len
!= 6 || !(ret
= heap_alloc( 18 * sizeof(WCHAR
) ))) return NULL
;
2059 sprintfW( ret
, fmtW
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4], addr
[5] );
2062 static const WCHAR
*get_adaptertype( DWORD type
, int *physical
)
2064 static const WCHAR ethernetW
[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2065 static const WCHAR wirelessW
[] = {'W','i','r','e','l','e','s','s',0};
2066 static const WCHAR firewireW
[] = {'1','3','9','4',0};
2067 static const WCHAR tunnelW
[] = {'T','u','n','n','e','l',0};
2071 case IF_TYPE_ETHERNET_CSMACD
: *physical
= -1; return ethernetW
;
2072 case IF_TYPE_IEEE80211
: *physical
= -1; return wirelessW
;
2073 case IF_TYPE_IEEE1394
: *physical
= -1; return firewireW
;
2074 case IF_TYPE_TUNNEL
: *physical
= 0; return tunnelW
;
2075 default: *physical
= 0; return NULL
;
2079 static enum fill_status
fill_networkadapter( struct table
*table
, const struct expr
*cond
)
2081 static const WCHAR fmtW
[] = {'%','u',0};
2082 WCHAR device_id
[11];
2083 struct record_networkadapter
*rec
;
2084 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2085 UINT row
= 0, offset
= 0, count
= 0;
2086 DWORD size
= 0, ret
;
2088 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2090 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
2091 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2093 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2094 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
2096 heap_free( buffer
);
2097 return FILL_STATUS_FAILED
;
2099 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2101 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2103 if (!resize_table( table
, count
, sizeof(*rec
) ))
2105 heap_free( buffer
);
2106 return FILL_STATUS_FAILED
;
2108 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2110 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2112 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
2113 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
2114 rec
->adaptertype
= get_adaptertype( aa
->IfType
, &physical
);
2115 rec
->device_id
= heap_strdupW( device_id
);
2116 rec
->index
= aa
->u
.s
.IfIndex
;
2117 rec
->interface_index
= aa
->u
.s
.IfIndex
;
2118 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2119 rec
->manufacturer
= compsys_manufacturerW
;
2120 rec
->name
= heap_strdupW( aa
->FriendlyName
);
2121 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
2122 rec
->physicaladapter
= physical
;
2123 rec
->pnpdevice_id
= networkadapter_pnpdeviceidW
;
2124 rec
->speed
= 1000000;
2125 if (!match_row( table
, row
, cond
, &status
))
2127 free_row_values( table
, row
);
2130 offset
+= sizeof(*rec
);
2133 TRACE("created %u rows\n", row
);
2134 table
->num_rows
= row
;
2136 heap_free( buffer
);
2140 static WCHAR
*get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS
*addr
)
2142 const SOCKET_ADDRESS
*sa
= &addr
->Address
;
2143 WCHAR buf
[NI_MAXHOST
];
2145 if (!addr
) return NULL
;
2146 if (GetNameInfoW( sa
->lpSockaddr
, sa
->iSockaddrLength
, buf
, sizeof(buf
)/sizeof(buf
[0]), NULL
,
2147 0, NI_NAMEREQD
)) return NULL
;
2148 return heap_strdupW( buf
);
2150 static struct array
*get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS
*list
)
2152 IP_ADAPTER_GATEWAY_ADDRESS
*gateway
;
2154 ULONG buflen
, i
= 0, count
= 0;
2155 WCHAR
**ptr
, buf
[54]; /* max IPv6 address length */
2157 if (!list
) return NULL
;
2158 for (gateway
= list
; gateway
; gateway
= gateway
->Next
) count
++;
2160 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2161 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2166 for (gateway
= list
; gateway
; gateway
= gateway
->Next
)
2168 buflen
= sizeof(buf
)/sizeof(buf
[0]);
2169 if (WSAAddressToStringW( gateway
->Address
.lpSockaddr
, gateway
->Address
.iSockaddrLength
,
2170 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2172 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2182 static struct array
*get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS
*list
)
2184 IP_ADAPTER_DNS_SERVER_ADDRESS
*server
;
2186 ULONG buflen
, i
= 0, count
= 0;
2187 WCHAR
**ptr
, *p
, buf
[54]; /* max IPv6 address length */
2189 if (!list
) return NULL
;
2190 for (server
= list
; server
; server
= server
->Next
) count
++;
2192 if (!(ret
= heap_alloc( sizeof(*ret
) ))) return NULL
;
2193 if (!(ptr
= heap_alloc( sizeof(*ptr
) * count
)))
2198 for (server
= list
; server
; server
= server
->Next
)
2200 buflen
= sizeof(buf
)/sizeof(buf
[0]);
2201 if (WSAAddressToStringW( server
->Address
.lpSockaddr
, server
->Address
.iSockaddrLength
,
2202 NULL
, buf
, &buflen
) || !(ptr
[i
++] = heap_strdupW( buf
)))
2204 for (; i
> 0; i
--) heap_free( ptr
[i
- 1] );
2209 if ((p
= strrchrW( ptr
[i
- 1], ':' ))) *p
= 0;
2215 static WCHAR
*get_settingid( UINT32 index
)
2219 memset( &guid
, 0, sizeof(guid
) );
2221 UuidToStringW( &guid
, &str
);
2222 ret
= heap_strdupW( str
);
2223 RpcStringFreeW( &str
);
2227 static enum fill_status
fill_networkadapterconfig( struct table
*table
, const struct expr
*cond
)
2229 struct record_networkadapterconfig
*rec
;
2230 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
2231 UINT row
= 0, offset
= 0, count
= 0;
2232 DWORD size
= 0, ret
;
2233 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2235 ret
= GetAdaptersAddresses( AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, NULL
, &size
);
2236 if (ret
!= ERROR_BUFFER_OVERFLOW
) return FILL_STATUS_FAILED
;
2238 if (!(buffer
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2239 if (GetAdaptersAddresses( AF_UNSPEC
, GAA_FLAG_INCLUDE_ALL_GATEWAYS
, NULL
, buffer
, &size
))
2241 heap_free( buffer
);
2242 return FILL_STATUS_FAILED
;
2244 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2246 if (aa
->IfType
!= IF_TYPE_SOFTWARE_LOOPBACK
) count
++;
2248 if (!resize_table( table
, count
, sizeof(*rec
) ))
2250 heap_free( buffer
);
2251 return FILL_STATUS_FAILED
;
2253 for (aa
= buffer
; aa
; aa
= aa
->Next
)
2255 if (aa
->IfType
== IF_TYPE_SOFTWARE_LOOPBACK
) continue;
2257 rec
= (struct record_networkadapterconfig
*)(table
->data
+ offset
);
2258 rec
->defaultipgateway
= get_defaultipgateway( aa
->FirstGatewayAddress
);
2259 rec
->description
= heap_strdupW( aa
->Description
);
2260 rec
->dhcpenabled
= -1;
2261 rec
->dnshostname
= get_dnshostname( aa
->FirstUnicastAddress
);
2262 rec
->dnsserversearchorder
= get_dnsserversearchorder( aa
->FirstDnsServerAddress
);
2263 rec
->index
= aa
->u
.s
.IfIndex
;
2264 rec
->ipconnectionmetric
= 20;
2265 rec
->ipenabled
= -1;
2266 rec
->mac_address
= get_mac_address( aa
->PhysicalAddress
, aa
->PhysicalAddressLength
);
2267 rec
->settingid
= get_settingid( rec
->index
);
2268 if (!match_row( table
, row
, cond
, &status
))
2270 free_row_values( table
, row
);
2273 offset
+= sizeof(*rec
);
2276 TRACE("created %u rows\n", row
);
2277 table
->num_rows
= row
;
2279 heap_free( buffer
);
2283 static enum fill_status
fill_physicalmemory( struct table
*table
, const struct expr
*cond
)
2285 struct record_physicalmemory
*rec
;
2286 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2289 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2291 rec
= (struct record_physicalmemory
*)table
->data
;
2292 rec
->capacity
= get_total_physical_memory();
2293 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2296 TRACE("created %u rows\n", row
);
2297 table
->num_rows
= row
;
2301 static enum fill_status
fill_printer( struct table
*table
, const struct expr
*cond
)
2303 static const WCHAR fmtW
[] = {'P','r','i','n','t','e','r','%','d',0};
2304 struct record_printer
*rec
;
2305 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2306 PRINTER_INFO_2W
*info
;
2307 DWORD i
, offset
= 0, count
= 0, size
= 0;
2310 EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &size
, &count
);
2311 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) return FILL_STATUS_FAILED
;
2313 if (!(info
= heap_alloc( size
))) return FILL_STATUS_FAILED
;
2314 if (!EnumPrintersW( PRINTER_ENUM_LOCAL
, NULL
, 2, (BYTE
*)info
, size
, &size
, &count
))
2317 return FILL_STATUS_FAILED
;
2319 if (!resize_table( table
, count
, sizeof(*rec
) ))
2322 return FILL_STATUS_FAILED
;
2325 for (i
= 0; i
< count
; i
++)
2327 rec
= (struct record_printer
*)(table
->data
+ offset
);
2328 rec
->attributes
= info
[i
].Attributes
;
2329 rec
->drivername
= heap_strdupW( info
[i
].pDriverName
);
2330 rec
->horizontalresolution
= info
[i
].pDevMode
->u1
.s1
.dmPrintQuality
;
2332 rec
->name
= heap_strdupW( info
[i
].pPrinterName
);
2334 sprintfW( id
, fmtW
, i
);
2335 rec
->device_id
= heap_strdupW( id
);
2336 rec
->portname
= heap_strdupW( info
[i
].pPortName
);
2337 rec
->location
= heap_strdupW( info
[i
].pLocation
);
2338 if (!match_row( table
, i
, cond
, &status
))
2340 free_row_values( table
, i
);
2343 offset
+= sizeof(*rec
);
2345 TRACE("created %u rows\n", count
);
2346 table
->num_rows
= count
;
2352 static WCHAR
*get_cmdline( DWORD process_id
)
2354 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2355 return NULL
; /* FIXME handle different process case */
2358 static enum fill_status
fill_process( struct table
*table
, const struct expr
*cond
)
2360 static const WCHAR fmtW
[] = {'%','u',0};
2362 struct record_process
*rec
;
2363 PROCESSENTRY32W entry
;
2365 enum fill_status status
= FILL_STATUS_FAILED
;
2366 UINT row
= 0, offset
= 0;
2368 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
2369 if (snap
== INVALID_HANDLE_VALUE
) return FILL_STATUS_FAILED
;
2371 entry
.dwSize
= sizeof(entry
);
2372 if (!Process32FirstW( snap
, &entry
)) goto done
;
2373 if (!resize_table( table
, 8, sizeof(*rec
) )) goto done
;
2377 if (!resize_table( table
, row
+ 1, sizeof(*rec
) )) goto done
;
2379 rec
= (struct record_process
*)(table
->data
+ offset
);
2380 rec
->caption
= heap_strdupW( entry
.szExeFile
);
2381 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
2382 rec
->description
= heap_strdupW( entry
.szExeFile
);
2383 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
2384 rec
->handle
= heap_strdupW( handle
);
2385 rec
->name
= heap_strdupW( entry
.szExeFile
);
2386 rec
->process_id
= entry
.th32ProcessID
;
2387 rec
->pprocess_id
= entry
.th32ParentProcessID
;
2388 rec
->thread_count
= entry
.cntThreads
;
2389 rec
->workingsetsize
= 0;
2390 rec
->get_owner
= process_get_owner
;
2391 if (!match_row( table
, row
, cond
, &status
))
2393 free_row_values( table
, row
);
2396 offset
+= sizeof(*rec
);
2398 } while (Process32NextW( snap
, &entry
));
2400 TRACE("created %u rows\n", row
);
2401 table
->num_rows
= row
;
2402 status
= FILL_STATUS_UNFILTERED
;
2405 CloseHandle( snap
);
2409 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
2415 __asm__("pushl %%ebx\n\t"
2417 "movl %%ebx, %%esi\n\t"
2419 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
2424 static const WCHAR
*get_osarchitecture(void)
2427 GetNativeSystemInfo( &info
);
2428 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
) return os_64bitW
;
2431 static void get_processor_caption( WCHAR
*caption
)
2433 static const WCHAR fmtW
[] =
2434 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2435 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2436 static const WCHAR x86W
[] = {'x','8','6',0};
2437 static const WCHAR intel64W
[] = {'I','n','t','e','l','6','4',0};
2438 const WCHAR
*arch
= (get_osarchitecture() == os_32bitW
) ? x86W
: intel64W
;
2439 unsigned int regs
[4] = {0, 0, 0, 0};
2441 do_cpuid( 1, regs
);
2442 sprintfW( caption
, fmtW
, arch
, (regs
[0] & (15 << 8)) >> 8, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2444 static void get_processor_version( WCHAR
*version
)
2446 static const WCHAR fmtW
[] =
2447 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2448 unsigned int regs
[4] = {0, 0, 0, 0};
2450 do_cpuid( 1, regs
);
2451 sprintfW( version
, fmtW
, (regs
[0] & (15 << 4)) >> 4, regs
[0] & 15 );
2453 static void get_processor_id( WCHAR
*processor_id
)
2455 static const WCHAR fmtW
[] = {'%','0','8','X','%','0','8','X',0};
2456 unsigned int regs
[4] = {0, 0, 0, 0};
2458 do_cpuid( 1, regs
);
2459 sprintfW( processor_id
, fmtW
, regs
[3], regs
[0] );
2461 static void regs_to_str( unsigned int *regs
, unsigned int len
, WCHAR
*buffer
)
2464 unsigned char *p
= (unsigned char *)regs
;
2466 for (i
= 0; i
< len
; i
++) { buffer
[i
] = *p
++; }
2469 static void get_processor_manufacturer( WCHAR
*manufacturer
)
2471 unsigned int tmp
, regs
[4] = {0, 0, 0, 0};
2473 do_cpuid( 0, regs
);
2474 tmp
= regs
[2]; /* swap edx and ecx */
2478 regs_to_str( regs
+ 1, 12, manufacturer
);
2480 static void get_processor_name( WCHAR
*name
)
2482 unsigned int regs
[4] = {0, 0, 0, 0};
2484 do_cpuid( 0x80000000, regs
);
2485 if (regs
[0] >= 0x80000004)
2487 do_cpuid( 0x80000002, regs
);
2488 regs_to_str( regs
, 16, name
);
2489 do_cpuid( 0x80000003, regs
);
2490 regs_to_str( regs
, 16, name
+ 16 );
2491 do_cpuid( 0x80000004, regs
);
2492 regs_to_str( regs
, 16, name
+ 32 );
2495 static UINT
get_processor_currentclockspeed( UINT index
)
2497 PROCESSOR_POWER_INFORMATION
*info
;
2498 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2501 if ((info
= heap_alloc( size
)))
2503 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2504 if (!status
) ret
= info
[index
].CurrentMhz
;
2509 static UINT
get_processor_maxclockspeed( UINT index
)
2511 PROCESSOR_POWER_INFORMATION
*info
;
2512 UINT ret
= 1000, size
= get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION
);
2515 if ((info
= heap_alloc( size
)))
2517 status
= NtPowerInformation( ProcessorInformation
, NULL
, 0, info
, size
);
2518 if (!status
) ret
= info
[index
].MaxMhz
;
2524 static enum fill_status
fill_processor( struct table
*table
, const struct expr
*cond
)
2526 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
2527 WCHAR caption
[100], device_id
[14], processor_id
[17], manufacturer
[13], name
[49] = {0}, version
[50];
2528 struct record_processor
*rec
;
2529 UINT i
, offset
= 0, num_cores
, num_logical_processors
, count
= get_processor_count();
2530 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2532 if (!resize_table( table
, count
, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2534 get_processor_caption( caption
);
2535 get_processor_id( processor_id
);
2536 get_processor_manufacturer( manufacturer
);
2537 get_processor_name( name
);
2538 get_processor_version( version
);
2540 num_logical_processors
= get_logical_processor_count( &num_cores
) / count
;
2543 for (i
= 0; i
< count
; i
++)
2545 rec
= (struct record_processor
*)(table
->data
+ offset
);
2546 rec
->addresswidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2547 rec
->caption
= heap_strdupW( caption
);
2548 rec
->cpu_status
= 1; /* CPU Enabled */
2549 rec
->currentclockspeed
= get_processor_currentclockspeed( i
);
2550 rec
->datawidth
= get_osarchitecture() == os_32bitW
? 32 : 64;
2551 rec
->description
= heap_strdupW( caption
);
2552 sprintfW( device_id
, fmtW
, i
);
2553 rec
->device_id
= heap_strdupW( device_id
);
2554 rec
->family
= 2; /* Unknown */
2555 rec
->manufacturer
= heap_strdupW( manufacturer
);
2556 rec
->maxclockspeed
= get_processor_maxclockspeed( i
);
2557 rec
->name
= heap_strdupW( name
);
2558 rec
->num_cores
= num_cores
;
2559 rec
->num_logical_processors
= num_logical_processors
;
2560 rec
->processor_id
= heap_strdupW( processor_id
);
2561 rec
->processortype
= 3; /* central processor */
2562 rec
->unique_id
= NULL
;
2563 rec
->version
= heap_strdupW( version
);
2564 if (!match_row( table
, i
, cond
, &status
))
2566 free_row_values( table
, i
);
2569 offset
+= sizeof(*rec
);
2572 TRACE("created %u rows\n", count
);
2573 table
->num_rows
= count
;
2577 static WCHAR
*get_lastbootuptime(void)
2579 static const WCHAR fmtW
[] =
2580 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2581 '.','%','0','6','u','+','0','0','0',0};
2582 SYSTEM_TIMEOFDAY_INFORMATION ti
;
2586 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2588 NtQuerySystemInformation( SystemTimeOfDayInformation
, &ti
, sizeof(ti
), NULL
);
2589 RtlTimeToTimeFields( &ti
.liKeBootTime
, &tf
);
2590 sprintfW( ret
, fmtW
, tf
.Year
, tf
.Month
, tf
.Day
, tf
.Hour
, tf
.Minute
, tf
.Second
, tf
.Milliseconds
* 1000 );
2593 static WCHAR
*get_localdatetime(void)
2595 static const WCHAR fmtW
[] =
2596 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2597 '.','%','0','6','u','%','+','0','3','d',0};
2598 TIME_ZONE_INFORMATION tzi
;
2604 Status
= GetTimeZoneInformation(&tzi
);
2606 if(Status
== TIME_ZONE_ID_INVALID
) return NULL
;
2608 if(Status
== TIME_ZONE_ID_DAYLIGHT
)
2609 Bias
+= tzi
.DaylightBias
;
2611 Bias
+= tzi
.StandardBias
;
2612 if (!(ret
= heap_alloc( 26 * sizeof(WCHAR
) ))) return NULL
;
2615 sprintfW( ret
, fmtW
, st
.wYear
, st
.wMonth
, st
.wDay
, st
.wHour
, st
.wMinute
, st
.wSecond
, st
.wMilliseconds
* 1000, -Bias
);
2618 static WCHAR
*get_systemdirectory(void)
2623 if (!(ret
= heap_alloc( MAX_PATH
* sizeof(WCHAR
) ))) return NULL
;
2624 Wow64DisableWow64FsRedirection( &redir
);
2625 GetSystemDirectoryW( ret
, MAX_PATH
);
2626 Wow64RevertWow64FsRedirection( redir
);
2629 static WCHAR
*get_codeset(void)
2631 static const WCHAR fmtW
[] = {'%','u',0};
2632 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2633 if (ret
) sprintfW( ret
, fmtW
, GetACP() );
2636 static WCHAR
*get_countrycode(void)
2638 WCHAR
*ret
= heap_alloc( 6 * sizeof(WCHAR
) );
2639 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ICOUNTRY
, ret
, 6 );
2642 static WCHAR
*get_locale(void)
2644 WCHAR
*ret
= heap_alloc( 5 * sizeof(WCHAR
) );
2645 if (ret
) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT
, LOCALE_ILANGUAGE
, ret
, 5 );
2648 static WCHAR
*get_osbuildnumber( OSVERSIONINFOEXW
*ver
)
2650 static const WCHAR fmtW
[] = {'%','u',0};
2651 WCHAR
*ret
= heap_alloc( 11 * sizeof(WCHAR
) );
2652 if (ret
) sprintfW( ret
, fmtW
, ver
->dwBuildNumber
);
2655 static WCHAR
*get_oscaption( OSVERSIONINFOEXW
*ver
)
2657 static const WCHAR windowsW
[] =
2658 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
2659 static const WCHAR win2000W
[] =
2660 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2661 static const WCHAR win2003W
[] =
2662 {'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};
2663 static const WCHAR winxpW
[] =
2664 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2665 static const WCHAR winxp64W
[] =
2666 {'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};
2667 static const WCHAR vistaW
[] =
2668 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
2669 static const WCHAR win2008W
[] =
2670 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
2671 static const WCHAR win7W
[] =
2672 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2673 static const WCHAR win2008r2W
[] =
2674 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
2675 static const WCHAR win8W
[] =
2676 {'8',' ','P','r','o',0};
2677 static const WCHAR win81W
[] =
2678 {'8','.','1',' ','P','r','o',0};
2679 static const WCHAR win10W
[] =
2680 {'1','0',' ','P','r','o',0};
2681 int len
= sizeof(windowsW
)/sizeof(windowsW
[0]);
2684 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(win2003W
) ))) return NULL
;
2685 memcpy( ret
, windowsW
, sizeof(windowsW
) );
2686 if (ver
->dwMajorVersion
== 10 && ver
->dwMinorVersion
== 0) memcpy( ret
+ len
, win10W
, sizeof(win10W
) );
2687 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 3) memcpy( ret
+ len
, win8W
, sizeof(win8W
) );
2688 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 2) memcpy( ret
+ len
, win81W
, sizeof(win81W
) );
2689 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 1)
2691 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, win7W
, sizeof(win7W
) );
2692 else memcpy( ret
+ len
, win2008r2W
, sizeof(win2008r2W
) );
2694 else if (ver
->dwMajorVersion
== 6 && ver
->dwMinorVersion
== 0)
2696 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, vistaW
, sizeof(vistaW
) );
2697 else memcpy( ret
+ len
, win2008W
, sizeof(win2008W
) );
2699 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 2)
2701 if (ver
->wProductType
== VER_NT_WORKSTATION
) memcpy( ret
+ len
, winxp64W
, sizeof(winxp64W
) );
2702 else memcpy( ret
+ len
, win2003W
, sizeof(win2003W
) );
2704 else if (ver
->dwMajorVersion
== 5 && ver
->dwMinorVersion
== 1) memcpy( ret
+ len
, winxpW
, sizeof(winxpW
) );
2705 else memcpy( ret
+ len
, win2000W
, sizeof(win2000W
) );
2708 static WCHAR
*get_osname( const WCHAR
*caption
)
2710 static const WCHAR partitionW
[] =
2711 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
2712 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
2713 int len
= strlenW( caption
);
2716 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) + sizeof(partitionW
) ))) return NULL
;
2717 memcpy( ret
, caption
, len
* sizeof(WCHAR
) );
2718 memcpy( ret
+ len
, partitionW
, sizeof(partitionW
) );
2721 static WCHAR
*get_osversion( OSVERSIONINFOEXW
*ver
)
2723 static const WCHAR fmtW
[] = {'%','u','.','%','u','.','%','u',0};
2724 WCHAR
*ret
= heap_alloc( 33 * sizeof(WCHAR
) );
2725 if (ret
) sprintfW( ret
, fmtW
, ver
->dwMajorVersion
, ver
->dwMinorVersion
, ver
->dwBuildNumber
);
2729 static enum fill_status
fill_os( struct table
*table
, const struct expr
*cond
)
2731 struct record_operatingsystem
*rec
;
2732 enum fill_status status
= FILL_STATUS_UNFILTERED
;
2733 OSVERSIONINFOEXW ver
;
2736 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2738 ver
.dwOSVersionInfoSize
= sizeof(ver
);
2739 GetVersionExW( (OSVERSIONINFOW
*)&ver
);
2741 rec
= (struct record_operatingsystem
*)table
->data
;
2742 rec
->buildnumber
= get_osbuildnumber( &ver
);
2743 rec
->caption
= get_oscaption( &ver
);
2744 rec
->codeset
= get_codeset();
2745 rec
->countrycode
= get_countrycode();
2746 rec
->csdversion
= ver
.szCSDVersion
[0] ? heap_strdupW( ver
.szCSDVersion
) : NULL
;
2747 rec
->installdate
= os_installdateW
;
2748 rec
->lastbootuptime
= get_lastbootuptime();
2749 rec
->localdatetime
= get_localdatetime();
2750 rec
->locale
= get_locale();
2751 rec
->name
= get_osname( rec
->caption
);
2752 rec
->osarchitecture
= get_osarchitecture();
2753 rec
->oslanguage
= GetSystemDefaultLangID();
2754 rec
->osproductsuite
= 2461140; /* Windows XP Professional */
2755 rec
->ostype
= 18; /* WINNT */
2757 rec
->serialnumber
= os_serialnumberW
;
2758 rec
->servicepackmajor
= ver
.wServicePackMajor
;
2759 rec
->servicepackminor
= ver
.wServicePackMinor
;
2760 rec
->suitemask
= 272; /* Single User + Terminal */
2761 rec
->systemdirectory
= get_systemdirectory();
2762 rec
->totalvisiblememorysize
= get_total_physical_memory() / 1024;
2763 rec
->version
= get_osversion( &ver
);
2764 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
2767 TRACE("created %u rows\n", row
);
2768 table
->num_rows
= row
;
2772 static const WCHAR
*get_service_type( DWORD type
)
2774 static const WCHAR filesystem_driverW
[] =
2775 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2776 static const WCHAR kernel_driverW
[] =
2777 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2778 static const WCHAR own_processW
[] =
2779 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2780 static const WCHAR share_processW
[] =
2781 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2783 if (type
& SERVICE_KERNEL_DRIVER
) return kernel_driverW
;
2784 else if (type
& SERVICE_FILE_SYSTEM_DRIVER
) return filesystem_driverW
;
2785 else if (type
& SERVICE_WIN32_OWN_PROCESS
) return own_processW
;
2786 else if (type
& SERVICE_WIN32_SHARE_PROCESS
) return share_processW
;
2787 else ERR("unhandled type 0x%08x\n", type
);
2790 static const WCHAR
*get_service_state( DWORD state
)
2792 static const WCHAR runningW
[] =
2793 {'R','u','n','n','i','n','g',0};
2794 static const WCHAR start_pendingW
[] =
2795 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2796 static const WCHAR stop_pendingW
[] =
2797 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2798 static const WCHAR stoppedW
[] =
2799 {'S','t','o','p','p','e','d',0};
2800 static const WCHAR unknownW
[] =
2801 {'U','n','k','n','o','w','n',0};
2805 case SERVICE_STOPPED
: return stoppedW
;
2806 case SERVICE_START_PENDING
: return start_pendingW
;
2807 case SERVICE_STOP_PENDING
: return stop_pendingW
;
2808 case SERVICE_RUNNING
: return runningW
;
2810 ERR("unknown state %u\n", state
);
2814 static const WCHAR
*get_service_startmode( DWORD mode
)
2816 static const WCHAR bootW
[] = {'B','o','o','t',0};
2817 static const WCHAR systemW
[] = {'S','y','s','t','e','m',0};
2818 static const WCHAR autoW
[] = {'A','u','t','o',0};
2819 static const WCHAR manualW
[] = {'M','a','n','u','a','l',0};
2820 static const WCHAR disabledW
[] = {'D','i','s','a','b','l','e','d',0};
2821 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
2825 case SERVICE_BOOT_START
: return bootW
;
2826 case SERVICE_SYSTEM_START
: return systemW
;
2827 case SERVICE_AUTO_START
: return autoW
;
2828 case SERVICE_DEMAND_START
: return manualW
;
2829 case SERVICE_DISABLED
: return disabledW
;
2831 ERR("unknown mode 0x%x\n", mode
);
2835 static QUERY_SERVICE_CONFIGW
*query_service_config( SC_HANDLE manager
, const WCHAR
*name
)
2837 QUERY_SERVICE_CONFIGW
*config
= NULL
;
2841 if (!(service
= OpenServiceW( manager
, name
, SERVICE_QUERY_CONFIG
))) return NULL
;
2842 QueryServiceConfigW( service
, NULL
, 0, &size
);
2843 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
) goto done
;
2844 if (!(config
= heap_alloc( size
))) goto done
;
2845 if (QueryServiceConfigW( service
, config
, size
, &size
)) goto done
;
2846 heap_free( config
);
2850 CloseServiceHandle( service
);
2854 static enum fill_status
fill_service( struct table
*table
, const struct expr
*cond
)
2856 struct record_service
*rec
;
2858 ENUM_SERVICE_STATUS_PROCESSW
*tmp
, *services
= NULL
;
2859 SERVICE_STATUS_PROCESS
*status
;
2860 WCHAR sysnameW
[MAX_COMPUTERNAME_LENGTH
+ 1];
2861 DWORD len
= sizeof(sysnameW
) / sizeof(sysnameW
[0]);
2862 UINT i
, row
= 0, offset
= 0, size
= 256, needed
, count
;
2863 enum fill_status fill_status
= FILL_STATUS_FAILED
;
2866 if (!(manager
= OpenSCManagerW( NULL
, NULL
, SC_MANAGER_ENUMERATE_SERVICE
))) return FILL_STATUS_FAILED
;
2867 if (!(services
= heap_alloc( size
))) goto done
;
2869 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2870 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2871 &count
, NULL
, NULL
);
2874 if (GetLastError() != ERROR_MORE_DATA
) goto done
;
2876 if (!(tmp
= heap_realloc( services
, size
))) goto done
;
2878 ret
= EnumServicesStatusExW( manager
, SC_ENUM_PROCESS_INFO
, SERVICE_TYPE_ALL
,
2879 SERVICE_STATE_ALL
, (BYTE
*)services
, size
, &needed
,
2880 &count
, NULL
, NULL
);
2881 if (!ret
) goto done
;
2883 if (!resize_table( table
, count
, sizeof(*rec
) )) goto done
;
2885 GetComputerNameW( sysnameW
, &len
);
2886 fill_status
= FILL_STATUS_UNFILTERED
;
2888 for (i
= 0; i
< count
; i
++)
2890 QUERY_SERVICE_CONFIGW
*config
;
2892 if (!(config
= query_service_config( manager
, services
[i
].lpServiceName
))) continue;
2894 status
= &services
[i
].ServiceStatusProcess
;
2895 rec
= (struct record_service
*)(table
->data
+ offset
);
2896 rec
->accept_pause
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_PAUSE_CONTINUE
) ? -1 : 0;
2897 rec
->accept_stop
= (status
->dwControlsAccepted
& SERVICE_ACCEPT_STOP
) ? -1 : 0;
2898 rec
->displayname
= heap_strdupW( services
[i
].lpDisplayName
);
2899 rec
->name
= heap_strdupW( services
[i
].lpServiceName
);
2900 rec
->process_id
= status
->dwProcessId
;
2901 rec
->servicetype
= get_service_type( status
->dwServiceType
);
2902 rec
->startmode
= get_service_startmode( config
->dwStartType
);
2903 rec
->state
= get_service_state( status
->dwCurrentState
);
2904 rec
->systemname
= heap_strdupW( sysnameW
);
2905 rec
->pause_service
= service_pause_service
;
2906 rec
->resume_service
= service_resume_service
;
2907 rec
->start_service
= service_start_service
;
2908 rec
->stop_service
= service_stop_service
;
2909 heap_free( config
);
2910 if (!match_row( table
, row
, cond
, &fill_status
))
2912 free_row_values( table
, row
);
2915 offset
+= sizeof(*rec
);
2919 TRACE("created %u rows\n", row
);
2920 table
->num_rows
= row
;
2923 CloseServiceHandle( manager
);
2924 heap_free( services
);
2928 static WCHAR
*get_accountname( LSA_TRANSLATED_NAME
*name
)
2930 if (!name
|| !name
->Name
.Buffer
) return NULL
;
2931 return heap_strdupW( name
->Name
.Buffer
);
2933 static struct array
*get_binaryrepresentation( PSID sid
, UINT len
)
2935 struct array
*array
= heap_alloc( sizeof(struct array
) );
2938 UINT8
*ret
= heap_alloc( len
);
2941 memcpy( ret
, sid
, len
);
2950 static WCHAR
*get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST
*domain
)
2952 if (!domain
|| !domain
->Domains
|| !domain
->Domains
->Name
.Buffer
) return NULL
;
2953 return heap_strdupW( domain
->Domains
->Name
.Buffer
);
2955 static const WCHAR
*find_sid_str( const struct expr
*cond
)
2957 const struct expr
*left
, *right
;
2958 const WCHAR
*ret
= NULL
;
2960 if (!cond
|| cond
->type
!= EXPR_COMPLEX
|| cond
->u
.expr
.op
!= OP_EQ
) return NULL
;
2962 left
= cond
->u
.expr
.left
;
2963 right
= cond
->u
.expr
.right
;
2964 if (left
->type
== EXPR_PROPVAL
&& right
->type
== EXPR_SVAL
&& !strcmpiW( left
->u
.propval
->name
, prop_sidW
))
2966 ret
= right
->u
.sval
;
2968 else if (left
->type
== EXPR_SVAL
&& right
->type
== EXPR_PROPVAL
&& !strcmpiW( right
->u
.propval
->name
, prop_sidW
))
2975 static enum fill_status
fill_sid( struct table
*table
, const struct expr
*cond
)
2978 LSA_REFERENCED_DOMAIN_LIST
*domain
;
2979 LSA_TRANSLATED_NAME
*name
;
2981 LSA_OBJECT_ATTRIBUTES attrs
;
2983 struct record_sid
*rec
;
2986 if (!(str
= find_sid_str( cond
))) return FILL_STATUS_FAILED
;
2987 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
2989 if (!ConvertStringSidToSidW( str
, &sid
)) return FILL_STATUS_FAILED
;
2990 len
= GetLengthSid( sid
);
2992 memset( &attrs
, 0, sizeof(attrs
) );
2993 attrs
.Length
= sizeof(attrs
);
2994 if (LsaOpenPolicy( NULL
, &attrs
, POLICY_ALL_ACCESS
, &handle
))
2997 return FILL_STATUS_FAILED
;
2999 if (LsaLookupSids( handle
, 1, &sid
, &domain
, &name
))
3003 return FILL_STATUS_FAILED
;
3006 rec
= (struct record_sid
*)table
->data
;
3007 rec
->accountname
= get_accountname( name
);
3008 rec
->binaryrepresentation
= get_binaryrepresentation( sid
, len
);
3009 rec
->referenceddomainname
= get_referenceddomainname( domain
);
3010 rec
->sid
= heap_strdupW( str
);
3011 rec
->sidlength
= len
;
3013 TRACE("created 1 row\n");
3014 table
->num_rows
= 1;
3016 LsaFreeMemory( domain
);
3017 LsaFreeMemory( name
);
3020 return FILL_STATUS_FILTERED
;
3025 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
3027 HDC hdc
= GetDC( NULL
);
3030 if (!hdc
) return 32;
3031 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
3032 *hres
= GetDeviceCaps( hdc
, HORZRES
);
3033 *vres
= GetDeviceCaps( hdc
, VERTRES
);
3034 ReleaseDC( NULL
, hdc
);
3037 static WCHAR
*get_pnpdeviceid( DXGI_ADAPTER_DESC
*desc
)
3039 static const WCHAR fmtW
[] =
3040 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
3041 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
3042 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
3045 if (!(ret
= heap_alloc( sizeof(fmtW
) + 2 * sizeof(WCHAR
) ))) return NULL
;
3046 sprintfW( ret
, fmtW
, desc
->VendorId
, desc
->DeviceId
, desc
->SubSysId
, desc
->Revision
);
3050 static enum fill_status
fill_videocontroller( struct table
*table
, const struct expr
*cond
)
3052 static const WCHAR fmtW
[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
3053 struct record_videocontroller
*rec
;
3055 IDXGIFactory
*factory
= NULL
;
3056 IDXGIAdapter
*adapter
= NULL
;
3057 DXGI_ADAPTER_DESC desc
;
3058 UINT row
= 0, hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
3059 const WCHAR
*name
= videocontroller_deviceidW
;
3060 enum fill_status status
= FILL_STATUS_UNFILTERED
;
3063 if (!resize_table( table
, 1, sizeof(*rec
) )) return FILL_STATUS_FAILED
;
3065 memset (&desc
, 0, sizeof(desc
));
3066 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
3067 if (FAILED(hr
)) goto done
;
3069 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
3070 if (FAILED(hr
)) goto done
;
3072 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
3075 vidmem
= desc
.DedicatedVideoMemory
;
3076 name
= desc
.Description
;
3080 rec
= (struct record_videocontroller
*)table
->data
;
3081 rec
->adapter_dactype
= videocontroller_dactypeW
;
3082 rec
->adapter_ram
= vidmem
;
3083 rec
->availability
= 3; /* Running or Full Power */
3084 rec
->caption
= heap_strdupW( name
);
3085 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
3086 rec
->current_horizontalres
= hres
;
3087 rec
->current_refreshrate
= 0; /* default refresh rate */
3088 rec
->current_scanmode
= 2; /* Unknown */
3089 rec
->current_verticalres
= vres
;
3090 rec
->description
= heap_strdupW( name
);
3091 rec
->device_id
= videocontroller_deviceidW
;
3092 rec
->driverversion
= videocontroller_driverversionW
;
3093 rec
->name
= heap_strdupW( name
);
3094 rec
->pnpdevice_id
= get_pnpdeviceid( &desc
);
3095 rec
->videoarchitecture
= 2; /* Unknown */
3096 rec
->videomemorytype
= 2; /* Unknown */
3097 wsprintfW( mode
, fmtW
, hres
, vres
, (UINT64
)1 << rec
->current_bitsperpixel
);
3098 rec
->videomodedescription
= heap_strdupW( mode
);
3099 rec
->videoprocessor
= heap_strdupW( name
);
3100 if (!match_row( table
, row
, cond
, &status
)) free_row_values( table
, row
);
3103 TRACE("created %u rows\n", row
);
3104 table
->num_rows
= row
;
3106 if (adapter
) IDXGIAdapter_Release( adapter
);
3107 if (factory
) IDXGIFactory_Release( factory
);
3111 #endif /* !__REACTOS__ */
3113 static struct table builtin_classes
[] =
3115 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), 0, (BYTE
*)data_baseboard
},
3116 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), 0, (BYTE
*)data_bios
},
3117 { class_cdromdriveW
, SIZEOF(col_cdromdrive
), col_cdromdrive
, 0, 0, NULL
, fill_cdromdrive
},
3118 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, 0, NULL
, fill_compsys
},
3119 { class_compsysproductW
, SIZEOF(col_compsysproduct
), col_compsysproduct
, 0, 0, NULL
, fill_compsysproduct
},
3120 { class_datafileW
, SIZEOF(col_datafile
), col_datafile
, 0, 0, NULL
, fill_datafile
},
3121 { class_desktopmonitorW
, SIZEOF(col_desktopmonitor
), col_desktopmonitor
, 0, 0, NULL
, fill_desktopmonitor
},
3122 { class_directoryW
, SIZEOF(col_directory
), col_directory
, 0, 0, NULL
, fill_directory
},
3123 { class_diskdriveW
, SIZEOF(col_diskdrive
), col_diskdrive
, 0, 0, NULL
, fill_diskdrive
},
3124 { class_diskpartitionW
, SIZEOF(col_diskpartition
), col_diskpartition
, 0, 0, NULL
, fill_diskpartition
},
3125 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3126 { class_logicaldisk2W
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, 0, NULL
, fill_logicaldisk
},
3127 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, 0, NULL
, fill_networkadapter
},
3128 { class_networkadapterconfigW
, SIZEOF(col_networkadapterconfig
), col_networkadapterconfig
, 0, 0, NULL
, fill_networkadapterconfig
},
3129 { class_osW
, SIZEOF(col_os
), col_os
, 0, 0, NULL
, fill_os
},
3130 { class_paramsW
, SIZEOF(col_param
), col_param
, SIZEOF(data_param
), 0, (BYTE
*)data_param
},
3131 { class_physicalmediaW
, SIZEOF(col_physicalmedia
), col_physicalmedia
, SIZEOF(data_physicalmedia
), 0, (BYTE
*)data_physicalmedia
},
3132 { class_physicalmemoryW
, SIZEOF(col_physicalmemory
), col_physicalmemory
, 0, 0, NULL
, fill_physicalmemory
},
3133 { class_printerW
, SIZEOF(col_printer
), col_printer
, 0, 0, NULL
, fill_printer
},
3134 { class_processW
, SIZEOF(col_process
), col_process
, 0, 0, NULL
, fill_process
},
3135 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3136 { class_processor2W
, SIZEOF(col_processor
), col_processor
, 0, 0, NULL
, fill_processor
},
3137 { class_qualifiersW
, SIZEOF(col_qualifier
), col_qualifier
, SIZEOF(data_qualifier
), 0, (BYTE
*)data_qualifier
},
3138 { class_serviceW
, SIZEOF(col_service
), col_service
, 0, 0, NULL
, fill_service
},
3139 { class_sidW
, SIZEOF(col_sid
), col_sid
, 0, 0, NULL
, fill_sid
},
3140 { class_sounddeviceW
, SIZEOF(col_sounddevice
), col_sounddevice
, SIZEOF(data_sounddevice
), 0, (BYTE
*)data_sounddevice
},
3141 { class_stdregprovW
, SIZEOF(col_stdregprov
), col_stdregprov
, SIZEOF(data_stdregprov
), 0, (BYTE
*)data_stdregprov
},
3142 { class_systemsecurityW
, SIZEOF(col_systemsecurity
), col_systemsecurity
, SIZEOF(data_systemsecurity
), 0, (BYTE
*)data_systemsecurity
},
3143 { class_systemenclosureW
, SIZEOF(col_systemenclosure
), col_systemenclosure
, SIZEOF(data_systemenclosure
), 0, (BYTE
*)data_systemenclosure
},
3145 /* Requires dxgi.dll */
3146 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, 0, NULL
, fill_videocontroller
}
3150 void init_table_list( void )
3152 static struct list tables
= LIST_INIT( tables
);
3155 for (i
= 0; i
< SIZEOF(builtin_classes
); i
++) list_add_tail( &tables
, &builtin_classes
[i
].entry
);
3156 table_list
= &tables
;