wbemprox: Implement Win32_NetworkAdapterConfiguration.DNSServerSearchOrder.
[wine.git] / dlls / wbemprox / builtin.c
blobd20ef82c4cfbd93e2b274feafd0bc179751cd62a
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_qualifiersW[] =
89 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
90 static const WCHAR class_printerW[] =
91 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
92 static const WCHAR class_process_getowner_outW[] =
93 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
94 'N','E','R','_','O','U','T',0};
95 static const WCHAR class_processorW[] =
96 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
97 static const WCHAR class_processor2W[] =
98 {'C','I','M','_','P','r','o','c','e','s','s','o','r',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_smbiosbiosversionW[] =
309 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
310 static const WCHAR prop_startmodeW[] =
311 {'S','t','a','r','t','M','o','d','e',0};
312 static const WCHAR prop_sidW[] =
313 {'S','I','D',0};
314 static const WCHAR prop_sidlengthW[] =
315 {'S','i','d','L','e','n','g','t','h',0};
316 static const WCHAR prop_sizeW[] =
317 {'S','i','z','e',0};
318 static const WCHAR prop_speedW[] =
319 {'S','p','e','e','d',0};
320 static const WCHAR prop_startingoffsetW[] =
321 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
322 static const WCHAR prop_stateW[] =
323 {'S','t','a','t','e',0};
324 static const WCHAR prop_statusinfoW[] =
325 {'S','t','a','t','u','s','I','n','f','o',0};
326 static const WCHAR prop_strvalueW[] =
327 {'S','t','r','i','n','g','V','a','l','u','e',0};
328 static const WCHAR prop_suitemaskW[] =
329 {'S','u','i','t','e','M','a','s','k',0};
330 static const WCHAR prop_systemdirectoryW[] =
331 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
332 static const WCHAR prop_systemnameW[] =
333 {'S','y','s','t','e','m','N','a','m','e',0};
334 static const WCHAR prop_tagW[] =
335 {'T','a','g',0};
336 static const WCHAR prop_threadcountW[] =
337 {'T','h','r','e','a','d','C','o','u','n','t',0};
338 static const WCHAR prop_totalphysicalmemoryW[] =
339 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
340 static const WCHAR prop_totalvisiblememorysizeW[] =
341 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
342 static const WCHAR prop_typeW[] =
343 {'T','y','p','e',0};
344 static const WCHAR prop_uniqueidW[] =
345 {'U','n','i','q','u','e','I','d',0};
346 static const WCHAR prop_usernameW[] =
347 {'U','s','e','r','N','a','m','e',0};
348 static const WCHAR prop_uuidW[] =
349 {'U','U','I','D',0};
350 static const WCHAR prop_varianttypeW[] =
351 {'V','a','r','i','a','n','t','T','y','p','e',0};
352 static const WCHAR prop_versionW[] =
353 {'V','e','r','s','i','o','n',0};
354 static const WCHAR prop_videoarchitectureW[] =
355 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
356 static const WCHAR prop_videomemorytypeW[] =
357 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
358 static const WCHAR prop_videoprocessorW[] =
359 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
360 static const WCHAR prop_volumenameW[] =
361 {'V','o','l','u','m','e','N','a','m','e',0};
362 static const WCHAR prop_volumeserialnumberW[] =
363 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
364 static const WCHAR prop_workingsetsizeW[] =
365 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
367 /* column definitions must be kept in sync with record structures below */
368 static const struct column col_baseboard[] =
370 { prop_manufacturerW, CIM_STRING },
371 { prop_modelW, CIM_STRING },
372 { prop_nameW, CIM_STRING },
373 { prop_productW, CIM_STRING },
374 { prop_serialnumberW, CIM_STRING },
375 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
376 { prop_versionW, CIM_STRING }
378 static const struct column col_bios[] =
380 { prop_descriptionW, CIM_STRING },
381 { prop_identificationcodeW, CIM_STRING },
382 { prop_manufacturerW, CIM_STRING },
383 { prop_nameW, CIM_STRING },
384 { prop_releasedateW, CIM_DATETIME },
385 { prop_serialnumberW, CIM_STRING },
386 { prop_smbiosbiosversionW, CIM_STRING },
387 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
389 static const struct column col_cdromdrive[] =
391 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
392 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
393 { prop_mediatypeW, CIM_STRING },
394 { prop_nameW, CIM_STRING },
395 { prop_pnpdeviceidW, CIM_STRING }
397 static const struct column col_compsys[] =
399 { prop_descriptionW, CIM_STRING },
400 { prop_domainW, CIM_STRING },
401 { prop_domainroleW, CIM_UINT16, VT_I4 },
402 { prop_manufacturerW, CIM_STRING },
403 { prop_modelW, CIM_STRING },
404 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
405 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
406 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
407 { prop_totalphysicalmemoryW, CIM_UINT64 },
408 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
410 static const struct column col_compsysproduct[] =
412 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
413 { prop_uuidW, CIM_STRING }
415 static const struct column col_datafile[] =
417 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
418 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
420 static const struct column col_desktopmonitor[] =
422 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
424 static const struct column col_directory[] =
426 { prop_accessmaskW, CIM_UINT32 },
427 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
429 static const struct column col_diskdrive[] =
431 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
432 { prop_indexW, CIM_UINT32, VT_I4 },
433 { prop_interfacetypeW, CIM_STRING },
434 { prop_manufacturerW, CIM_STRING },
435 { prop_mediatypeW, CIM_STRING },
436 { prop_modelW, CIM_STRING },
437 { prop_pnpdeviceidW, CIM_STRING },
438 { prop_serialnumberW, CIM_STRING },
439 { prop_sizeW, CIM_UINT64 }
441 static const struct column col_diskpartition[] =
443 { prop_bootableW, CIM_BOOLEAN },
444 { prop_bootpartitionW, CIM_BOOLEAN },
445 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
446 { prop_diskindexW, CIM_UINT32, VT_I4 },
447 { prop_indexW, CIM_UINT32, VT_I4 },
448 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
449 { prop_sizeW, CIM_UINT64 },
450 { prop_startingoffsetW, CIM_UINT64 },
451 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
453 static const struct column col_logicaldisk[] =
455 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
456 { prop_drivetypeW, CIM_UINT32, VT_I4 },
457 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
458 { prop_freespaceW, CIM_UINT64 },
459 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
460 { prop_sizeW, CIM_UINT64 },
461 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
462 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
464 static const struct column col_networkadapter[] =
466 { prop_adaptertypeW, CIM_STRING },
467 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
468 { prop_indexW, CIM_UINT32, VT_I4 },
469 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
470 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
471 { prop_manufacturerW, CIM_STRING },
472 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
473 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
474 { prop_physicaladapterW, CIM_BOOLEAN },
475 { prop_pnpdeviceidW, CIM_STRING },
476 { prop_speedW, CIM_UINT64 }
478 static const struct column col_networkadapterconfig[] =
480 { prop_defaultipgatewayW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
481 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
482 { prop_dhcpenabledW, CIM_BOOLEAN },
483 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
484 { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
485 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
486 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
487 { prop_ipenabledW, CIM_BOOLEAN },
488 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC }
490 static const struct column col_os[] =
492 { prop_buildnumberW, CIM_STRING },
493 { prop_captionW, CIM_STRING },
494 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
495 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
496 { prop_csdversionW, CIM_STRING },
497 { prop_installdateW, CIM_DATETIME },
498 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
499 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
500 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
501 { prop_nameW, CIM_STRING },
502 { prop_osarchitectureW, CIM_STRING },
503 { prop_oslanguageW, CIM_UINT32, VT_I4 },
504 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
505 { prop_ostypeW, CIM_UINT16, VT_I4 },
506 { prop_primaryW, CIM_BOOLEAN },
507 { prop_serialnumberW, CIM_STRING },
508 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
509 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
510 { prop_suitemaskW, CIM_UINT32, VT_I4 },
511 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
512 { prop_totalvisiblememorysizeW, CIM_UINT64 },
513 { prop_versionW, CIM_STRING }
515 static const struct column col_param[] =
517 { prop_classW, CIM_STRING },
518 { prop_methodW, CIM_STRING },
519 { prop_directionW, CIM_SINT32 },
520 { prop_parameterW, CIM_STRING },
521 { prop_typeW, CIM_UINT32 },
522 { prop_varianttypeW, CIM_UINT32 },
523 { prop_defaultvalueW, CIM_UINT32 }
525 static const struct column col_physicalmedia[] =
527 { prop_serialnumberW, CIM_STRING },
528 { prop_tagW, CIM_STRING }
530 static const struct column col_physicalmemory[] =
532 { prop_capacityW, CIM_UINT64 }
534 static const struct column col_printer[] =
536 { prop_attributesW, CIM_UINT32 },
537 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
538 { prop_horizontalresolutionW, CIM_UINT32 },
539 { prop_localW, CIM_BOOLEAN },
540 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
541 { prop_networkW, CIM_BOOLEAN }
543 static const struct column col_process[] =
545 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
546 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
547 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
548 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
549 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
550 { prop_pprocessidW, CIM_UINT32, VT_I4 },
551 { prop_processidW, CIM_UINT32, VT_I4 },
552 { prop_threadcountW, CIM_UINT32, VT_I4 },
553 { prop_workingsetsizeW, CIM_UINT64 },
554 /* methods */
555 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
557 static const struct column col_processor[] =
559 { prop_addresswidthW, CIM_UINT16, VT_I4 },
560 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
561 { prop_cpustatusW, CIM_UINT16 },
562 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
563 { prop_datawidthW, CIM_UINT16, VT_I4 },
564 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
565 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
566 { prop_familyW, CIM_UINT16, VT_I4 },
567 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
568 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
569 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
570 { prop_numcoresW, CIM_UINT32, VT_I4 },
571 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
572 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
573 { prop_processortypeW, CIM_UINT16, VT_I4 },
574 { prop_uniqueidW, CIM_STRING },
575 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
577 static const struct column col_qualifier[] =
579 { prop_classW, CIM_STRING },
580 { prop_memberW, CIM_STRING },
581 { prop_typeW, CIM_UINT32 },
582 { prop_flavorW, CIM_SINT32 },
583 { prop_nameW, CIM_STRING },
584 { prop_intvalueW, CIM_SINT32 },
585 { prop_strvalueW, CIM_STRING }
587 static const struct column col_service[] =
589 { prop_acceptpauseW, CIM_BOOLEAN },
590 { prop_acceptstopW, CIM_BOOLEAN },
591 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
592 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
593 { prop_processidW, CIM_UINT32 },
594 { prop_servicetypeW, CIM_STRING },
595 { prop_startmodeW, CIM_STRING },
596 { prop_stateW, CIM_STRING },
597 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
598 /* methods */
599 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
600 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
601 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
602 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
604 static const struct column col_sid[] =
606 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
607 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
608 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
609 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
610 { prop_sidlengthW, CIM_UINT32 }
612 static const struct column col_sounddevice[] =
614 { prop_nameW, CIM_STRING },
615 { prop_productnameW, CIM_STRING },
616 { prop_statusinfoW, CIM_UINT16, VT_I4 }
618 static const struct column col_stdregprov[] =
620 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
621 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
622 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
624 static const struct column col_systemenclosure[] =
626 { prop_captionW, CIM_STRING },
627 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY },
628 { prop_descriptionW, CIM_STRING },
629 { prop_lockpresentW, CIM_BOOLEAN },
630 { prop_manufacturerW, CIM_STRING },
631 { prop_nameW, CIM_STRING },
632 { prop_tagW, CIM_STRING },
634 static const struct column col_systemsecurity[] =
636 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
637 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
639 static const struct column col_videocontroller[] =
641 { prop_adapterdactypeW, CIM_STRING },
642 { prop_adapterramW, CIM_UINT32, VT_I4 },
643 { prop_availabilityW, CIM_UINT16 },
644 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
645 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
646 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
647 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
648 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
649 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
650 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
651 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
652 { prop_driverversionW, CIM_STRING },
653 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
654 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
655 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
656 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
657 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC }
660 static const WCHAR baseboard_manufacturerW[] =
661 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
662 static const WCHAR baseboard_serialnumberW[] =
663 {'N','o','n','e',0};
664 static const WCHAR baseboard_tagW[] =
665 {'B','a','s','e',' ','B','o','a','r','d',0};
666 static const WCHAR baseboard_versionW[] =
667 {'1','.','0',0};
668 static const WCHAR bios_descriptionW[] =
669 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
670 static const WCHAR bios_manufacturerW[] =
671 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
672 static const WCHAR bios_nameW[] =
673 {'W','I','N','E',' ','B','I','O','S',0};
674 static const WCHAR bios_releasedateW[] =
675 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
676 static const WCHAR bios_serialnumberW[] =
677 {'0',0};
678 static const WCHAR bios_smbiosbiosversionW[] =
679 {'W','i','n','e',0};
680 static const WCHAR bios_versionW[] =
681 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
682 static const WCHAR cdromdrive_mediatypeW[] =
683 {'C','D','-','R','O','M',0};
684 static const WCHAR cdromdrive_nameW[] =
685 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
686 static const WCHAR cdromdrive_pnpdeviceidW[]=
687 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
688 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
689 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
690 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
691 static const WCHAR compsys_descriptionW[] =
692 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
693 static const WCHAR compsys_domainW[] =
694 {'W','O','R','K','G','R','O','U','P',0};
695 static const WCHAR compsys_manufacturerW[] =
696 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
697 static const WCHAR compsys_modelW[] =
698 {'W','i','n','e',0};
699 static const WCHAR compsysproduct_identifyingnumberW[] =
700 {'0',0};
701 static const WCHAR compsysproduct_uuidW[] =
702 {'0','0','0','0','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-','0','0','0','0','-',
703 '0','0','0','0','0','0','0','0','0','0','0','0',0};
704 static const WCHAR diskdrive_interfacetypeW[] =
705 {'I','D','E',0};
706 static const WCHAR diskdrive_manufacturerW[] =
707 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
708 static const WCHAR diskdrive_mediatype_fixedW[] =
709 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
710 static const WCHAR diskdrive_mediatype_removableW[] =
711 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
712 static const WCHAR diskdrive_modelW[] =
713 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
714 static const WCHAR diskdrive_pnpdeviceidW[] =
715 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
716 static const WCHAR diskdrive_serialW[] =
717 {'W','I','N','E','H','D','I','S','K',0};
718 static const WCHAR networkadapter_pnpdeviceidW[]=
719 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
720 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
721 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
722 static const WCHAR os_32bitW[] =
723 {'3','2','-','b','i','t',0};
724 static const WCHAR os_64bitW[] =
725 {'6','4','-','b','i','t',0};
726 static const WCHAR os_buildnumberW[] =
727 {'2','6','0','0',0};
728 static const WCHAR os_captionW[] =
729 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
730 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
731 static const WCHAR os_csdversionW[] =
732 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
733 static const WCHAR os_installdateW[] =
734 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
735 static const WCHAR os_nameW[] =
736 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
737 'P','r','o','f','e','s','s','i','o','n','a','l','|','C',':','\\','W','I','N','D','O','W','S',
738 '|','\\','D','e','v','i','c','e','\\','H','a','r','d','d','i','s','k','0',
739 '\\','P','a','r','t','i','t','i','o','n','1',0};
740 static const WCHAR os_serialnumberW[] =
741 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
742 static const WCHAR os_versionW[] =
743 {'5','.','1','.','2','6','0','0',0};
744 static const WCHAR physicalmedia_tagW[] =
745 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
746 static const WCHAR sounddevice_productnameW[] =
747 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
748 static const WCHAR systemenclosure_systemenclosureW[] =
749 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
750 static const WCHAR systemenclosure_tagW[] =
751 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
752 static const WCHAR systemenclosure_manufacturerW[] =
753 {'W','i','n','e',0};
754 static const WCHAR videocontroller_dactypeW[] =
755 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
756 static const WCHAR videocontroller_deviceidW[] =
757 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
758 static const WCHAR videocontroller_driverversionW[] =
759 {'1','.','0',0};
761 #include "pshpack1.h"
762 struct record_baseboard
764 const WCHAR *manufacturer;
765 const WCHAR *model;
766 const WCHAR *name;
767 const WCHAR *product;
768 const WCHAR *serialnumber;
769 const WCHAR *tag;
770 const WCHAR *version;
772 struct record_bios
774 const WCHAR *description;
775 const WCHAR *identificationcode;
776 const WCHAR *manufacturer;
777 const WCHAR *name;
778 const WCHAR *releasedate;
779 const WCHAR *serialnumber;
780 const WCHAR *smbiosbiosversion;
781 const WCHAR *version;
783 struct record_cdromdrive
785 const WCHAR *device_id;
786 const WCHAR *drive;
787 const WCHAR *mediatype;
788 const WCHAR *name;
789 const WCHAR *pnpdevice_id;
791 struct record_computersystem
793 const WCHAR *description;
794 const WCHAR *domain;
795 UINT16 domainrole;
796 const WCHAR *manufacturer;
797 const WCHAR *model;
798 const WCHAR *name;
799 UINT32 num_logical_processors;
800 UINT32 num_processors;
801 UINT64 total_physical_memory;
802 const WCHAR *username;
804 struct record_computersystemproduct
806 const WCHAR *identifyingnumber;
807 const WCHAR *uuid;
809 struct record_datafile
811 const WCHAR *name;
812 const WCHAR *version;
814 struct record_desktopmonitor
816 UINT32 pixelsperxlogicalinch;
818 struct record_directory
820 UINT32 accessmask;
821 const WCHAR *name;
823 struct record_diskdrive
825 const WCHAR *device_id;
826 UINT32 index;
827 const WCHAR *interfacetype;
828 const WCHAR *manufacturer;
829 const WCHAR *mediatype;
830 const WCHAR *model;
831 const WCHAR *pnpdevice_id;
832 const WCHAR *serialnumber;
833 UINT64 size;
835 struct record_diskpartition
837 int bootable;
838 int bootpartition;
839 const WCHAR *device_id;
840 UINT32 diskindex;
841 UINT32 index;
842 const WCHAR *pnpdevice_id;
843 UINT64 size;
844 UINT64 startingoffset;
845 const WCHAR *type;
847 struct record_logicaldisk
849 const WCHAR *device_id;
850 UINT32 drivetype;
851 const WCHAR *filesystem;
852 UINT64 freespace;
853 const WCHAR *name;
854 UINT64 size;
855 const WCHAR *volumename;
856 const WCHAR *volumeserialnumber;
858 struct record_networkadapter
860 const WCHAR *adaptertype;
861 const WCHAR *device_id;
862 UINT32 index;
863 UINT32 interface_index;
864 const WCHAR *mac_address;
865 const WCHAR *manufacturer;
866 const WCHAR *name;
867 UINT16 netconnection_status;
868 int physicaladapter;
869 const WCHAR *pnpdevice_id;
870 UINT64 speed;
872 struct record_networkadapterconfig
874 const struct array *defaultipgateway;
875 const WCHAR *description;
876 int dhcpenabled;
877 const WCHAR *dnshostname;
878 const struct array *dnsserversearchorder;
879 UINT32 index;
880 UINT32 ipconnectionmetric;
881 int ipenabled;
882 const WCHAR *mac_address;
884 struct record_operatingsystem
886 const WCHAR *buildnumber;
887 const WCHAR *caption;
888 const WCHAR *codeset;
889 const WCHAR *countrycode;
890 const WCHAR *csdversion;
891 const WCHAR *installdate;
892 const WCHAR *lastbootuptime;
893 const WCHAR *localdatetime;
894 const WCHAR *locale;
895 const WCHAR *name;
896 const WCHAR *osarchitecture;
897 UINT32 oslanguage;
898 UINT32 osproductsuite;
899 UINT16 ostype;
900 int primary;
901 const WCHAR *serialnumber;
902 UINT16 servicepackmajor;
903 UINT16 servicepackminor;
904 UINT32 suitemask;
905 const WCHAR *systemdirectory;
906 UINT64 totalvisiblememorysize;
907 const WCHAR *version;
909 struct record_param
911 const WCHAR *class;
912 const WCHAR *method;
913 INT32 direction;
914 const WCHAR *parameter;
915 UINT32 type;
916 UINT32 varianttype;
917 UINT32 defaultvalue;
919 struct record_physicalmedia
921 const WCHAR *serialnumber;
922 const WCHAR *tag;
924 struct record_physicalmemory
926 UINT64 capacity;
928 struct record_printer
930 UINT32 attributes;
931 const WCHAR *drivername;
932 UINT32 horizontalresolution;
933 int local;
934 const WCHAR *name;
935 int network;
937 struct record_process
939 const WCHAR *caption;
940 const WCHAR *commandline;
941 const WCHAR *description;
942 const WCHAR *handle;
943 const WCHAR *name;
944 UINT32 pprocess_id;
945 UINT32 process_id;
946 UINT32 thread_count;
947 UINT64 workingsetsize;
948 /* methods */
949 class_method *get_owner;
951 struct record_processor
953 UINT16 addresswidth;
954 const WCHAR *caption;
955 UINT16 cpu_status;
956 UINT32 currentclockspeed;
957 UINT16 datawidth;
958 const WCHAR *description;
959 const WCHAR *device_id;
960 UINT16 family;
961 const WCHAR *manufacturer;
962 UINT32 maxclockspeed;
963 const WCHAR *name;
964 UINT32 num_cores;
965 UINT32 num_logical_processors;
966 const WCHAR *processor_id;
967 UINT16 processortype;
968 const WCHAR *unique_id;
969 const WCHAR *version;
971 struct record_qualifier
973 const WCHAR *class;
974 const WCHAR *member;
975 UINT32 type;
976 INT32 flavor;
977 const WCHAR *name;
978 INT32 intvalue;
979 const WCHAR *strvalue;
981 struct record_service
983 int accept_pause;
984 int accept_stop;
985 const WCHAR *displayname;
986 const WCHAR *name;
987 UINT32 process_id;
988 const WCHAR *servicetype;
989 const WCHAR *startmode;
990 const WCHAR *state;
991 const WCHAR *systemname;
992 /* methods */
993 class_method *pause_service;
994 class_method *resume_service;
995 class_method *start_service;
996 class_method *stop_service;
998 struct record_sid
1000 const WCHAR *accountname;
1001 const struct array *binaryrepresentation;
1002 const WCHAR *referenceddomainname;
1003 const WCHAR *sid;
1004 UINT32 sidlength;
1006 struct record_sounddevice
1008 const WCHAR *name;
1009 const WCHAR *productname;
1010 UINT16 statusinfo;
1012 struct record_stdregprov
1014 class_method *enumkey;
1015 class_method *enumvalues;
1016 class_method *getstringvalue;
1018 struct record_systemsecurity
1020 class_method *getsd;
1021 class_method *setsd;
1023 struct record_systemenclosure
1025 const WCHAR *caption;
1026 const struct array *chassistypes;
1027 const WCHAR *description;
1028 int lockpresent;
1029 const WCHAR *manufacturer;
1030 const WCHAR *name;
1031 const WCHAR *tag;
1033 struct record_videocontroller
1035 const WCHAR *adapter_dactype;
1036 UINT32 adapter_ram;
1037 UINT16 availability;
1038 const WCHAR *caption;
1039 UINT32 current_bitsperpixel;
1040 UINT32 current_horizontalres;
1041 UINT32 current_refreshrate;
1042 UINT16 current_scanmode;
1043 UINT32 current_verticalres;
1044 const WCHAR *description;
1045 const WCHAR *device_id;
1046 const WCHAR *driverversion;
1047 const WCHAR *name;
1048 const WCHAR *pnpdevice_id;
1049 UINT16 videoarchitecture;
1050 UINT16 videomemorytype;
1051 const WCHAR *videoprocessor;
1053 #include "poppack.h"
1055 static const struct record_baseboard data_baseboard[] =
1057 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1059 static const struct record_bios data_bios[] =
1061 { bios_descriptionW, bios_descriptionW, bios_manufacturerW, bios_nameW, bios_releasedateW, bios_serialnumberW,
1062 bios_smbiosbiosversionW, bios_versionW }
1064 static const struct record_computersystemproduct data_compsysproduct[] =
1066 { compsysproduct_identifyingnumberW, compsysproduct_uuidW }
1068 static const struct record_param data_param[] =
1070 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1071 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1072 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1073 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1074 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1075 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1076 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1077 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1078 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1079 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1080 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1081 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1082 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1083 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1084 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1085 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1086 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1087 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1088 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1089 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1090 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1091 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1092 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1093 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1094 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1097 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1098 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1100 static const struct record_physicalmedia data_physicalmedia[] =
1102 { diskdrive_serialW, physicalmedia_tagW }
1104 static const struct record_qualifier data_qualifier[] =
1106 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1107 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1109 static const struct record_sounddevice data_sounddevice[] =
1111 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1113 static const struct record_stdregprov data_stdregprov[] =
1115 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1117 static UINT16 systemenclosure_chassistypes[] =
1121 static const struct array systemenclosure_chassistypes_array =
1123 SIZEOF(systemenclosure_chassistypes),
1124 &systemenclosure_chassistypes
1126 static const struct record_systemenclosure data_systemenclosure[] =
1129 systemenclosure_systemenclosureW,
1130 &systemenclosure_chassistypes_array,
1131 systemenclosure_systemenclosureW,
1132 FALSE,
1133 systemenclosure_manufacturerW,
1134 systemenclosure_systemenclosureW,
1135 systemenclosure_tagW,
1138 static const struct record_systemsecurity data_systemsecurity[] =
1140 { security_get_sd, security_set_sd }
1143 /* check if row matches condition and update status */
1144 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1146 LONGLONG val;
1147 UINT type;
1149 if (!cond)
1151 *status = FILL_STATUS_UNFILTERED;
1152 return TRUE;
1154 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1156 *status = FILL_STATUS_FAILED;
1157 return FALSE;
1159 *status = FILL_STATUS_FILTERED;
1160 return val != 0;
1163 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1165 if (!table->num_rows_allocated)
1167 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1168 table->num_rows_allocated = row_count;
1169 return TRUE;
1171 if (row_count > table->num_rows_allocated)
1173 BYTE *data;
1174 UINT count = max( row_count, table->num_rows_allocated * 2 );
1175 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1176 table->data = data;
1177 table->num_rows_allocated = count;
1179 return TRUE;
1182 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1184 static const WCHAR fmtW[] = {'%','c',':',0};
1185 WCHAR drive[3], root[] = {'A',':','\\',0};
1186 struct record_cdromdrive *rec;
1187 UINT i, row = 0, offset = 0;
1188 DWORD drives = GetLogicalDrives();
1189 enum fill_status status = FILL_STATUS_UNFILTERED;
1191 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1193 for (i = 0; i < 26; i++)
1195 if (drives & (1 << i))
1197 root[0] = 'A' + i;
1198 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1199 continue;
1201 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1203 rec = (struct record_cdromdrive *)(table->data + offset);
1204 rec->device_id = cdromdrive_pnpdeviceidW;
1205 sprintfW( drive, fmtW, 'A' + i );
1206 rec->drive = heap_strdupW( drive );
1207 rec->mediatype = cdromdrive_mediatypeW;
1208 rec->name = cdromdrive_nameW;
1209 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1210 if (!match_row( table, row, cond, &status ))
1212 free_row_values( table, row );
1213 continue;
1215 offset += sizeof(*rec);
1216 row++;
1219 TRACE("created %u rows\n", row);
1220 table->num_rows = row;
1221 return status;
1224 static UINT get_processor_count(void)
1226 SYSTEM_BASIC_INFORMATION info;
1228 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1229 return info.NumberOfProcessors;
1232 static UINT get_logical_processor_count( UINT *num_cores )
1234 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1235 UINT i, j, count = 0;
1236 NTSTATUS status;
1237 ULONG len;
1239 if (num_cores) *num_cores = get_processor_count();
1240 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1241 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1243 if (!(info = heap_alloc( len ))) return get_processor_count();
1244 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1245 if (status != STATUS_SUCCESS)
1247 heap_free( info );
1248 return get_processor_count();
1250 if (num_cores) *num_cores = 0;
1251 for (i = 0; i < len / sizeof(*info); i++)
1253 if (info[i].Relationship == RelationProcessorCore)
1255 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1257 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1259 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1262 heap_free( info );
1263 return count;
1266 static UINT64 get_total_physical_memory(void)
1268 MEMORYSTATUSEX status;
1270 status.dwLength = sizeof(status);
1271 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1272 return status.ullTotalPhys;
1275 static WCHAR *get_computername(void)
1277 WCHAR *ret;
1278 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1280 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1281 GetComputerNameW( ret, &size );
1282 return ret;
1285 static WCHAR *get_username(void)
1287 WCHAR *ret;
1288 DWORD compsize, usersize;
1289 DWORD size;
1291 compsize = 0;
1292 GetComputerNameW( NULL, &compsize );
1293 usersize = 0;
1294 GetUserNameW( NULL, &usersize );
1295 size = compsize + usersize; /* two null terminators account for the \ */
1296 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1297 GetComputerNameW( ret, &compsize );
1298 ret[compsize] = '\\';
1299 GetUserNameW( ret + compsize + 1, &usersize );
1300 return ret;
1303 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1305 struct record_computersystem *rec;
1306 enum fill_status status = FILL_STATUS_UNFILTERED;
1307 UINT row = 0;
1309 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1311 rec = (struct record_computersystem *)table->data;
1312 rec->description = compsys_descriptionW;
1313 rec->domain = compsys_domainW;
1314 rec->domainrole = 0; /* standalone workstation */
1315 rec->manufacturer = compsys_manufacturerW;
1316 rec->model = compsys_modelW;
1317 rec->name = get_computername();
1318 rec->num_logical_processors = get_logical_processor_count( NULL );
1319 rec->num_processors = get_processor_count();
1320 rec->total_physical_memory = get_total_physical_memory();
1321 rec->username = get_username();
1322 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1323 else row++;
1325 TRACE("created %u rows\n", row);
1326 table->num_rows = row;
1327 return status;
1330 struct dirstack
1332 WCHAR **dirs;
1333 UINT *len_dirs;
1334 UINT num_dirs;
1335 UINT num_allocated;
1338 static struct dirstack *alloc_dirstack( UINT size )
1340 struct dirstack *dirstack;
1342 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1343 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1345 heap_free( dirstack );
1346 return NULL;
1348 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1350 heap_free( dirstack->dirs );
1351 heap_free( dirstack );
1352 return NULL;
1354 dirstack->num_dirs = 0;
1355 dirstack->num_allocated = size;
1356 return dirstack;
1359 static void clear_dirstack( struct dirstack *dirstack )
1361 UINT i;
1362 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1363 dirstack->num_dirs = 0;
1366 static void free_dirstack( struct dirstack *dirstack )
1368 clear_dirstack( dirstack );
1369 heap_free( dirstack->dirs );
1370 heap_free( dirstack->len_dirs );
1371 heap_free( dirstack );
1374 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1376 UINT size, i = dirstack->num_dirs;
1378 if (!dir) return FALSE;
1380 if (i == dirstack->num_allocated)
1382 WCHAR **tmp;
1383 UINT *len_tmp;
1385 size = dirstack->num_allocated * 2;
1386 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1387 dirstack->dirs = tmp;
1388 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1389 dirstack->len_dirs = len_tmp;
1390 dirstack->num_allocated = size;
1392 dirstack->dirs[i] = dir;
1393 dirstack->len_dirs[i] = len;
1394 dirstack->num_dirs++;
1395 return TRUE;
1398 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1400 if (!dirstack->num_dirs)
1402 *len = 0;
1403 return NULL;
1405 dirstack->num_dirs--;
1406 *len = dirstack->len_dirs[dirstack->num_dirs];
1407 return dirstack->dirs[dirstack->num_dirs];
1410 static const WCHAR *peek_dir( struct dirstack *dirstack )
1412 if (!dirstack->num_dirs) return NULL;
1413 return dirstack->dirs[dirstack->num_dirs - 1];
1416 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1418 UINT i = 0;
1419 WCHAR *ret;
1421 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1422 ret[i++] = drive;
1423 ret[i++] = ':';
1424 ret[i++] = '\\';
1425 if (path && len)
1427 memcpy( ret + i, path, len * sizeof(WCHAR) );
1428 i += len;
1429 ret[i++] = '\\';
1431 ret[i++] = '*';
1432 ret[i] = 0;
1433 return ret;
1436 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1438 UINT i = 0, len = 0;
1439 const WCHAR *p;
1440 WCHAR *ret;
1442 for (p = path; *p; p++)
1444 if (*p == '\\') len += 2;
1445 else len++;
1447 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1448 ret[i++] = drive;
1449 ret[i++] = ':';
1450 ret[i++] = '\\';
1451 ret[i++] = '\\';
1452 for (p = path; *p; p++)
1454 if (*p != '\\') ret[i++] = *p;
1455 else
1457 ret[i++] = '\\';
1458 ret[i++] = '\\';
1461 ret[i] = 0;
1462 return ret;
1465 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1467 const WCHAR *p = path, *start;
1468 UINT len, i;
1469 WCHAR *ret;
1471 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1472 start = path + 4;
1473 len = strlenW( start );
1474 p = start + len - 1;
1475 if (*p == '\\') return NULL;
1477 while (p >= start && *p != '\\') { len--; p--; };
1478 while (p >= start && *p == '\\') { len--; p--; };
1480 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1481 for (i = 0, p = start; p < start + len; p++)
1483 if (p[0] == '\\' && p[1] == '\\')
1485 ret[i++] = '\\';
1486 p++;
1488 else ret[i++] = *p;
1490 ret[i] = 0;
1491 *ret_len = i;
1492 return ret;
1495 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1497 UINT i;
1498 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1499 return FALSE;
1502 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1503 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1505 const struct expr *left, *right;
1507 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1509 left = cond->u.expr.left;
1510 right = cond->u.expr.right;
1511 if (cond->u.expr.op == OP_EQ)
1513 UINT len;
1514 WCHAR *path;
1515 const WCHAR *str = NULL;
1517 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1518 !strcmpW( left->u.propval->name, prop_nameW ) &&
1519 toupperW( right->u.sval[0] ) == toupperW( root ))
1521 str = right->u.sval;
1523 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1524 !strcmpW( right->u.propval->name, prop_nameW ) &&
1525 toupperW( left->u.sval[0] ) == toupperW( root ))
1527 str = left->u.sval;
1529 if (str && (path = build_dirname( str, &len )))
1531 if (seen_dir( dirstack, path ))
1533 heap_free( path );
1534 return ++*count;
1536 else if (push_dir( dirstack, path, len )) return ++*count;
1537 heap_free( path );
1538 return *count = 0;
1541 else if (cond->u.expr.op == OP_OR)
1543 UINT left_count = 0, right_count = 0;
1545 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1546 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1547 return *count += left_count + right_count;
1549 return *count = 0;
1552 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1554 UINT len_path = 0, len_segment = strlenW( segment );
1555 WCHAR *ret;
1557 *len = 0;
1558 if (path) len_path = strlenW( path );
1559 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1560 if (path && len_path)
1562 memcpy( ret, path, len_path * sizeof(WCHAR) );
1563 ret[len_path] = '\\';
1564 *len += len_path + 1;
1566 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1567 *len += len_segment;
1568 ret[*len] = 0;
1569 return ret;
1572 static WCHAR *get_file_version( const WCHAR *filename )
1574 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1575 VS_FIXEDFILEINFO *info;
1576 DWORD size;
1577 void *block;
1578 WCHAR *ret;
1580 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1581 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1583 heap_free( ret );
1584 return NULL;
1586 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1587 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1589 heap_free( block );
1590 heap_free( ret );
1591 return NULL;
1593 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1594 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1595 heap_free( block );
1596 return ret;
1599 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1601 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1602 struct record_datafile *rec;
1603 UINT i, len, row = 0, offset = 0, num_expected_rows;
1604 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1605 DWORD drives = GetLogicalDrives();
1606 WIN32_FIND_DATAW data;
1607 HANDLE handle;
1608 struct dirstack *dirstack;
1609 enum fill_status status = FILL_STATUS_UNFILTERED;
1611 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1613 dirstack = alloc_dirstack(2);
1615 for (i = 0; i < 26; i++)
1617 if (!(drives & (1 << i))) continue;
1619 root[0] = 'A' + i;
1620 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1622 num_expected_rows = 0;
1623 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1625 for (;;)
1627 heap_free( glob );
1628 heap_free( path );
1629 path = pop_dir( dirstack, &len );
1630 if (!(glob = build_glob( root[0], path, len )))
1632 status = FILL_STATUS_FAILED;
1633 goto done;
1635 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1639 if (!resize_table( table, row + 1, sizeof(*rec) ))
1641 status = FILL_STATUS_FAILED;
1642 FindClose( handle );
1643 goto done;
1645 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1646 new_path = append_path( path, data.cFileName, &len );
1648 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1650 if (push_dir( dirstack, new_path, len )) continue;
1651 heap_free( new_path );
1652 FindClose( handle );
1653 status = FILL_STATUS_FAILED;
1654 goto done;
1656 rec = (struct record_datafile *)(table->data + offset);
1657 rec->name = build_name( root[0], new_path );
1658 rec->version = get_file_version( rec->name );
1659 if (!match_row( table, row, cond, &status ))
1661 free_row_values( table, row );
1662 continue;
1664 else if (num_expected_rows && row == num_expected_rows - 1)
1666 row++;
1667 FindClose( handle );
1668 status = FILL_STATUS_FILTERED;
1669 goto done;
1671 offset += sizeof(*rec);
1672 row++;
1674 while (FindNextFileW( handle, &data ));
1675 FindClose( handle );
1677 if (!peek_dir( dirstack )) break;
1681 done:
1682 free_dirstack( dirstack );
1683 heap_free( glob );
1684 heap_free( path );
1686 TRACE("created %u rows\n", row);
1687 table->num_rows = row;
1688 return status;
1691 static UINT32 get_pixelsperxlogicalinch(void)
1693 HDC hdc = GetDC( NULL );
1694 UINT32 ret;
1696 if (!hdc) return 96;
1697 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1698 ReleaseDC( NULL, hdc );
1699 return ret;
1702 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1704 struct record_desktopmonitor *rec;
1705 enum fill_status status = FILL_STATUS_UNFILTERED;
1706 UINT row = 0;
1708 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1710 rec = (struct record_desktopmonitor *)table->data;
1711 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1713 if (match_row( table, row, cond, &status )) row++;
1715 TRACE("created %u rows\n", row);
1716 table->num_rows = row;
1717 return status;
1720 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1722 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1723 struct record_directory *rec;
1724 UINT i, len, row = 0, offset = 0, num_expected_rows;
1725 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1726 DWORD drives = GetLogicalDrives();
1727 WIN32_FIND_DATAW data;
1728 HANDLE handle;
1729 struct dirstack *dirstack;
1730 enum fill_status status = FILL_STATUS_UNFILTERED;
1732 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1734 dirstack = alloc_dirstack(2);
1736 for (i = 0; i < 26; i++)
1738 if (!(drives & (1 << i))) continue;
1740 root[0] = 'A' + i;
1741 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1743 num_expected_rows = 0;
1744 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1746 for (;;)
1748 heap_free( glob );
1749 heap_free( path );
1750 path = pop_dir( dirstack, &len );
1751 if (!(glob = build_glob( root[0], path, len )))
1753 status = FILL_STATUS_FAILED;
1754 goto done;
1756 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1760 if (!resize_table( table, row + 1, sizeof(*rec) ))
1762 FindClose( handle );
1763 status = FILL_STATUS_FAILED;
1764 goto done;
1766 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1767 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1768 continue;
1770 new_path = append_path( path, data.cFileName, &len );
1771 if (!(push_dir( dirstack, new_path, len )))
1773 heap_free( new_path );
1774 FindClose( handle );
1775 status = FILL_STATUS_FAILED;
1776 goto done;
1778 rec = (struct record_directory *)(table->data + offset);
1779 rec->accessmask = FILE_ALL_ACCESS;
1780 rec->name = build_name( root[0], new_path );
1781 if (!match_row( table, row, cond, &status ))
1783 free_row_values( table, row );
1784 continue;
1786 else if (num_expected_rows && row == num_expected_rows - 1)
1788 row++;
1789 FindClose( handle );
1790 status = FILL_STATUS_FILTERED;
1791 goto done;
1793 offset += sizeof(*rec);
1794 row++;
1796 while (FindNextFileW( handle, &data ));
1797 FindClose( handle );
1799 if (!peek_dir( dirstack )) break;
1803 done:
1804 free_dirstack( dirstack );
1805 heap_free( glob );
1806 heap_free( path );
1808 TRACE("created %u rows\n", row);
1809 table->num_rows = row;
1810 return status;
1813 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1815 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1816 ULARGE_INTEGER free;
1817 DISK_GEOMETRY_EX info;
1818 HANDLE handle;
1819 DWORD bytes_returned;
1821 free.QuadPart = 512 * 1024 * 1024;
1822 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1824 root[4] = dir[0];
1825 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1826 if (handle != INVALID_HANDLE_VALUE)
1828 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1829 *disksize = info.DiskSize.QuadPart;
1830 CloseHandle( handle );
1832 return free.QuadPart;
1835 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1837 static const WCHAR fmtW[] =
1838 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
1839 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
1840 struct record_diskdrive *rec;
1841 UINT i, row = 0, offset = 0, index = 0, type;
1842 UINT64 size = 1024 * 1024 * 1024;
1843 DWORD drives = GetLogicalDrives();
1844 enum fill_status status = FILL_STATUS_UNFILTERED;
1846 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
1848 for (i = 0; i < 26; i++)
1850 if (drives & (1 << i))
1852 root[0] = 'A' + i;
1853 type = GetDriveTypeW( root );
1854 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1855 continue;
1857 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1859 rec = (struct record_diskdrive *)(table->data + offset);
1860 sprintfW( device_id, fmtW, index );
1861 rec->device_id = heap_strdupW( device_id );
1862 rec->index = index;
1863 rec->interfacetype = diskdrive_interfacetypeW;
1864 rec->manufacturer = diskdrive_manufacturerW;
1865 if (type == DRIVE_FIXED)
1866 rec->mediatype = diskdrive_mediatype_fixedW;
1867 else
1868 rec->mediatype = diskdrive_mediatype_removableW;
1869 rec->model = diskdrive_modelW;
1870 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
1871 rec->serialnumber = diskdrive_serialW;
1872 get_freespace( root, &size );
1873 rec->size = size;
1874 if (!match_row( table, row, cond, &status ))
1876 free_row_values( table, row );
1877 continue;
1879 offset += sizeof(*rec);
1880 index++;
1881 row++;
1884 TRACE("created %u rows\n", row);
1885 table->num_rows = row;
1886 return status;
1889 static WCHAR *get_filesystem( const WCHAR *root )
1891 static const WCHAR ntfsW[] = {'N','T','F','S',0};
1892 WCHAR buffer[MAX_PATH + 1];
1894 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
1895 return heap_strdupW( buffer );
1896 return heap_strdupW( ntfsW );
1899 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1901 static const WCHAR fmtW[] =
1902 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1903 WCHAR device_id[32], root[] = {'A',':','\\',0};
1904 struct record_diskpartition *rec;
1905 UINT i, row = 0, offset = 0, type, index = 0;
1906 UINT64 size = 1024 * 1024 * 1024;
1907 DWORD drives = GetLogicalDrives();
1908 enum fill_status status = FILL_STATUS_UNFILTERED;
1910 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1912 for (i = 0; i < 26; i++)
1914 if (drives & (1 << i))
1916 root[0] = 'A' + i;
1917 type = GetDriveTypeW( root );
1918 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1919 continue;
1921 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1923 rec = (struct record_diskpartition *)(table->data + offset);
1924 rec->bootable = (i == 2) ? -1 : 0;
1925 rec->bootpartition = (i == 2) ? -1 : 0;
1926 sprintfW( device_id, fmtW, index );
1927 rec->device_id = heap_strdupW( device_id );
1928 rec->diskindex = index;
1929 rec->index = 0;
1930 rec->pnpdevice_id = heap_strdupW( device_id );
1931 get_freespace( root, &size );
1932 rec->size = size;
1933 rec->startingoffset = 0;
1934 rec->type = get_filesystem( root );
1935 if (!match_row( table, row, cond, &status ))
1937 free_row_values( table, row );
1938 continue;
1940 offset += sizeof(*rec);
1941 row++;
1942 index++;
1945 TRACE("created %u rows\n", row);
1946 table->num_rows = row;
1947 return status;
1950 static WCHAR *get_volumename( const WCHAR *root )
1952 WCHAR buf[MAX_PATH + 1] = {0};
1953 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
1954 return heap_strdupW( buf );
1956 static WCHAR *get_volumeserialnumber( const WCHAR *root )
1958 static const WCHAR fmtW[] = {'%','0','8','X',0};
1959 DWORD serial = 0;
1960 WCHAR buffer[9];
1962 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
1963 sprintfW( buffer, fmtW, serial );
1964 return heap_strdupW( buffer );
1967 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1969 static const WCHAR fmtW[] = {'%','c',':',0};
1970 WCHAR device_id[3], root[] = {'A',':','\\',0};
1971 struct record_logicaldisk *rec;
1972 UINT i, row = 0, offset = 0, type;
1973 UINT64 size = 1024 * 1024 * 1024;
1974 DWORD drives = GetLogicalDrives();
1975 enum fill_status status = FILL_STATUS_UNFILTERED;
1977 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1979 for (i = 0; i < 26; i++)
1981 if (drives & (1 << i))
1983 root[0] = 'A' + i;
1984 type = GetDriveTypeW( root );
1985 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1986 continue;
1988 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1990 rec = (struct record_logicaldisk *)(table->data + offset);
1991 sprintfW( device_id, fmtW, 'A' + i );
1992 rec->device_id = heap_strdupW( device_id );
1993 rec->drivetype = type;
1994 rec->filesystem = get_filesystem( root );
1995 rec->freespace = get_freespace( root, &size );
1996 rec->name = heap_strdupW( device_id );
1997 rec->size = size;
1998 rec->volumename = get_volumename( root );
1999 rec->volumeserialnumber = get_volumeserialnumber( root );
2000 if (!match_row( table, row, cond, &status ))
2002 free_row_values( table, row );
2003 continue;
2005 offset += sizeof(*rec);
2006 row++;
2009 TRACE("created %u rows\n", row);
2010 table->num_rows = row;
2011 return status;
2014 static UINT16 get_connection_status( IF_OPER_STATUS status )
2016 switch (status)
2018 case IfOperStatusDown:
2019 return 0; /* Disconnected */
2020 case IfOperStatusUp:
2021 return 2; /* Connected */
2022 default:
2023 ERR("unhandled status %u\n", status);
2024 break;
2026 return 0;
2028 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2030 static const WCHAR fmtW[] =
2031 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2032 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2033 WCHAR *ret;
2035 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2036 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2037 return ret;
2039 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2041 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2042 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2043 static const WCHAR firewireW[] = {'1','3','9','4',0};
2044 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2046 switch (type)
2048 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2049 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2050 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2051 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2052 default: *physical = 0; return NULL;
2056 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2058 static const WCHAR fmtW[] = {'%','u',0};
2059 WCHAR device_id[11];
2060 struct record_networkadapter *rec;
2061 IP_ADAPTER_ADDRESSES *aa, *buffer;
2062 UINT row = 0, offset = 0, count = 0;
2063 DWORD size = 0, ret;
2064 int physical;
2065 enum fill_status status = FILL_STATUS_UNFILTERED;
2067 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
2068 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2070 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2071 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
2073 heap_free( buffer );
2074 return FILL_STATUS_FAILED;
2076 for (aa = buffer; aa; aa = aa->Next)
2078 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2080 if (!resize_table( table, count, sizeof(*rec) ))
2082 heap_free( buffer );
2083 return FILL_STATUS_FAILED;
2085 for (aa = buffer; aa; aa = aa->Next)
2087 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2089 rec = (struct record_networkadapter *)(table->data + offset);
2090 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2091 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2092 rec->device_id = heap_strdupW( device_id );
2093 rec->index = aa->u.s.IfIndex;
2094 rec->interface_index = aa->u.s.IfIndex;
2095 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2096 rec->manufacturer = compsys_manufacturerW;
2097 rec->name = heap_strdupW( aa->FriendlyName );
2098 rec->netconnection_status = get_connection_status( aa->OperStatus );
2099 rec->physicaladapter = physical;
2100 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2101 rec->speed = 1000000;
2102 if (!match_row( table, row, cond, &status ))
2104 free_row_values( table, row );
2105 continue;
2107 offset += sizeof(*rec);
2108 row++;
2110 TRACE("created %u rows\n", row);
2111 table->num_rows = row;
2113 heap_free( buffer );
2114 return status;
2117 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2119 const SOCKET_ADDRESS *sa = &addr->Address;
2120 WCHAR buf[NI_MAXHOST];
2122 if (!addr) return NULL;
2123 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2124 0, NI_NAMEREQD )) return NULL;
2125 return heap_strdupW( buf );
2127 static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
2129 IP_ADAPTER_GATEWAY_ADDRESS *gateway;
2130 struct array *ret;
2131 ULONG buflen, i = 0, count = 0;
2132 WCHAR **ptr, buf[54]; /* max IPv6 address length */
2134 if (!list) return NULL;
2135 for (gateway = list; gateway; gateway = gateway->Next) count++;
2137 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2138 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2140 heap_free( ret );
2141 return NULL;
2143 for (gateway = list; gateway; gateway = gateway->Next)
2145 buflen = sizeof(buf)/sizeof(buf[0]);
2146 if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
2147 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2149 for (; i > 0; i--) heap_free( ptr[i - 1] );
2150 heap_free( ptr );
2151 heap_free( ret );
2152 return NULL;
2155 ret->count = count;
2156 ret->ptr = ptr;
2157 return ret;
2159 static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
2161 IP_ADAPTER_DNS_SERVER_ADDRESS *server;
2162 struct array *ret;
2163 ULONG buflen, i = 0, count = 0;
2164 WCHAR **ptr, *p, buf[54]; /* max IPv6 address length */
2166 if (!list) return NULL;
2167 for (server = list; server; server = server->Next) count++;
2169 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2170 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2172 heap_free( ret );
2173 return NULL;
2175 for (server = list; server; server = server->Next)
2177 buflen = sizeof(buf)/sizeof(buf[0]);
2178 if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
2179 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2181 for (; i > 0; i--) heap_free( ptr[i - 1] );
2182 heap_free( ptr );
2183 heap_free( ret );
2184 return NULL;
2186 if ((p = strrchrW( ptr[i - 1], ':' ))) *p = 0;
2188 ret->count = count;
2189 ret->ptr = ptr;
2190 return ret;
2193 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2195 struct record_networkadapterconfig *rec;
2196 IP_ADAPTER_ADDRESSES *aa, *buffer;
2197 UINT row = 0, offset = 0, count = 0;
2198 DWORD size = 0, ret;
2199 enum fill_status status = FILL_STATUS_UNFILTERED;
2201 ret = GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &size );
2202 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2204 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2205 if (GetAdaptersAddresses( AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, buffer, &size ))
2207 heap_free( buffer );
2208 return FILL_STATUS_FAILED;
2210 for (aa = buffer; aa; aa = aa->Next)
2212 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2214 if (!resize_table( table, count, sizeof(*rec) ))
2216 heap_free( buffer );
2217 return FILL_STATUS_FAILED;
2219 for (aa = buffer; aa; aa = aa->Next)
2221 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2223 rec = (struct record_networkadapterconfig *)(table->data + offset);
2224 rec->defaultipgateway = get_defaultipgateway( aa->FirstGatewayAddress );
2225 rec->description = heap_strdupW( aa->Description );
2226 rec->dhcpenabled = -1;
2227 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2228 rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress );
2229 rec->index = aa->u.s.IfIndex;
2230 rec->ipconnectionmetric = 20;
2231 rec->ipenabled = -1;
2232 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2233 if (!match_row( table, row, cond, &status ))
2235 free_row_values( table, row );
2236 continue;
2238 offset += sizeof(*rec);
2239 row++;
2241 TRACE("created %u rows\n", row);
2242 table->num_rows = row;
2244 heap_free( buffer );
2245 return status;
2248 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2250 struct record_physicalmemory *rec;
2251 enum fill_status status = FILL_STATUS_UNFILTERED;
2252 UINT row = 0;
2254 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2256 rec = (struct record_physicalmemory *)table->data;
2257 rec->capacity = get_total_physical_memory();
2258 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2259 else row++;
2261 TRACE("created %u rows\n", row);
2262 table->num_rows = row;
2263 return status;
2266 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2268 struct record_printer *rec;
2269 enum fill_status status = FILL_STATUS_UNFILTERED;
2270 PRINTER_INFO_2W *info;
2271 DWORD i, offset = 0, count = 0, size = 0;
2273 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2274 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2276 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2277 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2279 heap_free( info );
2280 return FILL_STATUS_FAILED;
2282 if (!resize_table( table, count, sizeof(*rec) ))
2284 heap_free( info );
2285 return FILL_STATUS_FAILED;
2288 for (i = 0; i < count; i++)
2290 rec = (struct record_printer *)(table->data + offset);
2291 rec->attributes = info[i].Attributes;
2292 rec->drivername = heap_strdupW( info[i].pDriverName );
2293 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2294 rec->local = -1;
2295 rec->name = heap_strdupW( info[i].pPrinterName );
2296 rec->network = 0;
2297 if (!match_row( table, i, cond, &status ))
2299 free_row_values( table, i );
2300 continue;
2302 offset += sizeof(*rec);
2304 TRACE("created %u rows\n", count);
2305 table->num_rows = count;
2307 heap_free( info );
2308 return status;
2311 static WCHAR *get_cmdline( DWORD process_id )
2313 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2314 return NULL; /* FIXME handle different process case */
2317 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2319 static const WCHAR fmtW[] = {'%','u',0};
2320 WCHAR handle[11];
2321 struct record_process *rec;
2322 PROCESSENTRY32W entry;
2323 HANDLE snap;
2324 enum fill_status status = FILL_STATUS_FAILED;
2325 UINT row = 0, offset = 0;
2327 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2328 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2330 entry.dwSize = sizeof(entry);
2331 if (!Process32FirstW( snap, &entry )) goto done;
2332 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2336 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2338 rec = (struct record_process *)(table->data + offset);
2339 rec->caption = heap_strdupW( entry.szExeFile );
2340 rec->commandline = get_cmdline( entry.th32ProcessID );
2341 rec->description = heap_strdupW( entry.szExeFile );
2342 sprintfW( handle, fmtW, entry.th32ProcessID );
2343 rec->handle = heap_strdupW( handle );
2344 rec->name = heap_strdupW( entry.szExeFile );
2345 rec->process_id = entry.th32ProcessID;
2346 rec->pprocess_id = entry.th32ParentProcessID;
2347 rec->thread_count = entry.cntThreads;
2348 rec->workingsetsize = 0;
2349 rec->get_owner = process_get_owner;
2350 if (!match_row( table, row, cond, &status ))
2352 free_row_values( table, row );
2353 continue;
2355 offset += sizeof(*rec);
2356 row++;
2357 } while (Process32NextW( snap, &entry ));
2359 TRACE("created %u rows\n", row);
2360 table->num_rows = row;
2361 status = FILL_STATUS_UNFILTERED;
2363 done:
2364 CloseHandle( snap );
2365 return status;
2368 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2370 #ifdef __i386__
2371 #ifdef _MSC_VER
2372 __cpuid(p, ax);
2373 #else
2374 __asm__("pushl %%ebx\n\t"
2375 "cpuid\n\t"
2376 "movl %%ebx, %%esi\n\t"
2377 "popl %%ebx"
2378 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2379 : "0" (ax));
2380 #endif
2381 #endif
2383 static const WCHAR *get_osarchitecture(void)
2385 SYSTEM_INFO info;
2386 GetNativeSystemInfo( &info );
2387 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2388 return os_32bitW;
2390 static void get_processor_caption( WCHAR *caption )
2392 static const WCHAR fmtW[] =
2393 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2394 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2395 static const WCHAR x86W[] = {'x','8','6',0};
2396 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2397 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2398 unsigned int regs[4] = {0, 0, 0, 0};
2400 do_cpuid( 1, regs );
2401 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2403 static void get_processor_version( WCHAR *version )
2405 static const WCHAR fmtW[] =
2406 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2407 unsigned int regs[4] = {0, 0, 0, 0};
2409 do_cpuid( 1, regs );
2410 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2412 static void get_processor_id( WCHAR *processor_id )
2414 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2415 unsigned int regs[4] = {0, 0, 0, 0};
2417 do_cpuid( 1, regs );
2418 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2420 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2422 unsigned int i;
2423 unsigned char *p = (unsigned char *)regs;
2425 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2426 buffer[i] = 0;
2428 static void get_processor_manufacturer( WCHAR *manufacturer )
2430 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2432 do_cpuid( 0, regs );
2433 tmp = regs[2]; /* swap edx and ecx */
2434 regs[2] = regs[3];
2435 regs[3] = tmp;
2437 regs_to_str( regs + 1, 12, manufacturer );
2439 static void get_processor_name( WCHAR *name )
2441 unsigned int regs[4] = {0, 0, 0, 0};
2443 do_cpuid( 0x80000000, regs );
2444 if (regs[0] >= 0x80000004)
2446 do_cpuid( 0x80000002, regs );
2447 regs_to_str( regs, 16, name );
2448 do_cpuid( 0x80000003, regs );
2449 regs_to_str( regs, 16, name + 16 );
2450 do_cpuid( 0x80000004, regs );
2451 regs_to_str( regs, 16, name + 32 );
2454 static UINT get_processor_currentclockspeed( UINT index )
2456 PROCESSOR_POWER_INFORMATION *info;
2457 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2458 NTSTATUS status;
2460 if ((info = heap_alloc( size )))
2462 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2463 if (!status) ret = info[index].CurrentMhz;
2464 heap_free( info );
2466 return ret;
2468 static UINT get_processor_maxclockspeed( UINT index )
2470 PROCESSOR_POWER_INFORMATION *info;
2471 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2472 NTSTATUS status;
2474 if ((info = heap_alloc( size )))
2476 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2477 if (!status) ret = info[index].MaxMhz;
2478 heap_free( info );
2480 return ret;
2483 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2485 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2486 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2487 struct record_processor *rec;
2488 UINT i, offset = 0, num_cores, num_logical_processors, count = get_processor_count();
2489 enum fill_status status = FILL_STATUS_UNFILTERED;
2491 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2493 get_processor_caption( caption );
2494 get_processor_id( processor_id );
2495 get_processor_manufacturer( manufacturer );
2496 get_processor_name( name );
2497 get_processor_version( version );
2499 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2500 num_cores /= count;
2502 for (i = 0; i < count; i++)
2504 rec = (struct record_processor *)(table->data + offset);
2505 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2506 rec->caption = heap_strdupW( caption );
2507 rec->cpu_status = 1; /* CPU Enabled */
2508 rec->currentclockspeed = get_processor_currentclockspeed( i );
2509 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2510 rec->description = heap_strdupW( caption );
2511 sprintfW( device_id, fmtW, i );
2512 rec->device_id = heap_strdupW( device_id );
2513 rec->family = 2; /* Unknown */
2514 rec->manufacturer = heap_strdupW( manufacturer );
2515 rec->maxclockspeed = get_processor_maxclockspeed( i );
2516 rec->name = heap_strdupW( name );
2517 rec->num_cores = num_cores;
2518 rec->num_logical_processors = num_logical_processors;
2519 rec->processor_id = heap_strdupW( processor_id );
2520 rec->processortype = 3; /* central processor */
2521 rec->unique_id = NULL;
2522 rec->version = heap_strdupW( version );
2523 if (!match_row( table, i, cond, &status ))
2525 free_row_values( table, i );
2526 continue;
2528 offset += sizeof(*rec);
2531 TRACE("created %u rows\n", count);
2532 table->num_rows = count;
2533 return status;
2536 static WCHAR *get_lastbootuptime(void)
2538 static const WCHAR fmtW[] =
2539 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2540 '.','%','0','6','u','+','0','0','0',0};
2541 SYSTEM_TIMEOFDAY_INFORMATION ti;
2542 TIME_FIELDS tf;
2543 WCHAR *ret;
2545 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2547 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2548 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2549 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2550 return ret;
2552 static WCHAR *get_localdatetime(void)
2554 static const WCHAR fmtW[] =
2555 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2556 '.','%','0','6','u','%','+','0','3','d',0};
2557 TIME_ZONE_INFORMATION tzi;
2558 SYSTEMTIME st;
2559 WCHAR *ret;
2560 DWORD Status;
2561 LONG Bias;
2563 Status = GetTimeZoneInformation(&tzi);
2565 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2566 Bias = tzi.Bias;
2567 if(Status == TIME_ZONE_ID_DAYLIGHT)
2568 Bias+= tzi.DaylightBias;
2569 else
2570 Bias+= tzi.StandardBias;
2571 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2573 GetLocalTime(&st);
2574 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2575 return ret;
2577 static WCHAR *get_systemdirectory(void)
2579 void *redir;
2580 WCHAR *ret;
2582 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2583 Wow64DisableWow64FsRedirection( &redir );
2584 GetSystemDirectoryW( ret, MAX_PATH );
2585 Wow64RevertWow64FsRedirection( redir );
2586 return ret;
2588 static WCHAR *get_codeset(void)
2590 static const WCHAR fmtW[] = {'%','u',0};
2591 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2592 if (ret) sprintfW( ret, fmtW, GetACP() );
2593 return ret;
2595 static WCHAR *get_countrycode(void)
2597 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2598 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2599 return ret;
2601 static WCHAR *get_locale(void)
2603 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2604 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2605 return ret;
2608 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2610 struct record_operatingsystem *rec;
2611 enum fill_status status = FILL_STATUS_UNFILTERED;
2612 UINT row = 0;
2614 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2616 rec = (struct record_operatingsystem *)table->data;
2617 rec->buildnumber = os_buildnumberW;
2618 rec->caption = os_captionW;
2619 rec->codeset = get_codeset();
2620 rec->countrycode = get_countrycode();
2621 rec->csdversion = os_csdversionW;
2622 rec->installdate = os_installdateW;
2623 rec->lastbootuptime = get_lastbootuptime();
2624 rec->localdatetime = get_localdatetime();
2625 rec->locale = get_locale();
2626 rec->name = os_nameW;
2627 rec->osarchitecture = get_osarchitecture();
2628 rec->oslanguage = GetSystemDefaultLangID();
2629 rec->osproductsuite = 2461140; /* Windows XP Professional */
2630 rec->ostype = 18; /* WINNT */
2631 rec->primary = -1;
2632 rec->serialnumber = os_serialnumberW;
2633 rec->servicepackmajor = 3;
2634 rec->servicepackminor = 0;
2635 rec->suitemask = 272; /* Single User + Terminal */
2636 rec->systemdirectory = get_systemdirectory();
2637 rec->totalvisiblememorysize = get_total_physical_memory() / 1024;
2638 rec->version = os_versionW;
2639 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2640 else row++;
2642 TRACE("created %u rows\n", row);
2643 table->num_rows = row;
2644 return status;
2647 static const WCHAR *get_service_type( DWORD type )
2649 static const WCHAR filesystem_driverW[] =
2650 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2651 static const WCHAR kernel_driverW[] =
2652 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2653 static const WCHAR own_processW[] =
2654 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2655 static const WCHAR share_processW[] =
2656 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2658 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2659 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2660 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2661 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2662 else ERR("unhandled type 0x%08x\n", type);
2663 return NULL;
2665 static const WCHAR *get_service_state( DWORD state )
2667 static const WCHAR runningW[] =
2668 {'R','u','n','n','i','n','g',0};
2669 static const WCHAR start_pendingW[] =
2670 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2671 static const WCHAR stop_pendingW[] =
2672 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2673 static const WCHAR stoppedW[] =
2674 {'S','t','o','p','p','e','d',0};
2675 static const WCHAR unknownW[] =
2676 {'U','n','k','n','o','w','n',0};
2678 switch (state)
2680 case SERVICE_STOPPED: return stoppedW;
2681 case SERVICE_START_PENDING: return start_pendingW;
2682 case SERVICE_STOP_PENDING: return stop_pendingW;
2683 case SERVICE_RUNNING: return runningW;
2684 default:
2685 ERR("unknown state %u\n", state);
2686 return unknownW;
2689 static const WCHAR *get_service_startmode( DWORD mode )
2691 static const WCHAR bootW[] = {'B','o','o','t',0};
2692 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
2693 static const WCHAR autoW[] = {'A','u','t','o',0};
2694 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
2695 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
2696 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
2698 switch (mode)
2700 case SERVICE_BOOT_START: return bootW;
2701 case SERVICE_SYSTEM_START: return systemW;
2702 case SERVICE_AUTO_START: return autoW;
2703 case SERVICE_DEMAND_START: return manualW;
2704 case SERVICE_DISABLED: return disabledW;
2705 default:
2706 ERR("unknown mode 0x%x\n", mode);
2707 return unknownW;
2710 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
2712 QUERY_SERVICE_CONFIGW *config = NULL;
2713 SC_HANDLE service;
2714 DWORD size;
2716 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
2717 QueryServiceConfigW( service, NULL, 0, &size );
2718 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
2719 if (!(config = heap_alloc( size ))) goto done;
2720 if (QueryServiceConfigW( service, config, size, &size )) goto done;
2721 heap_free( config );
2722 config = NULL;
2724 done:
2725 CloseServiceHandle( service );
2726 return config;
2729 static enum fill_status fill_service( struct table *table, const struct expr *cond )
2731 struct record_service *rec;
2732 SC_HANDLE manager;
2733 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
2734 SERVICE_STATUS_PROCESS *status;
2735 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
2736 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
2737 UINT i, row = 0, offset = 0, size = 256, needed, count;
2738 enum fill_status fill_status = FILL_STATUS_FAILED;
2739 BOOL ret;
2741 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
2742 if (!(services = heap_alloc( size ))) goto done;
2744 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2745 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2746 &count, NULL, NULL );
2747 if (!ret)
2749 if (GetLastError() != ERROR_MORE_DATA) goto done;
2750 size = needed;
2751 if (!(tmp = heap_realloc( services, size ))) goto done;
2752 services = tmp;
2753 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
2754 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
2755 &count, NULL, NULL );
2756 if (!ret) goto done;
2758 if (!resize_table( table, count, sizeof(*rec) )) goto done;
2760 GetComputerNameW( sysnameW, &len );
2761 fill_status = FILL_STATUS_UNFILTERED;
2763 for (i = 0; i < count; i++)
2765 QUERY_SERVICE_CONFIGW *config;
2767 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
2769 status = &services[i].ServiceStatusProcess;
2770 rec = (struct record_service *)(table->data + offset);
2771 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
2772 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
2773 rec->displayname = heap_strdupW( services[i].lpDisplayName );
2774 rec->name = heap_strdupW( services[i].lpServiceName );
2775 rec->process_id = status->dwProcessId;
2776 rec->servicetype = get_service_type( status->dwServiceType );
2777 rec->startmode = get_service_startmode( config->dwStartType );
2778 rec->state = get_service_state( status->dwCurrentState );
2779 rec->systemname = heap_strdupW( sysnameW );
2780 rec->pause_service = service_pause_service;
2781 rec->resume_service = service_resume_service;
2782 rec->start_service = service_start_service;
2783 rec->stop_service = service_stop_service;
2784 heap_free( config );
2785 if (!match_row( table, row, cond, &fill_status ))
2787 free_row_values( table, row );
2788 continue;
2790 offset += sizeof(*rec);
2791 row++;
2794 TRACE("created %u rows\n", row);
2795 table->num_rows = row;
2797 done:
2798 CloseServiceHandle( manager );
2799 heap_free( services );
2800 return fill_status;
2803 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
2805 if (!name || !name->Name.Buffer) return NULL;
2806 return heap_strdupW( name->Name.Buffer );
2808 static struct array *get_binaryrepresentation( PSID sid, UINT len )
2810 struct array *array = heap_alloc( sizeof(struct array) );
2811 if (array)
2813 UINT8 *ret = heap_alloc( len );
2814 if (ret)
2816 memcpy( ret, sid, len );
2817 array->count = len;
2818 array->ptr = ret;
2819 return array;
2821 heap_free( array );
2823 return NULL;
2825 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
2827 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
2828 return heap_strdupW( domain->Domains->Name.Buffer );
2830 static const WCHAR *find_sid_str( const struct expr *cond )
2832 const struct expr *left, *right;
2833 const WCHAR *ret = NULL;
2835 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
2837 left = cond->u.expr.left;
2838 right = cond->u.expr.right;
2839 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
2841 ret = right->u.sval;
2843 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
2845 ret = left->u.sval;
2847 return ret;
2850 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
2852 PSID sid;
2853 LSA_REFERENCED_DOMAIN_LIST *domain;
2854 LSA_TRANSLATED_NAME *name;
2855 LSA_HANDLE handle;
2856 LSA_OBJECT_ATTRIBUTES attrs;
2857 const WCHAR *str;
2858 struct record_sid *rec;
2859 UINT len;
2861 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
2862 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2864 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
2865 len = GetLengthSid( sid );
2867 memset( &attrs, 0, sizeof(attrs) );
2868 attrs.Length = sizeof(attrs);
2869 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
2871 LocalFree( sid );
2872 return FILL_STATUS_FAILED;
2874 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
2876 LocalFree( sid );
2877 LsaClose( handle );
2878 return FILL_STATUS_FAILED;
2881 rec = (struct record_sid *)table->data;
2882 rec->accountname = get_accountname( name );
2883 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
2884 rec->referenceddomainname = get_referenceddomainname( domain );
2885 rec->sid = heap_strdupW( str );
2886 rec->sidlength = len;
2888 TRACE("created 1 row\n");
2889 table->num_rows = 1;
2891 LsaFreeMemory( domain );
2892 LsaFreeMemory( name );
2893 LocalFree( sid );
2894 LsaClose( handle );
2895 return FILL_STATUS_FILTERED;
2898 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
2900 HDC hdc = GetDC( NULL );
2901 UINT32 ret;
2903 if (!hdc) return 32;
2904 ret = GetDeviceCaps( hdc, BITSPIXEL );
2905 *hres = GetDeviceCaps( hdc, HORZRES );
2906 *vres = GetDeviceCaps( hdc, VERTRES );
2907 ReleaseDC( NULL, hdc );
2908 return ret;
2910 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
2912 static const WCHAR fmtW[] =
2913 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
2914 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
2915 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
2916 WCHAR *ret;
2918 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
2919 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
2920 return ret;
2923 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
2926 struct record_videocontroller *rec;
2927 HRESULT hr;
2928 IDXGIFactory *factory = NULL;
2929 IDXGIAdapter *adapter = NULL;
2930 DXGI_ADAPTER_DESC desc;
2931 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
2932 const WCHAR *name = videocontroller_deviceidW;
2933 enum fill_status status = FILL_STATUS_UNFILTERED;
2934 UINT row = 0;
2936 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2938 memset (&desc, 0, sizeof(desc));
2939 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
2940 if (FAILED(hr)) goto done;
2942 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
2943 if (FAILED(hr)) goto done;
2945 hr = IDXGIAdapter_GetDesc( adapter, &desc );
2946 if (SUCCEEDED(hr))
2948 vidmem = desc.DedicatedVideoMemory;
2949 name = desc.Description;
2952 done:
2953 rec = (struct record_videocontroller *)table->data;
2954 rec->adapter_dactype = videocontroller_dactypeW;
2955 rec->adapter_ram = vidmem;
2956 rec->availability = 3; /* Running or Full Power */
2957 rec->caption = heap_strdupW( name );
2958 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
2959 rec->current_horizontalres = hres;
2960 rec->current_refreshrate = 0; /* default refresh rate */
2961 rec->current_scanmode = 2; /* Unknown */
2962 rec->current_verticalres = vres;
2963 rec->description = heap_strdupW( name );
2964 rec->device_id = videocontroller_deviceidW;
2965 rec->driverversion = videocontroller_driverversionW;
2966 rec->name = heap_strdupW( name );
2967 rec->pnpdevice_id = get_pnpdeviceid( &desc );
2968 rec->videoarchitecture = 2; /* Unknown */
2969 rec->videomemorytype = 2; /* Unknown */
2970 rec->videoprocessor = heap_strdupW( name );
2971 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2972 else row++;
2974 TRACE("created %u rows\n", row);
2975 table->num_rows = row;
2977 if (adapter) IDXGIAdapter_Release( adapter );
2978 if (factory) IDXGIFactory_Release( factory );
2979 return status;
2982 static struct table builtin_classes[] =
2984 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
2985 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
2986 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
2987 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
2988 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, SIZEOF(data_compsysproduct), 0, (BYTE *)data_compsysproduct },
2989 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
2990 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
2991 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
2992 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
2993 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
2994 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2995 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
2996 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
2997 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
2998 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
2999 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
3000 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
3001 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
3002 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
3003 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
3004 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3005 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3006 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
3007 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
3008 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
3009 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
3010 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
3011 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
3012 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
3013 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
3016 void init_table_list( void )
3018 static struct list tables = LIST_INIT( tables );
3019 UINT i;
3021 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
3022 table_list = &tables;