wined3d: Rename wined3d_cull enum values.
[wine.git] / dlls / wbemprox / builtin.c
blob13f708f0757cc8de2bc1ee41ab518de58e79cdb1
1 /*
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 #define COBJMACROS
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
23 #include "config.h"
24 #include <stdarg.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winsock2.h"
31 #include "ws2tcpip.h"
32 #include "initguid.h"
33 #include "wbemcli.h"
34 #include "wbemprov.h"
35 #include "iphlpapi.h"
36 #include "tlhelp32.h"
37 #include "d3d10.h"
38 #include "winternl.h"
39 #include "winioctl.h"
40 #include "winsvc.h"
41 #include "winver.h"
42 #include "sddl.h"
43 #include "ntsecapi.h"
44 #include "winspool.h"
46 #include "wine/debug.h"
47 #include "wbemprox_private.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
51 static const WCHAR class_baseboardW[] =
52 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
53 static const WCHAR class_biosW[] =
54 {'W','i','n','3','2','_','B','I','O','S',0};
55 static const WCHAR class_cdromdriveW[] =
56 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
57 static const WCHAR class_compsysW[] =
58 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
59 static const WCHAR class_compsysproductW[] =
60 {'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};
61 static const WCHAR class_datafileW[] =
62 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
63 static const WCHAR class_desktopmonitorW[] =
64 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
65 static const WCHAR class_directoryW[] =
66 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
67 static const WCHAR class_diskdriveW[] =
68 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
69 static const WCHAR class_diskpartitionW[] =
70 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
71 static const WCHAR class_logicaldiskW[] =
72 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
73 static const WCHAR class_logicaldisk2W[] =
74 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
75 static const WCHAR class_networkadapterW[] =
76 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
77 static const WCHAR class_networkadapterconfigW[] =
78 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
79 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
80 static const WCHAR class_osW[] =
81 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
82 static const WCHAR class_paramsW[] =
83 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
84 static const WCHAR class_physicalmediaW[] =
85 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
86 static const WCHAR class_physicalmemoryW[] =
87 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
88 static const WCHAR class_printerW[] =
89 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
90 static const WCHAR class_process_getowner_outW[] =
91 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
92 'N','E','R','_','O','U','T',0};
93 static const WCHAR class_processorW[] =
94 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
95 static const WCHAR class_processor2W[] =
96 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
97 static const WCHAR class_qualifiersW[] =
98 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
99 static const WCHAR class_sidW[] =
100 {'W','i','n','3','2','_','S','I','D',0};
101 static const WCHAR class_sounddeviceW[] =
102 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
103 static const WCHAR class_systemenclosureW[] =
104 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
105 static const WCHAR class_videocontrollerW[] =
106 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
108 static const WCHAR prop_accountnameW[] =
109 {'A','c','c','o','u','n','t','N','a','m','e',0};
110 static const WCHAR prop_acceptpauseW[] =
111 {'A','c','c','e','p','t','P','a','u','s','e',0};
112 static const WCHAR prop_acceptstopW[] =
113 {'A','c','c','e','p','t','S','t','o','p',0};
114 static const WCHAR prop_accessmaskW[] =
115 {'A','c','c','e','s','s','M','a','s','k',0};
116 static const WCHAR prop_adapterdactypeW[] =
117 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
118 static const WCHAR prop_adapterramW[] =
119 {'A','d','a','p','t','e','r','R','A','M',0};
120 static const WCHAR prop_adaptertypeW[] =
121 {'A','d','a','p','t','e','r','T','y','p','e',0};
122 static const WCHAR prop_addresswidthW[] =
123 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
124 static const WCHAR prop_attributesW[] =
125 {'A','t','t','r','i','b','u','t','e','s',0};
126 static const WCHAR prop_availabilityW[] =
127 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
128 static const WCHAR prop_binaryrepresentationW[] =
129 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
130 static const WCHAR prop_bootableW[] =
131 {'B','o','o','t','a','b','l','e',0};
132 static const WCHAR prop_bootpartitionW[] =
133 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
134 static const WCHAR prop_buildnumberW[] =
135 {'B','u','i','l','d','N','u','m','b','e','r',0};
136 static const WCHAR prop_capacityW[] =
137 {'C','a','p','a','c','i','t','y',0};
138 static const WCHAR prop_captionW[] =
139 {'C','a','p','t','i','o','n',0};
140 static const WCHAR prop_chassistypesW[] =
141 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
142 static const WCHAR prop_classW[] =
143 {'C','l','a','s','s',0};
144 static const WCHAR prop_codesetW[] =
145 {'C','o','d','e','S','e','t',0};
146 static const WCHAR prop_commandlineW[] =
147 {'C','o','m','m','a','n','d','L','i','n','e',0};
148 static const WCHAR prop_countrycodeW[] =
149 {'C','o','u','n','t','r','y','C','o','d','e',0};
150 static const WCHAR prop_cpustatusW[] =
151 {'C','p','u','S','t','a','t','u','s',0};
152 static const WCHAR prop_csdversionW[] =
153 {'C','S','D','V','e','r','s','i','o','n',0};
154 static const WCHAR prop_currentbitsperpixelW[] =
155 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
156 static const WCHAR prop_currentclockspeedW[] =
157 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
158 static const WCHAR prop_currenthorizontalresW[] =
159 {'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};
160 static const WCHAR prop_currentrefreshrateW[] =
161 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
162 static const WCHAR prop_currentscanmodeW[] =
163 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
164 static const WCHAR prop_currentverticalresW[] =
165 {'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};
166 static const WCHAR prop_datawidthW[] =
167 {'D','a','t','a','W','i','d','t','h',0};
168 static const WCHAR prop_defaultipgatewayW[] =
169 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
170 static const WCHAR prop_defaultvalueW[] =
171 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
172 static const WCHAR prop_descriptionW[] =
173 {'D','e','s','c','r','i','p','t','i','o','n',0};
174 static const WCHAR prop_deviceidW[] =
175 {'D','e','v','i','c','e','I','d',0};
176 static const WCHAR prop_dhcpenabledW[] =
177 {'D','H','C','P','E','n','a','b','l','e','d',0};
178 static const WCHAR prop_directionW[] =
179 {'D','i','r','e','c','t','i','o','n',0};
180 static const WCHAR prop_displaynameW[] =
181 {'D','i','s','p','l','a','y','N','a','m','e',0};
182 static const WCHAR prop_diskindexW[] =
183 {'D','i','s','k','I','n','d','e','x',0};
184 static const WCHAR prop_dnshostnameW[] =
185 {'D','N','S','H','o','s','t','N','a','m','e',0};
186 static const WCHAR prop_dnsserversearchorderW[] =
187 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
188 static const WCHAR prop_domainW[] =
189 {'D','o','m','a','i','n',0};
190 static const WCHAR prop_domainroleW[] =
191 {'D','o','m','a','i','n','R','o','l','e',0};
192 static const WCHAR prop_driveW[] =
193 {'D','r','i','v','e',0};
194 static const WCHAR prop_drivernameW[] =
195 {'D','r','i','v','e','r','N','a','m','e',0};
196 static const WCHAR prop_driverversionW[] =
197 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
198 static const WCHAR prop_drivetypeW[] =
199 {'D','r','i','v','e','T','y','p','e',0};
200 static const WCHAR prop_familyW[] =
201 {'F','a','m','i','l','y',0};
202 static const WCHAR prop_filesystemW[] =
203 {'F','i','l','e','S','y','s','t','e','m',0};
204 static const WCHAR prop_flavorW[] =
205 {'F','l','a','v','o','r',0};
206 static const WCHAR prop_freespaceW[] =
207 {'F','r','e','e','S','p','a','c','e',0};
208 static const WCHAR prop_handleW[] =
209 {'H','a','n','d','l','e',0};
210 static const WCHAR prop_horizontalresolutionW[] =
211 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
212 static const WCHAR prop_idW[] =
213 {'I','D',0};
214 static const WCHAR prop_identificationcodeW[] =
215 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
216 static const WCHAR prop_identifyingnumberW[] =
217 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
218 static const WCHAR prop_indexW[] =
219 {'I','n','d','e','x',0};
220 static const WCHAR prop_installdateW[] =
221 {'I','n','s','t','a','l','l','D','a','t','e',0};
222 static const WCHAR prop_interfaceindexW[] =
223 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
224 static const WCHAR prop_interfacetypeW[] =
225 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
226 static const WCHAR prop_intvalueW[] =
227 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
228 static const WCHAR prop_ipconnectionmetricW[] =
229 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
230 static const WCHAR prop_ipenabledW[] =
231 {'I','P','E','n','a','b','l','e','d',0};
232 static const WCHAR prop_lastbootuptimeW[] =
233 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
234 static const WCHAR prop_localW[] =
235 {'L','o','c','a','l',0};
236 static const WCHAR prop_localdatetimeW[] =
237 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
238 static const WCHAR prop_localeW[] =
239 {'L','o','c','a','l','e',0};
240 static const WCHAR prop_lockpresentW[] =
241 {'L','o','c','k','P','r','e','s','e','n','t',0};
242 static const WCHAR prop_macaddressW[] =
243 {'M','A','C','A','d','d','r','e','s','s',0};
244 static const WCHAR prop_manufacturerW[] =
245 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
246 static const WCHAR prop_maxclockspeedW[] =
247 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
248 static const WCHAR prop_mediatypeW[] =
249 {'M','e','d','i','a','T','y','p','e',0};
250 static const WCHAR prop_memberW[] =
251 {'M','e','m','b','e','r',0};
252 static const WCHAR prop_methodW[] =
253 {'M','e','t','h','o','d',0};
254 static const WCHAR prop_modelW[] =
255 {'M','o','d','e','l',0};
256 static const WCHAR prop_netconnectionstatusW[] =
257 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
258 static const WCHAR prop_networkW[] =
259 {'N','e','t','w','o','r','k',0};
260 static const WCHAR prop_numcoresW[] =
261 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
262 static const WCHAR prop_numlogicalprocessorsW[] =
263 {'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};
264 static const WCHAR prop_numprocessorsW[] =
265 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
266 static const WCHAR prop_osarchitectureW[] =
267 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
268 static const WCHAR prop_oslanguageW[] =
269 {'O','S','L','a','n','g','u','a','g','e',0};
270 static const WCHAR prop_osproductsuiteW[] =
271 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
272 static const WCHAR prop_ostypeW[] =
273 {'O','S','T','y','p','e',0};
274 static const WCHAR prop_parameterW[] =
275 {'P','a','r','a','m','e','t','e','r',0};
276 static const WCHAR prop_physicaladapterW[] =
277 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
278 static const WCHAR prop_pixelsperxlogicalinchW[] =
279 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
280 static const WCHAR prop_pnpdeviceidW[] =
281 {'P','N','P','D','e','v','i','c','e','I','D',0};
282 static const WCHAR prop_pprocessidW[] =
283 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
284 static const WCHAR prop_primaryW[] =
285 {'P','r','i','m','a','r','y',0};
286 static const WCHAR prop_processidW[] =
287 {'P','r','o','c','e','s','s','I','D',0};
288 static const WCHAR prop_processoridW[] =
289 {'P','r','o','c','e','s','s','o','r','I','d',0};
290 static const WCHAR prop_processortypeW[] =
291 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
292 static const WCHAR prop_productW[] =
293 {'P','r','o','d','u','c','t',0};
294 static const WCHAR prop_productnameW[] =
295 {'P','r','o','d','u','c','t','N','a','m','e',0};
296 static const WCHAR prop_referenceddomainnameW[] =
297 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
298 static const WCHAR prop_releasedateW[] =
299 {'R','e','l','e','a','s','e','D','a','t','e',0};
300 static const WCHAR prop_serialnumberW[] =
301 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
302 static const WCHAR prop_servicepackmajorW[] =
303 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
304 static const WCHAR prop_servicepackminorW[] =
305 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
306 static const WCHAR prop_servicetypeW[] =
307 {'S','e','r','v','i','c','e','T','y','p','e',0};
308 static const WCHAR prop_settingidW[] =
309 {'S','e','t','t','i','n','g','I','D',0};
310 static const WCHAR prop_smbiosbiosversionW[] =
311 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
312 static const WCHAR prop_startmodeW[] =
313 {'S','t','a','r','t','M','o','d','e',0};
314 static const WCHAR prop_sidW[] =
315 {'S','I','D',0};
316 static const WCHAR prop_sidlengthW[] =
317 {'S','i','d','L','e','n','g','t','h',0};
318 static const WCHAR prop_sizeW[] =
319 {'S','i','z','e',0};
320 static const WCHAR prop_speedW[] =
321 {'S','p','e','e','d',0};
322 static const WCHAR prop_startingoffsetW[] =
323 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
324 static const WCHAR prop_stateW[] =
325 {'S','t','a','t','e',0};
326 static const WCHAR prop_statusinfoW[] =
327 {'S','t','a','t','u','s','I','n','f','o',0};
328 static const WCHAR prop_strvalueW[] =
329 {'S','t','r','i','n','g','V','a','l','u','e',0};
330 static const WCHAR prop_suitemaskW[] =
331 {'S','u','i','t','e','M','a','s','k',0};
332 static const WCHAR prop_systemdirectoryW[] =
333 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
334 static const WCHAR prop_systemnameW[] =
335 {'S','y','s','t','e','m','N','a','m','e',0};
336 static const WCHAR prop_tagW[] =
337 {'T','a','g',0};
338 static const WCHAR prop_threadcountW[] =
339 {'T','h','r','e','a','d','C','o','u','n','t',0};
340 static const WCHAR prop_totalphysicalmemoryW[] =
341 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
342 static const WCHAR prop_totalvisiblememorysizeW[] =
343 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
344 static const WCHAR prop_typeW[] =
345 {'T','y','p','e',0};
346 static const WCHAR prop_uniqueidW[] =
347 {'U','n','i','q','u','e','I','d',0};
348 static const WCHAR prop_usernameW[] =
349 {'U','s','e','r','N','a','m','e',0};
350 static const WCHAR prop_uuidW[] =
351 {'U','U','I','D',0};
352 static const WCHAR prop_varianttypeW[] =
353 {'V','a','r','i','a','n','t','T','y','p','e',0};
354 static const WCHAR prop_versionW[] =
355 {'V','e','r','s','i','o','n',0};
356 static const WCHAR prop_videoarchitectureW[] =
357 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
358 static const WCHAR prop_videomemorytypeW[] =
359 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
360 static const WCHAR prop_videomodedescriptionW[] =
361 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
362 static const WCHAR prop_videoprocessorW[] =
363 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
364 static const WCHAR prop_volumenameW[] =
365 {'V','o','l','u','m','e','N','a','m','e',0};
366 static const WCHAR prop_volumeserialnumberW[] =
367 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
368 static const WCHAR prop_workingsetsizeW[] =
369 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
371 /* column definitions must be kept in sync with record structures below */
372 static const struct column col_baseboard[] =
374 { prop_manufacturerW, CIM_STRING },
375 { prop_modelW, CIM_STRING },
376 { prop_nameW, CIM_STRING },
377 { prop_productW, CIM_STRING },
378 { prop_serialnumberW, CIM_STRING },
379 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
380 { prop_versionW, CIM_STRING }
382 static const struct column col_bios[] =
384 { prop_descriptionW, CIM_STRING },
385 { prop_identificationcodeW, CIM_STRING },
386 { prop_manufacturerW, CIM_STRING },
387 { prop_nameW, CIM_STRING },
388 { prop_releasedateW, CIM_DATETIME },
389 { prop_serialnumberW, CIM_STRING },
390 { prop_smbiosbiosversionW, CIM_STRING },
391 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
393 static const struct column col_cdromdrive[] =
395 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
396 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
397 { prop_mediatypeW, CIM_STRING },
398 { prop_nameW, CIM_STRING },
399 { prop_pnpdeviceidW, CIM_STRING }
401 static const struct column col_compsys[] =
403 { prop_descriptionW, CIM_STRING },
404 { prop_domainW, CIM_STRING },
405 { prop_domainroleW, CIM_UINT16, VT_I4 },
406 { prop_manufacturerW, CIM_STRING },
407 { prop_modelW, CIM_STRING },
408 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
409 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
410 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
411 { prop_totalphysicalmemoryW, CIM_UINT64 },
412 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
414 static const struct column col_compsysproduct[] =
416 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
417 { prop_uuidW, CIM_STRING }
419 static const struct column col_datafile[] =
421 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
422 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
424 static const struct column col_desktopmonitor[] =
426 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
428 static const struct column col_directory[] =
430 { prop_accessmaskW, CIM_UINT32 },
431 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
433 static const struct column col_diskdrive[] =
435 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
436 { prop_indexW, CIM_UINT32, VT_I4 },
437 { prop_interfacetypeW, CIM_STRING },
438 { prop_manufacturerW, CIM_STRING },
439 { prop_mediatypeW, CIM_STRING },
440 { prop_modelW, CIM_STRING },
441 { prop_pnpdeviceidW, CIM_STRING },
442 { prop_serialnumberW, CIM_STRING },
443 { prop_sizeW, CIM_UINT64 }
445 static const struct column col_diskpartition[] =
447 { prop_bootableW, CIM_BOOLEAN },
448 { prop_bootpartitionW, CIM_BOOLEAN },
449 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
450 { prop_diskindexW, CIM_UINT32, VT_I4 },
451 { prop_indexW, CIM_UINT32, VT_I4 },
452 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
453 { prop_sizeW, CIM_UINT64 },
454 { prop_startingoffsetW, CIM_UINT64 },
455 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
457 static const struct column col_logicaldisk[] =
459 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
460 { prop_drivetypeW, CIM_UINT32, VT_I4 },
461 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
462 { prop_freespaceW, CIM_UINT64 },
463 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
464 { prop_sizeW, CIM_UINT64 },
465 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
466 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
468 static const struct column col_networkadapter[] =
470 { prop_adaptertypeW, CIM_STRING },
471 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
472 { prop_indexW, CIM_UINT32, VT_I4 },
473 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
474 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
475 { prop_manufacturerW, CIM_STRING },
476 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
477 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
478 { prop_physicaladapterW, CIM_BOOLEAN },
479 { prop_pnpdeviceidW, CIM_STRING },
480 { prop_speedW, CIM_UINT64 }
482 static const struct column col_networkadapterconfig[] =
484 { prop_defaultipgatewayW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
485 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
486 { prop_dhcpenabledW, CIM_BOOLEAN },
487 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
488 { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
489 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
490 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
491 { prop_ipenabledW, CIM_BOOLEAN },
492 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
493 { prop_settingidW, CIM_STRING|COL_FLAG_DYNAMIC }
495 static const struct column col_os[] =
497 { prop_buildnumberW, CIM_STRING },
498 { prop_captionW, CIM_STRING },
499 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
500 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
501 { prop_csdversionW, CIM_STRING },
502 { prop_installdateW, CIM_DATETIME },
503 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
504 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
505 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
506 { prop_nameW, CIM_STRING },
507 { prop_osarchitectureW, CIM_STRING },
508 { prop_oslanguageW, CIM_UINT32, VT_I4 },
509 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
510 { prop_ostypeW, CIM_UINT16, VT_I4 },
511 { prop_primaryW, CIM_BOOLEAN },
512 { prop_serialnumberW, CIM_STRING },
513 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
514 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
515 { prop_suitemaskW, CIM_UINT32, VT_I4 },
516 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
517 { prop_totalvisiblememorysizeW, CIM_UINT64 },
518 { prop_versionW, CIM_STRING }
520 static const struct column col_param[] =
522 { prop_classW, CIM_STRING },
523 { prop_methodW, CIM_STRING },
524 { prop_directionW, CIM_SINT32 },
525 { prop_parameterW, CIM_STRING },
526 { prop_typeW, CIM_UINT32 },
527 { prop_varianttypeW, CIM_UINT32 },
528 { prop_defaultvalueW, CIM_UINT32 }
530 static const struct column col_physicalmedia[] =
532 { prop_serialnumberW, CIM_STRING },
533 { prop_tagW, CIM_STRING }
535 static const struct column col_physicalmemory[] =
537 { prop_capacityW, CIM_UINT64 }
539 static const struct column col_printer[] =
541 { prop_attributesW, CIM_UINT32 },
542 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
543 { prop_horizontalresolutionW, CIM_UINT32 },
544 { prop_localW, CIM_BOOLEAN },
545 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
546 { prop_networkW, CIM_BOOLEAN }
548 static const struct column col_process[] =
550 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
551 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
552 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
553 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
554 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
555 { prop_pprocessidW, CIM_UINT32, VT_I4 },
556 { prop_processidW, CIM_UINT32, VT_I4 },
557 { prop_threadcountW, CIM_UINT32, VT_I4 },
558 { prop_workingsetsizeW, CIM_UINT64 },
559 /* methods */
560 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
562 static const struct column col_processor[] =
564 { prop_addresswidthW, CIM_UINT16, VT_I4 },
565 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
566 { prop_cpustatusW, CIM_UINT16 },
567 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
568 { prop_datawidthW, CIM_UINT16, VT_I4 },
569 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
570 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
571 { prop_familyW, CIM_UINT16, VT_I4 },
572 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
573 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
574 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
575 { prop_numcoresW, CIM_UINT32, VT_I4 },
576 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
577 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
578 { prop_processortypeW, CIM_UINT16, VT_I4 },
579 { prop_uniqueidW, CIM_STRING },
580 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
582 static const struct column col_qualifier[] =
584 { prop_classW, CIM_STRING },
585 { prop_memberW, CIM_STRING },
586 { prop_typeW, CIM_UINT32 },
587 { prop_flavorW, CIM_SINT32 },
588 { prop_nameW, CIM_STRING },
589 { prop_intvalueW, CIM_SINT32 },
590 { prop_strvalueW, CIM_STRING }
592 static const struct column col_service[] =
594 { prop_acceptpauseW, CIM_BOOLEAN },
595 { prop_acceptstopW, CIM_BOOLEAN },
596 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
597 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
598 { prop_processidW, CIM_UINT32 },
599 { prop_servicetypeW, CIM_STRING },
600 { prop_startmodeW, CIM_STRING },
601 { prop_stateW, CIM_STRING },
602 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
603 /* methods */
604 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
605 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
606 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
607 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
609 static const struct column col_sid[] =
611 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
612 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
613 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
614 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
615 { prop_sidlengthW, CIM_UINT32 }
617 static const struct column col_sounddevice[] =
619 { prop_nameW, CIM_STRING },
620 { prop_productnameW, CIM_STRING },
621 { prop_statusinfoW, CIM_UINT16, VT_I4 }
623 static const struct column col_stdregprov[] =
625 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
626 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
627 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
629 static const struct column col_systemenclosure[] =
631 { prop_captionW, CIM_STRING },
632 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY },
633 { prop_descriptionW, CIM_STRING },
634 { prop_lockpresentW, CIM_BOOLEAN },
635 { prop_manufacturerW, CIM_STRING },
636 { prop_nameW, CIM_STRING },
637 { prop_tagW, CIM_STRING },
639 static const struct column col_systemsecurity[] =
641 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
642 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
644 static const struct column col_videocontroller[] =
646 { prop_adapterdactypeW, CIM_STRING },
647 { prop_adapterramW, CIM_UINT32, VT_I4 },
648 { prop_availabilityW, CIM_UINT16 },
649 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
650 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
651 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
652 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
653 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
654 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
655 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
656 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
657 { prop_driverversionW, CIM_STRING },
658 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
659 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
660 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
661 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
662 { prop_videomodedescriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
663 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC }
666 static const WCHAR baseboard_manufacturerW[] =
667 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
668 static const WCHAR baseboard_serialnumberW[] =
669 {'N','o','n','e',0};
670 static const WCHAR baseboard_tagW[] =
671 {'B','a','s','e',' ','B','o','a','r','d',0};
672 static const WCHAR baseboard_versionW[] =
673 {'1','.','0',0};
674 static const WCHAR bios_descriptionW[] =
675 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
676 static const WCHAR bios_manufacturerW[] =
677 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
678 static const WCHAR bios_nameW[] =
679 {'W','I','N','E',' ','B','I','O','S',0};
680 static const WCHAR bios_releasedateW[] =
681 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
682 static const WCHAR bios_serialnumberW[] =
683 {'0',0};
684 static const WCHAR bios_smbiosbiosversionW[] =
685 {'W','i','n','e',0};
686 static const WCHAR bios_versionW[] =
687 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
688 static const WCHAR cdromdrive_mediatypeW[] =
689 {'C','D','-','R','O','M',0};
690 static const WCHAR cdromdrive_nameW[] =
691 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
692 static const WCHAR cdromdrive_pnpdeviceidW[]=
693 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
694 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
695 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
696 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
697 static const WCHAR compsys_descriptionW[] =
698 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
699 static const WCHAR compsys_domainW[] =
700 {'W','O','R','K','G','R','O','U','P',0};
701 static const WCHAR compsys_manufacturerW[] =
702 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
703 static const WCHAR compsys_modelW[] =
704 {'W','i','n','e',0};
705 static const WCHAR compsysproduct_identifyingnumberW[] =
706 {'0',0};
707 static const WCHAR compsysproduct_uuidW[] =
708 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
709 '0','0','0','0','0','0','0','0','0','0','0','0',0};
710 static const WCHAR diskdrive_interfacetypeW[] =
711 {'I','D','E',0};
712 static const WCHAR diskdrive_manufacturerW[] =
713 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
714 static const WCHAR diskdrive_mediatype_fixedW[] =
715 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
716 static const WCHAR diskdrive_mediatype_removableW[] =
717 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
718 static const WCHAR diskdrive_modelW[] =
719 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
720 static const WCHAR diskdrive_pnpdeviceidW[] =
721 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
722 static const WCHAR diskdrive_serialW[] =
723 {'W','I','N','E','H','D','I','S','K',0};
724 static const WCHAR networkadapter_pnpdeviceidW[]=
725 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
726 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
727 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
728 static const WCHAR os_32bitW[] =
729 {'3','2','-','b','i','t',0};
730 static const WCHAR os_64bitW[] =
731 {'6','4','-','b','i','t',0};
732 static const WCHAR os_buildnumberW[] =
733 {'2','6','0','0',0};
734 static const WCHAR os_captionW[] =
735 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
736 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
737 static const WCHAR os_csdversionW[] =
738 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
739 static const WCHAR os_installdateW[] =
740 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
741 static const WCHAR os_nameW[] =
742 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
743 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
744 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
745 '\\','P','a','r','t','i','t','i','o','n','1',0};
746 static const WCHAR os_serialnumberW[] =
747 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
748 static const WCHAR os_versionW[] =
749 {'5','.','1','.','2','6','0','0',0};
750 static const WCHAR physicalmedia_tagW[] =
751 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
752 static const WCHAR sounddevice_productnameW[] =
753 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
754 static const WCHAR systemenclosure_systemenclosureW[] =
755 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
756 static const WCHAR systemenclosure_tagW[] =
757 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
758 static const WCHAR systemenclosure_manufacturerW[] =
759 {'W','i','n','e',0};
760 static const WCHAR videocontroller_dactypeW[] =
761 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
762 static const WCHAR videocontroller_deviceidW[] =
763 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
764 static const WCHAR videocontroller_driverversionW[] =
765 {'1','.','0',0};
767 #include "pshpack1.h"
768 struct record_baseboard
770 const WCHAR *manufacturer;
771 const WCHAR *model;
772 const WCHAR *name;
773 const WCHAR *product;
774 const WCHAR *serialnumber;
775 const WCHAR *tag;
776 const WCHAR *version;
778 struct record_bios
780 const WCHAR *description;
781 const WCHAR *identificationcode;
782 const WCHAR *manufacturer;
783 const WCHAR *name;
784 const WCHAR *releasedate;
785 const WCHAR *serialnumber;
786 const WCHAR *smbiosbiosversion;
787 const WCHAR *version;
789 struct record_cdromdrive
791 const WCHAR *device_id;
792 const WCHAR *drive;
793 const WCHAR *mediatype;
794 const WCHAR *name;
795 const WCHAR *pnpdevice_id;
797 struct record_computersystem
799 const WCHAR *description;
800 const WCHAR *domain;
801 UINT16 domainrole;
802 const WCHAR *manufacturer;
803 const WCHAR *model;
804 const WCHAR *name;
805 UINT32 num_logical_processors;
806 UINT32 num_processors;
807 UINT64 total_physical_memory;
808 const WCHAR *username;
810 struct record_computersystemproduct
812 const WCHAR *identifyingnumber;
813 const WCHAR *uuid;
815 struct record_datafile
817 const WCHAR *name;
818 const WCHAR *version;
820 struct record_desktopmonitor
822 UINT32 pixelsperxlogicalinch;
824 struct record_directory
826 UINT32 accessmask;
827 const WCHAR *name;
829 struct record_diskdrive
831 const WCHAR *device_id;
832 UINT32 index;
833 const WCHAR *interfacetype;
834 const WCHAR *manufacturer;
835 const WCHAR *mediatype;
836 const WCHAR *model;
837 const WCHAR *pnpdevice_id;
838 const WCHAR *serialnumber;
839 UINT64 size;
841 struct record_diskpartition
843 int bootable;
844 int bootpartition;
845 const WCHAR *device_id;
846 UINT32 diskindex;
847 UINT32 index;
848 const WCHAR *pnpdevice_id;
849 UINT64 size;
850 UINT64 startingoffset;
851 const WCHAR *type;
853 struct record_logicaldisk
855 const WCHAR *device_id;
856 UINT32 drivetype;
857 const WCHAR *filesystem;
858 UINT64 freespace;
859 const WCHAR *name;
860 UINT64 size;
861 const WCHAR *volumename;
862 const WCHAR *volumeserialnumber;
864 struct record_networkadapter
866 const WCHAR *adaptertype;
867 const WCHAR *device_id;
868 UINT32 index;
869 UINT32 interface_index;
870 const WCHAR *mac_address;
871 const WCHAR *manufacturer;
872 const WCHAR *name;
873 UINT16 netconnection_status;
874 int physicaladapter;
875 const WCHAR *pnpdevice_id;
876 UINT64 speed;
878 struct record_networkadapterconfig
880 const struct array *defaultipgateway;
881 const WCHAR *description;
882 int dhcpenabled;
883 const WCHAR *dnshostname;
884 const struct array *dnsserversearchorder;
885 UINT32 index;
886 UINT32 ipconnectionmetric;
887 int ipenabled;
888 const WCHAR *mac_address;
889 const WCHAR *settingid;
891 struct record_operatingsystem
893 const WCHAR *buildnumber;
894 const WCHAR *caption;
895 const WCHAR *codeset;
896 const WCHAR *countrycode;
897 const WCHAR *csdversion;
898 const WCHAR *installdate;
899 const WCHAR *lastbootuptime;
900 const WCHAR *localdatetime;
901 const WCHAR *locale;
902 const WCHAR *name;
903 const WCHAR *osarchitecture;
904 UINT32 oslanguage;
905 UINT32 osproductsuite;
906 UINT16 ostype;
907 int primary;
908 const WCHAR *serialnumber;
909 UINT16 servicepackmajor;
910 UINT16 servicepackminor;
911 UINT32 suitemask;
912 const WCHAR *systemdirectory;
913 UINT64 totalvisiblememorysize;
914 const WCHAR *version;
916 struct record_param
918 const WCHAR *class;
919 const WCHAR *method;
920 INT32 direction;
921 const WCHAR *parameter;
922 UINT32 type;
923 UINT32 varianttype;
924 UINT32 defaultvalue;
926 struct record_physicalmedia
928 const WCHAR *serialnumber;
929 const WCHAR *tag;
931 struct record_physicalmemory
933 UINT64 capacity;
935 struct record_printer
937 UINT32 attributes;
938 const WCHAR *drivername;
939 UINT32 horizontalresolution;
940 int local;
941 const WCHAR *name;
942 int network;
944 struct record_process
946 const WCHAR *caption;
947 const WCHAR *commandline;
948 const WCHAR *description;
949 const WCHAR *handle;
950 const WCHAR *name;
951 UINT32 pprocess_id;
952 UINT32 process_id;
953 UINT32 thread_count;
954 UINT64 workingsetsize;
955 /* methods */
956 class_method *get_owner;
958 struct record_processor
960 UINT16 addresswidth;
961 const WCHAR *caption;
962 UINT16 cpu_status;
963 UINT32 currentclockspeed;
964 UINT16 datawidth;
965 const WCHAR *description;
966 const WCHAR *device_id;
967 UINT16 family;
968 const WCHAR *manufacturer;
969 UINT32 maxclockspeed;
970 const WCHAR *name;
971 UINT32 num_cores;
972 UINT32 num_logical_processors;
973 const WCHAR *processor_id;
974 UINT16 processortype;
975 const WCHAR *unique_id;
976 const WCHAR *version;
978 struct record_qualifier
980 const WCHAR *class;
981 const WCHAR *member;
982 UINT32 type;
983 INT32 flavor;
984 const WCHAR *name;
985 INT32 intvalue;
986 const WCHAR *strvalue;
988 struct record_service
990 int accept_pause;
991 int accept_stop;
992 const WCHAR *displayname;
993 const WCHAR *name;
994 UINT32 process_id;
995 const WCHAR *servicetype;
996 const WCHAR *startmode;
997 const WCHAR *state;
998 const WCHAR *systemname;
999 /* methods */
1000 class_method *pause_service;
1001 class_method *resume_service;
1002 class_method *start_service;
1003 class_method *stop_service;
1005 struct record_sid
1007 const WCHAR *accountname;
1008 const struct array *binaryrepresentation;
1009 const WCHAR *referenceddomainname;
1010 const WCHAR *sid;
1011 UINT32 sidlength;
1013 struct record_sounddevice
1015 const WCHAR *name;
1016 const WCHAR *productname;
1017 UINT16 statusinfo;
1019 struct record_stdregprov
1021 class_method *enumkey;
1022 class_method *enumvalues;
1023 class_method *getstringvalue;
1025 struct record_systemsecurity
1027 class_method *getsd;
1028 class_method *setsd;
1030 struct record_systemenclosure
1032 const WCHAR *caption;
1033 const struct array *chassistypes;
1034 const WCHAR *description;
1035 int lockpresent;
1036 const WCHAR *manufacturer;
1037 const WCHAR *name;
1038 const WCHAR *tag;
1040 struct record_videocontroller
1042 const WCHAR *adapter_dactype;
1043 UINT32 adapter_ram;
1044 UINT16 availability;
1045 const WCHAR *caption;
1046 UINT32 current_bitsperpixel;
1047 UINT32 current_horizontalres;
1048 UINT32 current_refreshrate;
1049 UINT16 current_scanmode;
1050 UINT32 current_verticalres;
1051 const WCHAR *description;
1052 const WCHAR *device_id;
1053 const WCHAR *driverversion;
1054 const WCHAR *name;
1055 const WCHAR *pnpdevice_id;
1056 UINT16 videoarchitecture;
1057 UINT16 videomemorytype;
1058 const WCHAR *videomodedescription;
1059 const WCHAR *videoprocessor;
1061 #include "poppack.h"
1063 static const struct record_baseboard data_baseboard[] =
1065 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1067 static const struct record_bios data_bios[] =
1069 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_nameW, bios_releasedateW, bios_serialnumberW,
1070 bios_smbiosbiosversionW, bios_versionW }
1072 static const struct record_computersystemproduct data_compsysproduct[] =
1074 { compsysproduct_identifyingnumberW, compsysproduct_uuidW }
1076 static const struct record_param data_param[] =
1078 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1079 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1080 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1081 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1082 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1083 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1084 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1085 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1086 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1087 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1088 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1089 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1090 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1091 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1092 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1093 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1094 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1095 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1096 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1097 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1098 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1099 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1100 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1101 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1102 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1105 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1106 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1108 static const struct record_physicalmedia data_physicalmedia[] =
1110 { diskdrive_serialW, physicalmedia_tagW }
1112 static const struct record_qualifier data_qualifier[] =
1114 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1115 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1117 static const struct record_sounddevice data_sounddevice[] =
1119 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1121 static const struct record_stdregprov data_stdregprov[] =
1123 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1125 static UINT16 systemenclosure_chassistypes[] =
1129 static const struct array systemenclosure_chassistypes_array =
1131 SIZEOF(systemenclosure_chassistypes),
1132 &systemenclosure_chassistypes
1134 static const struct record_systemenclosure data_systemenclosure[] =
1137 systemenclosure_systemenclosureW,
1138 &systemenclosure_chassistypes_array,
1139 systemenclosure_systemenclosureW,
1140 FALSE,
1141 systemenclosure_manufacturerW,
1142 systemenclosure_systemenclosureW,
1143 systemenclosure_tagW,
1146 static const struct record_systemsecurity data_systemsecurity[] =
1148 { security_get_sd, security_set_sd }
1151 /* check if row matches condition and update status */
1152 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1154 LONGLONG val;
1155 UINT type;
1157 if (!cond)
1159 *status = FILL_STATUS_UNFILTERED;
1160 return TRUE;
1162 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1164 *status = FILL_STATUS_FAILED;
1165 return FALSE;
1167 *status = FILL_STATUS_FILTERED;
1168 return val != 0;
1171 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1173 if (!table->num_rows_allocated)
1175 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1176 table->num_rows_allocated = row_count;
1177 return TRUE;
1179 if (row_count > table->num_rows_allocated)
1181 BYTE *data;
1182 UINT count = max( row_count, table->num_rows_allocated * 2 );
1183 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1184 table->data = data;
1185 table->num_rows_allocated = count;
1187 return TRUE;
1190 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1192 static const WCHAR fmtW[] = {'%','c',':',0};
1193 WCHAR drive[3], root[] = {'A',':','\\',0};
1194 struct record_cdromdrive *rec;
1195 UINT i, row = 0, offset = 0;
1196 DWORD drives = GetLogicalDrives();
1197 enum fill_status status = FILL_STATUS_UNFILTERED;
1199 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1201 for (i = 0; i < 26; i++)
1203 if (drives & (1 << i))
1205 root[0] = 'A' + i;
1206 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1207 continue;
1209 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1211 rec = (struct record_cdromdrive *)(table->data + offset);
1212 rec->device_id = cdromdrive_pnpdeviceidW;
1213 sprintfW( drive, fmtW, 'A' + i );
1214 rec->drive = heap_strdupW( drive );
1215 rec->mediatype = cdromdrive_mediatypeW;
1216 rec->name = cdromdrive_nameW;
1217 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1218 if (!match_row( table, row, cond, &status ))
1220 free_row_values( table, row );
1221 continue;
1223 offset += sizeof(*rec);
1224 row++;
1227 TRACE("created %u rows\n", row);
1228 table->num_rows = row;
1229 return status;
1232 static UINT get_processor_count(void)
1234 SYSTEM_BASIC_INFORMATION info;
1236 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1237 return info.NumberOfProcessors;
1240 static UINT get_logical_processor_count( UINT *num_cores )
1242 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1243 UINT i, j, count = 0;
1244 NTSTATUS status;
1245 ULONG len;
1247 if (num_cores) *num_cores = get_processor_count();
1248 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1249 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1251 if (!(info = heap_alloc( len ))) return get_processor_count();
1252 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1253 if (status != STATUS_SUCCESS)
1255 heap_free( info );
1256 return get_processor_count();
1258 if (num_cores) *num_cores = 0;
1259 for (i = 0; i < len / sizeof(*info); i++)
1261 if (info[i].Relationship == RelationProcessorCore)
1263 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1265 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1267 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1270 heap_free( info );
1271 return count;
1274 static UINT64 get_total_physical_memory(void)
1276 MEMORYSTATUSEX status;
1278 status.dwLength = sizeof(status);
1279 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1280 return status.ullTotalPhys;
1283 static WCHAR *get_computername(void)
1285 WCHAR *ret;
1286 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1288 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1289 GetComputerNameW( ret, &size );
1290 return ret;
1293 static WCHAR *get_username(void)
1295 WCHAR *ret;
1296 DWORD compsize, usersize;
1297 DWORD size;
1299 compsize = 0;
1300 GetComputerNameW( NULL, &compsize );
1301 usersize = 0;
1302 GetUserNameW( NULL, &usersize );
1303 size = compsize + usersize; /* two null terminators account for the \ */
1304 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1305 GetComputerNameW( ret, &compsize );
1306 ret[compsize] = '\\';
1307 GetUserNameW( ret + compsize + 1, &usersize );
1308 return ret;
1311 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1313 struct record_computersystem *rec;
1314 enum fill_status status = FILL_STATUS_UNFILTERED;
1315 UINT row = 0;
1317 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1319 rec = (struct record_computersystem *)table->data;
1320 rec->description = compsys_descriptionW;
1321 rec->domain = compsys_domainW;
1322 rec->domainrole = 0; /* standalone workstation */
1323 rec->manufacturer = compsys_manufacturerW;
1324 rec->model = compsys_modelW;
1325 rec->name = get_computername();
1326 rec->num_logical_processors = get_logical_processor_count( NULL );
1327 rec->num_processors = get_processor_count();
1328 rec->total_physical_memory = get_total_physical_memory();
1329 rec->username = get_username();
1330 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1331 else row++;
1333 TRACE("created %u rows\n", row);
1334 table->num_rows = row;
1335 return status;
1338 struct dirstack
1340 WCHAR **dirs;
1341 UINT *len_dirs;
1342 UINT num_dirs;
1343 UINT num_allocated;
1346 static struct dirstack *alloc_dirstack( UINT size )
1348 struct dirstack *dirstack;
1350 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1351 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1353 heap_free( dirstack );
1354 return NULL;
1356 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1358 heap_free( dirstack->dirs );
1359 heap_free( dirstack );
1360 return NULL;
1362 dirstack->num_dirs = 0;
1363 dirstack->num_allocated = size;
1364 return dirstack;
1367 static void clear_dirstack( struct dirstack *dirstack )
1369 UINT i;
1370 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1371 dirstack->num_dirs = 0;
1374 static void free_dirstack( struct dirstack *dirstack )
1376 clear_dirstack( dirstack );
1377 heap_free( dirstack->dirs );
1378 heap_free( dirstack->len_dirs );
1379 heap_free( dirstack );
1382 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1384 UINT size, i = dirstack->num_dirs;
1386 if (!dir) return FALSE;
1388 if (i == dirstack->num_allocated)
1390 WCHAR **tmp;
1391 UINT *len_tmp;
1393 size = dirstack->num_allocated * 2;
1394 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1395 dirstack->dirs = tmp;
1396 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1397 dirstack->len_dirs = len_tmp;
1398 dirstack->num_allocated = size;
1400 dirstack->dirs[i] = dir;
1401 dirstack->len_dirs[i] = len;
1402 dirstack->num_dirs++;
1403 return TRUE;
1406 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1408 if (!dirstack->num_dirs)
1410 *len = 0;
1411 return NULL;
1413 dirstack->num_dirs--;
1414 *len = dirstack->len_dirs[dirstack->num_dirs];
1415 return dirstack->dirs[dirstack->num_dirs];
1418 static const WCHAR *peek_dir( struct dirstack *dirstack )
1420 if (!dirstack->num_dirs) return NULL;
1421 return dirstack->dirs[dirstack->num_dirs - 1];
1424 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1426 UINT i = 0;
1427 WCHAR *ret;
1429 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1430 ret[i++] = drive;
1431 ret[i++] = ':';
1432 ret[i++] = '\\';
1433 if (path && len)
1435 memcpy( ret + i, path, len * sizeof(WCHAR) );
1436 i += len;
1437 ret[i++] = '\\';
1439 ret[i++] = '*';
1440 ret[i] = 0;
1441 return ret;
1444 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1446 UINT i = 0, len = 0;
1447 const WCHAR *p;
1448 WCHAR *ret;
1450 for (p = path; *p; p++)
1452 if (*p == '\\') len += 2;
1453 else len++;
1455 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1456 ret[i++] = drive;
1457 ret[i++] = ':';
1458 ret[i++] = '\\';
1459 ret[i++] = '\\';
1460 for (p = path; *p; p++)
1462 if (*p != '\\') ret[i++] = *p;
1463 else
1465 ret[i++] = '\\';
1466 ret[i++] = '\\';
1469 ret[i] = 0;
1470 return ret;
1473 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1475 const WCHAR *p = path, *start;
1476 UINT len, i;
1477 WCHAR *ret;
1479 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1480 start = path + 4;
1481 len = strlenW( start );
1482 p = start + len - 1;
1483 if (*p == '\\') return NULL;
1485 while (p >= start && *p != '\\') { len--; p--; };
1486 while (p >= start && *p == '\\') { len--; p--; };
1488 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1489 for (i = 0, p = start; p < start + len; p++)
1491 if (p[0] == '\\' && p[1] == '\\')
1493 ret[i++] = '\\';
1494 p++;
1496 else ret[i++] = *p;
1498 ret[i] = 0;
1499 *ret_len = i;
1500 return ret;
1503 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1505 UINT i;
1506 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1507 return FALSE;
1510 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1511 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1513 const struct expr *left, *right;
1515 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1517 left = cond->u.expr.left;
1518 right = cond->u.expr.right;
1519 if (cond->u.expr.op == OP_EQ)
1521 UINT len;
1522 WCHAR *path;
1523 const WCHAR *str = NULL;
1525 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1526 !strcmpW( left->u.propval->name, prop_nameW ) &&
1527 toupperW( right->u.sval[0] ) == toupperW( root ))
1529 str = right->u.sval;
1531 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1532 !strcmpW( right->u.propval->name, prop_nameW ) &&
1533 toupperW( left->u.sval[0] ) == toupperW( root ))
1535 str = left->u.sval;
1537 if (str && (path = build_dirname( str, &len )))
1539 if (seen_dir( dirstack, path ))
1541 heap_free( path );
1542 return ++*count;
1544 else if (push_dir( dirstack, path, len )) return ++*count;
1545 heap_free( path );
1546 return *count = 0;
1549 else if (cond->u.expr.op == OP_OR)
1551 UINT left_count = 0, right_count = 0;
1553 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1554 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1555 return *count += left_count + right_count;
1557 return *count = 0;
1560 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1562 UINT len_path = 0, len_segment = strlenW( segment );
1563 WCHAR *ret;
1565 *len = 0;
1566 if (path) len_path = strlenW( path );
1567 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1568 if (path && len_path)
1570 memcpy( ret, path, len_path * sizeof(WCHAR) );
1571 ret[len_path] = '\\';
1572 *len += len_path + 1;
1574 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1575 *len += len_segment;
1576 ret[*len] = 0;
1577 return ret;
1580 static WCHAR *get_file_version( const WCHAR *filename )
1582 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1583 VS_FIXEDFILEINFO *info;
1584 DWORD size;
1585 void *block;
1586 WCHAR *ret;
1588 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1589 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1591 heap_free( ret );
1592 return NULL;
1594 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1595 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1597 heap_free( block );
1598 heap_free( ret );
1599 return NULL;
1601 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1602 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1603 heap_free( block );
1604 return ret;
1607 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1609 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1610 struct record_datafile *rec;
1611 UINT i, len, row = 0, offset = 0, num_expected_rows;
1612 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1613 DWORD drives = GetLogicalDrives();
1614 WIN32_FIND_DATAW data;
1615 HANDLE handle;
1616 struct dirstack *dirstack;
1617 enum fill_status status = FILL_STATUS_UNFILTERED;
1619 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1621 dirstack = alloc_dirstack(2);
1623 for (i = 0; i < 26; i++)
1625 if (!(drives & (1 << i))) continue;
1627 root[0] = 'A' + i;
1628 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1630 num_expected_rows = 0;
1631 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1633 for (;;)
1635 heap_free( glob );
1636 heap_free( path );
1637 path = pop_dir( dirstack, &len );
1638 if (!(glob = build_glob( root[0], path, len )))
1640 status = FILL_STATUS_FAILED;
1641 goto done;
1643 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1647 if (!resize_table( table, row + 1, sizeof(*rec) ))
1649 status = FILL_STATUS_FAILED;
1650 FindClose( handle );
1651 goto done;
1653 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1654 new_path = append_path( path, data.cFileName, &len );
1656 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1658 if (push_dir( dirstack, new_path, len )) continue;
1659 heap_free( new_path );
1660 FindClose( handle );
1661 status = FILL_STATUS_FAILED;
1662 goto done;
1664 rec = (struct record_datafile *)(table->data + offset);
1665 rec->name = build_name( root[0], new_path );
1666 rec->version = get_file_version( rec->name );
1667 if (!match_row( table, row, cond, &status ))
1669 free_row_values( table, row );
1670 continue;
1672 else if (num_expected_rows && row == num_expected_rows - 1)
1674 row++;
1675 FindClose( handle );
1676 status = FILL_STATUS_FILTERED;
1677 goto done;
1679 offset += sizeof(*rec);
1680 row++;
1682 while (FindNextFileW( handle, &data ));
1683 FindClose( handle );
1685 if (!peek_dir( dirstack )) break;
1689 done:
1690 free_dirstack( dirstack );
1691 heap_free( glob );
1692 heap_free( path );
1694 TRACE("created %u rows\n", row);
1695 table->num_rows = row;
1696 return status;
1699 static UINT32 get_pixelsperxlogicalinch(void)
1701 HDC hdc = GetDC( NULL );
1702 UINT32 ret;
1704 if (!hdc) return 96;
1705 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1706 ReleaseDC( NULL, hdc );
1707 return ret;
1710 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1712 struct record_desktopmonitor *rec;
1713 enum fill_status status = FILL_STATUS_UNFILTERED;
1714 UINT row = 0;
1716 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1718 rec = (struct record_desktopmonitor *)table->data;
1719 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1721 if (match_row( table, row, cond, &status )) row++;
1723 TRACE("created %u rows\n", row);
1724 table->num_rows = row;
1725 return status;
1728 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1730 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1731 struct record_directory *rec;
1732 UINT i, len, row = 0, offset = 0, num_expected_rows;
1733 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1734 DWORD drives = GetLogicalDrives();
1735 WIN32_FIND_DATAW data;
1736 HANDLE handle;
1737 struct dirstack *dirstack;
1738 enum fill_status status = FILL_STATUS_UNFILTERED;
1740 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1742 dirstack = alloc_dirstack(2);
1744 for (i = 0; i < 26; i++)
1746 if (!(drives & (1 << i))) continue;
1748 root[0] = 'A' + i;
1749 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1751 num_expected_rows = 0;
1752 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1754 for (;;)
1756 heap_free( glob );
1757 heap_free( path );
1758 path = pop_dir( dirstack, &len );
1759 if (!(glob = build_glob( root[0], path, len )))
1761 status = FILL_STATUS_FAILED;
1762 goto done;
1764 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1768 if (!resize_table( table, row + 1, sizeof(*rec) ))
1770 FindClose( handle );
1771 status = FILL_STATUS_FAILED;
1772 goto done;
1774 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1775 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1776 continue;
1778 new_path = append_path( path, data.cFileName, &len );
1779 if (!(push_dir( dirstack, new_path, len )))
1781 heap_free( new_path );
1782 FindClose( handle );
1783 status = FILL_STATUS_FAILED;
1784 goto done;
1786 rec = (struct record_directory *)(table->data + offset);
1787 rec->accessmask = FILE_ALL_ACCESS;
1788 rec->name = build_name( root[0], new_path );
1789 if (!match_row( table, row, cond, &status ))
1791 free_row_values( table, row );
1792 continue;
1794 else if (num_expected_rows && row == num_expected_rows - 1)
1796 row++;
1797 FindClose( handle );
1798 status = FILL_STATUS_FILTERED;
1799 goto done;
1801 offset += sizeof(*rec);
1802 row++;
1804 while (FindNextFileW( handle, &data ));
1805 FindClose( handle );
1807 if (!peek_dir( dirstack )) break;
1811 done:
1812 free_dirstack( dirstack );
1813 heap_free( glob );
1814 heap_free( path );
1816 TRACE("created %u rows\n", row);
1817 table->num_rows = row;
1818 return status;
1821 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1823 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1824 ULARGE_INTEGER free;
1825 DISK_GEOMETRY_EX info;
1826 HANDLE handle;
1827 DWORD bytes_returned;
1829 free.QuadPart = 512 * 1024 * 1024;
1830 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1832 root[4] = dir[0];
1833 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1834 if (handle != INVALID_HANDLE_VALUE)
1836 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1837 *disksize = info.DiskSize.QuadPart;
1838 CloseHandle( handle );
1840 return free.QuadPart;
1843 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1845 static const WCHAR fmtW[] =
1846 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1847 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
1848 struct record_diskdrive *rec;
1849 UINT i, row = 0, offset = 0, index = 0, type;
1850 UINT64 size = 1024 * 1024 * 1024;
1851 DWORD drives = GetLogicalDrives();
1852 enum fill_status status = FILL_STATUS_UNFILTERED;
1854 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
1856 for (i = 0; i < 26; i++)
1858 if (drives & (1 << i))
1860 root[0] = 'A' + i;
1861 type = GetDriveTypeW( root );
1862 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1863 continue;
1865 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1867 rec = (struct record_diskdrive *)(table->data + offset);
1868 sprintfW( device_id, fmtW, index );
1869 rec->device_id = heap_strdupW( device_id );
1870 rec->index = index;
1871 rec->interfacetype = diskdrive_interfacetypeW;
1872 rec->manufacturer = diskdrive_manufacturerW;
1873 if (type == DRIVE_FIXED)
1874 rec->mediatype = diskdrive_mediatype_fixedW;
1875 else
1876 rec->mediatype = diskdrive_mediatype_removableW;
1877 rec->model = diskdrive_modelW;
1878 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
1879 rec->serialnumber = diskdrive_serialW;
1880 get_freespace( root, &size );
1881 rec->size = size;
1882 if (!match_row( table, row, cond, &status ))
1884 free_row_values( table, row );
1885 continue;
1887 offset += sizeof(*rec);
1888 index++;
1889 row++;
1892 TRACE("created %u rows\n", row);
1893 table->num_rows = row;
1894 return status;
1897 static WCHAR *get_filesystem( const WCHAR *root )
1899 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1900 WCHAR buffer[MAX_PATH + 1];
1902 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1903 return heap_strdupW( buffer );
1904 return heap_strdupW( ntfsW );
1907 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1909 static const WCHAR fmtW[] =
1910 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1911 WCHAR device_id[32], root[] = {'A',':','\\',0};
1912 struct record_diskpartition *rec;
1913 UINT i, row = 0, offset = 0, type, index = 0;
1914 UINT64 size = 1024 * 1024 * 1024;
1915 DWORD drives = GetLogicalDrives();
1916 enum fill_status status = FILL_STATUS_UNFILTERED;
1918 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1920 for (i = 0; i < 26; i++)
1922 if (drives & (1 << i))
1924 root[0] = 'A' + i;
1925 type = GetDriveTypeW( root );
1926 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1927 continue;
1929 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1931 rec = (struct record_diskpartition *)(table->data + offset);
1932 rec->bootable = (i == 2) ? -1 : 0;
1933 rec->bootpartition = (i == 2) ? -1 : 0;
1934 sprintfW( device_id, fmtW, index );
1935 rec->device_id = heap_strdupW( device_id );
1936 rec->diskindex = index;
1937 rec->index = 0;
1938 rec->pnpdevice_id = heap_strdupW( device_id );
1939 get_freespace( root, &size );
1940 rec->size = size;
1941 rec->startingoffset = 0;
1942 rec->type = get_filesystem( root );
1943 if (!match_row( table, row, cond, &status ))
1945 free_row_values( table, row );
1946 continue;
1948 offset += sizeof(*rec);
1949 row++;
1950 index++;
1953 TRACE("created %u rows\n", row);
1954 table->num_rows = row;
1955 return status;
1958 static WCHAR *get_volumename( const WCHAR *root )
1960 WCHAR buf[MAX_PATH + 1] = {0};
1961 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
1962 return heap_strdupW( buf );
1964 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1966 static const WCHAR fmtW[] = {'%','0','8','X',0};
1967 DWORD serial = 0;
1968 WCHAR buffer[9];
1970 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1971 sprintfW( buffer, fmtW, serial );
1972 return heap_strdupW( buffer );
1975 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1977 static const WCHAR fmtW[] = {'%','c',':',0};
1978 WCHAR device_id[3], root[] = {'A',':','\\',0};
1979 struct record_logicaldisk *rec;
1980 UINT i, row = 0, offset = 0, type;
1981 UINT64 size = 1024 * 1024 * 1024;
1982 DWORD drives = GetLogicalDrives();
1983 enum fill_status status = FILL_STATUS_UNFILTERED;
1985 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1987 for (i = 0; i < 26; i++)
1989 if (drives & (1 << i))
1991 root[0] = 'A' + i;
1992 type = GetDriveTypeW( root );
1993 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1994 continue;
1996 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1998 rec = (struct record_logicaldisk *)(table->data + offset);
1999 sprintfW( device_id, fmtW, 'A' + i );
2000 rec->device_id = heap_strdupW( device_id );
2001 rec->drivetype = type;
2002 rec->filesystem = get_filesystem( root );
2003 rec->freespace = get_freespace( root, &size );
2004 rec->name = heap_strdupW( device_id );
2005 rec->size = size;
2006 rec->volumename = get_volumename( root );
2007 rec->volumeserialnumber = get_volumeserialnumber( root );
2008 if (!match_row( table, row, cond, &status ))
2010 free_row_values( table, row );
2011 continue;
2013 offset += sizeof(*rec);
2014 row++;
2017 TRACE("created %u rows\n", row);
2018 table->num_rows = row;
2019 return status;
2022 static UINT16 get_connection_status( IF_OPER_STATUS status )
2024 switch (status)
2026 case IfOperStatusDown:
2027 return 0; /* Disconnected */
2028 case IfOperStatusUp:
2029 return 2; /* Connected */
2030 default:
2031 ERR("unhandled status %u\n", status);
2032 break;
2034 return 0;
2036 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2038 static const WCHAR fmtW[] =
2039 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2040 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2041 WCHAR *ret;
2043 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2044 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2045 return ret;
2047 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2049 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2050 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2051 static const WCHAR firewireW[] = {'1','3','9','4',0};
2052 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2054 switch (type)
2056 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2057 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2058 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2059 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2060 default: *physical = 0; return NULL;
2064 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2066 static const WCHAR fmtW[] = {'%','u',0};
2067 WCHAR device_id[11];
2068 struct record_networkadapter *rec;
2069 IP_ADAPTER_ADDRESSES *aa, *buffer;
2070 UINT row = 0, offset = 0, count = 0;
2071 DWORD size = 0, ret;
2072 int physical;
2073 enum fill_status status = FILL_STATUS_UNFILTERED;
2075 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2076 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2078 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2079 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2081 heap_free( buffer );
2082 return FILL_STATUS_FAILED;
2084 for (aa = buffer; aa; aa = aa->Next)
2086 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2088 if (!resize_table( table, count, sizeof(*rec) ))
2090 heap_free( buffer );
2091 return FILL_STATUS_FAILED;
2093 for (aa = buffer; aa; aa = aa->Next)
2095 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2097 rec = (struct record_networkadapter *)(table->data + offset);
2098 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2099 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2100 rec->device_id = heap_strdupW( device_id );
2101 rec->index = aa->u.s.IfIndex;
2102 rec->interface_index = aa->u.s.IfIndex;
2103 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2104 rec->manufacturer = compsys_manufacturerW;
2105 rec->name = heap_strdupW( aa->FriendlyName );
2106 rec->netconnection_status = get_connection_status( aa->OperStatus );
2107 rec->physicaladapter = physical;
2108 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2109 rec->speed = 1000000;
2110 if (!match_row( table, row, cond, &status ))
2112 free_row_values( table, row );
2113 continue;
2115 offset += sizeof(*rec);
2116 row++;
2118 TRACE("created %u rows\n", row);
2119 table->num_rows = row;
2121 heap_free( buffer );
2122 return status;
2125 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2127 const SOCKET_ADDRESS *sa = &addr->Address;
2128 WCHAR buf[NI_MAXHOST];
2130 if (!addr) return NULL;
2131 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2132 0, NI_NAMEREQD )) return NULL;
2133 return heap_strdupW( buf );
2135 static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
2137 IP_ADAPTER_GATEWAY_ADDRESS *gateway;
2138 struct array *ret;
2139 ULONG buflen, i = 0, count = 0;
2140 WCHAR **ptr, buf[54]; /* max IPv6 address length */
2142 if (!list) return NULL;
2143 for (gateway = list; gateway; gateway = gateway->Next) count++;
2145 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2146 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2148 heap_free( ret );
2149 return NULL;
2151 for (gateway = list; gateway; gateway = gateway->Next)
2153 buflen = sizeof(buf)/sizeof(buf[0]);
2154 if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
2155 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2157 for (; i > 0; i--) heap_free( ptr[i - 1] );
2158 heap_free( ptr );
2159 heap_free( ret );
2160 return NULL;
2163 ret->count = count;
2164 ret->ptr = ptr;
2165 return ret;
2167 static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
2169 IP_ADAPTER_DNS_SERVER_ADDRESS *server;
2170 struct array *ret;
2171 ULONG buflen, i = 0, count = 0;
2172 WCHAR **ptr, *p, buf[54]; /* max IPv6 address length */
2174 if (!list) return NULL;
2175 for (server = list; server; server = server->Next) count++;
2177 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2178 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2180 heap_free( ret );
2181 return NULL;
2183 for (server = list; server; server = server->Next)
2185 buflen = sizeof(buf)/sizeof(buf[0]);
2186 if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
2187 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2189 for (; i > 0; i--) heap_free( ptr[i - 1] );
2190 heap_free( ptr );
2191 heap_free( ret );
2192 return NULL;
2194 if ((p = strrchrW( ptr[i - 1], ':' ))) *p = 0;
2196 ret->count = count;
2197 ret->ptr = ptr;
2198 return ret;
2200 static WCHAR *get_settingid( UINT32 index )
2202 GUID guid;
2203 WCHAR *ret, *str;
2204 memset( &guid, 0, sizeof(guid) );
2205 guid.Data1 = index;
2206 UuidToStringW( &guid, &str );
2207 ret = heap_strdupW( str );
2208 RpcStringFreeW( &str );
2209 return ret;
2212 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2214 struct record_networkadapterconfig *rec;
2215 IP_ADAPTER_ADDRESSES *aa, *buffer;
2216 UINT row = 0, offset = 0, count = 0;
2217 DWORD size = 0, ret;
2218 enum fill_status status = FILL_STATUS_UNFILTERED;
2220 ret = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &size );
2221 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2223 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2224 if (GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, buffer, &size ))
2226 heap_free( buffer );
2227 return FILL_STATUS_FAILED;
2229 for (aa = buffer; aa; aa = aa->Next)
2231 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2233 if (!resize_table( table, count, sizeof(*rec) ))
2235 heap_free( buffer );
2236 return FILL_STATUS_FAILED;
2238 for (aa = buffer; aa; aa = aa->Next)
2240 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2242 rec = (struct record_networkadapterconfig *)(table->data + offset);
2243 rec->defaultipgateway = get_defaultipgateway( aa->FirstGatewayAddress );
2244 rec->description = heap_strdupW( aa->Description );
2245 rec->dhcpenabled = -1;
2246 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2247 rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress );
2248 rec->index = aa->u.s.IfIndex;
2249 rec->ipconnectionmetric = 20;
2250 rec->ipenabled = -1;
2251 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2252 rec->settingid = get_settingid( rec->index );
2253 if (!match_row( table, row, cond, &status ))
2255 free_row_values( table, row );
2256 continue;
2258 offset += sizeof(*rec);
2259 row++;
2261 TRACE("created %u rows\n", row);
2262 table->num_rows = row;
2264 heap_free( buffer );
2265 return status;
2268 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2270 struct record_physicalmemory *rec;
2271 enum fill_status status = FILL_STATUS_UNFILTERED;
2272 UINT row = 0;
2274 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2276 rec = (struct record_physicalmemory *)table->data;
2277 rec->capacity = get_total_physical_memory();
2278 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2279 else row++;
2281 TRACE("created %u rows\n", row);
2282 table->num_rows = row;
2283 return status;
2286 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2288 struct record_printer *rec;
2289 enum fill_status status = FILL_STATUS_UNFILTERED;
2290 PRINTER_INFO_2W *info;
2291 DWORD i, offset = 0, count = 0, size = 0;
2293 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2294 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2296 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2297 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2299 heap_free( info );
2300 return FILL_STATUS_FAILED;
2302 if (!resize_table( table, count, sizeof(*rec) ))
2304 heap_free( info );
2305 return FILL_STATUS_FAILED;
2308 for (i = 0; i < count; i++)
2310 rec = (struct record_printer *)(table->data + offset);
2311 rec->attributes = info[i].Attributes;
2312 rec->drivername = heap_strdupW( info[i].pDriverName );
2313 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2314 rec->local = -1;
2315 rec->name = heap_strdupW( info[i].pPrinterName );
2316 rec->network = 0;
2317 if (!match_row( table, i, cond, &status ))
2319 free_row_values( table, i );
2320 continue;
2322 offset += sizeof(*rec);
2324 TRACE("created %u rows\n", count);
2325 table->num_rows = count;
2327 heap_free( info );
2328 return status;
2331 static WCHAR *get_cmdline( DWORD process_id )
2333 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2334 return NULL; /* FIXME handle different process case */
2337 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2339 static const WCHAR fmtW[] = {'%','u',0};
2340 WCHAR handle[11];
2341 struct record_process *rec;
2342 PROCESSENTRY32W entry;
2343 HANDLE snap;
2344 enum fill_status status = FILL_STATUS_FAILED;
2345 UINT row = 0, offset = 0;
2347 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2348 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2350 entry.dwSize = sizeof(entry);
2351 if (!Process32FirstW( snap, &entry )) goto done;
2352 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2356 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2358 rec = (struct record_process *)(table->data + offset);
2359 rec->caption = heap_strdupW( entry.szExeFile );
2360 rec->commandline = get_cmdline( entry.th32ProcessID );
2361 rec->description = heap_strdupW( entry.szExeFile );
2362 sprintfW( handle, fmtW, entry.th32ProcessID );
2363 rec->handle = heap_strdupW( handle );
2364 rec->name = heap_strdupW( entry.szExeFile );
2365 rec->process_id = entry.th32ProcessID;
2366 rec->pprocess_id = entry.th32ParentProcessID;
2367 rec->thread_count = entry.cntThreads;
2368 rec->workingsetsize = 0;
2369 rec->get_owner = process_get_owner;
2370 if (!match_row( table, row, cond, &status ))
2372 free_row_values( table, row );
2373 continue;
2375 offset += sizeof(*rec);
2376 row++;
2377 } while (Process32NextW( snap, &entry ));
2379 TRACE("created %u rows\n", row);
2380 table->num_rows = row;
2381 status = FILL_STATUS_UNFILTERED;
2383 done:
2384 CloseHandle( snap );
2385 return status;
2388 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2390 #ifdef __i386__
2391 #ifdef _MSC_VER
2392 __cpuid(p, ax);
2393 #else
2394 __asm__("pushl %%ebx\n\t"
2395 "cpuid\n\t"
2396 "movl %%ebx, %%esi\n\t"
2397 "popl %%ebx"
2398 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2399 : "0" (ax));
2400 #endif
2401 #endif
2403 static const WCHAR *get_osarchitecture(void)
2405 SYSTEM_INFO info;
2406 GetNativeSystemInfo( &info );
2407 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2408 return os_32bitW;
2410 static void get_processor_caption( WCHAR *caption )
2412 static const WCHAR fmtW[] =
2413 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2414 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2415 static const WCHAR x86W[] = {'x','8','6',0};
2416 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2417 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2418 unsigned int regs[4] = {0, 0, 0, 0};
2420 do_cpuid( 1, regs );
2421 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2423 static void get_processor_version( WCHAR *version )
2425 static const WCHAR fmtW[] =
2426 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2427 unsigned int regs[4] = {0, 0, 0, 0};
2429 do_cpuid( 1, regs );
2430 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2432 static void get_processor_id( WCHAR *processor_id )
2434 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2435 unsigned int regs[4] = {0, 0, 0, 0};
2437 do_cpuid( 1, regs );
2438 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2440 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2442 unsigned int i;
2443 unsigned char *p = (unsigned char *)regs;
2445 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2446 buffer[i] = 0;
2448 static void get_processor_manufacturer( WCHAR *manufacturer )
2450 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2452 do_cpuid( 0, regs );
2453 tmp = regs[2]; /* swap edx and ecx */
2454 regs[2] = regs[3];
2455 regs[3] = tmp;
2457 regs_to_str( regs + 1, 12, manufacturer );
2459 static void get_processor_name( WCHAR *name )
2461 unsigned int regs[4] = {0, 0, 0, 0};
2463 do_cpuid( 0x80000000, regs );
2464 if (regs[0] >= 0x80000004)
2466 do_cpuid( 0x80000002, regs );
2467 regs_to_str( regs, 16, name );
2468 do_cpuid( 0x80000003, regs );
2469 regs_to_str( regs, 16, name + 16 );
2470 do_cpuid( 0x80000004, regs );
2471 regs_to_str( regs, 16, name + 32 );
2474 static UINT get_processor_currentclockspeed( UINT index )
2476 PROCESSOR_POWER_INFORMATION *info;
2477 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2478 NTSTATUS status;
2480 if ((info = heap_alloc( size )))
2482 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2483 if (!status) ret = info[index].CurrentMhz;
2484 heap_free( info );
2486 return ret;
2488 static UINT get_processor_maxclockspeed( UINT index )
2490 PROCESSOR_POWER_INFORMATION *info;
2491 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2492 NTSTATUS status;
2494 if ((info = heap_alloc( size )))
2496 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2497 if (!status) ret = info[index].MaxMhz;
2498 heap_free( info );
2500 return ret;
2503 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2505 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2506 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2507 struct record_processor *rec;
2508 UINT i, offset = 0, num_cores, num_logical_processors, count = get_processor_count();
2509 enum fill_status status = FILL_STATUS_UNFILTERED;
2511 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2513 get_processor_caption( caption );
2514 get_processor_id( processor_id );
2515 get_processor_manufacturer( manufacturer );
2516 get_processor_name( name );
2517 get_processor_version( version );
2519 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2520 num_cores /= count;
2522 for (i = 0; i < count; i++)
2524 rec = (struct record_processor *)(table->data + offset);
2525 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2526 rec->caption = heap_strdupW( caption );
2527 rec->cpu_status = 1; /* CPU Enabled */
2528 rec->currentclockspeed = get_processor_currentclockspeed( i );
2529 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2530 rec->description = heap_strdupW( caption );
2531 sprintfW( device_id, fmtW, i );
2532 rec->device_id = heap_strdupW( device_id );
2533 rec->family = 2; /* Unknown */
2534 rec->manufacturer = heap_strdupW( manufacturer );
2535 rec->maxclockspeed = get_processor_maxclockspeed( i );
2536 rec->name = heap_strdupW( name );
2537 rec->num_cores = num_cores;
2538 rec->num_logical_processors = num_logical_processors;
2539 rec->processor_id = heap_strdupW( processor_id );
2540 rec->processortype = 3; /* central processor */
2541 rec->unique_id = NULL;
2542 rec->version = heap_strdupW( version );
2543 if (!match_row( table, i, cond, &status ))
2545 free_row_values( table, i );
2546 continue;
2548 offset += sizeof(*rec);
2551 TRACE("created %u rows\n", count);
2552 table->num_rows = count;
2553 return status;
2556 static WCHAR *get_lastbootuptime(void)
2558 static const WCHAR fmtW[] =
2559 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2560 '.','%','0','6','u','+','0','0','0',0};
2561 SYSTEM_TIMEOFDAY_INFORMATION ti;
2562 TIME_FIELDS tf;
2563 WCHAR *ret;
2565 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2567 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2568 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2569 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2570 return ret;
2572 static WCHAR *get_localdatetime(void)
2574 static const WCHAR fmtW[] =
2575 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2576 '.','%','0','6','u','%','+','0','3','d',0};
2577 TIME_ZONE_INFORMATION tzi;
2578 SYSTEMTIME st;
2579 WCHAR *ret;
2580 DWORD Status;
2581 LONG Bias;
2583 Status = GetTimeZoneInformation(&tzi);
2585 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2586 Bias = tzi.Bias;
2587 if(Status == TIME_ZONE_ID_DAYLIGHT)
2588 Bias+= tzi.DaylightBias;
2589 else
2590 Bias+= tzi.StandardBias;
2591 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2593 GetLocalTime(&st);
2594 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2595 return ret;
2597 static WCHAR *get_systemdirectory(void)
2599 void *redir;
2600 WCHAR *ret;
2602 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2603 Wow64DisableWow64FsRedirection( &redir );
2604 GetSystemDirectoryW( ret, MAX_PATH );
2605 Wow64RevertWow64FsRedirection( redir );
2606 return ret;
2608 static WCHAR *get_codeset(void)
2610 static const WCHAR fmtW[] = {'%','u',0};
2611 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2612 if (ret) sprintfW( ret, fmtW, GetACP() );
2613 return ret;
2615 static WCHAR *get_countrycode(void)
2617 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2618 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2619 return ret;
2621 static WCHAR *get_locale(void)
2623 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2624 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2625 return ret;
2628 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2630 struct record_operatingsystem *rec;
2631 enum fill_status status = FILL_STATUS_UNFILTERED;
2632 UINT row = 0;
2634 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2636 rec = (struct record_operatingsystem *)table->data;
2637 rec->buildnumber = os_buildnumberW;
2638 rec->caption = os_captionW;
2639 rec->codeset = get_codeset();
2640 rec->countrycode = get_countrycode();
2641 rec->csdversion = os_csdversionW;
2642 rec->installdate = os_installdateW;
2643 rec->lastbootuptime = get_lastbootuptime();
2644 rec->localdatetime = get_localdatetime();
2645 rec->locale = get_locale();
2646 rec->name = os_nameW;
2647 rec->osarchitecture = get_osarchitecture();
2648 rec->oslanguage = GetSystemDefaultLangID();
2649 rec->osproductsuite = 2461140; /* Windows XP Professional */
2650 rec->ostype = 18; /* WINNT */
2651 rec->primary = -1;
2652 rec->serialnumber = os_serialnumberW;
2653 rec->servicepackmajor = 3;
2654 rec->servicepackminor = 0;
2655 rec->suitemask = 272; /* Single User + Terminal */
2656 rec->systemdirectory = get_systemdirectory();
2657 rec->totalvisiblememorysize = get_total_physical_memory() / 1024;
2658 rec->version = os_versionW;
2659 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2660 else row++;
2662 TRACE("created %u rows\n", row);
2663 table->num_rows = row;
2664 return status;
2667 static const WCHAR *get_service_type( DWORD type )
2669 static const WCHAR filesystem_driverW[] =
2670 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2671 static const WCHAR kernel_driverW[] =
2672 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2673 static const WCHAR own_processW[] =
2674 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2675 static const WCHAR share_processW[] =
2676 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2678 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2679 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2680 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2681 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2682 else ERR("unhandled type 0x%08x\n", type);
2683 return NULL;
2685 static const WCHAR *get_service_state( DWORD state )
2687 static const WCHAR runningW[] =
2688 {'R','u','n','n','i','n','g',0};
2689 static const WCHAR start_pendingW[] =
2690 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2691 static const WCHAR stop_pendingW[] =
2692 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2693 static const WCHAR stoppedW[] =
2694 {'S','t','o','p','p','e','d',0};
2695 static const WCHAR unknownW[] =
2696 {'U','n','k','n','o','w','n',0};
2698 switch (state)
2700 case SERVICE_STOPPED: return stoppedW;
2701 case SERVICE_START_PENDING: return start_pendingW;
2702 case SERVICE_STOP_PENDING: return stop_pendingW;
2703 case SERVICE_RUNNING: return runningW;
2704 default:
2705 ERR("unknown state %u\n", state);
2706 return unknownW;
2709 static const WCHAR *get_service_startmode( DWORD mode )
2711 static const WCHAR bootW[] = {'B','o','o','t',0};
2712 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2713 static const WCHAR autoW[] = {'A','u','t','o',0};
2714 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2715 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2716 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2718 switch (mode)
2720 case SERVICE_BOOT_START: return bootW;
2721 case SERVICE_SYSTEM_START: return systemW;
2722 case SERVICE_AUTO_START: return autoW;
2723 case SERVICE_DEMAND_START: return manualW;
2724 case SERVICE_DISABLED: return disabledW;
2725 default:
2726 ERR("unknown mode 0x%x\n", mode);
2727 return unknownW;
2730 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2732 QUERY_SERVICE_CONFIGW *config = NULL;
2733 SC_HANDLE service;
2734 DWORD size;
2736 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2737 QueryServiceConfigW( service, NULL, 0, &size );
2738 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2739 if (!(config = heap_alloc( size ))) goto done;
2740 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2741 heap_free( config );
2742 config = NULL;
2744 done:
2745 CloseServiceHandle( service );
2746 return config;
2749 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2751 struct record_service *rec;
2752 SC_HANDLE manager;
2753 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2754 SERVICE_STATUS_PROCESS *status;
2755 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2756 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2757 UINT i, row = 0, offset = 0, size = 256, needed, count;
2758 enum fill_status fill_status = FILL_STATUS_FAILED;
2759 BOOL ret;
2761 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2762 if (!(services = heap_alloc( size ))) goto done;
2764 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2765 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2766 &count, NULL, NULL );
2767 if (!ret)
2769 if (GetLastError() != ERROR_MORE_DATA) goto done;
2770 size = needed;
2771 if (!(tmp = heap_realloc( services, size ))) goto done;
2772 services = tmp;
2773 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2774 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2775 &count, NULL, NULL );
2776 if (!ret) goto done;
2778 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2780 GetComputerNameW( sysnameW, &len );
2781 fill_status = FILL_STATUS_UNFILTERED;
2783 for (i = 0; i < count; i++)
2785 QUERY_SERVICE_CONFIGW *config;
2787 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2789 status = &services[i].ServiceStatusProcess;
2790 rec = (struct record_service *)(table->data + offset);
2791 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2792 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2793 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2794 rec->name = heap_strdupW( services[i].lpServiceName );
2795 rec->process_id = status->dwProcessId;
2796 rec->servicetype = get_service_type( status->dwServiceType );
2797 rec->startmode = get_service_startmode( config->dwStartType );
2798 rec->state = get_service_state( status->dwCurrentState );
2799 rec->systemname = heap_strdupW( sysnameW );
2800 rec->pause_service = service_pause_service;
2801 rec->resume_service = service_resume_service;
2802 rec->start_service = service_start_service;
2803 rec->stop_service = service_stop_service;
2804 heap_free( config );
2805 if (!match_row( table, row, cond, &fill_status ))
2807 free_row_values( table, row );
2808 continue;
2810 offset += sizeof(*rec);
2811 row++;
2814 TRACE("created %u rows\n", row);
2815 table->num_rows = row;
2817 done:
2818 CloseServiceHandle( manager );
2819 heap_free( services );
2820 return fill_status;
2823 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
2825 if (!name || !name->Name.Buffer) return NULL;
2826 return heap_strdupW( name->Name.Buffer );
2828 static struct array *get_binaryrepresentation( PSID sid, UINT len )
2830 struct array *array = heap_alloc( sizeof(struct array) );
2831 if (array)
2833 UINT8 *ret = heap_alloc( len );
2834 if (ret)
2836 memcpy( ret, sid, len );
2837 array->count = len;
2838 array->ptr = ret;
2839 return array;
2841 heap_free( array );
2843 return NULL;
2845 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
2847 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
2848 return heap_strdupW( domain->Domains->Name.Buffer );
2850 static const WCHAR *find_sid_str( const struct expr *cond )
2852 const struct expr *left, *right;
2853 const WCHAR *ret = NULL;
2855 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
2857 left = cond->u.expr.left;
2858 right = cond->u.expr.right;
2859 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
2861 ret = right->u.sval;
2863 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
2865 ret = left->u.sval;
2867 return ret;
2870 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
2872 PSID sid;
2873 LSA_REFERENCED_DOMAIN_LIST *domain;
2874 LSA_TRANSLATED_NAME *name;
2875 LSA_HANDLE handle;
2876 LSA_OBJECT_ATTRIBUTES attrs;
2877 const WCHAR *str;
2878 struct record_sid *rec;
2879 UINT len;
2881 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
2882 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2884 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
2885 len = GetLengthSid( sid );
2887 memset( &attrs, 0, sizeof(attrs) );
2888 attrs.Length = sizeof(attrs);
2889 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
2891 LocalFree( sid );
2892 return FILL_STATUS_FAILED;
2894 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
2896 LocalFree( sid );
2897 LsaClose( handle );
2898 return FILL_STATUS_FAILED;
2901 rec = (struct record_sid *)table->data;
2902 rec->accountname = get_accountname( name );
2903 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
2904 rec->referenceddomainname = get_referenceddomainname( domain );
2905 rec->sid = heap_strdupW( str );
2906 rec->sidlength = len;
2908 TRACE("created 1 row\n");
2909 table->num_rows = 1;
2911 LsaFreeMemory( domain );
2912 LsaFreeMemory( name );
2913 LocalFree( sid );
2914 LsaClose( handle );
2915 return FILL_STATUS_FILTERED;
2918 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2920 HDC hdc = GetDC( NULL );
2921 UINT32 ret;
2923 if (!hdc) return 32;
2924 ret = GetDeviceCaps( hdc, BITSPIXEL );
2925 *hres = GetDeviceCaps( hdc, HORZRES );
2926 *vres = GetDeviceCaps( hdc, VERTRES );
2927 ReleaseDC( NULL, hdc );
2928 return ret;
2930 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2932 static const WCHAR fmtW[] =
2933 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2934 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2935 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2936 WCHAR *ret;
2938 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2939 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2940 return ret;
2943 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2945 static const WCHAR fmtW[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
2946 struct record_videocontroller *rec;
2947 HRESULT hr;
2948 IDXGIFactory *factory = NULL;
2949 IDXGIAdapter *adapter = NULL;
2950 DXGI_ADAPTER_DESC desc;
2951 UINT row = 0, hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2952 const WCHAR *name = videocontroller_deviceidW;
2953 enum fill_status status = FILL_STATUS_UNFILTERED;
2954 WCHAR mode[44];
2956 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2958 memset (&desc, 0, sizeof(desc));
2959 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2960 if (FAILED(hr)) goto done;
2962 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2963 if (FAILED(hr)) goto done;
2965 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2966 if (SUCCEEDED(hr))
2968 vidmem = desc.DedicatedVideoMemory;
2969 name = desc.Description;
2972 done:
2973 rec = (struct record_videocontroller *)table->data;
2974 rec->adapter_dactype = videocontroller_dactypeW;
2975 rec->adapter_ram = vidmem;
2976 rec->availability = 3; /* Running or Full Power */
2977 rec->caption = heap_strdupW( name );
2978 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2979 rec->current_horizontalres = hres;
2980 rec->current_refreshrate = 0; /* default refresh rate */
2981 rec->current_scanmode = 2; /* Unknown */
2982 rec->current_verticalres = vres;
2983 rec->description = heap_strdupW( name );
2984 rec->device_id = videocontroller_deviceidW;
2985 rec->driverversion = videocontroller_driverversionW;
2986 rec->name = heap_strdupW( name );
2987 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2988 rec->videoarchitecture = 2; /* Unknown */
2989 rec->videomemorytype = 2; /* Unknown */
2990 wsprintfW( mode, fmtW, hres, vres, (UINT64)1 << rec->current_bitsperpixel );
2991 rec->videomodedescription = heap_strdupW( mode );
2992 rec->videoprocessor = heap_strdupW( name );
2993 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2994 else row++;
2996 TRACE("created %u rows\n", row);
2997 table->num_rows = row;
2999 if (adapter) IDXGIAdapter_Release( adapter );
3000 if (factory) IDXGIFactory_Release( factory );
3001 return status;
3004 static struct table builtin_classes[] =
3006 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
3007 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
3008 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
3009 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
3010 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, SIZEOF(data_compsysproduct), 0, (BYTE *)data_compsysproduct },
3011 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
3012 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
3013 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
3014 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
3015 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
3016 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3017 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3018 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
3019 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
3020 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
3021 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
3022 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
3023 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
3024 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
3025 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
3026 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3027 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3028 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
3029 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
3030 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
3031 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
3032 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
3033 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
3034 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
3035 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
3038 void init_table_list( void )
3040 static struct list tables = LIST_INIT( tables );
3041 UINT i;
3043 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
3044 table_list = &tables;