wbemprox: Add DriverDate for Win32_VideoController.
[wine.git] / dlls / wbemprox / builtin.c
blob9dfc939caf90e27720890bbbdf9878ff41bcc167
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>
25 #include <fcntl.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #ifdef HAVE_ARPA_INET_H
30 # include <arpa/inet.h>
31 #endif
33 #include "ntstatus.h"
34 #define WIN32_NO_STATUS
35 #include "windef.h"
36 #include "winbase.h"
37 #ifdef __MINGW32__
38 # include "winsock2.h"
39 # include "ws2tcpip.h"
40 # define WS_AF_UNSPEC AF_UNSPEC
41 # define WS_NI_MAXHOST NI_MAXHOST
42 # define WS_NI_NAMEREQD NI_NAMEREQD
43 #else
44 # define USE_WS_PREFIX
45 # include "winsock2.h"
46 # include "ws2tcpip.h"
47 #endif
48 #include "initguid.h"
49 #include "wbemcli.h"
50 #include "wbemprov.h"
51 #include "iphlpapi.h"
52 #include "tlhelp32.h"
53 #include "d3d10.h"
54 #include "winternl.h"
55 #include "winioctl.h"
56 #include "winsvc.h"
57 #include "winver.h"
58 #include "sddl.h"
59 #include "ntsecapi.h"
60 #include "winspool.h"
62 #include "wine/debug.h"
63 #include "wbemprox_private.h"
65 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
67 static const WCHAR class_baseboardW[] =
68 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
69 static const WCHAR class_biosW[] =
70 {'W','i','n','3','2','_','B','I','O','S',0};
71 static const WCHAR class_cdromdriveW[] =
72 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
73 static const WCHAR class_compsysW[] =
74 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
75 static const WCHAR class_compsysproductW[] =
76 {'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};
77 static const WCHAR class_datafileW[] =
78 {'C','I','M','_','D','a','t','a','F','i','l','e',0};
79 static const WCHAR class_desktopmonitorW[] =
80 {'W','i','n','3','2','_','D','e','s','k','t','o','p','M','o','n','i','t','o','r',0};
81 static const WCHAR class_directoryW[] =
82 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
83 static const WCHAR class_diskdriveW[] =
84 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
85 static const WCHAR class_diskpartitionW[] =
86 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
87 static const WCHAR class_ip4routetableW[] =
88 {'W','i','n','3','2','_','I','P','4','R','o','u','t','e','T','a','b','l','e',0};
89 static const WCHAR class_logicaldiskW[] =
90 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
91 static const WCHAR class_logicaldisk2W[] =
92 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
93 static const WCHAR class_networkadapterW[] =
94 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
95 static const WCHAR class_networkadapterconfigW[] =
96 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',
97 'C','o','n','f','i','g','u','r','a','t','i','o','n',0};
98 static const WCHAR class_osW[] =
99 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
100 static const WCHAR class_paramsW[] =
101 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
102 static const WCHAR class_physicalmediaW[] =
103 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','d','i','a',0};
104 static const WCHAR class_physicalmemoryW[] =
105 {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
106 static const WCHAR class_printerW[] =
107 {'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
108 static const WCHAR class_process_getowner_outW[] =
109 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
110 'N','E','R','_','O','U','T',0};
111 static const WCHAR class_processorW[] =
112 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
113 static const WCHAR class_processor2W[] =
114 {'C','I','M','_','P','r','o','c','e','s','s','o','r',0};
115 static const WCHAR class_qualifiersW[] =
116 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
117 static const WCHAR class_sidW[] =
118 {'W','i','n','3','2','_','S','I','D',0};
119 static const WCHAR class_sounddeviceW[] =
120 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
121 static const WCHAR class_systemenclosureW[] =
122 {'W','i','n','3','2','_','S','y','s','t','e','m','E','n','c','l','o','s','u','r','e',0};
123 static const WCHAR class_videocontrollerW[] =
124 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
126 static const WCHAR prop_accountnameW[] =
127 {'A','c','c','o','u','n','t','N','a','m','e',0};
128 static const WCHAR prop_acceptpauseW[] =
129 {'A','c','c','e','p','t','P','a','u','s','e',0};
130 static const WCHAR prop_acceptstopW[] =
131 {'A','c','c','e','p','t','S','t','o','p',0};
132 static const WCHAR prop_accessmaskW[] =
133 {'A','c','c','e','s','s','M','a','s','k',0};
134 static const WCHAR prop_adapterdactypeW[] =
135 {'A','d','a','p','t','e','r','D','A','C','T','y','p','e',0};
136 static const WCHAR prop_adapterramW[] =
137 {'A','d','a','p','t','e','r','R','A','M',0};
138 static const WCHAR prop_adaptertypeW[] =
139 {'A','d','a','p','t','e','r','T','y','p','e',0};
140 static const WCHAR prop_addresswidthW[] =
141 {'A','d','d','r','e','s','s','W','i','d','t','h',0};
142 static const WCHAR prop_architectureW[] =
143 {'A','r','c','h','i','t','e','c','t','u','r','e',0};
144 static const WCHAR prop_attributesW[] =
145 {'A','t','t','r','i','b','u','t','e','s',0};
146 static const WCHAR prop_availabilityW[] =
147 {'A','v','a','i','l','a','b','i','l','i','t','y',0};
148 static const WCHAR prop_binaryrepresentationW[] =
149 {'B','i','n','a','r','y','R','e','p','r','e','s','e','n','t','a','t','i','o','n',0};
150 static const WCHAR prop_bootableW[] =
151 {'B','o','o','t','a','b','l','e',0};
152 static const WCHAR prop_bootpartitionW[] =
153 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
154 static const WCHAR prop_buildnumberW[] =
155 {'B','u','i','l','d','N','u','m','b','e','r',0};
156 static const WCHAR prop_capacityW[] =
157 {'C','a','p','a','c','i','t','y',0};
158 static const WCHAR prop_captionW[] =
159 {'C','a','p','t','i','o','n',0};
160 static const WCHAR prop_chassistypesW[] =
161 {'C','h','a','s','s','i','s','T','y','p','e','s',0};
162 static const WCHAR prop_classW[] =
163 {'C','l','a','s','s',0};
164 static const WCHAR prop_codesetW[] =
165 {'C','o','d','e','S','e','t',0};
166 static const WCHAR prop_commandlineW[] =
167 {'C','o','m','m','a','n','d','L','i','n','e',0};
168 static const WCHAR prop_configmanagererrorcodeW[] =
169 {'C','o','n','f','i','g','M','a','n','a','g','e','r','E','r','r','o','r','C','o','d','e',0};
170 static const WCHAR prop_countrycodeW[] =
171 {'C','o','u','n','t','r','y','C','o','d','e',0};
172 static const WCHAR prop_cpustatusW[] =
173 {'C','p','u','S','t','a','t','u','s',0};
174 static const WCHAR prop_csdversionW[] =
175 {'C','S','D','V','e','r','s','i','o','n',0};
176 static const WCHAR prop_currentbitsperpixelW[] =
177 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
178 static const WCHAR prop_currentclockspeedW[] =
179 {'C','u','r','r','e','n','t','C','l','o','c','k','S','p','e','e','d',0};
180 static const WCHAR prop_currenthorizontalresW[] =
181 {'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};
182 static const WCHAR prop_currentrefreshrateW[] =
183 {'C','u','r','r','e','n','t','R','e','f','r','e','s','h','R','a','t','e',0};
184 static const WCHAR prop_currentscanmodeW[] =
185 {'C','u','r','r','e','n','t','S','c','a','n','M','o','d','e',0};
186 static const WCHAR prop_currentverticalresW[] =
187 {'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};
188 static const WCHAR prop_datawidthW[] =
189 {'D','a','t','a','W','i','d','t','h',0};
190 static const WCHAR prop_defaultipgatewayW[] =
191 {'D','e','f','a','u','l','t','I','P','G','a','t','e','w','a','y',0};
192 static const WCHAR prop_defaultvalueW[] =
193 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
194 static const WCHAR prop_descriptionW[] =
195 {'D','e','s','c','r','i','p','t','i','o','n',0};
196 static const WCHAR prop_destinationW[] =
197 {'D','e','s','t','i','n','a','t','i','o','n',0};
198 static const WCHAR prop_deviceidW[] =
199 {'D','e','v','i','c','e','I','d',0};
200 static const WCHAR prop_dhcpenabledW[] =
201 {'D','H','C','P','E','n','a','b','l','e','d',0};
202 static const WCHAR prop_directionW[] =
203 {'D','i','r','e','c','t','i','o','n',0};
204 static const WCHAR prop_displaynameW[] =
205 {'D','i','s','p','l','a','y','N','a','m','e',0};
206 static const WCHAR prop_diskindexW[] =
207 {'D','i','s','k','I','n','d','e','x',0};
208 static const WCHAR prop_dnshostnameW[] =
209 {'D','N','S','H','o','s','t','N','a','m','e',0};
210 static const WCHAR prop_dnsserversearchorderW[] =
211 {'D','N','S','S','e','r','v','e','r','S','e','a','r','c','h','O','r','d','e','r',0};
212 static const WCHAR prop_domainW[] =
213 {'D','o','m','a','i','n',0};
214 static const WCHAR prop_domainroleW[] =
215 {'D','o','m','a','i','n','R','o','l','e',0};
216 static const WCHAR prop_driveW[] =
217 {'D','r','i','v','e',0};
218 static const WCHAR prop_driverdateW[] =
219 {'D','r','i','v','e','r','D','a','t','e',0};
220 static const WCHAR prop_drivernameW[] =
221 {'D','r','i','v','e','r','N','a','m','e',0};
222 static const WCHAR prop_driverversionW[] =
223 {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
224 static const WCHAR prop_drivetypeW[] =
225 {'D','r','i','v','e','T','y','p','e',0};
226 static const WCHAR prop_familyW[] =
227 {'F','a','m','i','l','y',0};
228 static const WCHAR prop_filesystemW[] =
229 {'F','i','l','e','S','y','s','t','e','m',0};
230 static const WCHAR prop_flavorW[] =
231 {'F','l','a','v','o','r',0};
232 static const WCHAR prop_freespaceW[] =
233 {'F','r','e','e','S','p','a','c','e',0};
234 static const WCHAR prop_handleW[] =
235 {'H','a','n','d','l','e',0};
236 static const WCHAR prop_horizontalresolutionW[] =
237 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
238 static const WCHAR prop_idW[] =
239 {'I','D',0};
240 static const WCHAR prop_identificationcodeW[] =
241 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
242 static const WCHAR prop_identifyingnumberW[] =
243 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
244 static const WCHAR prop_indexW[] =
245 {'I','n','d','e','x',0};
246 static const WCHAR prop_installdateW[] =
247 {'I','n','s','t','a','l','l','D','a','t','e',0};
248 static const WCHAR prop_installeddisplaydriversW[]=
249 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
250 static const WCHAR prop_interfaceindexW[] =
251 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
252 static const WCHAR prop_interfacetypeW[] =
253 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
254 static const WCHAR prop_intvalueW[] =
255 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
256 static const WCHAR prop_ipconnectionmetricW[] =
257 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
258 static const WCHAR prop_ipenabledW[] =
259 {'I','P','E','n','a','b','l','e','d',0};
260 static const WCHAR prop_lastbootuptimeW[] =
261 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
262 static const WCHAR prop_levelW[] =
263 {'L','e','v','e','l',0};
264 static const WCHAR prop_localW[] =
265 {'L','o','c','a','l',0};
266 static const WCHAR prop_localdatetimeW[] =
267 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
268 static const WCHAR prop_localeW[] =
269 {'L','o','c','a','l','e',0};
270 static const WCHAR prop_lockpresentW[] =
271 {'L','o','c','k','P','r','e','s','e','n','t',0};
272 static const WCHAR prop_macaddressW[] =
273 {'M','A','C','A','d','d','r','e','s','s',0};
274 static const WCHAR prop_manufacturerW[] =
275 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
276 static const WCHAR prop_maxclockspeedW[] =
277 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
278 static const WCHAR prop_mediatypeW[] =
279 {'M','e','d','i','a','T','y','p','e',0};
280 static const WCHAR prop_memberW[] =
281 {'M','e','m','b','e','r',0};
282 static const WCHAR prop_memorytypeW[] =
283 {'M','e','m','o','r','y','T','y','p','e',0};
284 static const WCHAR prop_methodW[] =
285 {'M','e','t','h','o','d',0};
286 static const WCHAR prop_modelW[] =
287 {'M','o','d','e','l',0};
288 static const WCHAR prop_netconnectionstatusW[] =
289 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
290 static const WCHAR prop_networkW[] =
291 {'N','e','t','w','o','r','k',0};
292 static const WCHAR prop_nexthopW[] =
293 {'N','e','x','t','H','o','p',0};
294 static const WCHAR prop_numcoresW[] =
295 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
296 static const WCHAR prop_numlogicalprocessorsW[] =
297 {'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};
298 static const WCHAR prop_numprocessorsW[] =
299 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
300 static const WCHAR prop_osarchitectureW[] =
301 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
302 static const WCHAR prop_oslanguageW[] =
303 {'O','S','L','a','n','g','u','a','g','e',0};
304 static const WCHAR prop_osproductsuiteW[] =
305 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
306 static const WCHAR prop_ostypeW[] =
307 {'O','S','T','y','p','e',0};
308 static const WCHAR prop_parameterW[] =
309 {'P','a','r','a','m','e','t','e','r',0};
310 static const WCHAR prop_physicaladapterW[] =
311 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
312 static const WCHAR prop_pixelsperxlogicalinchW[] =
313 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
314 static const WCHAR prop_pnpdeviceidW[] =
315 {'P','N','P','D','e','v','i','c','e','I','D',0};
316 static const WCHAR prop_pprocessidW[] =
317 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
318 static const WCHAR prop_primaryW[] =
319 {'P','r','i','m','a','r','y',0};
320 static const WCHAR prop_processidW[] =
321 {'P','r','o','c','e','s','s','I','D',0};
322 static const WCHAR prop_processoridW[] =
323 {'P','r','o','c','e','s','s','o','r','I','d',0};
324 static const WCHAR prop_processortypeW[] =
325 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
326 static const WCHAR prop_productW[] =
327 {'P','r','o','d','u','c','t',0};
328 static const WCHAR prop_productnameW[] =
329 {'P','r','o','d','u','c','t','N','a','m','e',0};
330 static const WCHAR prop_referenceddomainnameW[] =
331 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
332 static const WCHAR prop_releasedateW[] =
333 {'R','e','l','e','a','s','e','D','a','t','e',0};
334 static const WCHAR prop_revisionW[] =
335 {'R','e','v','i','s','i','o','n',0};
336 static const WCHAR prop_serialnumberW[] =
337 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
338 static const WCHAR prop_servicepackmajorW[] =
339 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
340 static const WCHAR prop_servicepackminorW[] =
341 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
342 static const WCHAR prop_servicetypeW[] =
343 {'S','e','r','v','i','c','e','T','y','p','e',0};
344 static const WCHAR prop_settingidW[] =
345 {'S','e','t','t','i','n','g','I','D',0};
346 static const WCHAR prop_skunumberW[] =
347 {'S','K','U','N','u','m','b','e','r',0};
348 static const WCHAR prop_smbiosbiosversionW[] =
349 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
350 static const WCHAR prop_smbiosmajorversionW[] =
351 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
352 static const WCHAR prop_smbiosminorversionW[] =
353 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
354 static const WCHAR prop_startmodeW[] =
355 {'S','t','a','r','t','M','o','d','e',0};
356 static const WCHAR prop_sidW[] =
357 {'S','I','D',0};
358 static const WCHAR prop_sidlengthW[] =
359 {'S','i','d','L','e','n','g','t','h',0};
360 static const WCHAR prop_sizeW[] =
361 {'S','i','z','e',0};
362 static const WCHAR prop_speedW[] =
363 {'S','p','e','e','d',0};
364 static const WCHAR prop_startingoffsetW[] =
365 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
366 static const WCHAR prop_stateW[] =
367 {'S','t','a','t','e',0};
368 static const WCHAR prop_statusW[] =
369 {'S','t','a','t','u','s',0};
370 static const WCHAR prop_statusinfoW[] =
371 {'S','t','a','t','u','s','I','n','f','o',0};
372 static const WCHAR prop_strvalueW[] =
373 {'S','t','r','i','n','g','V','a','l','u','e',0};
374 static const WCHAR prop_suitemaskW[] =
375 {'S','u','i','t','e','M','a','s','k',0};
376 static const WCHAR prop_systemdirectoryW[] =
377 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
378 static const WCHAR prop_systemnameW[] =
379 {'S','y','s','t','e','m','N','a','m','e',0};
380 static const WCHAR prop_tagW[] =
381 {'T','a','g',0};
382 static const WCHAR prop_threadcountW[] =
383 {'T','h','r','e','a','d','C','o','u','n','t',0};
384 static const WCHAR prop_totalphysicalmemoryW[] =
385 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
386 static const WCHAR prop_totalvirtualmemorysizeW[] =
387 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
388 static const WCHAR prop_totalvisiblememorysizeW[] =
389 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
390 static const WCHAR prop_typeW[] =
391 {'T','y','p','e',0};
392 static const WCHAR prop_uniqueidW[] =
393 {'U','n','i','q','u','e','I','d',0};
394 static const WCHAR prop_usernameW[] =
395 {'U','s','e','r','N','a','m','e',0};
396 static const WCHAR prop_uuidW[] =
397 {'U','U','I','D',0};
398 static const WCHAR prop_varianttypeW[] =
399 {'V','a','r','i','a','n','t','T','y','p','e',0};
400 static const WCHAR prop_vendorW[] =
401 {'V','e','n','d','o','r',0};
402 static const WCHAR prop_versionW[] =
403 {'V','e','r','s','i','o','n',0};
404 static const WCHAR prop_videoarchitectureW[] =
405 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
406 static const WCHAR prop_videomemorytypeW[] =
407 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
408 static const WCHAR prop_videomodedescriptionW[] =
409 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
410 static const WCHAR prop_videoprocessorW[] =
411 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
412 static const WCHAR prop_volumenameW[] =
413 {'V','o','l','u','m','e','N','a','m','e',0};
414 static const WCHAR prop_volumeserialnumberW[] =
415 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
416 static const WCHAR prop_workingsetsizeW[] =
417 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
419 /* column definitions must be kept in sync with record structures below */
420 static const struct column col_baseboard[] =
422 { prop_manufacturerW, CIM_STRING },
423 { prop_modelW, CIM_STRING },
424 { prop_nameW, CIM_STRING },
425 { prop_productW, CIM_STRING },
426 { prop_serialnumberW, CIM_STRING },
427 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
428 { prop_versionW, CIM_STRING }
430 static const struct column col_bios[] =
432 { prop_descriptionW, CIM_STRING },
433 { prop_identificationcodeW, CIM_STRING },
434 { prop_manufacturerW, CIM_STRING },
435 { prop_nameW, CIM_STRING },
436 { prop_releasedateW, CIM_DATETIME },
437 { prop_serialnumberW, CIM_STRING },
438 { prop_smbiosbiosversionW, CIM_STRING },
439 { prop_smbiosmajorversionW, CIM_UINT16, VT_I4 },
440 { prop_smbiosminorversionW, CIM_UINT16, VT_I4 },
441 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
443 static const struct column col_cdromdrive[] =
445 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
446 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
447 { prop_mediatypeW, CIM_STRING },
448 { prop_nameW, CIM_STRING },
449 { prop_pnpdeviceidW, CIM_STRING }
451 static const struct column col_compsys[] =
453 { prop_descriptionW, CIM_STRING },
454 { prop_domainW, CIM_STRING },
455 { prop_domainroleW, CIM_UINT16, VT_I4 },
456 { prop_manufacturerW, CIM_STRING },
457 { prop_modelW, CIM_STRING },
458 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
459 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
460 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
461 { prop_totalphysicalmemoryW, CIM_UINT64 },
462 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
464 static const struct column col_compsysproduct[] =
466 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
467 { prop_nameW, CIM_STRING|COL_FLAG_KEY },
468 { prop_skunumberW, CIM_STRING },
469 { prop_uuidW, CIM_STRING|COL_FLAG_DYNAMIC },
470 { prop_vendorW, CIM_STRING },
471 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
473 static const struct column col_datafile[] =
475 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
476 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
478 static const struct column col_desktopmonitor[] =
480 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
482 static const struct column col_directory[] =
484 { prop_accessmaskW, CIM_UINT32 },
485 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
487 static const struct column col_diskdrive[] =
489 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
490 { prop_indexW, CIM_UINT32, VT_I4 },
491 { prop_interfacetypeW, CIM_STRING },
492 { prop_manufacturerW, CIM_STRING },
493 { prop_mediatypeW, CIM_STRING },
494 { prop_modelW, CIM_STRING },
495 { prop_pnpdeviceidW, CIM_STRING },
496 { prop_serialnumberW, CIM_STRING },
497 { prop_sizeW, CIM_UINT64 }
499 static const struct column col_diskpartition[] =
501 { prop_bootableW, CIM_BOOLEAN },
502 { prop_bootpartitionW, CIM_BOOLEAN },
503 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
504 { prop_diskindexW, CIM_UINT32, VT_I4 },
505 { prop_indexW, CIM_UINT32, VT_I4 },
506 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
507 { prop_sizeW, CIM_UINT64 },
508 { prop_startingoffsetW, CIM_UINT64 },
509 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
511 static const struct column col_ip4routetable[] =
513 { prop_destinationW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
514 { prop_interfaceindexW, CIM_SINT32|COL_FLAG_KEY },
515 { prop_nexthopW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
517 static const struct column col_logicaldisk[] =
519 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
520 { prop_drivetypeW, CIM_UINT32, VT_I4 },
521 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
522 { prop_freespaceW, CIM_UINT64 },
523 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
524 { prop_sizeW, CIM_UINT64 },
525 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
526 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
528 static const struct column col_networkadapter[] =
530 { prop_adaptertypeW, CIM_STRING },
531 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
532 { prop_indexW, CIM_UINT32, VT_I4 },
533 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
534 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
535 { prop_manufacturerW, CIM_STRING },
536 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
537 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
538 { prop_physicaladapterW, CIM_BOOLEAN },
539 { prop_pnpdeviceidW, CIM_STRING },
540 { prop_speedW, CIM_UINT64 }
542 static const struct column col_networkadapterconfig[] =
544 { prop_defaultipgatewayW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
545 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
546 { prop_dhcpenabledW, CIM_BOOLEAN },
547 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
548 { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
549 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
550 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
551 { prop_ipenabledW, CIM_BOOLEAN },
552 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
553 { prop_settingidW, CIM_STRING|COL_FLAG_DYNAMIC }
555 static const struct column col_os[] =
557 { prop_buildnumberW, CIM_STRING|COL_FLAG_DYNAMIC },
558 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
559 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
560 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
561 { prop_csdversionW, CIM_STRING|COL_FLAG_DYNAMIC },
562 { prop_installdateW, CIM_DATETIME },
563 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
564 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
565 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
566 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
567 { prop_osarchitectureW, CIM_STRING },
568 { prop_oslanguageW, CIM_UINT32, VT_I4 },
569 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
570 { prop_ostypeW, CIM_UINT16, VT_I4 },
571 { prop_primaryW, CIM_BOOLEAN },
572 { prop_serialnumberW, CIM_STRING },
573 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
574 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
575 { prop_suitemaskW, CIM_UINT32, VT_I4 },
576 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
577 { prop_totalvirtualmemorysizeW, CIM_UINT64 },
578 { prop_totalvisiblememorysizeW, CIM_UINT64 },
579 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
581 static const struct column col_param[] =
583 { prop_classW, CIM_STRING },
584 { prop_methodW, CIM_STRING },
585 { prop_directionW, CIM_SINT32 },
586 { prop_parameterW, CIM_STRING },
587 { prop_typeW, CIM_UINT32 },
588 { prop_varianttypeW, CIM_UINT32 },
589 { prop_defaultvalueW, CIM_UINT32 }
591 static const struct column col_physicalmedia[] =
593 { prop_serialnumberW, CIM_STRING },
594 { prop_tagW, CIM_STRING }
596 static const struct column col_physicalmemory[] =
598 { prop_capacityW, CIM_UINT64 },
599 { prop_memorytypeW, CIM_UINT16, VT_I4 }
601 static const struct column col_printer[] =
603 { prop_attributesW, CIM_UINT32 },
604 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
605 { prop_horizontalresolutionW, CIM_UINT32 },
606 { prop_localW, CIM_BOOLEAN },
607 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
608 { prop_networkW, CIM_BOOLEAN }
610 static const struct column col_process[] =
612 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
613 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
614 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
615 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
616 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
617 { prop_pprocessidW, CIM_UINT32, VT_I4 },
618 { prop_processidW, CIM_UINT32, VT_I4 },
619 { prop_threadcountW, CIM_UINT32, VT_I4 },
620 { prop_workingsetsizeW, CIM_UINT64 },
621 /* methods */
622 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
624 static const struct column col_processor[] =
626 { prop_addresswidthW, CIM_UINT16, VT_I4 },
627 { prop_architectureW, CIM_UINT16, VT_I4 },
628 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
629 { prop_cpustatusW, CIM_UINT16 },
630 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
631 { prop_datawidthW, CIM_UINT16, VT_I4 },
632 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
633 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
634 { prop_familyW, CIM_UINT16, VT_I4 },
635 { prop_levelW, CIM_UINT16, VT_I4 },
636 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
637 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
638 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
639 { prop_numcoresW, CIM_UINT32, VT_I4 },
640 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
641 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
642 { prop_processortypeW, CIM_UINT16, VT_I4 },
643 { prop_revisionW, CIM_UINT16, VT_I4 },
644 { prop_uniqueidW, CIM_STRING },
645 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
647 static const struct column col_qualifier[] =
649 { prop_classW, CIM_STRING },
650 { prop_memberW, CIM_STRING },
651 { prop_typeW, CIM_UINT32 },
652 { prop_flavorW, CIM_SINT32 },
653 { prop_nameW, CIM_STRING },
654 { prop_intvalueW, CIM_SINT32 },
655 { prop_strvalueW, CIM_STRING }
657 static const struct column col_service[] =
659 { prop_acceptpauseW, CIM_BOOLEAN },
660 { prop_acceptstopW, CIM_BOOLEAN },
661 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
662 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
663 { prop_processidW, CIM_UINT32 },
664 { prop_servicetypeW, CIM_STRING },
665 { prop_startmodeW, CIM_STRING },
666 { prop_stateW, CIM_STRING },
667 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
668 /* methods */
669 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
670 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
671 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
672 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
674 static const struct column col_sid[] =
676 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
677 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
678 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
679 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
680 { prop_sidlengthW, CIM_UINT32 }
682 static const struct column col_sounddevice[] =
684 { prop_nameW, CIM_STRING },
685 { prop_productnameW, CIM_STRING },
686 { prop_statusinfoW, CIM_UINT16, VT_I4 }
688 static const struct column col_stdregprov[] =
690 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
691 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
692 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
694 static const struct column col_systemenclosure[] =
696 { prop_captionW, CIM_STRING },
697 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY, VT_I4|VT_ARRAY },
698 { prop_descriptionW, CIM_STRING },
699 { prop_lockpresentW, CIM_BOOLEAN },
700 { prop_manufacturerW, CIM_STRING },
701 { prop_nameW, CIM_STRING },
702 { prop_tagW, CIM_STRING },
704 static const struct column col_systemsecurity[] =
706 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
707 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
709 static const struct column col_videocontroller[] =
711 { prop_adapterdactypeW, CIM_STRING },
712 { prop_adapterramW, CIM_UINT32, VT_I4 },
713 { prop_availabilityW, CIM_UINT16 },
714 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
715 { prop_configmanagererrorcodeW, CIM_UINT32, VT_I4 },
716 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
717 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
718 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
719 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
720 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
721 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
722 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
723 { prop_driverdateW, CIM_DATETIME },
724 { prop_driverversionW, CIM_STRING },
725 { prop_installeddisplaydriversW,CIM_STRING },
726 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
727 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
728 { prop_statusW, CIM_STRING },
729 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
730 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
731 { prop_videomodedescriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
732 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC },
735 static const WCHAR baseboard_manufacturerW[] =
736 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
737 static const WCHAR baseboard_serialnumberW[] =
738 {'N','o','n','e',0};
739 static const WCHAR baseboard_tagW[] =
740 {'B','a','s','e',' ','B','o','a','r','d',0};
741 static const WCHAR baseboard_versionW[] =
742 {'1','.','0',0};
743 static const WCHAR bios_descriptionW[] =
744 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
745 static const WCHAR bios_manufacturerW[] =
746 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
747 static const WCHAR bios_nameW[] =
748 {'W','I','N','E',' ','B','I','O','S',0};
749 static const WCHAR bios_releasedateW[] =
750 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
751 static const WCHAR bios_serialnumberW[] =
752 {'0',0};
753 static const WCHAR bios_smbiosbiosversionW[] =
754 {'W','i','n','e',0};
755 static const WCHAR bios_versionW[] =
756 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
757 static const WCHAR cdromdrive_mediatypeW[] =
758 {'C','D','-','R','O','M',0};
759 static const WCHAR cdromdrive_nameW[] =
760 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
761 static const WCHAR cdromdrive_pnpdeviceidW[]=
762 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
763 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
764 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
765 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
766 static const WCHAR compsys_descriptionW[] =
767 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
768 static const WCHAR compsys_domainW[] =
769 {'W','O','R','K','G','R','O','U','P',0};
770 static const WCHAR compsys_manufacturerW[] =
771 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
772 static const WCHAR compsys_modelW[] =
773 {'W','i','n','e',0};
774 static const WCHAR compsysproduct_identifyingnumberW[] =
775 {'0',0};
776 static const WCHAR compsysproduct_nameW[] =
777 {'W','i','n','e',0};
778 static const WCHAR compsysproduct_uuidW[] =
779 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
780 'd','e','a','d','d','e','a','d','d','e','a','d',0};
781 static const WCHAR compsysproduct_vendorW[] =
782 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
783 static const WCHAR compsysproduct_versionW[] =
784 {'1','.','0',0};
785 static const WCHAR diskdrive_interfacetypeW[] =
786 {'I','D','E',0};
787 static const WCHAR diskdrive_manufacturerW[] =
788 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
789 static const WCHAR diskdrive_mediatype_fixedW[] =
790 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
791 static const WCHAR diskdrive_mediatype_removableW[] =
792 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
793 static const WCHAR diskdrive_modelW[] =
794 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
795 static const WCHAR diskdrive_pnpdeviceidW[] =
796 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
797 static const WCHAR diskdrive_serialW[] =
798 {'W','I','N','E','H','D','I','S','K',0};
799 static const WCHAR networkadapter_pnpdeviceidW[]=
800 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
801 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
802 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
803 static const WCHAR os_32bitW[] =
804 {'3','2','-','b','i','t',0};
805 static const WCHAR os_64bitW[] =
806 {'6','4','-','b','i','t',0};
807 static const WCHAR os_installdateW[] =
808 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
809 static const WCHAR os_serialnumberW[] =
810 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
811 static const WCHAR physicalmedia_tagW[] =
812 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
813 static const WCHAR sounddevice_productnameW[] =
814 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
815 static const WCHAR systemenclosure_systemenclosureW[] =
816 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
817 static const WCHAR systemenclosure_tagW[] =
818 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
819 static const WCHAR systemenclosure_manufacturerW[] =
820 {'W','i','n','e',0};
821 static const WCHAR videocontroller_dactypeW[] =
822 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
823 static const WCHAR videocontroller_deviceidW[] =
824 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
825 static const WCHAR videocontroller_driverdateW[] =
826 {'2','0','1','7','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
827 static const WCHAR videocontroller_driverversionW[] =
828 {'1','.','0',0};
829 static const WCHAR videocontroller_statusW[] =
830 {'O','K',0};
832 #include "pshpack1.h"
833 struct record_baseboard
835 const WCHAR *manufacturer;
836 const WCHAR *model;
837 const WCHAR *name;
838 const WCHAR *product;
839 const WCHAR *serialnumber;
840 const WCHAR *tag;
841 const WCHAR *version;
843 struct record_bios
845 const WCHAR *description;
846 const WCHAR *identificationcode;
847 const WCHAR *manufacturer;
848 const WCHAR *name;
849 const WCHAR *releasedate;
850 const WCHAR *serialnumber;
851 const WCHAR *smbiosbiosversion;
852 UINT16 smbiosmajorversion;
853 UINT16 smbiosminorversion;
854 const WCHAR *version;
856 struct record_cdromdrive
858 const WCHAR *device_id;
859 const WCHAR *drive;
860 const WCHAR *mediatype;
861 const WCHAR *name;
862 const WCHAR *pnpdevice_id;
864 struct record_computersystem
866 const WCHAR *description;
867 const WCHAR *domain;
868 UINT16 domainrole;
869 const WCHAR *manufacturer;
870 const WCHAR *model;
871 const WCHAR *name;
872 UINT32 num_logical_processors;
873 UINT32 num_processors;
874 UINT64 total_physical_memory;
875 const WCHAR *username;
877 struct record_computersystemproduct
879 const WCHAR *identifyingnumber;
880 const WCHAR *name;
881 const WCHAR *skunumber;
882 const WCHAR *uuid;
883 const WCHAR *vendor;
884 const WCHAR *version;
886 struct record_datafile
888 const WCHAR *name;
889 const WCHAR *version;
891 struct record_desktopmonitor
893 UINT32 pixelsperxlogicalinch;
895 struct record_directory
897 UINT32 accessmask;
898 const WCHAR *name;
900 struct record_diskdrive
902 const WCHAR *device_id;
903 UINT32 index;
904 const WCHAR *interfacetype;
905 const WCHAR *manufacturer;
906 const WCHAR *mediatype;
907 const WCHAR *model;
908 const WCHAR *pnpdevice_id;
909 const WCHAR *serialnumber;
910 UINT64 size;
912 struct record_diskpartition
914 int bootable;
915 int bootpartition;
916 const WCHAR *device_id;
917 UINT32 diskindex;
918 UINT32 index;
919 const WCHAR *pnpdevice_id;
920 UINT64 size;
921 UINT64 startingoffset;
922 const WCHAR *type;
924 struct record_ip4routetable
926 const WCHAR *destination;
927 INT32 interfaceindex;
928 const WCHAR *nexthop;
930 struct record_logicaldisk
932 const WCHAR *device_id;
933 UINT32 drivetype;
934 const WCHAR *filesystem;
935 UINT64 freespace;
936 const WCHAR *name;
937 UINT64 size;
938 const WCHAR *volumename;
939 const WCHAR *volumeserialnumber;
941 struct record_networkadapter
943 const WCHAR *adaptertype;
944 const WCHAR *device_id;
945 UINT32 index;
946 UINT32 interface_index;
947 const WCHAR *mac_address;
948 const WCHAR *manufacturer;
949 const WCHAR *name;
950 UINT16 netconnection_status;
951 int physicaladapter;
952 const WCHAR *pnpdevice_id;
953 UINT64 speed;
955 struct record_networkadapterconfig
957 const struct array *defaultipgateway;
958 const WCHAR *description;
959 int dhcpenabled;
960 const WCHAR *dnshostname;
961 const struct array *dnsserversearchorder;
962 UINT32 index;
963 UINT32 ipconnectionmetric;
964 int ipenabled;
965 const WCHAR *mac_address;
966 const WCHAR *settingid;
968 struct record_operatingsystem
970 const WCHAR *buildnumber;
971 const WCHAR *caption;
972 const WCHAR *codeset;
973 const WCHAR *countrycode;
974 const WCHAR *csdversion;
975 const WCHAR *installdate;
976 const WCHAR *lastbootuptime;
977 const WCHAR *localdatetime;
978 const WCHAR *locale;
979 const WCHAR *name;
980 const WCHAR *osarchitecture;
981 UINT32 oslanguage;
982 UINT32 osproductsuite;
983 UINT16 ostype;
984 int primary;
985 const WCHAR *serialnumber;
986 UINT16 servicepackmajor;
987 UINT16 servicepackminor;
988 UINT32 suitemask;
989 const WCHAR *systemdirectory;
990 UINT64 totalvirtualmemorysize;
991 UINT64 totalvisiblememorysize;
992 const WCHAR *version;
994 struct record_param
996 const WCHAR *class;
997 const WCHAR *method;
998 INT32 direction;
999 const WCHAR *parameter;
1000 UINT32 type;
1001 UINT32 varianttype;
1002 UINT32 defaultvalue;
1004 struct record_physicalmedia
1006 const WCHAR *serialnumber;
1007 const WCHAR *tag;
1009 struct record_physicalmemory
1011 UINT64 capacity;
1012 UINT16 memorytype;
1014 struct record_printer
1016 UINT32 attributes;
1017 const WCHAR *drivername;
1018 UINT32 horizontalresolution;
1019 int local;
1020 const WCHAR *name;
1021 int network;
1023 struct record_process
1025 const WCHAR *caption;
1026 const WCHAR *commandline;
1027 const WCHAR *description;
1028 const WCHAR *handle;
1029 const WCHAR *name;
1030 UINT32 pprocess_id;
1031 UINT32 process_id;
1032 UINT32 thread_count;
1033 UINT64 workingsetsize;
1034 /* methods */
1035 class_method *get_owner;
1037 struct record_processor
1039 UINT16 addresswidth;
1040 UINT16 architecture;
1041 const WCHAR *caption;
1042 UINT16 cpu_status;
1043 UINT32 currentclockspeed;
1044 UINT16 datawidth;
1045 const WCHAR *description;
1046 const WCHAR *device_id;
1047 UINT16 family;
1048 UINT16 level;
1049 const WCHAR *manufacturer;
1050 UINT32 maxclockspeed;
1051 const WCHAR *name;
1052 UINT32 num_cores;
1053 UINT32 num_logical_processors;
1054 const WCHAR *processor_id;
1055 UINT16 processortype;
1056 UINT16 revision;
1057 const WCHAR *unique_id;
1058 const WCHAR *version;
1060 struct record_qualifier
1062 const WCHAR *class;
1063 const WCHAR *member;
1064 UINT32 type;
1065 INT32 flavor;
1066 const WCHAR *name;
1067 INT32 intvalue;
1068 const WCHAR *strvalue;
1070 struct record_service
1072 int accept_pause;
1073 int accept_stop;
1074 const WCHAR *displayname;
1075 const WCHAR *name;
1076 UINT32 process_id;
1077 const WCHAR *servicetype;
1078 const WCHAR *startmode;
1079 const WCHAR *state;
1080 const WCHAR *systemname;
1081 /* methods */
1082 class_method *pause_service;
1083 class_method *resume_service;
1084 class_method *start_service;
1085 class_method *stop_service;
1087 struct record_sid
1089 const WCHAR *accountname;
1090 const struct array *binaryrepresentation;
1091 const WCHAR *referenceddomainname;
1092 const WCHAR *sid;
1093 UINT32 sidlength;
1095 struct record_sounddevice
1097 const WCHAR *name;
1098 const WCHAR *productname;
1099 UINT16 statusinfo;
1101 struct record_stdregprov
1103 class_method *enumkey;
1104 class_method *enumvalues;
1105 class_method *getstringvalue;
1107 struct record_systemsecurity
1109 class_method *getsd;
1110 class_method *setsd;
1112 struct record_systemenclosure
1114 const WCHAR *caption;
1115 const struct array *chassistypes;
1116 const WCHAR *description;
1117 int lockpresent;
1118 const WCHAR *manufacturer;
1119 const WCHAR *name;
1120 const WCHAR *tag;
1122 struct record_videocontroller
1124 const WCHAR *adapter_dactype;
1125 UINT32 adapter_ram;
1126 UINT16 availability;
1127 const WCHAR *caption;
1128 UINT32 config_errorcode;
1129 UINT32 current_bitsperpixel;
1130 UINT32 current_horizontalres;
1131 UINT32 current_refreshrate;
1132 UINT16 current_scanmode;
1133 UINT32 current_verticalres;
1134 const WCHAR *description;
1135 const WCHAR *device_id;
1136 const WCHAR *driverdate;
1137 const WCHAR *driverversion;
1138 const WCHAR *installeddriver;
1139 const WCHAR *name;
1140 const WCHAR *pnpdevice_id;
1141 const WCHAR *status;
1142 UINT16 videoarchitecture;
1143 UINT16 videomemorytype;
1144 const WCHAR *videomodedescription;
1145 const WCHAR *videoprocessor;
1147 #include "poppack.h"
1149 static const struct record_baseboard data_baseboard[] =
1151 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1153 static const struct record_bios data_bios[] =
1155 { bios_descriptionW, NULL, bios_manufacturerW, bios_nameW, bios_releasedateW, bios_serialnumberW,
1156 bios_smbiosbiosversionW, 1, 0, bios_versionW }
1158 static const struct record_param data_param[] =
1160 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1161 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1162 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1163 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1164 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1165 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1166 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1167 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1168 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1169 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1170 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1171 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1172 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1173 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1174 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1175 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1176 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1177 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1178 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1179 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1180 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1181 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1182 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1183 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1184 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1187 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1188 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1190 static const struct record_physicalmedia data_physicalmedia[] =
1192 { diskdrive_serialW, physicalmedia_tagW }
1194 static const struct record_qualifier data_qualifier[] =
1196 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1197 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1199 static const struct record_sounddevice data_sounddevice[] =
1201 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1203 static const struct record_stdregprov data_stdregprov[] =
1205 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1207 static UINT16 systemenclosure_chassistypes[] =
1211 static const struct array systemenclosure_chassistypes_array =
1213 SIZEOF(systemenclosure_chassistypes),
1214 &systemenclosure_chassistypes
1216 static const struct record_systemenclosure data_systemenclosure[] =
1219 systemenclosure_systemenclosureW,
1220 &systemenclosure_chassistypes_array,
1221 systemenclosure_systemenclosureW,
1222 FALSE,
1223 systemenclosure_manufacturerW,
1224 systemenclosure_systemenclosureW,
1225 systemenclosure_tagW,
1228 static const struct record_systemsecurity data_systemsecurity[] =
1230 { security_get_sd, security_set_sd }
1233 /* check if row matches condition and update status */
1234 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1236 LONGLONG val;
1237 UINT type;
1239 if (!cond)
1241 *status = FILL_STATUS_UNFILTERED;
1242 return TRUE;
1244 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1246 *status = FILL_STATUS_FAILED;
1247 return FALSE;
1249 *status = FILL_STATUS_FILTERED;
1250 return val != 0;
1253 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1255 if (!table->num_rows_allocated)
1257 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1258 table->num_rows_allocated = row_count;
1259 return TRUE;
1261 if (row_count > table->num_rows_allocated)
1263 BYTE *data;
1264 UINT count = max( row_count, table->num_rows_allocated * 2 );
1265 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1266 table->data = data;
1267 table->num_rows_allocated = count;
1269 return TRUE;
1272 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1274 static const WCHAR fmtW[] = {'%','c',':',0};
1275 WCHAR drive[3], root[] = {'A',':','\\',0};
1276 struct record_cdromdrive *rec;
1277 UINT i, row = 0, offset = 0;
1278 DWORD drives = GetLogicalDrives();
1279 enum fill_status status = FILL_STATUS_UNFILTERED;
1281 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1283 for (i = 0; i < 26; i++)
1285 if (drives & (1 << i))
1287 root[0] = 'A' + i;
1288 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1289 continue;
1291 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1293 rec = (struct record_cdromdrive *)(table->data + offset);
1294 rec->device_id = cdromdrive_pnpdeviceidW;
1295 sprintfW( drive, fmtW, 'A' + i );
1296 rec->drive = heap_strdupW( drive );
1297 rec->mediatype = cdromdrive_mediatypeW;
1298 rec->name = cdromdrive_nameW;
1299 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1300 if (!match_row( table, row, cond, &status ))
1302 free_row_values( table, row );
1303 continue;
1305 offset += sizeof(*rec);
1306 row++;
1309 TRACE("created %u rows\n", row);
1310 table->num_rows = row;
1311 return status;
1314 static UINT get_processor_count(void)
1316 SYSTEM_BASIC_INFORMATION info;
1318 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1319 return info.NumberOfProcessors;
1322 static UINT get_logical_processor_count( UINT *num_cores )
1324 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1325 UINT i, j, count = 0;
1326 NTSTATUS status;
1327 ULONG len;
1329 if (num_cores) *num_cores = get_processor_count();
1330 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1331 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1333 if (!(info = heap_alloc( len ))) return get_processor_count();
1334 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1335 if (status != STATUS_SUCCESS)
1337 heap_free( info );
1338 return get_processor_count();
1340 if (num_cores) *num_cores = 0;
1341 for (i = 0; i < len / sizeof(*info); i++)
1343 if (info[i].Relationship == RelationProcessorCore)
1345 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1347 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1349 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1352 heap_free( info );
1353 return count;
1356 static UINT64 get_total_physical_memory(void)
1358 MEMORYSTATUSEX status;
1360 status.dwLength = sizeof(status);
1361 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1362 return status.ullTotalPhys;
1365 static WCHAR *get_computername(void)
1367 WCHAR *ret;
1368 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1370 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1371 GetComputerNameW( ret, &size );
1372 return ret;
1375 static WCHAR *get_username(void)
1377 WCHAR *ret;
1378 DWORD compsize, usersize;
1379 DWORD size;
1381 compsize = 0;
1382 GetComputerNameW( NULL, &compsize );
1383 usersize = 0;
1384 GetUserNameW( NULL, &usersize );
1385 size = compsize + usersize; /* two null terminators account for the \ */
1386 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1387 GetComputerNameW( ret, &compsize );
1388 ret[compsize] = '\\';
1389 GetUserNameW( ret + compsize + 1, &usersize );
1390 return ret;
1393 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1395 struct record_computersystem *rec;
1396 enum fill_status status = FILL_STATUS_UNFILTERED;
1397 UINT row = 0;
1399 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1401 rec = (struct record_computersystem *)table->data;
1402 rec->description = compsys_descriptionW;
1403 rec->domain = compsys_domainW;
1404 rec->domainrole = 0; /* standalone workstation */
1405 rec->manufacturer = compsys_manufacturerW;
1406 rec->model = compsys_modelW;
1407 rec->name = get_computername();
1408 rec->num_logical_processors = get_logical_processor_count( NULL );
1409 rec->num_processors = get_processor_count();
1410 rec->total_physical_memory = get_total_physical_memory();
1411 rec->username = get_username();
1412 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1413 else row++;
1415 TRACE("created %u rows\n", row);
1416 table->num_rows = row;
1417 return status;
1420 static WCHAR *get_compsysproduct_uuid(void)
1422 #ifdef __APPLE__
1423 unsigned char uuid[16];
1424 const struct timespec timeout = {1, 0};
1425 if (!gethostuuid( uuid, &timeout ))
1427 static const WCHAR fmtW[] =
1428 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1429 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1430 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1431 WCHAR *ret = heap_alloc( 37 * sizeof(WCHAR) );
1432 if (!ret) return NULL;
1433 sprintfW( ret, fmtW, uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
1434 uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15] );
1435 return ret;
1437 #endif
1438 #ifdef __linux__
1439 int file;
1440 if ((file = open( "/var/lib/dbus/machine-id", O_RDONLY )) != -1)
1442 unsigned char buf[32];
1443 if (read( file, buf, sizeof(buf) ) == sizeof(buf))
1445 unsigned int i, j;
1446 WCHAR *ret, *p;
1448 close( file );
1449 if (!(p = ret = heap_alloc( 37 * sizeof(WCHAR) ))) return NULL;
1450 for (i = 0, j = 0; i < 8; i++) p[i] = toupperW( buf[j++] );
1451 p[8] = '-';
1452 for (i = 9; i < 13; i++) p[i] = toupperW( buf[j++] );
1453 p[13] = '-';
1454 for (i = 14; i < 18; i++) p[i] = toupperW( buf[j++] );
1455 p[18] = '-';
1456 for (i = 19; i < 23; i++) p[i] = toupperW( buf[j++] );
1457 p[23] = '-';
1458 for (i = 24; i < 36; i++) p[i] = toupperW( buf[j++] );
1459 ret[i] = 0;
1460 return ret;
1462 close( file );
1464 #endif
1465 return heap_strdupW( compsysproduct_uuidW );
1468 static enum fill_status fill_compsysproduct( struct table *table, const struct expr *cond )
1470 struct record_computersystemproduct *rec;
1471 enum fill_status status = FILL_STATUS_UNFILTERED;
1472 UINT row = 0;
1474 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1476 rec = (struct record_computersystemproduct *)table->data;
1477 rec->identifyingnumber = compsysproduct_identifyingnumberW;
1478 rec->name = compsysproduct_nameW;
1479 rec->skunumber = NULL;
1480 rec->uuid = get_compsysproduct_uuid();
1481 rec->vendor = compsysproduct_vendorW;
1482 rec->version = compsysproduct_versionW;
1483 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1484 else row++;
1486 TRACE("created %u rows\n", row);
1487 table->num_rows = row;
1488 return status;
1491 struct dirstack
1493 WCHAR **dirs;
1494 UINT *len_dirs;
1495 UINT num_dirs;
1496 UINT num_allocated;
1499 static struct dirstack *alloc_dirstack( UINT size )
1501 struct dirstack *dirstack;
1503 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1504 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1506 heap_free( dirstack );
1507 return NULL;
1509 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1511 heap_free( dirstack->dirs );
1512 heap_free( dirstack );
1513 return NULL;
1515 dirstack->num_dirs = 0;
1516 dirstack->num_allocated = size;
1517 return dirstack;
1520 static void clear_dirstack( struct dirstack *dirstack )
1522 UINT i;
1523 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1524 dirstack->num_dirs = 0;
1527 static void free_dirstack( struct dirstack *dirstack )
1529 clear_dirstack( dirstack );
1530 heap_free( dirstack->dirs );
1531 heap_free( dirstack->len_dirs );
1532 heap_free( dirstack );
1535 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1537 UINT size, i = dirstack->num_dirs;
1539 if (!dir) return FALSE;
1541 if (i == dirstack->num_allocated)
1543 WCHAR **tmp;
1544 UINT *len_tmp;
1546 size = dirstack->num_allocated * 2;
1547 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1548 dirstack->dirs = tmp;
1549 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1550 dirstack->len_dirs = len_tmp;
1551 dirstack->num_allocated = size;
1553 dirstack->dirs[i] = dir;
1554 dirstack->len_dirs[i] = len;
1555 dirstack->num_dirs++;
1556 return TRUE;
1559 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1561 if (!dirstack->num_dirs)
1563 *len = 0;
1564 return NULL;
1566 dirstack->num_dirs--;
1567 *len = dirstack->len_dirs[dirstack->num_dirs];
1568 return dirstack->dirs[dirstack->num_dirs];
1571 static const WCHAR *peek_dir( struct dirstack *dirstack )
1573 if (!dirstack->num_dirs) return NULL;
1574 return dirstack->dirs[dirstack->num_dirs - 1];
1577 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1579 UINT i = 0;
1580 WCHAR *ret;
1582 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1583 ret[i++] = drive;
1584 ret[i++] = ':';
1585 ret[i++] = '\\';
1586 if (path && len)
1588 memcpy( ret + i, path, len * sizeof(WCHAR) );
1589 i += len;
1590 ret[i++] = '\\';
1592 ret[i++] = '*';
1593 ret[i] = 0;
1594 return ret;
1597 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1599 UINT i = 0, len = 0;
1600 const WCHAR *p;
1601 WCHAR *ret;
1603 for (p = path; *p; p++)
1605 if (*p == '\\') len += 2;
1606 else len++;
1608 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1609 ret[i++] = drive;
1610 ret[i++] = ':';
1611 ret[i++] = '\\';
1612 ret[i++] = '\\';
1613 for (p = path; *p; p++)
1615 if (*p != '\\') ret[i++] = *p;
1616 else
1618 ret[i++] = '\\';
1619 ret[i++] = '\\';
1622 ret[i] = 0;
1623 return ret;
1626 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1628 const WCHAR *p = path, *start;
1629 UINT len, i;
1630 WCHAR *ret;
1632 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1633 start = path + 4;
1634 len = strlenW( start );
1635 p = start + len - 1;
1636 if (*p == '\\') return NULL;
1638 while (p >= start && *p != '\\') { len--; p--; };
1639 while (p >= start && *p == '\\') { len--; p--; };
1641 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1642 for (i = 0, p = start; p < start + len; p++)
1644 if (p[0] == '\\' && p[1] == '\\')
1646 ret[i++] = '\\';
1647 p++;
1649 else ret[i++] = *p;
1651 ret[i] = 0;
1652 *ret_len = i;
1653 return ret;
1656 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1658 UINT i;
1659 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1660 return FALSE;
1663 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1664 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1666 const struct expr *left, *right;
1668 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1670 left = cond->u.expr.left;
1671 right = cond->u.expr.right;
1672 if (cond->u.expr.op == OP_EQ)
1674 UINT len;
1675 WCHAR *path;
1676 const WCHAR *str = NULL;
1678 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1679 !strcmpW( left->u.propval->name, prop_nameW ) &&
1680 toupperW( right->u.sval[0] ) == toupperW( root ))
1682 str = right->u.sval;
1684 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1685 !strcmpW( right->u.propval->name, prop_nameW ) &&
1686 toupperW( left->u.sval[0] ) == toupperW( root ))
1688 str = left->u.sval;
1690 if (str && (path = build_dirname( str, &len )))
1692 if (seen_dir( dirstack, path ))
1694 heap_free( path );
1695 return ++*count;
1697 else if (push_dir( dirstack, path, len )) return ++*count;
1698 heap_free( path );
1699 return *count = 0;
1702 else if (cond->u.expr.op == OP_OR)
1704 UINT left_count = 0, right_count = 0;
1706 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1707 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1708 return *count += left_count + right_count;
1710 return *count = 0;
1713 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1715 UINT len_path = 0, len_segment = strlenW( segment );
1716 WCHAR *ret;
1718 *len = 0;
1719 if (path) len_path = strlenW( path );
1720 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1721 if (path && len_path)
1723 memcpy( ret, path, len_path * sizeof(WCHAR) );
1724 ret[len_path] = '\\';
1725 *len += len_path + 1;
1727 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1728 *len += len_segment;
1729 ret[*len] = 0;
1730 return ret;
1733 static WCHAR *get_file_version( const WCHAR *filename )
1735 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1736 VS_FIXEDFILEINFO *info;
1737 DWORD size;
1738 void *block;
1739 WCHAR *ret;
1741 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1742 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1744 heap_free( ret );
1745 return NULL;
1747 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1748 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1750 heap_free( block );
1751 heap_free( ret );
1752 return NULL;
1754 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1755 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1756 heap_free( block );
1757 return ret;
1760 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1762 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1763 struct record_datafile *rec;
1764 UINT i, len, row = 0, offset = 0, num_expected_rows;
1765 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1766 DWORD drives = GetLogicalDrives();
1767 WIN32_FIND_DATAW data;
1768 HANDLE handle;
1769 struct dirstack *dirstack;
1770 enum fill_status status = FILL_STATUS_UNFILTERED;
1772 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1774 dirstack = alloc_dirstack(2);
1776 for (i = 0; i < 26; i++)
1778 if (!(drives & (1 << i))) continue;
1780 root[0] = 'A' + i;
1781 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1783 num_expected_rows = 0;
1784 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1786 for (;;)
1788 heap_free( glob );
1789 heap_free( path );
1790 path = pop_dir( dirstack, &len );
1791 if (!(glob = build_glob( root[0], path, len )))
1793 status = FILL_STATUS_FAILED;
1794 goto done;
1796 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1800 if (!resize_table( table, row + 1, sizeof(*rec) ))
1802 status = FILL_STATUS_FAILED;
1803 FindClose( handle );
1804 goto done;
1806 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1807 new_path = append_path( path, data.cFileName, &len );
1809 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1811 if (push_dir( dirstack, new_path, len )) continue;
1812 heap_free( new_path );
1813 FindClose( handle );
1814 status = FILL_STATUS_FAILED;
1815 goto done;
1817 rec = (struct record_datafile *)(table->data + offset);
1818 rec->name = build_name( root[0], new_path );
1819 rec->version = get_file_version( rec->name );
1820 if (!match_row( table, row, cond, &status ))
1822 free_row_values( table, row );
1823 continue;
1825 else if (num_expected_rows && row == num_expected_rows - 1)
1827 row++;
1828 FindClose( handle );
1829 status = FILL_STATUS_FILTERED;
1830 goto done;
1832 offset += sizeof(*rec);
1833 row++;
1835 while (FindNextFileW( handle, &data ));
1836 FindClose( handle );
1838 if (!peek_dir( dirstack )) break;
1842 done:
1843 free_dirstack( dirstack );
1844 heap_free( glob );
1845 heap_free( path );
1847 TRACE("created %u rows\n", row);
1848 table->num_rows = row;
1849 return status;
1852 static UINT32 get_pixelsperxlogicalinch(void)
1854 HDC hdc = GetDC( NULL );
1855 UINT32 ret;
1857 if (!hdc) return 96;
1858 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1859 ReleaseDC( NULL, hdc );
1860 return ret;
1863 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1865 struct record_desktopmonitor *rec;
1866 enum fill_status status = FILL_STATUS_UNFILTERED;
1867 UINT row = 0;
1869 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1871 rec = (struct record_desktopmonitor *)table->data;
1872 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1874 if (match_row( table, row, cond, &status )) row++;
1876 TRACE("created %u rows\n", row);
1877 table->num_rows = row;
1878 return status;
1881 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1883 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1884 struct record_directory *rec;
1885 UINT i, len, row = 0, offset = 0, num_expected_rows;
1886 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1887 DWORD drives = GetLogicalDrives();
1888 WIN32_FIND_DATAW data;
1889 HANDLE handle;
1890 struct dirstack *dirstack;
1891 enum fill_status status = FILL_STATUS_UNFILTERED;
1893 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1895 dirstack = alloc_dirstack(2);
1897 for (i = 0; i < 26; i++)
1899 if (!(drives & (1 << i))) continue;
1901 root[0] = 'A' + i;
1902 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1904 num_expected_rows = 0;
1905 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1907 for (;;)
1909 heap_free( glob );
1910 heap_free( path );
1911 path = pop_dir( dirstack, &len );
1912 if (!(glob = build_glob( root[0], path, len )))
1914 status = FILL_STATUS_FAILED;
1915 goto done;
1917 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1921 if (!resize_table( table, row + 1, sizeof(*rec) ))
1923 FindClose( handle );
1924 status = FILL_STATUS_FAILED;
1925 goto done;
1927 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1928 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1929 continue;
1931 new_path = append_path( path, data.cFileName, &len );
1932 if (!(push_dir( dirstack, new_path, len )))
1934 heap_free( new_path );
1935 FindClose( handle );
1936 status = FILL_STATUS_FAILED;
1937 goto done;
1939 rec = (struct record_directory *)(table->data + offset);
1940 rec->accessmask = FILE_ALL_ACCESS;
1941 rec->name = build_name( root[0], new_path );
1942 if (!match_row( table, row, cond, &status ))
1944 free_row_values( table, row );
1945 continue;
1947 else if (num_expected_rows && row == num_expected_rows - 1)
1949 row++;
1950 FindClose( handle );
1951 status = FILL_STATUS_FILTERED;
1952 goto done;
1954 offset += sizeof(*rec);
1955 row++;
1957 while (FindNextFileW( handle, &data ));
1958 FindClose( handle );
1960 if (!peek_dir( dirstack )) break;
1964 done:
1965 free_dirstack( dirstack );
1966 heap_free( glob );
1967 heap_free( path );
1969 TRACE("created %u rows\n", row);
1970 table->num_rows = row;
1971 return status;
1974 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1976 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
1977 ULARGE_INTEGER free;
1978 DISK_GEOMETRY_EX info;
1979 HANDLE handle;
1980 DWORD bytes_returned;
1982 free.QuadPart = 512 * 1024 * 1024;
1983 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
1985 root[4] = dir[0];
1986 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
1987 if (handle != INVALID_HANDLE_VALUE)
1989 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
1990 *disksize = info.DiskSize.QuadPart;
1991 CloseHandle( handle );
1993 return free.QuadPart;
1996 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
1998 static const WCHAR fmtW[] =
1999 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
2000 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
2001 struct record_diskdrive *rec;
2002 UINT i, row = 0, offset = 0, index = 0, type;
2003 UINT64 size = 1024 * 1024 * 1024;
2004 DWORD drives = GetLogicalDrives();
2005 enum fill_status status = FILL_STATUS_UNFILTERED;
2007 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
2009 for (i = 0; i < 26; i++)
2011 if (drives & (1 << i))
2013 root[0] = 'A' + i;
2014 type = GetDriveTypeW( root );
2015 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2016 continue;
2018 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2020 rec = (struct record_diskdrive *)(table->data + offset);
2021 sprintfW( device_id, fmtW, index );
2022 rec->device_id = heap_strdupW( device_id );
2023 rec->index = index;
2024 rec->interfacetype = diskdrive_interfacetypeW;
2025 rec->manufacturer = diskdrive_manufacturerW;
2026 if (type == DRIVE_FIXED)
2027 rec->mediatype = diskdrive_mediatype_fixedW;
2028 else
2029 rec->mediatype = diskdrive_mediatype_removableW;
2030 rec->model = diskdrive_modelW;
2031 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
2032 rec->serialnumber = diskdrive_serialW;
2033 get_freespace( root, &size );
2034 rec->size = size;
2035 if (!match_row( table, row, cond, &status ))
2037 free_row_values( table, row );
2038 continue;
2040 offset += sizeof(*rec);
2041 index++;
2042 row++;
2045 TRACE("created %u rows\n", row);
2046 table->num_rows = row;
2047 return status;
2050 static WCHAR *get_filesystem( const WCHAR *root )
2052 static const WCHAR ntfsW[] = {'N','T','F','S',0};
2053 WCHAR buffer[MAX_PATH + 1];
2055 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
2056 return heap_strdupW( buffer );
2057 return heap_strdupW( ntfsW );
2060 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
2062 static const WCHAR fmtW[] =
2063 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
2064 WCHAR device_id[32], root[] = {'A',':','\\',0};
2065 struct record_diskpartition *rec;
2066 UINT i, row = 0, offset = 0, type, index = 0;
2067 UINT64 size = 1024 * 1024 * 1024;
2068 DWORD drives = GetLogicalDrives();
2069 enum fill_status status = FILL_STATUS_UNFILTERED;
2071 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2073 for (i = 0; i < 26; i++)
2075 if (drives & (1 << i))
2077 root[0] = 'A' + i;
2078 type = GetDriveTypeW( root );
2079 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2080 continue;
2082 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2084 rec = (struct record_diskpartition *)(table->data + offset);
2085 rec->bootable = (i == 2) ? -1 : 0;
2086 rec->bootpartition = (i == 2) ? -1 : 0;
2087 sprintfW( device_id, fmtW, index );
2088 rec->device_id = heap_strdupW( device_id );
2089 rec->diskindex = index;
2090 rec->index = 0;
2091 rec->pnpdevice_id = heap_strdupW( device_id );
2092 get_freespace( root, &size );
2093 rec->size = size;
2094 rec->startingoffset = 0;
2095 rec->type = get_filesystem( root );
2096 if (!match_row( table, row, cond, &status ))
2098 free_row_values( table, row );
2099 continue;
2101 offset += sizeof(*rec);
2102 row++;
2103 index++;
2106 TRACE("created %u rows\n", row);
2107 table->num_rows = row;
2108 return status;
2111 static WCHAR *get_ip4_string( DWORD addr )
2113 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2114 WCHAR *ret;
2116 if (!(ret = heap_alloc( sizeof("ddd.ddd.ddd.ddd") * sizeof(WCHAR) ))) return NULL;
2117 sprintfW( ret, fmtW, (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff );
2118 return ret;
2121 static enum fill_status fill_ip4routetable( struct table *table, const struct expr *cond )
2123 struct record_ip4routetable *rec;
2124 UINT i, row = 0, offset = 0, size = 0;
2125 MIB_IPFORWARDTABLE *forwards;
2126 enum fill_status status = FILL_STATUS_UNFILTERED;
2128 if (GetIpForwardTable( NULL, &size, TRUE ) != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2129 if (!(forwards = heap_alloc( size ))) return FILL_STATUS_FAILED;
2130 if (GetIpForwardTable( forwards, &size, TRUE ))
2132 heap_free( forwards );
2133 return FILL_STATUS_FAILED;
2135 if (!resize_table( table, max(forwards->dwNumEntries, 1), sizeof(*rec) ))
2137 heap_free( forwards );
2138 return FILL_STATUS_FAILED;
2141 for (i = 0; i < forwards->dwNumEntries; i++)
2143 rec = (struct record_ip4routetable *)(table->data + offset);
2145 rec->destination = get_ip4_string( ntohl(forwards->table[i].dwForwardDest) );
2146 rec->interfaceindex = forwards->table[i].dwForwardIfIndex;
2147 rec->nexthop = get_ip4_string( ntohl(forwards->table[i].dwForwardNextHop) );
2149 if (!match_row( table, row, cond, &status ))
2151 free_row_values( table, row );
2152 continue;
2154 offset += sizeof(*rec);
2155 row++;
2157 TRACE("created %u rows\n", row);
2158 table->num_rows = row;
2160 heap_free( forwards );
2161 return status;
2164 static WCHAR *get_volumename( const WCHAR *root )
2166 WCHAR buf[MAX_PATH + 1] = {0};
2167 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
2168 return heap_strdupW( buf );
2170 static WCHAR *get_volumeserialnumber( const WCHAR *root )
2172 static const WCHAR fmtW[] = {'%','0','8','X',0};
2173 DWORD serial = 0;
2174 WCHAR buffer[9];
2176 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
2177 sprintfW( buffer, fmtW, serial );
2178 return heap_strdupW( buffer );
2181 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
2183 static const WCHAR fmtW[] = {'%','c',':',0};
2184 WCHAR device_id[3], root[] = {'A',':','\\',0};
2185 struct record_logicaldisk *rec;
2186 UINT i, row = 0, offset = 0, type;
2187 UINT64 size = 1024 * 1024 * 1024;
2188 DWORD drives = GetLogicalDrives();
2189 enum fill_status status = FILL_STATUS_UNFILTERED;
2191 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2193 for (i = 0; i < 26; i++)
2195 if (drives & (1 << i))
2197 root[0] = 'A' + i;
2198 type = GetDriveTypeW( root );
2199 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
2200 continue;
2202 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2204 rec = (struct record_logicaldisk *)(table->data + offset);
2205 sprintfW( device_id, fmtW, 'A' + i );
2206 rec->device_id = heap_strdupW( device_id );
2207 rec->drivetype = type;
2208 rec->filesystem = get_filesystem( root );
2209 rec->freespace = get_freespace( root, &size );
2210 rec->name = heap_strdupW( device_id );
2211 rec->size = size;
2212 rec->volumename = get_volumename( root );
2213 rec->volumeserialnumber = get_volumeserialnumber( root );
2214 if (!match_row( table, row, cond, &status ))
2216 free_row_values( table, row );
2217 continue;
2219 offset += sizeof(*rec);
2220 row++;
2223 TRACE("created %u rows\n", row);
2224 table->num_rows = row;
2225 return status;
2228 static UINT16 get_connection_status( IF_OPER_STATUS status )
2230 switch (status)
2232 case IfOperStatusDown:
2233 return 0; /* Disconnected */
2234 case IfOperStatusUp:
2235 return 2; /* Connected */
2236 default:
2237 ERR("unhandled status %u\n", status);
2238 break;
2240 return 0;
2242 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2244 static const WCHAR fmtW[] =
2245 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2246 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2247 WCHAR *ret;
2249 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2250 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2251 return ret;
2253 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2255 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2256 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2257 static const WCHAR firewireW[] = {'1','3','9','4',0};
2258 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2260 switch (type)
2262 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2263 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2264 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2265 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2266 default: *physical = 0; return NULL;
2270 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2272 static const WCHAR fmtW[] = {'%','u',0};
2273 WCHAR device_id[11];
2274 struct record_networkadapter *rec;
2275 IP_ADAPTER_ADDRESSES *aa, *buffer;
2276 UINT row = 0, offset = 0, count = 0;
2277 DWORD size = 0, ret;
2278 int physical;
2279 enum fill_status status = FILL_STATUS_UNFILTERED;
2281 ret = GetAdaptersAddresses( WS_AF_UNSPEC, 0, NULL, NULL, &size );
2282 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2284 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2285 if (GetAdaptersAddresses( WS_AF_UNSPEC, 0, NULL, buffer, &size ))
2287 heap_free( buffer );
2288 return FILL_STATUS_FAILED;
2290 for (aa = buffer; aa; aa = aa->Next)
2292 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2294 if (!resize_table( table, count, sizeof(*rec) ))
2296 heap_free( buffer );
2297 return FILL_STATUS_FAILED;
2299 for (aa = buffer; aa; aa = aa->Next)
2301 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2303 rec = (struct record_networkadapter *)(table->data + offset);
2304 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2305 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2306 rec->device_id = heap_strdupW( device_id );
2307 rec->index = aa->u.s.IfIndex;
2308 rec->interface_index = aa->u.s.IfIndex;
2309 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2310 rec->manufacturer = compsys_manufacturerW;
2311 rec->name = heap_strdupW( aa->FriendlyName );
2312 rec->netconnection_status = get_connection_status( aa->OperStatus );
2313 rec->physicaladapter = physical;
2314 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2315 rec->speed = 1000000;
2316 if (!match_row( table, row, cond, &status ))
2318 free_row_values( table, row );
2319 continue;
2321 offset += sizeof(*rec);
2322 row++;
2324 TRACE("created %u rows\n", row);
2325 table->num_rows = row;
2327 heap_free( buffer );
2328 return status;
2331 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2333 const SOCKET_ADDRESS *sa = &addr->Address;
2334 WCHAR buf[WS_NI_MAXHOST];
2336 if (!addr) return NULL;
2337 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2338 0, WS_NI_NAMEREQD )) return NULL;
2339 return heap_strdupW( buf );
2341 static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
2343 IP_ADAPTER_GATEWAY_ADDRESS *gateway;
2344 struct array *ret;
2345 ULONG buflen, i = 0, count = 0;
2346 WCHAR **ptr, buf[54]; /* max IPv6 address length */
2348 if (!list) return NULL;
2349 for (gateway = list; gateway; gateway = gateway->Next) count++;
2351 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2352 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2354 heap_free( ret );
2355 return NULL;
2357 for (gateway = list; gateway; gateway = gateway->Next)
2359 buflen = sizeof(buf)/sizeof(buf[0]);
2360 if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
2361 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2363 for (; i > 0; i--) heap_free( ptr[i - 1] );
2364 heap_free( ptr );
2365 heap_free( ret );
2366 return NULL;
2369 ret->count = count;
2370 ret->ptr = ptr;
2371 return ret;
2373 static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
2375 IP_ADAPTER_DNS_SERVER_ADDRESS *server;
2376 struct array *ret;
2377 ULONG buflen, i = 0, count = 0;
2378 WCHAR **ptr, *p, buf[54]; /* max IPv6 address length */
2380 if (!list) return NULL;
2381 for (server = list; server; server = server->Next) count++;
2383 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2384 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2386 heap_free( ret );
2387 return NULL;
2389 for (server = list; server; server = server->Next)
2391 buflen = sizeof(buf)/sizeof(buf[0]);
2392 if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
2393 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2395 for (; i > 0; i--) heap_free( ptr[i - 1] );
2396 heap_free( ptr );
2397 heap_free( ret );
2398 return NULL;
2400 if ((p = strrchrW( ptr[i - 1], ':' ))) *p = 0;
2402 ret->count = count;
2403 ret->ptr = ptr;
2404 return ret;
2406 static WCHAR *get_settingid( UINT32 index )
2408 GUID guid;
2409 WCHAR *ret, *str;
2410 memset( &guid, 0, sizeof(guid) );
2411 guid.Data1 = index;
2412 UuidToStringW( &guid, &str );
2413 ret = heap_strdupW( str );
2414 RpcStringFreeW( &str );
2415 return ret;
2418 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2420 struct record_networkadapterconfig *rec;
2421 IP_ADAPTER_ADDRESSES *aa, *buffer;
2422 UINT row = 0, offset = 0, count = 0;
2423 DWORD size = 0, ret;
2424 enum fill_status status = FILL_STATUS_UNFILTERED;
2426 ret = GetAdaptersAddresses( WS_AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &size );
2427 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2429 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2430 if (GetAdaptersAddresses( WS_AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, buffer, &size ))
2432 heap_free( buffer );
2433 return FILL_STATUS_FAILED;
2435 for (aa = buffer; aa; aa = aa->Next)
2437 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2439 if (!resize_table( table, count, sizeof(*rec) ))
2441 heap_free( buffer );
2442 return FILL_STATUS_FAILED;
2444 for (aa = buffer; aa; aa = aa->Next)
2446 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2448 rec = (struct record_networkadapterconfig *)(table->data + offset);
2449 rec->defaultipgateway = get_defaultipgateway( aa->FirstGatewayAddress );
2450 rec->description = heap_strdupW( aa->Description );
2451 rec->dhcpenabled = -1;
2452 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2453 rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress );
2454 rec->index = aa->u.s.IfIndex;
2455 rec->ipconnectionmetric = 20;
2456 rec->ipenabled = -1;
2457 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2458 rec->settingid = get_settingid( rec->index );
2459 if (!match_row( table, row, cond, &status ))
2461 free_row_values( table, row );
2462 continue;
2464 offset += sizeof(*rec);
2465 row++;
2467 TRACE("created %u rows\n", row);
2468 table->num_rows = row;
2470 heap_free( buffer );
2471 return status;
2474 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2476 struct record_physicalmemory *rec;
2477 enum fill_status status = FILL_STATUS_UNFILTERED;
2478 UINT row = 0;
2480 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2482 rec = (struct record_physicalmemory *)table->data;
2483 rec->capacity = get_total_physical_memory();
2484 rec->memorytype = 9; /* RAM */
2485 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2486 else row++;
2488 TRACE("created %u rows\n", row);
2489 table->num_rows = row;
2490 return status;
2493 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2495 struct record_printer *rec;
2496 enum fill_status status = FILL_STATUS_UNFILTERED;
2497 PRINTER_INFO_2W *info;
2498 DWORD i, offset = 0, count = 0, size = 0, num_rows = 0;
2500 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2501 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2503 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2504 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2506 heap_free( info );
2507 return FILL_STATUS_FAILED;
2509 if (!resize_table( table, count, sizeof(*rec) ))
2511 heap_free( info );
2512 return FILL_STATUS_FAILED;
2515 for (i = 0; i < count; i++)
2517 rec = (struct record_printer *)(table->data + offset);
2518 rec->attributes = info[i].Attributes;
2519 rec->drivername = heap_strdupW( info[i].pDriverName );
2520 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2521 rec->local = -1;
2522 rec->name = heap_strdupW( info[i].pPrinterName );
2523 rec->network = 0;
2524 if (!match_row( table, i, cond, &status ))
2526 free_row_values( table, i );
2527 continue;
2529 offset += sizeof(*rec);
2530 num_rows++;
2532 TRACE("created %u rows\n", num_rows);
2533 table->num_rows = num_rows;
2535 heap_free( info );
2536 return status;
2539 static WCHAR *get_cmdline( DWORD process_id )
2541 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2542 return NULL; /* FIXME handle different process case */
2545 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2547 static const WCHAR fmtW[] = {'%','u',0};
2548 WCHAR handle[11];
2549 struct record_process *rec;
2550 PROCESSENTRY32W entry;
2551 HANDLE snap;
2552 enum fill_status status = FILL_STATUS_FAILED;
2553 UINT row = 0, offset = 0;
2555 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2556 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2558 entry.dwSize = sizeof(entry);
2559 if (!Process32FirstW( snap, &entry )) goto done;
2560 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2564 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2566 rec = (struct record_process *)(table->data + offset);
2567 rec->caption = heap_strdupW( entry.szExeFile );
2568 rec->commandline = get_cmdline( entry.th32ProcessID );
2569 rec->description = heap_strdupW( entry.szExeFile );
2570 sprintfW( handle, fmtW, entry.th32ProcessID );
2571 rec->handle = heap_strdupW( handle );
2572 rec->name = heap_strdupW( entry.szExeFile );
2573 rec->process_id = entry.th32ProcessID;
2574 rec->pprocess_id = entry.th32ParentProcessID;
2575 rec->thread_count = entry.cntThreads;
2576 rec->workingsetsize = 0;
2577 rec->get_owner = process_get_owner;
2578 if (!match_row( table, row, cond, &status ))
2580 free_row_values( table, row );
2581 continue;
2583 offset += sizeof(*rec);
2584 row++;
2585 } while (Process32NextW( snap, &entry ));
2587 TRACE("created %u rows\n", row);
2588 table->num_rows = row;
2589 status = FILL_STATUS_UNFILTERED;
2591 done:
2592 CloseHandle( snap );
2593 return status;
2596 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2598 #ifdef __i386__
2599 #ifdef _MSC_VER
2600 __cpuid(p, ax);
2601 #else
2602 __asm__("pushl %%ebx\n\t"
2603 "cpuid\n\t"
2604 "movl %%ebx, %%esi\n\t"
2605 "popl %%ebx"
2606 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2607 : "0" (ax));
2608 #endif
2609 #endif
2611 static const WCHAR *get_osarchitecture(void)
2613 SYSTEM_INFO info;
2614 GetNativeSystemInfo( &info );
2615 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2616 return os_32bitW;
2618 static void get_processor_caption( WCHAR *caption )
2620 static const WCHAR fmtW[] =
2621 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2622 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2623 static const WCHAR x86W[] = {'x','8','6',0};
2624 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2625 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2626 unsigned int regs[4] = {0, 0, 0, 0};
2628 do_cpuid( 1, regs );
2629 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2631 static void get_processor_version( WCHAR *version )
2633 static const WCHAR fmtW[] =
2634 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2635 unsigned int regs[4] = {0, 0, 0, 0};
2637 do_cpuid( 1, regs );
2638 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2640 static UINT16 get_processor_revision(void)
2642 unsigned int regs[4] = {0, 0, 0, 0};
2643 do_cpuid( 1, regs );
2644 return regs[0];
2646 static void get_processor_id( WCHAR *processor_id )
2648 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2649 unsigned int regs[4] = {0, 0, 0, 0};
2651 do_cpuid( 1, regs );
2652 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2654 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2656 unsigned int i;
2657 unsigned char *p = (unsigned char *)regs;
2659 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2660 buffer[i] = 0;
2662 static void get_processor_manufacturer( WCHAR *manufacturer )
2664 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2666 do_cpuid( 0, regs );
2667 tmp = regs[2]; /* swap edx and ecx */
2668 regs[2] = regs[3];
2669 regs[3] = tmp;
2671 regs_to_str( regs + 1, 12, manufacturer );
2673 static void get_processor_name( WCHAR *name )
2675 unsigned int regs[4] = {0, 0, 0, 0};
2677 do_cpuid( 0x80000000, regs );
2678 if (regs[0] >= 0x80000004)
2680 do_cpuid( 0x80000002, regs );
2681 regs_to_str( regs, 16, name );
2682 do_cpuid( 0x80000003, regs );
2683 regs_to_str( regs, 16, name + 16 );
2684 do_cpuid( 0x80000004, regs );
2685 regs_to_str( regs, 16, name + 32 );
2688 static UINT get_processor_currentclockspeed( UINT index )
2690 PROCESSOR_POWER_INFORMATION *info;
2691 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2692 NTSTATUS status;
2694 if ((info = heap_alloc( size )))
2696 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2697 if (!status) ret = info[index].CurrentMhz;
2698 heap_free( info );
2700 return ret;
2702 static UINT get_processor_maxclockspeed( UINT index )
2704 PROCESSOR_POWER_INFORMATION *info;
2705 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2706 NTSTATUS status;
2708 if ((info = heap_alloc( size )))
2710 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2711 if (!status) ret = info[index].MaxMhz;
2712 heap_free( info );
2714 return ret;
2717 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2719 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2720 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2721 struct record_processor *rec;
2722 UINT i, offset = 0, num_rows = 0, num_cores, num_logical_processors, count = get_processor_count();
2723 enum fill_status status = FILL_STATUS_UNFILTERED;
2725 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2727 get_processor_caption( caption );
2728 get_processor_id( processor_id );
2729 get_processor_manufacturer( manufacturer );
2730 get_processor_name( name );
2731 get_processor_version( version );
2733 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2734 num_cores /= count;
2736 for (i = 0; i < count; i++)
2738 rec = (struct record_processor *)(table->data + offset);
2739 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2740 rec->architecture = get_osarchitecture() == os_32bitW ? 0 : 9;
2741 rec->caption = heap_strdupW( caption );
2742 rec->cpu_status = 1; /* CPU Enabled */
2743 rec->currentclockspeed = get_processor_currentclockspeed( i );
2744 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2745 rec->description = heap_strdupW( caption );
2746 sprintfW( device_id, fmtW, i );
2747 rec->device_id = heap_strdupW( device_id );
2748 rec->family = 2; /* Unknown */
2749 rec->level = 15;
2750 rec->manufacturer = heap_strdupW( manufacturer );
2751 rec->maxclockspeed = get_processor_maxclockspeed( i );
2752 rec->name = heap_strdupW( name );
2753 rec->num_cores = num_cores;
2754 rec->num_logical_processors = num_logical_processors;
2755 rec->processor_id = heap_strdupW( processor_id );
2756 rec->processortype = 3; /* central processor */
2757 rec->revision = get_processor_revision();
2758 rec->unique_id = NULL;
2759 rec->version = heap_strdupW( version );
2760 if (!match_row( table, i, cond, &status ))
2762 free_row_values( table, i );
2763 continue;
2765 offset += sizeof(*rec);
2766 num_rows++;
2769 TRACE("created %u rows\n", num_rows);
2770 table->num_rows = num_rows;
2771 return status;
2774 static WCHAR *get_lastbootuptime(void)
2776 static const WCHAR fmtW[] =
2777 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2778 '.','%','0','6','u','+','0','0','0',0};
2779 SYSTEM_TIMEOFDAY_INFORMATION ti;
2780 TIME_FIELDS tf;
2781 WCHAR *ret;
2783 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2785 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2786 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2787 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2788 return ret;
2790 static WCHAR *get_localdatetime(void)
2792 static const WCHAR fmtW[] =
2793 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2794 '.','%','0','6','u','%','+','0','3','d',0};
2795 TIME_ZONE_INFORMATION tzi;
2796 SYSTEMTIME st;
2797 WCHAR *ret;
2798 DWORD Status;
2799 LONG Bias;
2801 Status = GetTimeZoneInformation(&tzi);
2803 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2804 Bias = tzi.Bias;
2805 if(Status == TIME_ZONE_ID_DAYLIGHT)
2806 Bias+= tzi.DaylightBias;
2807 else
2808 Bias+= tzi.StandardBias;
2809 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2811 GetLocalTime(&st);
2812 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2813 return ret;
2815 static WCHAR *get_systemdirectory(void)
2817 void *redir;
2818 WCHAR *ret;
2820 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2821 Wow64DisableWow64FsRedirection( &redir );
2822 GetSystemDirectoryW( ret, MAX_PATH );
2823 Wow64RevertWow64FsRedirection( redir );
2824 return ret;
2826 static WCHAR *get_codeset(void)
2828 static const WCHAR fmtW[] = {'%','u',0};
2829 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2830 if (ret) sprintfW( ret, fmtW, GetACP() );
2831 return ret;
2833 static WCHAR *get_countrycode(void)
2835 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2836 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2837 return ret;
2839 static WCHAR *get_locale(void)
2841 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2842 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2843 return ret;
2845 static WCHAR *get_osbuildnumber( OSVERSIONINFOEXW *ver )
2847 static const WCHAR fmtW[] = {'%','u',0};
2848 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2849 if (ret) sprintfW( ret, fmtW, ver->dwBuildNumber );
2850 return ret;
2852 static WCHAR *get_oscaption( OSVERSIONINFOEXW *ver )
2854 static const WCHAR windowsW[] =
2855 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
2856 static const WCHAR win2000W[] =
2857 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2858 static const WCHAR win2003W[] =
2859 {'S','e','r','v','e','r',' ','2','0','0','3',' ','S','t','a','n','d','a','r','d',' ','E','d','i','t','i','o','n',0};
2860 static const WCHAR winxpW[] =
2861 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2862 static const WCHAR winxp64W[] =
2863 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',' ','x','6','4',' ','E','d','i','t','i','o','n',0};
2864 static const WCHAR vistaW[] =
2865 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
2866 static const WCHAR win2008W[] =
2867 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
2868 static const WCHAR win7W[] =
2869 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2870 static const WCHAR win2008r2W[] =
2871 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
2872 static const WCHAR win8W[] =
2873 {'8',' ','P','r','o',0};
2874 static const WCHAR win81W[] =
2875 {'8','.','1',' ','P','r','o',0};
2876 static const WCHAR win10W[] =
2877 {'1','0',' ','P','r','o',0};
2878 int len = sizeof(windowsW)/sizeof(windowsW[0]);
2879 WCHAR *ret;
2881 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(win2003W) ))) return NULL;
2882 memcpy( ret, windowsW, sizeof(windowsW) );
2883 if (ver->dwMajorVersion == 10 && ver->dwMinorVersion == 0) memcpy( ret + len, win10W, sizeof(win10W) );
2884 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 3) memcpy( ret + len, win8W, sizeof(win8W) );
2885 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 2) memcpy( ret + len, win81W, sizeof(win81W) );
2886 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 1)
2888 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, win7W, sizeof(win7W) );
2889 else memcpy( ret + len, win2008r2W, sizeof(win2008r2W) );
2891 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 0)
2893 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, vistaW, sizeof(vistaW) );
2894 else memcpy( ret + len, win2008W, sizeof(win2008W) );
2896 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 2)
2898 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, winxp64W, sizeof(winxp64W) );
2899 else memcpy( ret + len, win2003W, sizeof(win2003W) );
2901 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 1) memcpy( ret + len, winxpW, sizeof(winxpW) );
2902 else memcpy( ret + len, win2000W, sizeof(win2000W) );
2903 return ret;
2905 static WCHAR *get_osname( const WCHAR *caption )
2907 static const WCHAR partitionW[] =
2908 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
2909 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
2910 int len = strlenW( caption );
2911 WCHAR *ret;
2913 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(partitionW) ))) return NULL;
2914 memcpy( ret, caption, len * sizeof(WCHAR) );
2915 memcpy( ret + len, partitionW, sizeof(partitionW) );
2916 return ret;
2918 static WCHAR *get_osversion( OSVERSIONINFOEXW *ver )
2920 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u',0};
2921 WCHAR *ret = heap_alloc( 33 * sizeof(WCHAR) );
2922 if (ret) sprintfW( ret, fmtW, ver->dwMajorVersion, ver->dwMinorVersion, ver->dwBuildNumber );
2923 return ret;
2926 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2928 struct record_operatingsystem *rec;
2929 enum fill_status status = FILL_STATUS_UNFILTERED;
2930 OSVERSIONINFOEXW ver;
2931 UINT row = 0;
2933 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2935 ver.dwOSVersionInfoSize = sizeof(ver);
2936 GetVersionExW( (OSVERSIONINFOW *)&ver );
2938 rec = (struct record_operatingsystem *)table->data;
2939 rec->buildnumber = get_osbuildnumber( &ver );
2940 rec->caption = get_oscaption( &ver );
2941 rec->codeset = get_codeset();
2942 rec->countrycode = get_countrycode();
2943 rec->csdversion = ver.szCSDVersion[0] ? heap_strdupW( ver.szCSDVersion ) : NULL;
2944 rec->installdate = os_installdateW;
2945 rec->lastbootuptime = get_lastbootuptime();
2946 rec->localdatetime = get_localdatetime();
2947 rec->locale = get_locale();
2948 rec->name = get_osname( rec->caption );
2949 rec->osarchitecture = get_osarchitecture();
2950 rec->oslanguage = GetSystemDefaultLangID();
2951 rec->osproductsuite = 2461140; /* Windows XP Professional */
2952 rec->ostype = 18; /* WINNT */
2953 rec->primary = -1;
2954 rec->serialnumber = os_serialnumberW;
2955 rec->servicepackmajor = ver.wServicePackMajor;
2956 rec->servicepackminor = ver.wServicePackMinor;
2957 rec->suitemask = 272; /* Single User + Terminal */
2958 rec->systemdirectory = get_systemdirectory();
2959 rec->totalvirtualmemorysize = get_total_physical_memory() / 1024;
2960 rec->totalvisiblememorysize = rec->totalvirtualmemorysize;
2961 rec->version = get_osversion( &ver );
2962 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2963 else row++;
2965 TRACE("created %u rows\n", row);
2966 table->num_rows = row;
2967 return status;
2970 static const WCHAR *get_service_type( DWORD type )
2972 static const WCHAR filesystem_driverW[] =
2973 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
2974 static const WCHAR kernel_driverW[] =
2975 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
2976 static const WCHAR own_processW[] =
2977 {'O','w','n',' ','P','r','o','c','e','s','s',0};
2978 static const WCHAR share_processW[] =
2979 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
2981 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
2982 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
2983 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
2984 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
2985 else ERR("unhandled type 0x%08x\n", type);
2986 return NULL;
2988 static const WCHAR *get_service_state( DWORD state )
2990 static const WCHAR runningW[] =
2991 {'R','u','n','n','i','n','g',0};
2992 static const WCHAR start_pendingW[] =
2993 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
2994 static const WCHAR stop_pendingW[] =
2995 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
2996 static const WCHAR stoppedW[] =
2997 {'S','t','o','p','p','e','d',0};
2998 static const WCHAR unknownW[] =
2999 {'U','n','k','n','o','w','n',0};
3001 switch (state)
3003 case SERVICE_STOPPED: return stoppedW;
3004 case SERVICE_START_PENDING: return start_pendingW;
3005 case SERVICE_STOP_PENDING: return stop_pendingW;
3006 case SERVICE_RUNNING: return runningW;
3007 default:
3008 ERR("unknown state %u\n", state);
3009 return unknownW;
3012 static const WCHAR *get_service_startmode( DWORD mode )
3014 static const WCHAR bootW[] = {'B','o','o','t',0};
3015 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
3016 static const WCHAR autoW[] = {'A','u','t','o',0};
3017 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
3018 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
3019 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
3021 switch (mode)
3023 case SERVICE_BOOT_START: return bootW;
3024 case SERVICE_SYSTEM_START: return systemW;
3025 case SERVICE_AUTO_START: return autoW;
3026 case SERVICE_DEMAND_START: return manualW;
3027 case SERVICE_DISABLED: return disabledW;
3028 default:
3029 ERR("unknown mode 0x%x\n", mode);
3030 return unknownW;
3033 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
3035 QUERY_SERVICE_CONFIGW *config = NULL;
3036 SC_HANDLE service;
3037 DWORD size;
3039 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
3040 QueryServiceConfigW( service, NULL, 0, &size );
3041 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
3042 if (!(config = heap_alloc( size ))) goto done;
3043 if (QueryServiceConfigW( service, config, size, &size )) goto done;
3044 heap_free( config );
3045 config = NULL;
3047 done:
3048 CloseServiceHandle( service );
3049 return config;
3052 static enum fill_status fill_service( struct table *table, const struct expr *cond )
3054 struct record_service *rec;
3055 SC_HANDLE manager;
3056 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
3057 SERVICE_STATUS_PROCESS *status;
3058 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
3059 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
3060 UINT i, row = 0, offset = 0, size = 256, needed, count;
3061 enum fill_status fill_status = FILL_STATUS_FAILED;
3062 BOOL ret;
3064 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
3065 if (!(services = heap_alloc( size ))) goto done;
3067 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
3068 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
3069 &count, NULL, NULL );
3070 if (!ret)
3072 if (GetLastError() != ERROR_MORE_DATA) goto done;
3073 size = needed;
3074 if (!(tmp = heap_realloc( services, size ))) goto done;
3075 services = tmp;
3076 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
3077 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
3078 &count, NULL, NULL );
3079 if (!ret) goto done;
3081 if (!resize_table( table, count, sizeof(*rec) )) goto done;
3083 GetComputerNameW( sysnameW, &len );
3084 fill_status = FILL_STATUS_UNFILTERED;
3086 for (i = 0; i < count; i++)
3088 QUERY_SERVICE_CONFIGW *config;
3090 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
3092 status = &services[i].ServiceStatusProcess;
3093 rec = (struct record_service *)(table->data + offset);
3094 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
3095 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
3096 rec->displayname = heap_strdupW( services[i].lpDisplayName );
3097 rec->name = heap_strdupW( services[i].lpServiceName );
3098 rec->process_id = status->dwProcessId;
3099 rec->servicetype = get_service_type( status->dwServiceType );
3100 rec->startmode = get_service_startmode( config->dwStartType );
3101 rec->state = get_service_state( status->dwCurrentState );
3102 rec->systemname = heap_strdupW( sysnameW );
3103 rec->pause_service = service_pause_service;
3104 rec->resume_service = service_resume_service;
3105 rec->start_service = service_start_service;
3106 rec->stop_service = service_stop_service;
3107 heap_free( config );
3108 if (!match_row( table, row, cond, &fill_status ))
3110 free_row_values( table, row );
3111 continue;
3113 offset += sizeof(*rec);
3114 row++;
3117 TRACE("created %u rows\n", row);
3118 table->num_rows = row;
3120 done:
3121 CloseServiceHandle( manager );
3122 heap_free( services );
3123 return fill_status;
3126 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
3128 if (!name || !name->Name.Buffer) return NULL;
3129 return heap_strdupW( name->Name.Buffer );
3131 static struct array *get_binaryrepresentation( PSID sid, UINT len )
3133 struct array *array = heap_alloc( sizeof(struct array) );
3134 if (array)
3136 UINT8 *ret = heap_alloc( len );
3137 if (ret)
3139 memcpy( ret, sid, len );
3140 array->count = len;
3141 array->ptr = ret;
3142 return array;
3144 heap_free( array );
3146 return NULL;
3148 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
3150 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
3151 return heap_strdupW( domain->Domains->Name.Buffer );
3153 static const WCHAR *find_sid_str( const struct expr *cond )
3155 const struct expr *left, *right;
3156 const WCHAR *ret = NULL;
3158 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
3160 left = cond->u.expr.left;
3161 right = cond->u.expr.right;
3162 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
3164 ret = right->u.sval;
3166 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
3168 ret = left->u.sval;
3170 return ret;
3173 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
3175 PSID sid;
3176 LSA_REFERENCED_DOMAIN_LIST *domain;
3177 LSA_TRANSLATED_NAME *name;
3178 LSA_HANDLE handle;
3179 LSA_OBJECT_ATTRIBUTES attrs;
3180 const WCHAR *str;
3181 struct record_sid *rec;
3182 UINT len;
3184 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
3185 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
3187 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
3188 len = GetLengthSid( sid );
3190 memset( &attrs, 0, sizeof(attrs) );
3191 attrs.Length = sizeof(attrs);
3192 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
3194 LocalFree( sid );
3195 return FILL_STATUS_FAILED;
3197 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
3199 LocalFree( sid );
3200 LsaClose( handle );
3201 return FILL_STATUS_FAILED;
3204 rec = (struct record_sid *)table->data;
3205 rec->accountname = get_accountname( name );
3206 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
3207 rec->referenceddomainname = get_referenceddomainname( domain );
3208 rec->sid = heap_strdupW( str );
3209 rec->sidlength = len;
3211 TRACE("created 1 row\n");
3212 table->num_rows = 1;
3214 LsaFreeMemory( domain );
3215 LsaFreeMemory( name );
3216 LocalFree( sid );
3217 LsaClose( handle );
3218 return FILL_STATUS_FILTERED;
3221 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
3223 HDC hdc = GetDC( NULL );
3224 UINT32 ret;
3226 if (!hdc) return 32;
3227 ret = GetDeviceCaps( hdc, BITSPIXEL );
3228 *hres = GetDeviceCaps( hdc, HORZRES );
3229 *vres = GetDeviceCaps( hdc, VERTRES );
3230 ReleaseDC( NULL, hdc );
3231 return ret;
3233 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
3235 static const WCHAR fmtW[] =
3236 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
3237 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
3238 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
3239 WCHAR *ret;
3241 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
3242 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
3243 return ret;
3246 #define HW_VENDOR_AMD 0x1002
3247 #define HW_VENDOR_NVIDIA 0x10de
3248 #define HW_VENDOR_VMWARE 0x15ad
3249 #define HW_VENDOR_INTEL 0x8086
3251 static const WCHAR *get_installeddriver( UINT vendorid )
3253 static const WCHAR driver_amdW[] = {'a','t','i','c','f','x','3','2','.','d','l','l',0};
3254 static const WCHAR driver_intelW[] = {'i','g','d','u','m','d','i','m','3','2','.','d','l','l',0};
3255 static const WCHAR driver_nvidiaW[] = {'n','v','d','3','d','u','m','.','d','l','l',0};
3256 static const WCHAR driver_wineW[] = {'w','i','n','e','.','d','l','l',0};
3258 /* FIXME: wined3d has a better table, but we can not access this information through dxgi */
3260 if (vendorid == HW_VENDOR_AMD)
3261 return driver_amdW;
3262 else if (vendorid == HW_VENDOR_NVIDIA)
3263 return driver_nvidiaW;
3264 else if (vendorid == HW_VENDOR_INTEL)
3265 return driver_intelW;
3266 return driver_wineW;
3269 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
3271 static const WCHAR fmtW[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
3272 struct record_videocontroller *rec;
3273 HRESULT hr;
3274 IDXGIFactory *factory = NULL;
3275 IDXGIAdapter *adapter = NULL;
3276 DXGI_ADAPTER_DESC desc;
3277 UINT row = 0, hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
3278 const WCHAR *name = videocontroller_deviceidW;
3279 enum fill_status status = FILL_STATUS_UNFILTERED;
3280 WCHAR mode[44];
3282 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
3284 memset (&desc, 0, sizeof(desc));
3285 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
3286 if (FAILED(hr)) goto done;
3288 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
3289 if (FAILED(hr)) goto done;
3291 hr = IDXGIAdapter_GetDesc( adapter, &desc );
3292 if (SUCCEEDED(hr))
3294 vidmem = desc.DedicatedVideoMemory;
3295 name = desc.Description;
3298 done:
3299 rec = (struct record_videocontroller *)table->data;
3300 rec->adapter_dactype = videocontroller_dactypeW;
3301 rec->adapter_ram = vidmem;
3302 rec->availability = 3; /* Running or Full Power */
3303 rec->config_errorcode = 0; /* no error */
3304 rec->caption = heap_strdupW( name );
3305 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
3306 rec->current_horizontalres = hres;
3307 rec->current_refreshrate = 0; /* default refresh rate */
3308 rec->current_scanmode = 2; /* Unknown */
3309 rec->current_verticalres = vres;
3310 rec->description = heap_strdupW( name );
3311 rec->device_id = videocontroller_deviceidW;
3312 rec->driverdate = videocontroller_driverdateW;
3313 rec->driverversion = videocontroller_driverversionW;
3314 rec->installeddriver = get_installeddriver( desc.VendorId );
3315 rec->name = heap_strdupW( name );
3316 rec->pnpdevice_id = get_pnpdeviceid( &desc );
3317 rec->status = videocontroller_statusW;
3318 rec->videoarchitecture = 2; /* Unknown */
3319 rec->videomemorytype = 2; /* Unknown */
3320 wsprintfW( mode, fmtW, hres, vres, (UINT64)1 << rec->current_bitsperpixel );
3321 rec->videomodedescription = heap_strdupW( mode );
3322 rec->videoprocessor = heap_strdupW( name );
3323 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
3324 else row++;
3326 TRACE("created %u rows\n", row);
3327 table->num_rows = row;
3329 if (adapter) IDXGIAdapter_Release( adapter );
3330 if (factory) IDXGIFactory_Release( factory );
3331 return status;
3334 static struct table builtin_classes[] =
3336 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
3337 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
3338 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
3339 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
3340 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct },
3341 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
3342 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
3343 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
3344 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
3345 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
3346 { class_ip4routetableW, SIZEOF(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable },
3347 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3348 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3349 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
3350 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
3351 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
3352 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
3353 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
3354 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
3355 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
3356 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
3357 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3358 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3359 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
3360 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
3361 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
3362 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
3363 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
3364 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
3365 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
3366 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
3369 void init_table_list( void )
3371 static struct list tables = LIST_INIT( tables );
3372 UINT i;
3374 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
3375 table_list = &tables;