wbemprox: Tweak a comment.
[wine.git] / dlls / wbemprox / builtin.c
blob73f4192779197c16952265d4e90485a7a0d601f1
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_freephysicalmemoryW[] =
235 {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
236 static const WCHAR prop_handleW[] =
237 {'H','a','n','d','l','e',0};
238 static const WCHAR prop_horizontalresolutionW[] =
239 {'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
240 static const WCHAR prop_idW[] =
241 {'I','D',0};
242 static const WCHAR prop_identificationcodeW[] =
243 {'I','d','e','n','t','i','f','i','c','a','t','i','o','n','C','o','d','e',0};
244 static const WCHAR prop_identifyingnumberW[] =
245 {'I','d','e','n','t','i','f','y','i','n','g','N','u','m','b','e','r',0};
246 static const WCHAR prop_indexW[] =
247 {'I','n','d','e','x',0};
248 static const WCHAR prop_installdateW[] =
249 {'I','n','s','t','a','l','l','D','a','t','e',0};
250 static const WCHAR prop_installeddisplaydriversW[]=
251 {'I','n','s','t','a','l','l','e','d','D','i','s','p','l','a','y','D','r','i','v','e','r','s',0};
252 static const WCHAR prop_interfaceindexW[] =
253 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
254 static const WCHAR prop_interfacetypeW[] =
255 {'I','n','t','e','r','f','a','c','e','T','y','p','e',0};
256 static const WCHAR prop_intvalueW[] =
257 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
258 static const WCHAR prop_ipconnectionmetricW[] =
259 {'I','P','C','o','n','n','e','c','t','i','o','n','M','e','t','r','i','c',0};
260 static const WCHAR prop_ipenabledW[] =
261 {'I','P','E','n','a','b','l','e','d',0};
262 static const WCHAR prop_lastbootuptimeW[] =
263 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
264 static const WCHAR prop_levelW[] =
265 {'L','e','v','e','l',0};
266 static const WCHAR prop_localW[] =
267 {'L','o','c','a','l',0};
268 static const WCHAR prop_localdatetimeW[] =
269 {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
270 static const WCHAR prop_localeW[] =
271 {'L','o','c','a','l','e',0};
272 static const WCHAR prop_locationW[] =
273 {'L','o','c','a','t','i','o','n',0};
274 static const WCHAR prop_lockpresentW[] =
275 {'L','o','c','k','P','r','e','s','e','n','t',0};
276 static const WCHAR prop_macaddressW[] =
277 {'M','A','C','A','d','d','r','e','s','s',0};
278 static const WCHAR prop_manufacturerW[] =
279 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
280 static const WCHAR prop_maxclockspeedW[] =
281 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
282 static const WCHAR prop_mediatypeW[] =
283 {'M','e','d','i','a','T','y','p','e',0};
284 static const WCHAR prop_memberW[] =
285 {'M','e','m','b','e','r',0};
286 static const WCHAR prop_memorytypeW[] =
287 {'M','e','m','o','r','y','T','y','p','e',0};
288 static const WCHAR prop_methodW[] =
289 {'M','e','t','h','o','d',0};
290 static const WCHAR prop_modelW[] =
291 {'M','o','d','e','l',0};
292 static const WCHAR prop_netconnectionstatusW[] =
293 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
294 static const WCHAR prop_networkW[] =
295 {'N','e','t','w','o','r','k',0};
296 static const WCHAR prop_nexthopW[] =
297 {'N','e','x','t','H','o','p',0};
298 static const WCHAR prop_numcoresW[] =
299 {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
300 static const WCHAR prop_numlogicalprocessorsW[] =
301 {'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};
302 static const WCHAR prop_numprocessorsW[] =
303 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
304 static const WCHAR prop_osarchitectureW[] =
305 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
306 static const WCHAR prop_oslanguageW[] =
307 {'O','S','L','a','n','g','u','a','g','e',0};
308 static const WCHAR prop_osproductsuiteW[] =
309 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
310 static const WCHAR prop_ostypeW[] =
311 {'O','S','T','y','p','e',0};
312 static const WCHAR prop_parameterW[] =
313 {'P','a','r','a','m','e','t','e','r',0};
314 static const WCHAR prop_physicaladapterW[] =
315 {'P','h','y','s','i','c','a','l','A','d','a','p','t','e','r',0};
316 static const WCHAR prop_pixelsperxlogicalinchW[] =
317 {'P','i','x','e','l','s','P','e','r','X','L','o','g','i','c','a','l','I','n','c','h',0};
318 static const WCHAR prop_pnpdeviceidW[] =
319 {'P','N','P','D','e','v','i','c','e','I','D',0};
320 static const WCHAR prop_portnameW[] =
321 {'P','o','r','t','N','a','m','e',0};
322 static const WCHAR prop_pprocessidW[] =
323 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
324 static const WCHAR prop_primaryW[] =
325 {'P','r','i','m','a','r','y',0};
326 static const WCHAR prop_processidW[] =
327 {'P','r','o','c','e','s','s','I','D',0};
328 static const WCHAR prop_processoridW[] =
329 {'P','r','o','c','e','s','s','o','r','I','d',0};
330 static const WCHAR prop_processortypeW[] =
331 {'P','r','o','c','e','s','s','o','r','T','y','p','e',0};
332 static const WCHAR prop_productW[] =
333 {'P','r','o','d','u','c','t',0};
334 static const WCHAR prop_productnameW[] =
335 {'P','r','o','d','u','c','t','N','a','m','e',0};
336 static const WCHAR prop_referenceddomainnameW[] =
337 {'R','e','f','e','r','e','n','c','e','d','D','o','m','a','i','n','N','a','m','e',0};
338 static const WCHAR prop_releasedateW[] =
339 {'R','e','l','e','a','s','e','D','a','t','e',0};
340 static const WCHAR prop_revisionW[] =
341 {'R','e','v','i','s','i','o','n',0};
342 static const WCHAR prop_serialnumberW[] =
343 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
344 static const WCHAR prop_servicepackmajorW[] =
345 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
346 static const WCHAR prop_servicepackminorW[] =
347 {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0};
348 static const WCHAR prop_servicetypeW[] =
349 {'S','e','r','v','i','c','e','T','y','p','e',0};
350 static const WCHAR prop_settingidW[] =
351 {'S','e','t','t','i','n','g','I','D',0};
352 static const WCHAR prop_skunumberW[] =
353 {'S','K','U','N','u','m','b','e','r',0};
354 static const WCHAR prop_smbiosbiosversionW[] =
355 {'S','M','B','I','O','S','B','I','O','S','V','e','r','s','i','o','n',0};
356 static const WCHAR prop_smbiosmajorversionW[] =
357 {'S','M','B','I','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
358 static const WCHAR prop_smbiosminorversionW[] =
359 {'S','M','B','I','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
360 static const WCHAR prop_startmodeW[] =
361 {'S','t','a','r','t','M','o','d','e',0};
362 static const WCHAR prop_sidW[] =
363 {'S','I','D',0};
364 static const WCHAR prop_sidlengthW[] =
365 {'S','i','d','L','e','n','g','t','h',0};
366 static const WCHAR prop_sizeW[] =
367 {'S','i','z','e',0};
368 static const WCHAR prop_speedW[] =
369 {'S','p','e','e','d',0};
370 static const WCHAR prop_startingoffsetW[] =
371 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
372 static const WCHAR prop_stateW[] =
373 {'S','t','a','t','e',0};
374 static const WCHAR prop_statusW[] =
375 {'S','t','a','t','u','s',0};
376 static const WCHAR prop_statusinfoW[] =
377 {'S','t','a','t','u','s','I','n','f','o',0};
378 static const WCHAR prop_strvalueW[] =
379 {'S','t','r','i','n','g','V','a','l','u','e',0};
380 static const WCHAR prop_suitemaskW[] =
381 {'S','u','i','t','e','M','a','s','k',0};
382 static const WCHAR prop_systemdirectoryW[] =
383 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
384 static const WCHAR prop_systemnameW[] =
385 {'S','y','s','t','e','m','N','a','m','e',0};
386 static const WCHAR prop_tagW[] =
387 {'T','a','g',0};
388 static const WCHAR prop_threadcountW[] =
389 {'T','h','r','e','a','d','C','o','u','n','t',0};
390 static const WCHAR prop_totalphysicalmemoryW[] =
391 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
392 static const WCHAR prop_totalvirtualmemorysizeW[] =
393 {'T','o','t','a','l','V','i','r','t','u','a','l','M','e','m','o','r','y','S','i','z','e',0};
394 static const WCHAR prop_totalvisiblememorysizeW[] =
395 {'T','o','t','a','l','V','i','s','i','b','l','e','M','e','m','o','r','y','S','i','z','e',0};
396 static const WCHAR prop_typeW[] =
397 {'T','y','p','e',0};
398 static const WCHAR prop_uniqueidW[] =
399 {'U','n','i','q','u','e','I','d',0};
400 static const WCHAR prop_usernameW[] =
401 {'U','s','e','r','N','a','m','e',0};
402 static const WCHAR prop_uuidW[] =
403 {'U','U','I','D',0};
404 static const WCHAR prop_varianttypeW[] =
405 {'V','a','r','i','a','n','t','T','y','p','e',0};
406 static const WCHAR prop_vendorW[] =
407 {'V','e','n','d','o','r',0};
408 static const WCHAR prop_versionW[] =
409 {'V','e','r','s','i','o','n',0};
410 static const WCHAR prop_videoarchitectureW[] =
411 {'V','i','d','e','o','A','r','c','h','i','t','e','c','t','u','r','e',0};
412 static const WCHAR prop_videomemorytypeW[] =
413 {'V','i','d','e','o','M','e','m','o','r','y','T','y','p','e',0};
414 static const WCHAR prop_videomodedescriptionW[] =
415 {'V','i','d','e','o','M','o','d','e','D','e','s','c','r','i','p','t','i','o','n',0};
416 static const WCHAR prop_videoprocessorW[] =
417 {'V','i','d','e','o','P','r','o','c','e','s','s','o','r',0};
418 static const WCHAR prop_volumenameW[] =
419 {'V','o','l','u','m','e','N','a','m','e',0};
420 static const WCHAR prop_volumeserialnumberW[] =
421 {'V','o','l','u','m','e','S','e','r','i','a','l','N','u','m','b','e','r',0};
422 static const WCHAR prop_workingsetsizeW[] =
423 {'W','o','r','k','i','n','g','S','e','t','S','i','z','e',0};
425 /* column definitions must be kept in sync with record structures below */
426 static const struct column col_baseboard[] =
428 { prop_manufacturerW, CIM_STRING },
429 { prop_modelW, CIM_STRING },
430 { prop_nameW, CIM_STRING },
431 { prop_productW, CIM_STRING },
432 { prop_serialnumberW, CIM_STRING },
433 { prop_tagW, CIM_STRING|COL_FLAG_KEY },
434 { prop_versionW, CIM_STRING }
436 static const struct column col_bios[] =
438 { prop_descriptionW, CIM_STRING },
439 { prop_identificationcodeW, CIM_STRING },
440 { prop_manufacturerW, CIM_STRING },
441 { prop_nameW, CIM_STRING },
442 { prop_releasedateW, CIM_DATETIME },
443 { prop_serialnumberW, CIM_STRING },
444 { prop_smbiosbiosversionW, CIM_STRING },
445 { prop_smbiosmajorversionW, CIM_UINT16, VT_I4 },
446 { prop_smbiosminorversionW, CIM_UINT16, VT_I4 },
447 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
449 static const struct column col_cdromdrive[] =
451 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
452 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
453 { prop_mediatypeW, CIM_STRING },
454 { prop_nameW, CIM_STRING },
455 { prop_pnpdeviceidW, CIM_STRING }
457 static const struct column col_compsys[] =
459 { prop_descriptionW, CIM_STRING },
460 { prop_domainW, CIM_STRING },
461 { prop_domainroleW, CIM_UINT16, VT_I4 },
462 { prop_manufacturerW, CIM_STRING },
463 { prop_modelW, CIM_STRING },
464 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
465 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
466 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
467 { prop_totalphysicalmemoryW, CIM_UINT64 },
468 { prop_usernameW, CIM_STRING|COL_FLAG_DYNAMIC }
470 static const struct column col_compsysproduct[] =
472 { prop_identifyingnumberW, CIM_STRING|COL_FLAG_KEY },
473 { prop_nameW, CIM_STRING|COL_FLAG_KEY },
474 { prop_skunumberW, CIM_STRING },
475 { prop_uuidW, CIM_STRING|COL_FLAG_DYNAMIC },
476 { prop_vendorW, CIM_STRING },
477 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
479 static const struct column col_datafile[] =
481 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
482 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
484 static const struct column col_desktopmonitor[] =
486 { prop_pixelsperxlogicalinchW, CIM_UINT32 }
488 static const struct column col_directory[] =
490 { prop_accessmaskW, CIM_UINT32 },
491 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }
493 static const struct column col_diskdrive[] =
495 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
496 { prop_indexW, CIM_UINT32, VT_I4 },
497 { prop_interfacetypeW, CIM_STRING },
498 { prop_manufacturerW, CIM_STRING },
499 { prop_mediatypeW, CIM_STRING },
500 { prop_modelW, CIM_STRING },
501 { prop_pnpdeviceidW, CIM_STRING },
502 { prop_serialnumberW, CIM_STRING },
503 { prop_sizeW, CIM_UINT64 }
505 static const struct column col_diskpartition[] =
507 { prop_bootableW, CIM_BOOLEAN },
508 { prop_bootpartitionW, CIM_BOOLEAN },
509 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
510 { prop_diskindexW, CIM_UINT32, VT_I4 },
511 { prop_indexW, CIM_UINT32, VT_I4 },
512 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
513 { prop_sizeW, CIM_UINT64 },
514 { prop_startingoffsetW, CIM_UINT64 },
515 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
517 static const struct column col_ip4routetable[] =
519 { prop_destinationW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
520 { prop_interfaceindexW, CIM_SINT32|COL_FLAG_KEY },
521 { prop_nexthopW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
523 static const struct column col_logicaldisk[] =
525 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
526 { prop_drivetypeW, CIM_UINT32, VT_I4 },
527 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
528 { prop_freespaceW, CIM_UINT64 },
529 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
530 { prop_sizeW, CIM_UINT64 },
531 { prop_volumenameW, CIM_STRING|COL_FLAG_DYNAMIC },
532 { prop_volumeserialnumberW, CIM_STRING|COL_FLAG_DYNAMIC }
534 static const struct column col_networkadapter[] =
536 { prop_adaptertypeW, CIM_STRING },
537 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
538 { prop_indexW, CIM_UINT32, VT_I4 },
539 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
540 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
541 { prop_manufacturerW, CIM_STRING },
542 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
543 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
544 { prop_physicaladapterW, CIM_BOOLEAN },
545 { prop_pnpdeviceidW, CIM_STRING },
546 { prop_speedW, CIM_UINT64 }
548 static const struct column col_networkadapterconfig[] =
550 { prop_defaultipgatewayW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
551 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
552 { prop_dhcpenabledW, CIM_BOOLEAN },
553 { prop_dnshostnameW, CIM_STRING|COL_FLAG_DYNAMIC },
554 { prop_dnsserversearchorderW, CIM_STRING|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
555 { prop_indexW, CIM_UINT32|COL_FLAG_KEY, VT_I4 },
556 { prop_ipconnectionmetricW, CIM_UINT32, VT_I4 },
557 { prop_ipenabledW, CIM_BOOLEAN },
558 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
559 { prop_settingidW, CIM_STRING|COL_FLAG_DYNAMIC }
561 static const struct column col_os[] =
563 { prop_buildnumberW, CIM_STRING|COL_FLAG_DYNAMIC },
564 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
565 { prop_codesetW, CIM_STRING|COL_FLAG_DYNAMIC },
566 { prop_countrycodeW, CIM_STRING|COL_FLAG_DYNAMIC },
567 { prop_csdversionW, CIM_STRING|COL_FLAG_DYNAMIC },
568 { prop_freephysicalmemoryW, CIM_UINT64 },
569 { prop_installdateW, CIM_DATETIME },
570 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
571 { prop_localdatetimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
572 { prop_localeW, CIM_STRING|COL_FLAG_DYNAMIC },
573 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
574 { prop_osarchitectureW, CIM_STRING },
575 { prop_oslanguageW, CIM_UINT32, VT_I4 },
576 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
577 { prop_ostypeW, CIM_UINT16, VT_I4 },
578 { prop_primaryW, CIM_BOOLEAN },
579 { prop_serialnumberW, CIM_STRING },
580 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
581 { prop_servicepackminorW, CIM_UINT16, VT_I4 },
582 { prop_suitemaskW, CIM_UINT32, VT_I4 },
583 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
584 { prop_totalvirtualmemorysizeW, CIM_UINT64 },
585 { prop_totalvisiblememorysizeW, CIM_UINT64 },
586 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
588 static const struct column col_param[] =
590 { prop_classW, CIM_STRING },
591 { prop_methodW, CIM_STRING },
592 { prop_directionW, CIM_SINT32 },
593 { prop_parameterW, CIM_STRING },
594 { prop_typeW, CIM_UINT32 },
595 { prop_varianttypeW, CIM_UINT32 },
596 { prop_defaultvalueW, CIM_UINT32 }
598 static const struct column col_physicalmedia[] =
600 { prop_serialnumberW, CIM_STRING },
601 { prop_tagW, CIM_STRING }
603 static const struct column col_physicalmemory[] =
605 { prop_capacityW, CIM_UINT64 },
606 { prop_memorytypeW, CIM_UINT16, VT_I4 }
608 static const struct column col_printer[] =
610 { prop_attributesW, CIM_UINT32 },
611 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
612 { prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
613 { prop_horizontalresolutionW, CIM_UINT32 },
614 { prop_localW, CIM_BOOLEAN },
615 { prop_locationW, CIM_STRING|COL_FLAG_DYNAMIC },
616 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
617 { prop_networkW, CIM_BOOLEAN },
618 { prop_portnameW, CIM_STRING|COL_FLAG_DYNAMIC },
620 static const struct column col_process[] =
622 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
623 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
624 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
625 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
626 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
627 { prop_pprocessidW, CIM_UINT32, VT_I4 },
628 { prop_processidW, CIM_UINT32, VT_I4 },
629 { prop_threadcountW, CIM_UINT32, VT_I4 },
630 { prop_workingsetsizeW, CIM_UINT64 },
631 /* methods */
632 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
634 static const struct column col_processor[] =
636 { prop_addresswidthW, CIM_UINT16, VT_I4 },
637 { prop_architectureW, CIM_UINT16, VT_I4 },
638 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
639 { prop_cpustatusW, CIM_UINT16 },
640 { prop_currentclockspeedW, CIM_UINT32, VT_I4 },
641 { prop_datawidthW, CIM_UINT16, VT_I4 },
642 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
643 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
644 { prop_familyW, CIM_UINT16, VT_I4 },
645 { prop_levelW, CIM_UINT16, VT_I4 },
646 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
647 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
648 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
649 { prop_numcoresW, CIM_UINT32, VT_I4 },
650 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
651 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
652 { prop_processortypeW, CIM_UINT16, VT_I4 },
653 { prop_revisionW, CIM_UINT16, VT_I4 },
654 { prop_uniqueidW, CIM_STRING },
655 { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC }
657 static const struct column col_qualifier[] =
659 { prop_classW, CIM_STRING },
660 { prop_memberW, CIM_STRING },
661 { prop_typeW, CIM_UINT32 },
662 { prop_flavorW, CIM_SINT32 },
663 { prop_nameW, CIM_STRING },
664 { prop_intvalueW, CIM_SINT32 },
665 { prop_strvalueW, CIM_STRING }
667 static const struct column col_service[] =
669 { prop_acceptpauseW, CIM_BOOLEAN },
670 { prop_acceptstopW, CIM_BOOLEAN },
671 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
672 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
673 { prop_processidW, CIM_UINT32 },
674 { prop_servicetypeW, CIM_STRING },
675 { prop_startmodeW, CIM_STRING },
676 { prop_stateW, CIM_STRING },
677 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
678 /* methods */
679 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
680 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
681 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
682 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
684 static const struct column col_sid[] =
686 { prop_accountnameW, CIM_STRING|COL_FLAG_DYNAMIC },
687 { prop_binaryrepresentationW, CIM_UINT8|CIM_FLAG_ARRAY|COL_FLAG_DYNAMIC },
688 { prop_referenceddomainnameW, CIM_STRING|COL_FLAG_DYNAMIC },
689 { prop_sidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
690 { prop_sidlengthW, CIM_UINT32 }
692 static const struct column col_sounddevice[] =
694 { prop_nameW, CIM_STRING },
695 { prop_productnameW, CIM_STRING },
696 { prop_statusinfoW, CIM_UINT16, VT_I4 }
698 static const struct column col_stdregprov[] =
700 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
701 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
702 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
704 static const struct column col_systemenclosure[] =
706 { prop_captionW, CIM_STRING },
707 { prop_chassistypesW, CIM_UINT16|CIM_FLAG_ARRAY, VT_I4|VT_ARRAY },
708 { prop_descriptionW, CIM_STRING },
709 { prop_lockpresentW, CIM_BOOLEAN },
710 { prop_manufacturerW, CIM_STRING },
711 { prop_nameW, CIM_STRING },
712 { prop_tagW, CIM_STRING },
714 static const struct column col_systemsecurity[] =
716 { method_getsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
717 { method_setsdW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
719 static const struct column col_videocontroller[] =
721 { prop_adapterdactypeW, CIM_STRING },
722 { prop_adapterramW, CIM_UINT32, VT_I4 },
723 { prop_availabilityW, CIM_UINT16 },
724 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
725 { prop_configmanagererrorcodeW, CIM_UINT32, VT_I4 },
726 { prop_currentbitsperpixelW, CIM_UINT32, VT_I4 },
727 { prop_currenthorizontalresW, CIM_UINT32, VT_I4 },
728 { prop_currentrefreshrateW, CIM_UINT32, VT_I4 },
729 { prop_currentscanmodeW, CIM_UINT16, VT_I4 },
730 { prop_currentverticalresW, CIM_UINT32, VT_I4 },
731 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
732 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
733 { prop_driverdateW, CIM_DATETIME },
734 { prop_driverversionW, CIM_STRING },
735 { prop_installeddisplaydriversW,CIM_STRING },
736 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
737 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
738 { prop_statusW, CIM_STRING },
739 { prop_videoarchitectureW, CIM_UINT16, VT_I4 },
740 { prop_videomemorytypeW, CIM_UINT16, VT_I4 },
741 { prop_videomodedescriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
742 { prop_videoprocessorW, CIM_STRING|COL_FLAG_DYNAMIC },
745 static const WCHAR baseboard_manufacturerW[] =
746 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
747 static const WCHAR baseboard_serialnumberW[] =
748 {'N','o','n','e',0};
749 static const WCHAR baseboard_tagW[] =
750 {'B','a','s','e',' ','B','o','a','r','d',0};
751 static const WCHAR baseboard_versionW[] =
752 {'1','.','0',0};
753 static const WCHAR bios_descriptionW[] =
754 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
755 static const WCHAR bios_manufacturerW[] =
756 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
757 static const WCHAR bios_nameW[] =
758 {'W','I','N','E',' ','B','I','O','S',0};
759 static const WCHAR bios_releasedateW[] =
760 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
761 static const WCHAR bios_serialnumberW[] =
762 {'0',0};
763 static const WCHAR bios_smbiosbiosversionW[] =
764 {'W','i','n','e',0};
765 static const WCHAR bios_versionW[] =
766 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
767 static const WCHAR cdromdrive_mediatypeW[] =
768 {'C','D','-','R','O','M',0};
769 static const WCHAR cdromdrive_nameW[] =
770 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
771 static const WCHAR cdromdrive_pnpdeviceidW[]=
772 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
773 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
774 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
775 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
776 static const WCHAR compsys_descriptionW[] =
777 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
778 static const WCHAR compsys_domainW[] =
779 {'W','O','R','K','G','R','O','U','P',0};
780 static const WCHAR compsys_manufacturerW[] =
781 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
782 static const WCHAR compsys_modelW[] =
783 {'W','i','n','e',0};
784 static const WCHAR compsysproduct_identifyingnumberW[] =
785 {'0',0};
786 static const WCHAR compsysproduct_nameW[] =
787 {'W','i','n','e',0};
788 static const WCHAR compsysproduct_uuidW[] =
789 {'d','e','a','d','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-','d','e','a','d','-',
790 'd','e','a','d','d','e','a','d','d','e','a','d',0};
791 static const WCHAR compsysproduct_vendorW[] =
792 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
793 static const WCHAR compsysproduct_versionW[] =
794 {'1','.','0',0};
795 static const WCHAR diskdrive_interfacetypeW[] =
796 {'I','D','E',0};
797 static const WCHAR diskdrive_manufacturerW[] =
798 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
799 static const WCHAR diskdrive_mediatype_fixedW[] =
800 {'F','i','x','e','d',' ','h','a','r','d',' ','d','i','s','k',0};
801 static const WCHAR diskdrive_mediatype_removableW[] =
802 {'R','e','m','o','v','a','b','l','e',' ','m','e','d','i','a',0};
803 static const WCHAR diskdrive_modelW[] =
804 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
805 static const WCHAR diskdrive_pnpdeviceidW[] =
806 {'I','D','E','\\','D','i','s','k','\\','V','E','N','_','W','I','N','E',0};
807 static const WCHAR diskdrive_serialW[] =
808 {'W','I','N','E','H','D','I','S','K',0};
809 static const WCHAR networkadapter_pnpdeviceidW[]=
810 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
811 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
812 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
813 static const WCHAR os_32bitW[] =
814 {'3','2','-','b','i','t',0};
815 static const WCHAR os_64bitW[] =
816 {'6','4','-','b','i','t',0};
817 static const WCHAR os_installdateW[] =
818 {'2','0','1','4','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
819 static const WCHAR os_serialnumberW[] =
820 {'1','2','3','4','5','-','O','E','M','-','1','2','3','4','5','6','7','-','1','2','3','4','5',0};
821 static const WCHAR physicalmedia_tagW[] =
822 {'\\','\\','.','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
823 static const WCHAR sounddevice_productnameW[] =
824 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
825 static const WCHAR systemenclosure_systemenclosureW[] =
826 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',0};
827 static const WCHAR systemenclosure_tagW[] =
828 {'S','y','s','t','e','m',' ','E','n','c','l','o','s','u','r','e',' ','0',0};
829 static const WCHAR systemenclosure_manufacturerW[] =
830 {'W','i','n','e',0};
831 static const WCHAR videocontroller_dactypeW[] =
832 {'I','n','t','e','g','r','a','t','e','d',' ','R','A','M','D','A','C',0};
833 static const WCHAR videocontroller_deviceidW[] =
834 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
835 static const WCHAR videocontroller_driverdateW[] =
836 {'2','0','1','7','0','1','0','1','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
837 static const WCHAR videocontroller_driverversionW[] =
838 {'1','.','0',0};
839 static const WCHAR videocontroller_statusW[] =
840 {'O','K',0};
842 #include "pshpack1.h"
843 struct record_baseboard
845 const WCHAR *manufacturer;
846 const WCHAR *model;
847 const WCHAR *name;
848 const WCHAR *product;
849 const WCHAR *serialnumber;
850 const WCHAR *tag;
851 const WCHAR *version;
853 struct record_bios
855 const WCHAR *description;
856 const WCHAR *identificationcode;
857 const WCHAR *manufacturer;
858 const WCHAR *name;
859 const WCHAR *releasedate;
860 const WCHAR *serialnumber;
861 const WCHAR *smbiosbiosversion;
862 UINT16 smbiosmajorversion;
863 UINT16 smbiosminorversion;
864 const WCHAR *version;
866 struct record_cdromdrive
868 const WCHAR *device_id;
869 const WCHAR *drive;
870 const WCHAR *mediatype;
871 const WCHAR *name;
872 const WCHAR *pnpdevice_id;
874 struct record_computersystem
876 const WCHAR *description;
877 const WCHAR *domain;
878 UINT16 domainrole;
879 const WCHAR *manufacturer;
880 const WCHAR *model;
881 const WCHAR *name;
882 UINT32 num_logical_processors;
883 UINT32 num_processors;
884 UINT64 total_physical_memory;
885 const WCHAR *username;
887 struct record_computersystemproduct
889 const WCHAR *identifyingnumber;
890 const WCHAR *name;
891 const WCHAR *skunumber;
892 const WCHAR *uuid;
893 const WCHAR *vendor;
894 const WCHAR *version;
896 struct record_datafile
898 const WCHAR *name;
899 const WCHAR *version;
901 struct record_desktopmonitor
903 UINT32 pixelsperxlogicalinch;
905 struct record_directory
907 UINT32 accessmask;
908 const WCHAR *name;
910 struct record_diskdrive
912 const WCHAR *device_id;
913 UINT32 index;
914 const WCHAR *interfacetype;
915 const WCHAR *manufacturer;
916 const WCHAR *mediatype;
917 const WCHAR *model;
918 const WCHAR *pnpdevice_id;
919 const WCHAR *serialnumber;
920 UINT64 size;
922 struct record_diskpartition
924 int bootable;
925 int bootpartition;
926 const WCHAR *device_id;
927 UINT32 diskindex;
928 UINT32 index;
929 const WCHAR *pnpdevice_id;
930 UINT64 size;
931 UINT64 startingoffset;
932 const WCHAR *type;
934 struct record_ip4routetable
936 const WCHAR *destination;
937 INT32 interfaceindex;
938 const WCHAR *nexthop;
940 struct record_logicaldisk
942 const WCHAR *device_id;
943 UINT32 drivetype;
944 const WCHAR *filesystem;
945 UINT64 freespace;
946 const WCHAR *name;
947 UINT64 size;
948 const WCHAR *volumename;
949 const WCHAR *volumeserialnumber;
951 struct record_networkadapter
953 const WCHAR *adaptertype;
954 const WCHAR *device_id;
955 UINT32 index;
956 UINT32 interface_index;
957 const WCHAR *mac_address;
958 const WCHAR *manufacturer;
959 const WCHAR *name;
960 UINT16 netconnection_status;
961 int physicaladapter;
962 const WCHAR *pnpdevice_id;
963 UINT64 speed;
965 struct record_networkadapterconfig
967 const struct array *defaultipgateway;
968 const WCHAR *description;
969 int dhcpenabled;
970 const WCHAR *dnshostname;
971 const struct array *dnsserversearchorder;
972 UINT32 index;
973 UINT32 ipconnectionmetric;
974 int ipenabled;
975 const WCHAR *mac_address;
976 const WCHAR *settingid;
978 struct record_operatingsystem
980 const WCHAR *buildnumber;
981 const WCHAR *caption;
982 const WCHAR *codeset;
983 const WCHAR *countrycode;
984 const WCHAR *csdversion;
985 UINT64 freephysicalmemory;
986 const WCHAR *installdate;
987 const WCHAR *lastbootuptime;
988 const WCHAR *localdatetime;
989 const WCHAR *locale;
990 const WCHAR *name;
991 const WCHAR *osarchitecture;
992 UINT32 oslanguage;
993 UINT32 osproductsuite;
994 UINT16 ostype;
995 int primary;
996 const WCHAR *serialnumber;
997 UINT16 servicepackmajor;
998 UINT16 servicepackminor;
999 UINT32 suitemask;
1000 const WCHAR *systemdirectory;
1001 UINT64 totalvirtualmemorysize;
1002 UINT64 totalvisiblememorysize;
1003 const WCHAR *version;
1005 struct record_param
1007 const WCHAR *class;
1008 const WCHAR *method;
1009 INT32 direction;
1010 const WCHAR *parameter;
1011 UINT32 type;
1012 UINT32 varianttype;
1013 UINT32 defaultvalue;
1015 struct record_physicalmedia
1017 const WCHAR *serialnumber;
1018 const WCHAR *tag;
1020 struct record_physicalmemory
1022 UINT64 capacity;
1023 UINT16 memorytype;
1025 struct record_printer
1027 UINT32 attributes;
1028 const WCHAR *device_id;
1029 const WCHAR *drivername;
1030 UINT32 horizontalresolution;
1031 int local;
1032 const WCHAR *location;
1033 const WCHAR *name;
1034 int network;
1035 const WCHAR *portname;
1037 struct record_process
1039 const WCHAR *caption;
1040 const WCHAR *commandline;
1041 const WCHAR *description;
1042 const WCHAR *handle;
1043 const WCHAR *name;
1044 UINT32 pprocess_id;
1045 UINT32 process_id;
1046 UINT32 thread_count;
1047 UINT64 workingsetsize;
1048 /* methods */
1049 class_method *get_owner;
1051 struct record_processor
1053 UINT16 addresswidth;
1054 UINT16 architecture;
1055 const WCHAR *caption;
1056 UINT16 cpu_status;
1057 UINT32 currentclockspeed;
1058 UINT16 datawidth;
1059 const WCHAR *description;
1060 const WCHAR *device_id;
1061 UINT16 family;
1062 UINT16 level;
1063 const WCHAR *manufacturer;
1064 UINT32 maxclockspeed;
1065 const WCHAR *name;
1066 UINT32 num_cores;
1067 UINT32 num_logical_processors;
1068 const WCHAR *processor_id;
1069 UINT16 processortype;
1070 UINT16 revision;
1071 const WCHAR *unique_id;
1072 const WCHAR *version;
1074 struct record_qualifier
1076 const WCHAR *class;
1077 const WCHAR *member;
1078 UINT32 type;
1079 INT32 flavor;
1080 const WCHAR *name;
1081 INT32 intvalue;
1082 const WCHAR *strvalue;
1084 struct record_service
1086 int accept_pause;
1087 int accept_stop;
1088 const WCHAR *displayname;
1089 const WCHAR *name;
1090 UINT32 process_id;
1091 const WCHAR *servicetype;
1092 const WCHAR *startmode;
1093 const WCHAR *state;
1094 const WCHAR *systemname;
1095 /* methods */
1096 class_method *pause_service;
1097 class_method *resume_service;
1098 class_method *start_service;
1099 class_method *stop_service;
1101 struct record_sid
1103 const WCHAR *accountname;
1104 const struct array *binaryrepresentation;
1105 const WCHAR *referenceddomainname;
1106 const WCHAR *sid;
1107 UINT32 sidlength;
1109 struct record_sounddevice
1111 const WCHAR *name;
1112 const WCHAR *productname;
1113 UINT16 statusinfo;
1115 struct record_stdregprov
1117 class_method *enumkey;
1118 class_method *enumvalues;
1119 class_method *getstringvalue;
1121 struct record_systemsecurity
1123 class_method *getsd;
1124 class_method *setsd;
1126 struct record_systemenclosure
1128 const WCHAR *caption;
1129 const struct array *chassistypes;
1130 const WCHAR *description;
1131 int lockpresent;
1132 const WCHAR *manufacturer;
1133 const WCHAR *name;
1134 const WCHAR *tag;
1136 struct record_videocontroller
1138 const WCHAR *adapter_dactype;
1139 UINT32 adapter_ram;
1140 UINT16 availability;
1141 const WCHAR *caption;
1142 UINT32 config_errorcode;
1143 UINT32 current_bitsperpixel;
1144 UINT32 current_horizontalres;
1145 UINT32 current_refreshrate;
1146 UINT16 current_scanmode;
1147 UINT32 current_verticalres;
1148 const WCHAR *description;
1149 const WCHAR *device_id;
1150 const WCHAR *driverdate;
1151 const WCHAR *driverversion;
1152 const WCHAR *installeddriver;
1153 const WCHAR *name;
1154 const WCHAR *pnpdevice_id;
1155 const WCHAR *status;
1156 UINT16 videoarchitecture;
1157 UINT16 videomemorytype;
1158 const WCHAR *videomodedescription;
1159 const WCHAR *videoprocessor;
1161 #include "poppack.h"
1163 static const struct record_baseboard data_baseboard[] =
1165 { baseboard_manufacturerW, baseboard_tagW, baseboard_tagW, baseboard_tagW, baseboard_serialnumberW, baseboard_versionW }
1167 static const struct record_bios data_bios[] =
1169 { bios_descriptionW, NULL, bios_manufacturerW, bios_nameW, bios_releasedateW, bios_serialnumberW,
1170 bios_smbiosbiosversionW, 1, 0, bios_versionW }
1172 static const struct record_param data_param[] =
1174 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1175 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
1176 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
1177 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1178 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1179 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1180 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1181 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1182 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
1183 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1184 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1185 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1186 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
1187 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1188 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
1189 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
1190 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
1191 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
1192 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
1193 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1194 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING },
1195 { class_systemsecurityW, method_getsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1196 { class_systemsecurityW, method_getsdW, -1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1197 { class_systemsecurityW, method_setsdW, 1, param_sdW, CIM_UINT8|CIM_FLAG_ARRAY },
1198 { class_systemsecurityW, method_setsdW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
1201 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
1202 WBEM_FLAVOR_ORIGIN_PROPAGATED)
1204 static const struct record_physicalmedia data_physicalmedia[] =
1206 { diskdrive_serialW, physicalmedia_tagW }
1208 static const struct record_qualifier data_qualifier[] =
1210 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
1211 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
1213 static const struct record_sounddevice data_sounddevice[] =
1215 { sounddevice_productnameW, sounddevice_productnameW, 3 /* enabled */ }
1217 static const struct record_stdregprov data_stdregprov[] =
1219 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
1221 static UINT16 systemenclosure_chassistypes[] =
1225 static const struct array systemenclosure_chassistypes_array =
1227 SIZEOF(systemenclosure_chassistypes),
1228 &systemenclosure_chassistypes
1230 static const struct record_systemenclosure data_systemenclosure[] =
1233 systemenclosure_systemenclosureW,
1234 &systemenclosure_chassistypes_array,
1235 systemenclosure_systemenclosureW,
1236 FALSE,
1237 systemenclosure_manufacturerW,
1238 systemenclosure_systemenclosureW,
1239 systemenclosure_tagW,
1242 static const struct record_systemsecurity data_systemsecurity[] =
1244 { security_get_sd, security_set_sd }
1247 /* check if row matches condition and update status */
1248 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
1250 LONGLONG val;
1251 UINT type;
1253 if (!cond)
1255 *status = FILL_STATUS_UNFILTERED;
1256 return TRUE;
1258 if (eval_cond( table, row, cond, &val, &type ) != S_OK)
1260 *status = FILL_STATUS_FAILED;
1261 return FALSE;
1263 *status = FILL_STATUS_FILTERED;
1264 return val != 0;
1267 static BOOL resize_table( struct table *table, UINT row_count, UINT row_size )
1269 if (!table->num_rows_allocated)
1271 if (!(table->data = heap_alloc( row_count * row_size ))) return FALSE;
1272 table->num_rows_allocated = row_count;
1273 return TRUE;
1275 if (row_count > table->num_rows_allocated)
1277 BYTE *data;
1278 UINT count = max( row_count, table->num_rows_allocated * 2 );
1279 if (!(data = heap_realloc( table->data, count * row_size ))) return FALSE;
1280 table->data = data;
1281 table->num_rows_allocated = count;
1283 return TRUE;
1286 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
1288 static const WCHAR fmtW[] = {'%','c',':',0};
1289 WCHAR drive[3], root[] = {'A',':','\\',0};
1290 struct record_cdromdrive *rec;
1291 UINT i, row = 0, offset = 0;
1292 DWORD drives = GetLogicalDrives();
1293 enum fill_status status = FILL_STATUS_UNFILTERED;
1295 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1297 for (i = 0; i < 26; i++)
1299 if (drives & (1 << i))
1301 root[0] = 'A' + i;
1302 if (GetDriveTypeW( root ) != DRIVE_CDROM)
1303 continue;
1305 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1307 rec = (struct record_cdromdrive *)(table->data + offset);
1308 rec->device_id = cdromdrive_pnpdeviceidW;
1309 sprintfW( drive, fmtW, 'A' + i );
1310 rec->drive = heap_strdupW( drive );
1311 rec->mediatype = cdromdrive_mediatypeW;
1312 rec->name = cdromdrive_nameW;
1313 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
1314 if (!match_row( table, row, cond, &status ))
1316 free_row_values( table, row );
1317 continue;
1319 offset += sizeof(*rec);
1320 row++;
1323 TRACE("created %u rows\n", row);
1324 table->num_rows = row;
1325 return status;
1328 static UINT get_processor_count(void)
1330 SYSTEM_BASIC_INFORMATION info;
1332 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
1333 return info.NumberOfProcessors;
1336 static UINT get_logical_processor_count( UINT *num_cores )
1338 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
1339 UINT i, j, count = 0;
1340 NTSTATUS status;
1341 ULONG len;
1343 if (num_cores) *num_cores = get_processor_count();
1344 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
1345 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
1347 if (!(info = heap_alloc( len ))) return get_processor_count();
1348 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
1349 if (status != STATUS_SUCCESS)
1351 heap_free( info );
1352 return get_processor_count();
1354 if (num_cores) *num_cores = 0;
1355 for (i = 0; i < len / sizeof(*info); i++)
1357 if (info[i].Relationship == RelationProcessorCore)
1359 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
1361 else if (info[i].Relationship == RelationProcessorPackage && num_cores)
1363 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) (*num_cores)++;
1366 heap_free( info );
1367 return count;
1370 static UINT64 get_total_physical_memory(void)
1372 MEMORYSTATUSEX status;
1374 status.dwLength = sizeof(status);
1375 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1376 return status.ullTotalPhys;
1379 static UINT64 get_available_physical_memory(void)
1381 MEMORYSTATUSEX status;
1383 status.dwLength = sizeof(status);
1384 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
1385 return status.ullAvailPhys;
1388 static WCHAR *get_computername(void)
1390 WCHAR *ret;
1391 DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
1393 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1394 GetComputerNameW( ret, &size );
1395 return ret;
1398 static WCHAR *get_username(void)
1400 WCHAR *ret;
1401 DWORD compsize, usersize;
1402 DWORD size;
1404 compsize = 0;
1405 GetComputerNameW( NULL, &compsize );
1406 usersize = 0;
1407 GetUserNameW( NULL, &usersize );
1408 size = compsize + usersize; /* two null terminators account for the \ */
1409 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
1410 GetComputerNameW( ret, &compsize );
1411 ret[compsize] = '\\';
1412 GetUserNameW( ret + compsize + 1, &usersize );
1413 return ret;
1416 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
1418 struct record_computersystem *rec;
1419 enum fill_status status = FILL_STATUS_UNFILTERED;
1420 UINT row = 0;
1422 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1424 rec = (struct record_computersystem *)table->data;
1425 rec->description = compsys_descriptionW;
1426 rec->domain = compsys_domainW;
1427 rec->domainrole = 0; /* standalone workstation */
1428 rec->manufacturer = compsys_manufacturerW;
1429 rec->model = compsys_modelW;
1430 rec->name = get_computername();
1431 rec->num_logical_processors = get_logical_processor_count( NULL );
1432 rec->num_processors = get_processor_count();
1433 rec->total_physical_memory = get_total_physical_memory();
1434 rec->username = get_username();
1435 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1436 else row++;
1438 TRACE("created %u rows\n", row);
1439 table->num_rows = row;
1440 return status;
1443 static WCHAR *get_compsysproduct_uuid(void)
1445 #ifdef __APPLE__
1446 unsigned char uuid[16];
1447 const struct timespec timeout = {1, 0};
1448 if (!gethostuuid( uuid, &timeout ))
1450 static const WCHAR fmtW[] =
1451 {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
1452 '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
1453 '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
1454 WCHAR *ret = heap_alloc( 37 * sizeof(WCHAR) );
1455 if (!ret) return NULL;
1456 sprintfW( ret, fmtW, uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
1457 uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15] );
1458 return ret;
1460 #endif
1461 #ifdef __linux__
1462 int file;
1463 if ((file = open( "/var/lib/dbus/machine-id", O_RDONLY )) != -1)
1465 unsigned char buf[32];
1466 if (read( file, buf, sizeof(buf) ) == sizeof(buf))
1468 unsigned int i, j;
1469 WCHAR *ret, *p;
1471 close( file );
1472 if (!(p = ret = heap_alloc( 37 * sizeof(WCHAR) ))) return NULL;
1473 for (i = 0, j = 0; i < 8; i++) p[i] = toupperW( buf[j++] );
1474 p[8] = '-';
1475 for (i = 9; i < 13; i++) p[i] = toupperW( buf[j++] );
1476 p[13] = '-';
1477 for (i = 14; i < 18; i++) p[i] = toupperW( buf[j++] );
1478 p[18] = '-';
1479 for (i = 19; i < 23; i++) p[i] = toupperW( buf[j++] );
1480 p[23] = '-';
1481 for (i = 24; i < 36; i++) p[i] = toupperW( buf[j++] );
1482 ret[i] = 0;
1483 return ret;
1485 close( file );
1487 #endif
1488 return heap_strdupW( compsysproduct_uuidW );
1491 static enum fill_status fill_compsysproduct( struct table *table, const struct expr *cond )
1493 struct record_computersystemproduct *rec;
1494 enum fill_status status = FILL_STATUS_UNFILTERED;
1495 UINT row = 0;
1497 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1499 rec = (struct record_computersystemproduct *)table->data;
1500 rec->identifyingnumber = compsysproduct_identifyingnumberW;
1501 rec->name = compsysproduct_nameW;
1502 rec->skunumber = NULL;
1503 rec->uuid = get_compsysproduct_uuid();
1504 rec->vendor = compsysproduct_vendorW;
1505 rec->version = compsysproduct_versionW;
1506 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1507 else row++;
1509 TRACE("created %u rows\n", row);
1510 table->num_rows = row;
1511 return status;
1514 struct dirstack
1516 WCHAR **dirs;
1517 UINT *len_dirs;
1518 UINT num_dirs;
1519 UINT num_allocated;
1522 static struct dirstack *alloc_dirstack( UINT size )
1524 struct dirstack *dirstack;
1526 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
1527 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
1529 heap_free( dirstack );
1530 return NULL;
1532 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
1534 heap_free( dirstack->dirs );
1535 heap_free( dirstack );
1536 return NULL;
1538 dirstack->num_dirs = 0;
1539 dirstack->num_allocated = size;
1540 return dirstack;
1543 static void clear_dirstack( struct dirstack *dirstack )
1545 UINT i;
1546 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
1547 dirstack->num_dirs = 0;
1550 static void free_dirstack( struct dirstack *dirstack )
1552 clear_dirstack( dirstack );
1553 heap_free( dirstack->dirs );
1554 heap_free( dirstack->len_dirs );
1555 heap_free( dirstack );
1558 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
1560 UINT size, i = dirstack->num_dirs;
1562 if (!dir) return FALSE;
1564 if (i == dirstack->num_allocated)
1566 WCHAR **tmp;
1567 UINT *len_tmp;
1569 size = dirstack->num_allocated * 2;
1570 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
1571 dirstack->dirs = tmp;
1572 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
1573 dirstack->len_dirs = len_tmp;
1574 dirstack->num_allocated = size;
1576 dirstack->dirs[i] = dir;
1577 dirstack->len_dirs[i] = len;
1578 dirstack->num_dirs++;
1579 return TRUE;
1582 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
1584 if (!dirstack->num_dirs)
1586 *len = 0;
1587 return NULL;
1589 dirstack->num_dirs--;
1590 *len = dirstack->len_dirs[dirstack->num_dirs];
1591 return dirstack->dirs[dirstack->num_dirs];
1594 static const WCHAR *peek_dir( struct dirstack *dirstack )
1596 if (!dirstack->num_dirs) return NULL;
1597 return dirstack->dirs[dirstack->num_dirs - 1];
1600 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
1602 UINT i = 0;
1603 WCHAR *ret;
1605 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
1606 ret[i++] = drive;
1607 ret[i++] = ':';
1608 ret[i++] = '\\';
1609 if (path && len)
1611 memcpy( ret + i, path, len * sizeof(WCHAR) );
1612 i += len;
1613 ret[i++] = '\\';
1615 ret[i++] = '*';
1616 ret[i] = 0;
1617 return ret;
1620 static WCHAR *build_name( WCHAR drive, const WCHAR *path )
1622 UINT i = 0, len = 0;
1623 const WCHAR *p;
1624 WCHAR *ret;
1626 for (p = path; *p; p++)
1628 if (*p == '\\') len += 2;
1629 else len++;
1631 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
1632 ret[i++] = drive;
1633 ret[i++] = ':';
1634 ret[i++] = '\\';
1635 ret[i++] = '\\';
1636 for (p = path; *p; p++)
1638 if (*p != '\\') ret[i++] = *p;
1639 else
1641 ret[i++] = '\\';
1642 ret[i++] = '\\';
1645 ret[i] = 0;
1646 return ret;
1649 static WCHAR *build_dirname( const WCHAR *path, UINT *ret_len )
1651 const WCHAR *p = path, *start;
1652 UINT len, i;
1653 WCHAR *ret;
1655 if (!isalphaW( p[0] ) || p[1] != ':' || p[2] != '\\' || p[3] != '\\' || !p[4]) return NULL;
1656 start = path + 4;
1657 len = strlenW( start );
1658 p = start + len - 1;
1659 if (*p == '\\') return NULL;
1661 while (p >= start && *p != '\\') { len--; p--; };
1662 while (p >= start && *p == '\\') { len--; p--; };
1664 if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1665 for (i = 0, p = start; p < start + len; p++)
1667 if (p[0] == '\\' && p[1] == '\\')
1669 ret[i++] = '\\';
1670 p++;
1672 else ret[i++] = *p;
1674 ret[i] = 0;
1675 *ret_len = i;
1676 return ret;
1679 static BOOL seen_dir( struct dirstack *dirstack, const WCHAR *path )
1681 UINT i;
1682 for (i = 0; i < dirstack->num_dirs; i++) if (!strcmpW( dirstack->dirs[i], path )) return TRUE;
1683 return FALSE;
1686 /* optimize queries of the form WHERE Name='...' [OR Name='...']* */
1687 static UINT seed_dirs( struct dirstack *dirstack, const struct expr *cond, WCHAR root, UINT *count )
1689 const struct expr *left, *right;
1691 if (!cond || cond->type != EXPR_COMPLEX) return *count = 0;
1693 left = cond->u.expr.left;
1694 right = cond->u.expr.right;
1695 if (cond->u.expr.op == OP_EQ)
1697 UINT len;
1698 WCHAR *path;
1699 const WCHAR *str = NULL;
1701 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL &&
1702 !strcmpW( left->u.propval->name, prop_nameW ) &&
1703 toupperW( right->u.sval[0] ) == toupperW( root ))
1705 str = right->u.sval;
1707 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL &&
1708 !strcmpW( right->u.propval->name, prop_nameW ) &&
1709 toupperW( left->u.sval[0] ) == toupperW( root ))
1711 str = left->u.sval;
1713 if (str && (path = build_dirname( str, &len )))
1715 if (seen_dir( dirstack, path ))
1717 heap_free( path );
1718 return ++*count;
1720 else if (push_dir( dirstack, path, len )) return ++*count;
1721 heap_free( path );
1722 return *count = 0;
1725 else if (cond->u.expr.op == OP_OR)
1727 UINT left_count = 0, right_count = 0;
1729 if (!(seed_dirs( dirstack, left, root, &left_count ))) return *count = 0;
1730 if (!(seed_dirs( dirstack, right, root, &right_count ))) return *count = 0;
1731 return *count += left_count + right_count;
1733 return *count = 0;
1736 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1738 UINT len_path = 0, len_segment = strlenW( segment );
1739 WCHAR *ret;
1741 *len = 0;
1742 if (path) len_path = strlenW( path );
1743 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1744 if (path && len_path)
1746 memcpy( ret, path, len_path * sizeof(WCHAR) );
1747 ret[len_path] = '\\';
1748 *len += len_path + 1;
1750 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1751 *len += len_segment;
1752 ret[*len] = 0;
1753 return ret;
1756 static WCHAR *get_file_version( const WCHAR *filename )
1758 static const WCHAR slashW[] = {'\\',0}, fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
1759 VS_FIXEDFILEINFO *info;
1760 DWORD size;
1761 void *block;
1762 WCHAR *ret;
1764 if (!(ret = heap_alloc( (4 * 5 + sizeof(fmtW) / sizeof(fmtW[0])) * sizeof(WCHAR) ))) return NULL;
1765 if (!(size = GetFileVersionInfoSizeW( filename, NULL )) || !(block = heap_alloc( size )))
1767 heap_free( ret );
1768 return NULL;
1770 if (!GetFileVersionInfoW( filename, 0, size, block ) ||
1771 !VerQueryValueW( block, slashW, (void **)&info, &size ))
1773 heap_free( block );
1774 heap_free( ret );
1775 return NULL;
1777 sprintfW( ret, fmtW, info->dwFileVersionMS >> 16, info->dwFileVersionMS & 0xffff,
1778 info->dwFileVersionLS >> 16, info->dwFileVersionLS & 0xffff );
1779 heap_free( block );
1780 return ret;
1783 static enum fill_status fill_datafile( struct table *table, const struct expr *cond )
1785 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1786 struct record_datafile *rec;
1787 UINT i, len, row = 0, offset = 0, num_expected_rows;
1788 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1789 DWORD drives = GetLogicalDrives();
1790 WIN32_FIND_DATAW data;
1791 HANDLE handle;
1792 struct dirstack *dirstack;
1793 enum fill_status status = FILL_STATUS_UNFILTERED;
1795 if (!resize_table( table, 8, sizeof(*rec) )) return FILL_STATUS_FAILED;
1797 dirstack = alloc_dirstack(2);
1799 for (i = 0; i < 26; i++)
1801 if (!(drives & (1 << i))) continue;
1803 root[0] = 'A' + i;
1804 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1806 num_expected_rows = 0;
1807 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1809 for (;;)
1811 heap_free( glob );
1812 heap_free( path );
1813 path = pop_dir( dirstack, &len );
1814 if (!(glob = build_glob( root[0], path, len )))
1816 status = FILL_STATUS_FAILED;
1817 goto done;
1819 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1823 if (!resize_table( table, row + 1, sizeof(*rec) ))
1825 status = FILL_STATUS_FAILED;
1826 FindClose( handle );
1827 goto done;
1829 if (!strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW )) continue;
1830 new_path = append_path( path, data.cFileName, &len );
1832 if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1834 if (push_dir( dirstack, new_path, len )) continue;
1835 heap_free( new_path );
1836 FindClose( handle );
1837 status = FILL_STATUS_FAILED;
1838 goto done;
1840 rec = (struct record_datafile *)(table->data + offset);
1841 rec->name = build_name( root[0], new_path );
1842 rec->version = get_file_version( rec->name );
1843 if (!match_row( table, row, cond, &status ))
1845 free_row_values( table, row );
1846 continue;
1848 else if (num_expected_rows && row == num_expected_rows - 1)
1850 row++;
1851 FindClose( handle );
1852 status = FILL_STATUS_FILTERED;
1853 goto done;
1855 offset += sizeof(*rec);
1856 row++;
1858 while (FindNextFileW( handle, &data ));
1859 FindClose( handle );
1861 if (!peek_dir( dirstack )) break;
1865 done:
1866 free_dirstack( dirstack );
1867 heap_free( glob );
1868 heap_free( path );
1870 TRACE("created %u rows\n", row);
1871 table->num_rows = row;
1872 return status;
1875 static UINT32 get_pixelsperxlogicalinch(void)
1877 HDC hdc = GetDC( NULL );
1878 UINT32 ret;
1880 if (!hdc) return 96;
1881 ret = GetDeviceCaps( hdc, LOGPIXELSX );
1882 ReleaseDC( NULL, hdc );
1883 return ret;
1886 static enum fill_status fill_desktopmonitor( struct table *table, const struct expr *cond )
1888 struct record_desktopmonitor *rec;
1889 enum fill_status status = FILL_STATUS_UNFILTERED;
1890 UINT row = 0;
1892 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
1894 rec = (struct record_desktopmonitor *)table->data;
1895 rec->pixelsperxlogicalinch = get_pixelsperxlogicalinch();
1897 if (match_row( table, row, cond, &status )) row++;
1899 TRACE("created %u rows\n", row);
1900 table->num_rows = row;
1901 return status;
1904 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1906 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1907 struct record_directory *rec;
1908 UINT i, len, row = 0, offset = 0, num_expected_rows;
1909 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1910 DWORD drives = GetLogicalDrives();
1911 WIN32_FIND_DATAW data;
1912 HANDLE handle;
1913 struct dirstack *dirstack;
1914 enum fill_status status = FILL_STATUS_UNFILTERED;
1916 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
1918 dirstack = alloc_dirstack(2);
1920 for (i = 0; i < 26; i++)
1922 if (!(drives & (1 << i))) continue;
1924 root[0] = 'A' + i;
1925 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1927 num_expected_rows = 0;
1928 if (!seed_dirs( dirstack, cond, root[0], &num_expected_rows )) clear_dirstack( dirstack );
1930 for (;;)
1932 heap_free( glob );
1933 heap_free( path );
1934 path = pop_dir( dirstack, &len );
1935 if (!(glob = build_glob( root[0], path, len )))
1937 status = FILL_STATUS_FAILED;
1938 goto done;
1940 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1944 if (!resize_table( table, row + 1, sizeof(*rec) ))
1946 FindClose( handle );
1947 status = FILL_STATUS_FAILED;
1948 goto done;
1950 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1951 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1952 continue;
1954 new_path = append_path( path, data.cFileName, &len );
1955 if (!(push_dir( dirstack, new_path, len )))
1957 heap_free( new_path );
1958 FindClose( handle );
1959 status = FILL_STATUS_FAILED;
1960 goto done;
1962 rec = (struct record_directory *)(table->data + offset);
1963 rec->accessmask = FILE_ALL_ACCESS;
1964 rec->name = build_name( root[0], new_path );
1965 if (!match_row( table, row, cond, &status ))
1967 free_row_values( table, row );
1968 continue;
1970 else if (num_expected_rows && row == num_expected_rows - 1)
1972 row++;
1973 FindClose( handle );
1974 status = FILL_STATUS_FILTERED;
1975 goto done;
1977 offset += sizeof(*rec);
1978 row++;
1980 while (FindNextFileW( handle, &data ));
1981 FindClose( handle );
1983 if (!peek_dir( dirstack )) break;
1987 done:
1988 free_dirstack( dirstack );
1989 heap_free( glob );
1990 heap_free( path );
1992 TRACE("created %u rows\n", row);
1993 table->num_rows = row;
1994 return status;
1997 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
1999 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
2000 ULARGE_INTEGER free;
2001 DISK_GEOMETRY_EX info;
2002 HANDLE handle;
2003 DWORD bytes_returned;
2005 free.QuadPart = 512 * 1024 * 1024;
2006 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
2008 root[4] = dir[0];
2009 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
2010 if (handle != INVALID_HANDLE_VALUE)
2012 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), &bytes_returned, NULL ))
2013 *disksize = info.DiskSize.QuadPart;
2014 CloseHandle( handle );
2016 return free.QuadPart;
2019 static enum fill_status fill_diskdrive( struct table *table, const struct expr *cond )
2021 static const WCHAR fmtW[] =
2022 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','%','u',0};
2023 WCHAR device_id[sizeof(fmtW)/sizeof(fmtW[0]) + 10], root[] = {'A',':','\\',0};
2024 struct record_diskdrive *rec;
2025 UINT i, row = 0, offset = 0, index = 0, type;
2026 UINT64 size = 1024 * 1024 * 1024;
2027 DWORD drives = GetLogicalDrives();
2028 enum fill_status status = FILL_STATUS_UNFILTERED;
2030 if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
2032 for (i = 0; i < 26; i++)
2034 if (drives & (1 << i))
2036 root[0] = 'A' + i;
2037 type = GetDriveTypeW( root );
2038 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2039 continue;
2041 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2043 rec = (struct record_diskdrive *)(table->data + offset);
2044 sprintfW( device_id, fmtW, index );
2045 rec->device_id = heap_strdupW( device_id );
2046 rec->index = index;
2047 rec->interfacetype = diskdrive_interfacetypeW;
2048 rec->manufacturer = diskdrive_manufacturerW;
2049 if (type == DRIVE_FIXED)
2050 rec->mediatype = diskdrive_mediatype_fixedW;
2051 else
2052 rec->mediatype = diskdrive_mediatype_removableW;
2053 rec->model = diskdrive_modelW;
2054 rec->pnpdevice_id = diskdrive_pnpdeviceidW;
2055 rec->serialnumber = diskdrive_serialW;
2056 get_freespace( root, &size );
2057 rec->size = size;
2058 if (!match_row( table, row, cond, &status ))
2060 free_row_values( table, row );
2061 continue;
2063 offset += sizeof(*rec);
2064 index++;
2065 row++;
2068 TRACE("created %u rows\n", row);
2069 table->num_rows = row;
2070 return status;
2073 static WCHAR *get_filesystem( const WCHAR *root )
2075 static const WCHAR ntfsW[] = {'N','T','F','S',0};
2076 WCHAR buffer[MAX_PATH + 1];
2078 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
2079 return heap_strdupW( buffer );
2080 return heap_strdupW( ntfsW );
2083 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
2085 static const WCHAR fmtW[] =
2086 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
2087 WCHAR device_id[32], root[] = {'A',':','\\',0};
2088 struct record_diskpartition *rec;
2089 UINT i, row = 0, offset = 0, type, index = 0;
2090 UINT64 size = 1024 * 1024 * 1024;
2091 DWORD drives = GetLogicalDrives();
2092 enum fill_status status = FILL_STATUS_UNFILTERED;
2094 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2096 for (i = 0; i < 26; i++)
2098 if (drives & (1 << i))
2100 root[0] = 'A' + i;
2101 type = GetDriveTypeW( root );
2102 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
2103 continue;
2105 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2107 rec = (struct record_diskpartition *)(table->data + offset);
2108 rec->bootable = (i == 2) ? -1 : 0;
2109 rec->bootpartition = (i == 2) ? -1 : 0;
2110 sprintfW( device_id, fmtW, index );
2111 rec->device_id = heap_strdupW( device_id );
2112 rec->diskindex = index;
2113 rec->index = 0;
2114 rec->pnpdevice_id = heap_strdupW( device_id );
2115 get_freespace( root, &size );
2116 rec->size = size;
2117 rec->startingoffset = 0;
2118 rec->type = get_filesystem( root );
2119 if (!match_row( table, row, cond, &status ))
2121 free_row_values( table, row );
2122 continue;
2124 offset += sizeof(*rec);
2125 row++;
2126 index++;
2129 TRACE("created %u rows\n", row);
2130 table->num_rows = row;
2131 return status;
2134 static WCHAR *get_ip4_string( DWORD addr )
2136 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0};
2137 WCHAR *ret;
2139 if (!(ret = heap_alloc( sizeof("ddd.ddd.ddd.ddd") * sizeof(WCHAR) ))) return NULL;
2140 sprintfW( ret, fmtW, (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff );
2141 return ret;
2144 static enum fill_status fill_ip4routetable( struct table *table, const struct expr *cond )
2146 struct record_ip4routetable *rec;
2147 UINT i, row = 0, offset = 0, size = 0;
2148 MIB_IPFORWARDTABLE *forwards;
2149 enum fill_status status = FILL_STATUS_UNFILTERED;
2151 if (GetIpForwardTable( NULL, &size, TRUE ) != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2152 if (!(forwards = heap_alloc( size ))) return FILL_STATUS_FAILED;
2153 if (GetIpForwardTable( forwards, &size, TRUE ))
2155 heap_free( forwards );
2156 return FILL_STATUS_FAILED;
2158 if (!resize_table( table, max(forwards->dwNumEntries, 1), sizeof(*rec) ))
2160 heap_free( forwards );
2161 return FILL_STATUS_FAILED;
2164 for (i = 0; i < forwards->dwNumEntries; i++)
2166 rec = (struct record_ip4routetable *)(table->data + offset);
2168 rec->destination = get_ip4_string( ntohl(forwards->table[i].dwForwardDest) );
2169 rec->interfaceindex = forwards->table[i].dwForwardIfIndex;
2170 rec->nexthop = get_ip4_string( ntohl(forwards->table[i].dwForwardNextHop) );
2172 if (!match_row( table, row, cond, &status ))
2174 free_row_values( table, row );
2175 continue;
2177 offset += sizeof(*rec);
2178 row++;
2180 TRACE("created %u rows\n", row);
2181 table->num_rows = row;
2183 heap_free( forwards );
2184 return status;
2187 static WCHAR *get_volumename( const WCHAR *root )
2189 WCHAR buf[MAX_PATH + 1] = {0};
2190 GetVolumeInformationW( root, buf, sizeof(buf)/sizeof(buf[0]), NULL, NULL, NULL, NULL, 0 );
2191 return heap_strdupW( buf );
2193 static WCHAR *get_volumeserialnumber( const WCHAR *root )
2195 static const WCHAR fmtW[] = {'%','0','8','X',0};
2196 DWORD serial = 0;
2197 WCHAR buffer[9];
2199 GetVolumeInformationW( root, NULL, 0, &serial, NULL, NULL, NULL, 0 );
2200 sprintfW( buffer, fmtW, serial );
2201 return heap_strdupW( buffer );
2204 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
2206 static const WCHAR fmtW[] = {'%','c',':',0};
2207 WCHAR device_id[3], root[] = {'A',':','\\',0};
2208 struct record_logicaldisk *rec;
2209 UINT i, row = 0, offset = 0, type;
2210 UINT64 size = 1024 * 1024 * 1024;
2211 DWORD drives = GetLogicalDrives();
2212 enum fill_status status = FILL_STATUS_UNFILTERED;
2214 if (!resize_table( table, 4, sizeof(*rec) )) return FILL_STATUS_FAILED;
2216 for (i = 0; i < 26; i++)
2218 if (drives & (1 << i))
2220 root[0] = 'A' + i;
2221 type = GetDriveTypeW( root );
2222 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
2223 continue;
2225 if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2227 rec = (struct record_logicaldisk *)(table->data + offset);
2228 sprintfW( device_id, fmtW, 'A' + i );
2229 rec->device_id = heap_strdupW( device_id );
2230 rec->drivetype = type;
2231 rec->filesystem = get_filesystem( root );
2232 rec->freespace = get_freespace( root, &size );
2233 rec->name = heap_strdupW( device_id );
2234 rec->size = size;
2235 rec->volumename = get_volumename( root );
2236 rec->volumeserialnumber = get_volumeserialnumber( root );
2237 if (!match_row( table, row, cond, &status ))
2239 free_row_values( table, row );
2240 continue;
2242 offset += sizeof(*rec);
2243 row++;
2246 TRACE("created %u rows\n", row);
2247 table->num_rows = row;
2248 return status;
2251 static UINT16 get_connection_status( IF_OPER_STATUS status )
2253 switch (status)
2255 case IfOperStatusDown:
2256 return 0; /* Disconnected */
2257 case IfOperStatusUp:
2258 return 2; /* Connected */
2259 default:
2260 ERR("unhandled status %u\n", status);
2261 break;
2263 return 0;
2265 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
2267 static const WCHAR fmtW[] =
2268 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
2269 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
2270 WCHAR *ret;
2272 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
2273 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
2274 return ret;
2276 static const WCHAR *get_adaptertype( DWORD type, int *physical )
2278 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
2279 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
2280 static const WCHAR firewireW[] = {'1','3','9','4',0};
2281 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
2283 switch (type)
2285 case IF_TYPE_ETHERNET_CSMACD: *physical = -1; return ethernetW;
2286 case IF_TYPE_IEEE80211: *physical = -1; return wirelessW;
2287 case IF_TYPE_IEEE1394: *physical = -1; return firewireW;
2288 case IF_TYPE_TUNNEL: *physical = 0; return tunnelW;
2289 default: *physical = 0; return NULL;
2293 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
2295 static const WCHAR fmtW[] = {'%','u',0};
2296 WCHAR device_id[11];
2297 struct record_networkadapter *rec;
2298 IP_ADAPTER_ADDRESSES *aa, *buffer;
2299 UINT row = 0, offset = 0, count = 0;
2300 DWORD size = 0, ret;
2301 int physical;
2302 enum fill_status status = FILL_STATUS_UNFILTERED;
2304 ret = GetAdaptersAddresses( WS_AF_UNSPEC, 0, NULL, NULL, &size );
2305 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2307 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2308 if (GetAdaptersAddresses( WS_AF_UNSPEC, 0, NULL, buffer, &size ))
2310 heap_free( buffer );
2311 return FILL_STATUS_FAILED;
2313 for (aa = buffer; aa; aa = aa->Next)
2315 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2317 if (!resize_table( table, count, sizeof(*rec) ))
2319 heap_free( buffer );
2320 return FILL_STATUS_FAILED;
2322 for (aa = buffer; aa; aa = aa->Next)
2324 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2326 rec = (struct record_networkadapter *)(table->data + offset);
2327 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
2328 rec->adaptertype = get_adaptertype( aa->IfType, &physical );
2329 rec->device_id = heap_strdupW( device_id );
2330 rec->index = aa->u.s.IfIndex;
2331 rec->interface_index = aa->u.s.IfIndex;
2332 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2333 rec->manufacturer = compsys_manufacturerW;
2334 rec->name = heap_strdupW( aa->FriendlyName );
2335 rec->netconnection_status = get_connection_status( aa->OperStatus );
2336 rec->physicaladapter = physical;
2337 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
2338 rec->speed = 1000000;
2339 if (!match_row( table, row, cond, &status ))
2341 free_row_values( table, row );
2342 continue;
2344 offset += sizeof(*rec);
2345 row++;
2347 TRACE("created %u rows\n", row);
2348 table->num_rows = row;
2350 heap_free( buffer );
2351 return status;
2354 static WCHAR *get_dnshostname( IP_ADAPTER_UNICAST_ADDRESS *addr )
2356 const SOCKET_ADDRESS *sa = &addr->Address;
2357 WCHAR buf[WS_NI_MAXHOST];
2359 if (!addr) return NULL;
2360 if (GetNameInfoW( sa->lpSockaddr, sa->iSockaddrLength, buf, sizeof(buf)/sizeof(buf[0]), NULL,
2361 0, WS_NI_NAMEREQD )) return NULL;
2362 return heap_strdupW( buf );
2364 static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
2366 IP_ADAPTER_GATEWAY_ADDRESS *gateway;
2367 struct array *ret;
2368 ULONG buflen, i = 0, count = 0;
2369 WCHAR **ptr, buf[54]; /* max IPv6 address length */
2371 if (!list) return NULL;
2372 for (gateway = list; gateway; gateway = gateway->Next) count++;
2374 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2375 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2377 heap_free( ret );
2378 return NULL;
2380 for (gateway = list; gateway; gateway = gateway->Next)
2382 buflen = sizeof(buf)/sizeof(buf[0]);
2383 if (WSAAddressToStringW( gateway->Address.lpSockaddr, gateway->Address.iSockaddrLength,
2384 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2386 for (; i > 0; i--) heap_free( ptr[i - 1] );
2387 heap_free( ptr );
2388 heap_free( ret );
2389 return NULL;
2392 ret->count = count;
2393 ret->ptr = ptr;
2394 return ret;
2396 static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
2398 IP_ADAPTER_DNS_SERVER_ADDRESS *server;
2399 struct array *ret;
2400 ULONG buflen, i = 0, count = 0;
2401 WCHAR **ptr, *p, buf[54]; /* max IPv6 address length */
2403 if (!list) return NULL;
2404 for (server = list; server; server = server->Next) count++;
2406 if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
2407 if (!(ptr = heap_alloc( sizeof(*ptr) * count )))
2409 heap_free( ret );
2410 return NULL;
2412 for (server = list; server; server = server->Next)
2414 buflen = sizeof(buf)/sizeof(buf[0]);
2415 if (WSAAddressToStringW( server->Address.lpSockaddr, server->Address.iSockaddrLength,
2416 NULL, buf, &buflen) || !(ptr[i++] = heap_strdupW( buf )))
2418 for (; i > 0; i--) heap_free( ptr[i - 1] );
2419 heap_free( ptr );
2420 heap_free( ret );
2421 return NULL;
2423 if ((p = strrchrW( ptr[i - 1], ':' ))) *p = 0;
2425 ret->count = count;
2426 ret->ptr = ptr;
2427 return ret;
2429 static WCHAR *get_settingid( UINT32 index )
2431 GUID guid;
2432 WCHAR *ret, *str;
2433 memset( &guid, 0, sizeof(guid) );
2434 guid.Data1 = index;
2435 UuidToStringW( &guid, &str );
2436 ret = heap_strdupW( str );
2437 RpcStringFreeW( &str );
2438 return ret;
2441 static enum fill_status fill_networkadapterconfig( struct table *table, const struct expr *cond )
2443 struct record_networkadapterconfig *rec;
2444 IP_ADAPTER_ADDRESSES *aa, *buffer;
2445 UINT row = 0, offset = 0, count = 0;
2446 DWORD size = 0, ret;
2447 enum fill_status status = FILL_STATUS_UNFILTERED;
2449 ret = GetAdaptersAddresses( WS_AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, NULL, &size );
2450 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
2452 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
2453 if (GetAdaptersAddresses( WS_AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_GATEWAYS, NULL, buffer, &size ))
2455 heap_free( buffer );
2456 return FILL_STATUS_FAILED;
2458 for (aa = buffer; aa; aa = aa->Next)
2460 if (aa->IfType != IF_TYPE_SOFTWARE_LOOPBACK) count++;
2462 if (!resize_table( table, count, sizeof(*rec) ))
2464 heap_free( buffer );
2465 return FILL_STATUS_FAILED;
2467 for (aa = buffer; aa; aa = aa->Next)
2469 if (aa->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue;
2471 rec = (struct record_networkadapterconfig *)(table->data + offset);
2472 rec->defaultipgateway = get_defaultipgateway( aa->FirstGatewayAddress );
2473 rec->description = heap_strdupW( aa->Description );
2474 rec->dhcpenabled = -1;
2475 rec->dnshostname = get_dnshostname( aa->FirstUnicastAddress );
2476 rec->dnsserversearchorder = get_dnsserversearchorder( aa->FirstDnsServerAddress );
2477 rec->index = aa->u.s.IfIndex;
2478 rec->ipconnectionmetric = 20;
2479 rec->ipenabled = -1;
2480 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
2481 rec->settingid = get_settingid( rec->index );
2482 if (!match_row( table, row, cond, &status ))
2484 free_row_values( table, row );
2485 continue;
2487 offset += sizeof(*rec);
2488 row++;
2490 TRACE("created %u rows\n", row);
2491 table->num_rows = row;
2493 heap_free( buffer );
2494 return status;
2497 static enum fill_status fill_physicalmemory( struct table *table, const struct expr *cond )
2499 struct record_physicalmemory *rec;
2500 enum fill_status status = FILL_STATUS_UNFILTERED;
2501 UINT row = 0;
2503 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2505 rec = (struct record_physicalmemory *)table->data;
2506 rec->capacity = get_total_physical_memory();
2507 rec->memorytype = 9; /* RAM */
2508 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2509 else row++;
2511 TRACE("created %u rows\n", row);
2512 table->num_rows = row;
2513 return status;
2516 static enum fill_status fill_printer( struct table *table, const struct expr *cond )
2518 static const WCHAR fmtW[] = {'P','r','i','n','t','e','r','%','d',0};
2519 struct record_printer *rec;
2520 enum fill_status status = FILL_STATUS_UNFILTERED;
2521 PRINTER_INFO_2W *info;
2522 DWORD i, offset = 0, count = 0, size = 0, num_rows = 0;
2523 WCHAR id[20];
2525 EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
2526 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
2528 if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
2529 if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
2531 heap_free( info );
2532 return FILL_STATUS_FAILED;
2534 if (!resize_table( table, count, sizeof(*rec) ))
2536 heap_free( info );
2537 return FILL_STATUS_FAILED;
2540 for (i = 0; i < count; i++)
2542 rec = (struct record_printer *)(table->data + offset);
2543 rec->attributes = info[i].Attributes;
2544 sprintfW( id, fmtW, i );
2545 rec->device_id = heap_strdupW( id );
2546 rec->drivername = heap_strdupW( info[i].pDriverName );
2547 rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
2548 rec->local = -1;
2549 rec->location = heap_strdupW( info[i].pLocation );
2550 rec->name = heap_strdupW( info[i].pPrinterName );
2551 rec->network = 0;
2552 rec->portname = heap_strdupW( info[i].pPortName );
2553 if (!match_row( table, i, cond, &status ))
2555 free_row_values( table, i );
2556 continue;
2558 offset += sizeof(*rec);
2559 num_rows++;
2561 TRACE("created %u rows\n", num_rows);
2562 table->num_rows = num_rows;
2564 heap_free( info );
2565 return status;
2568 static WCHAR *get_cmdline( DWORD process_id )
2570 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
2571 return NULL; /* FIXME handle different process case */
2574 static enum fill_status fill_process( struct table *table, const struct expr *cond )
2576 static const WCHAR fmtW[] = {'%','u',0};
2577 WCHAR handle[11];
2578 struct record_process *rec;
2579 PROCESSENTRY32W entry;
2580 HANDLE snap;
2581 enum fill_status status = FILL_STATUS_FAILED;
2582 UINT row = 0, offset = 0;
2584 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
2585 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
2587 entry.dwSize = sizeof(entry);
2588 if (!Process32FirstW( snap, &entry )) goto done;
2589 if (!resize_table( table, 8, sizeof(*rec) )) goto done;
2593 if (!resize_table( table, row + 1, sizeof(*rec) )) goto done;
2595 rec = (struct record_process *)(table->data + offset);
2596 rec->caption = heap_strdupW( entry.szExeFile );
2597 rec->commandline = get_cmdline( entry.th32ProcessID );
2598 rec->description = heap_strdupW( entry.szExeFile );
2599 sprintfW( handle, fmtW, entry.th32ProcessID );
2600 rec->handle = heap_strdupW( handle );
2601 rec->name = heap_strdupW( entry.szExeFile );
2602 rec->process_id = entry.th32ProcessID;
2603 rec->pprocess_id = entry.th32ParentProcessID;
2604 rec->thread_count = entry.cntThreads;
2605 rec->workingsetsize = 0;
2606 rec->get_owner = process_get_owner;
2607 if (!match_row( table, row, cond, &status ))
2609 free_row_values( table, row );
2610 continue;
2612 offset += sizeof(*rec);
2613 row++;
2614 } while (Process32NextW( snap, &entry ));
2616 TRACE("created %u rows\n", row);
2617 table->num_rows = row;
2618 status = FILL_STATUS_UNFILTERED;
2620 done:
2621 CloseHandle( snap );
2622 return status;
2625 static inline void do_cpuid( unsigned int ax, unsigned int *p )
2627 #ifdef __i386__
2628 #ifdef _MSC_VER
2629 __cpuid(p, ax);
2630 #else
2631 __asm__("pushl %%ebx\n\t"
2632 "cpuid\n\t"
2633 "movl %%ebx, %%esi\n\t"
2634 "popl %%ebx"
2635 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
2636 : "0" (ax));
2637 #endif
2638 #endif
2640 static const WCHAR *get_osarchitecture(void)
2642 SYSTEM_INFO info;
2643 GetNativeSystemInfo( &info );
2644 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
2645 return os_32bitW;
2647 static void get_processor_caption( WCHAR *caption )
2649 static const WCHAR fmtW[] =
2650 {'%','s',' ','F','a','m','i','l','y',' ','%','u',' ',
2651 'M','o','d','e','l',' ','%','u',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2652 static const WCHAR x86W[] = {'x','8','6',0};
2653 static const WCHAR intel64W[] = {'I','n','t','e','l','6','4',0};
2654 const WCHAR *arch = (get_osarchitecture() == os_32bitW) ? x86W : intel64W;
2655 unsigned int regs[4] = {0, 0, 0, 0};
2657 do_cpuid( 1, regs );
2658 sprintfW( caption, fmtW, arch, (regs[0] & (15 << 8)) >> 8, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2660 static void get_processor_version( WCHAR *version )
2662 static const WCHAR fmtW[] =
2663 {'M','o','d','e','l',' ','%','u',',',' ','S','t','e','p','p','i','n','g',' ','%','u',0};
2664 unsigned int regs[4] = {0, 0, 0, 0};
2666 do_cpuid( 1, regs );
2667 sprintfW( version, fmtW, (regs[0] & (15 << 4)) >> 4, regs[0] & 15 );
2669 static UINT16 get_processor_revision(void)
2671 unsigned int regs[4] = {0, 0, 0, 0};
2672 do_cpuid( 1, regs );
2673 return regs[0];
2675 static void get_processor_id( WCHAR *processor_id )
2677 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
2678 unsigned int regs[4] = {0, 0, 0, 0};
2680 do_cpuid( 1, regs );
2681 sprintfW( processor_id, fmtW, regs[3], regs[0] );
2683 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
2685 unsigned int i;
2686 unsigned char *p = (unsigned char *)regs;
2688 for (i = 0; i < len; i++) { buffer[i] = *p++; }
2689 buffer[i] = 0;
2691 static void get_processor_manufacturer( WCHAR *manufacturer )
2693 unsigned int tmp, regs[4] = {0, 0, 0, 0};
2695 do_cpuid( 0, regs );
2696 tmp = regs[2]; /* swap edx and ecx */
2697 regs[2] = regs[3];
2698 regs[3] = tmp;
2700 regs_to_str( regs + 1, 12, manufacturer );
2702 static void get_processor_name( WCHAR *name )
2704 unsigned int regs[4] = {0, 0, 0, 0};
2706 do_cpuid( 0x80000000, regs );
2707 if (regs[0] >= 0x80000004)
2709 do_cpuid( 0x80000002, regs );
2710 regs_to_str( regs, 16, name );
2711 do_cpuid( 0x80000003, regs );
2712 regs_to_str( regs, 16, name + 16 );
2713 do_cpuid( 0x80000004, regs );
2714 regs_to_str( regs, 16, name + 32 );
2717 static UINT get_processor_currentclockspeed( UINT index )
2719 PROCESSOR_POWER_INFORMATION *info;
2720 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2721 NTSTATUS status;
2723 if ((info = heap_alloc( size )))
2725 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2726 if (!status) ret = info[index].CurrentMhz;
2727 heap_free( info );
2729 return ret;
2731 static UINT get_processor_maxclockspeed( UINT index )
2733 PROCESSOR_POWER_INFORMATION *info;
2734 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
2735 NTSTATUS status;
2737 if ((info = heap_alloc( size )))
2739 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
2740 if (!status) ret = info[index].MaxMhz;
2741 heap_free( info );
2743 return ret;
2746 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
2748 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
2749 WCHAR caption[100], device_id[14], processor_id[17], manufacturer[13], name[49] = {0}, version[50];
2750 struct record_processor *rec;
2751 UINT i, offset = 0, num_rows = 0, num_cores, num_logical_processors, count = get_processor_count();
2752 enum fill_status status = FILL_STATUS_UNFILTERED;
2754 if (!resize_table( table, count, sizeof(*rec) )) return FILL_STATUS_FAILED;
2756 get_processor_caption( caption );
2757 get_processor_id( processor_id );
2758 get_processor_manufacturer( manufacturer );
2759 get_processor_name( name );
2760 get_processor_version( version );
2762 num_logical_processors = get_logical_processor_count( &num_cores ) / count;
2763 num_cores /= count;
2765 for (i = 0; i < count; i++)
2767 rec = (struct record_processor *)(table->data + offset);
2768 rec->addresswidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2769 rec->architecture = get_osarchitecture() == os_32bitW ? 0 : 9;
2770 rec->caption = heap_strdupW( caption );
2771 rec->cpu_status = 1; /* CPU Enabled */
2772 rec->currentclockspeed = get_processor_currentclockspeed( i );
2773 rec->datawidth = get_osarchitecture() == os_32bitW ? 32 : 64;
2774 rec->description = heap_strdupW( caption );
2775 sprintfW( device_id, fmtW, i );
2776 rec->device_id = heap_strdupW( device_id );
2777 rec->family = 2; /* Unknown */
2778 rec->level = 15;
2779 rec->manufacturer = heap_strdupW( manufacturer );
2780 rec->maxclockspeed = get_processor_maxclockspeed( i );
2781 rec->name = heap_strdupW( name );
2782 rec->num_cores = num_cores;
2783 rec->num_logical_processors = num_logical_processors;
2784 rec->processor_id = heap_strdupW( processor_id );
2785 rec->processortype = 3; /* central processor */
2786 rec->revision = get_processor_revision();
2787 rec->unique_id = NULL;
2788 rec->version = heap_strdupW( version );
2789 if (!match_row( table, i, cond, &status ))
2791 free_row_values( table, i );
2792 continue;
2794 offset += sizeof(*rec);
2795 num_rows++;
2798 TRACE("created %u rows\n", num_rows);
2799 table->num_rows = num_rows;
2800 return status;
2803 static WCHAR *get_lastbootuptime(void)
2805 static const WCHAR fmtW[] =
2806 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2807 '.','%','0','6','u','+','0','0','0',0};
2808 SYSTEM_TIMEOFDAY_INFORMATION ti;
2809 TIME_FIELDS tf;
2810 WCHAR *ret;
2812 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2814 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
2815 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
2816 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
2817 return ret;
2819 static WCHAR *get_localdatetime(void)
2821 static const WCHAR fmtW[] =
2822 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
2823 '.','%','0','6','u','%','+','0','3','d',0};
2824 TIME_ZONE_INFORMATION tzi;
2825 SYSTEMTIME st;
2826 WCHAR *ret;
2827 DWORD Status;
2828 LONG Bias;
2830 Status = GetTimeZoneInformation(&tzi);
2832 if(Status == TIME_ZONE_ID_INVALID) return NULL;
2833 Bias = tzi.Bias;
2834 if(Status == TIME_ZONE_ID_DAYLIGHT)
2835 Bias+= tzi.DaylightBias;
2836 else
2837 Bias+= tzi.StandardBias;
2838 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
2840 GetLocalTime(&st);
2841 sprintfW( ret, fmtW, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds * 1000, -Bias);
2842 return ret;
2844 static WCHAR *get_systemdirectory(void)
2846 void *redir;
2847 WCHAR *ret;
2849 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
2850 Wow64DisableWow64FsRedirection( &redir );
2851 GetSystemDirectoryW( ret, MAX_PATH );
2852 Wow64RevertWow64FsRedirection( redir );
2853 return ret;
2855 static WCHAR *get_codeset(void)
2857 static const WCHAR fmtW[] = {'%','u',0};
2858 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2859 if (ret) sprintfW( ret, fmtW, GetACP() );
2860 return ret;
2862 static WCHAR *get_countrycode(void)
2864 WCHAR *ret = heap_alloc( 6 * sizeof(WCHAR) );
2865 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ICOUNTRY, ret, 6 );
2866 return ret;
2868 static WCHAR *get_locale(void)
2870 WCHAR *ret = heap_alloc( 5 * sizeof(WCHAR) );
2871 if (ret) GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, ret, 5 );
2872 return ret;
2874 static WCHAR *get_osbuildnumber( OSVERSIONINFOEXW *ver )
2876 static const WCHAR fmtW[] = {'%','u',0};
2877 WCHAR *ret = heap_alloc( 11 * sizeof(WCHAR) );
2878 if (ret) sprintfW( ret, fmtW, ver->dwBuildNumber );
2879 return ret;
2881 static WCHAR *get_oscaption( OSVERSIONINFOEXW *ver )
2883 static const WCHAR windowsW[] =
2884 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' '};
2885 static const WCHAR win2000W[] =
2886 {'2','0','0','0',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2887 static const WCHAR win2003W[] =
2888 {'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};
2889 static const WCHAR winxpW[] =
2890 {'X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2891 static const WCHAR winxp64W[] =
2892 {'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};
2893 static const WCHAR vistaW[] =
2894 {'V','i','s','t','a',' ','U','l','t','i','m','a','t','e',0};
2895 static const WCHAR win2008W[] =
2896 {'S','e','r','v','e','r',' ','2','0','0','8',' ','S','t','a','n','d','a','r','d',0};
2897 static const WCHAR win7W[] =
2898 {'7',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
2899 static const WCHAR win2008r2W[] =
2900 {'S','e','r','v','e','r',' ','2','0','0','8',' ','R','2',' ','S','t','a','n','d','a','r','d',0};
2901 static const WCHAR win8W[] =
2902 {'8',' ','P','r','o',0};
2903 static const WCHAR win81W[] =
2904 {'8','.','1',' ','P','r','o',0};
2905 static const WCHAR win10W[] =
2906 {'1','0',' ','P','r','o',0};
2907 int len = sizeof(windowsW)/sizeof(windowsW[0]);
2908 WCHAR *ret;
2910 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(win2003W) ))) return NULL;
2911 memcpy( ret, windowsW, sizeof(windowsW) );
2912 if (ver->dwMajorVersion == 10 && ver->dwMinorVersion == 0) memcpy( ret + len, win10W, sizeof(win10W) );
2913 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 3) memcpy( ret + len, win8W, sizeof(win8W) );
2914 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 2) memcpy( ret + len, win81W, sizeof(win81W) );
2915 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 1)
2917 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, win7W, sizeof(win7W) );
2918 else memcpy( ret + len, win2008r2W, sizeof(win2008r2W) );
2920 else if (ver->dwMajorVersion == 6 && ver->dwMinorVersion == 0)
2922 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, vistaW, sizeof(vistaW) );
2923 else memcpy( ret + len, win2008W, sizeof(win2008W) );
2925 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 2)
2927 if (ver->wProductType == VER_NT_WORKSTATION) memcpy( ret + len, winxp64W, sizeof(winxp64W) );
2928 else memcpy( ret + len, win2003W, sizeof(win2003W) );
2930 else if (ver->dwMajorVersion == 5 && ver->dwMinorVersion == 1) memcpy( ret + len, winxpW, sizeof(winxpW) );
2931 else memcpy( ret + len, win2000W, sizeof(win2000W) );
2932 return ret;
2934 static WCHAR *get_osname( const WCHAR *caption )
2936 static const WCHAR partitionW[] =
2937 {'|','C',':','\\','W','I','N','D','O','W','S','|','\\','D','e','v','i','c','e','\\',
2938 'H','a','r','d','d','i','s','k','0','\\','P','a','r','t','i','t','i','o','n','1',0};
2939 int len = strlenW( caption );
2940 WCHAR *ret;
2942 if (!(ret = heap_alloc( len * sizeof(WCHAR) + sizeof(partitionW) ))) return NULL;
2943 memcpy( ret, caption, len * sizeof(WCHAR) );
2944 memcpy( ret + len, partitionW, sizeof(partitionW) );
2945 return ret;
2947 static WCHAR *get_osversion( OSVERSIONINFOEXW *ver )
2949 static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u',0};
2950 WCHAR *ret = heap_alloc( 33 * sizeof(WCHAR) );
2951 if (ret) sprintfW( ret, fmtW, ver->dwMajorVersion, ver->dwMinorVersion, ver->dwBuildNumber );
2952 return ret;
2955 static enum fill_status fill_os( struct table *table, const struct expr *cond )
2957 struct record_operatingsystem *rec;
2958 enum fill_status status = FILL_STATUS_UNFILTERED;
2959 OSVERSIONINFOEXW ver;
2960 UINT row = 0;
2962 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
2964 ver.dwOSVersionInfoSize = sizeof(ver);
2965 GetVersionExW( (OSVERSIONINFOW *)&ver );
2967 rec = (struct record_operatingsystem *)table->data;
2968 rec->buildnumber = get_osbuildnumber( &ver );
2969 rec->caption = get_oscaption( &ver );
2970 rec->codeset = get_codeset();
2971 rec->countrycode = get_countrycode();
2972 rec->csdversion = ver.szCSDVersion[0] ? heap_strdupW( ver.szCSDVersion ) : NULL;
2973 rec->freephysicalmemory = get_available_physical_memory() / 1024;
2974 rec->installdate = os_installdateW;
2975 rec->lastbootuptime = get_lastbootuptime();
2976 rec->localdatetime = get_localdatetime();
2977 rec->locale = get_locale();
2978 rec->name = get_osname( rec->caption );
2979 rec->osarchitecture = get_osarchitecture();
2980 rec->oslanguage = GetSystemDefaultLangID();
2981 rec->osproductsuite = 2461140; /* Windows XP Professional */
2982 rec->ostype = 18; /* WINNT */
2983 rec->primary = -1;
2984 rec->serialnumber = os_serialnumberW;
2985 rec->servicepackmajor = ver.wServicePackMajor;
2986 rec->servicepackminor = ver.wServicePackMinor;
2987 rec->suitemask = 272; /* Single User + Terminal */
2988 rec->systemdirectory = get_systemdirectory();
2989 rec->totalvirtualmemorysize = get_total_physical_memory() / 1024;
2990 rec->totalvisiblememorysize = rec->totalvirtualmemorysize;
2991 rec->version = get_osversion( &ver );
2992 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
2993 else row++;
2995 TRACE("created %u rows\n", row);
2996 table->num_rows = row;
2997 return status;
3000 static const WCHAR *get_service_type( DWORD type )
3002 static const WCHAR filesystem_driverW[] =
3003 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
3004 static const WCHAR kernel_driverW[] =
3005 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
3006 static const WCHAR own_processW[] =
3007 {'O','w','n',' ','P','r','o','c','e','s','s',0};
3008 static const WCHAR share_processW[] =
3009 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
3011 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
3012 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
3013 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
3014 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
3015 else ERR("unhandled type 0x%08x\n", type);
3016 return NULL;
3018 static const WCHAR *get_service_state( DWORD state )
3020 static const WCHAR runningW[] =
3021 {'R','u','n','n','i','n','g',0};
3022 static const WCHAR start_pendingW[] =
3023 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
3024 static const WCHAR stop_pendingW[] =
3025 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
3026 static const WCHAR stoppedW[] =
3027 {'S','t','o','p','p','e','d',0};
3028 static const WCHAR unknownW[] =
3029 {'U','n','k','n','o','w','n',0};
3031 switch (state)
3033 case SERVICE_STOPPED: return stoppedW;
3034 case SERVICE_START_PENDING: return start_pendingW;
3035 case SERVICE_STOP_PENDING: return stop_pendingW;
3036 case SERVICE_RUNNING: return runningW;
3037 default:
3038 ERR("unknown state %u\n", state);
3039 return unknownW;
3042 static const WCHAR *get_service_startmode( DWORD mode )
3044 static const WCHAR bootW[] = {'B','o','o','t',0};
3045 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
3046 static const WCHAR autoW[] = {'A','u','t','o',0};
3047 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
3048 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
3049 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
3051 switch (mode)
3053 case SERVICE_BOOT_START: return bootW;
3054 case SERVICE_SYSTEM_START: return systemW;
3055 case SERVICE_AUTO_START: return autoW;
3056 case SERVICE_DEMAND_START: return manualW;
3057 case SERVICE_DISABLED: return disabledW;
3058 default:
3059 ERR("unknown mode 0x%x\n", mode);
3060 return unknownW;
3063 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
3065 QUERY_SERVICE_CONFIGW *config = NULL;
3066 SC_HANDLE service;
3067 DWORD size;
3069 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
3070 QueryServiceConfigW( service, NULL, 0, &size );
3071 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
3072 if (!(config = heap_alloc( size ))) goto done;
3073 if (QueryServiceConfigW( service, config, size, &size )) goto done;
3074 heap_free( config );
3075 config = NULL;
3077 done:
3078 CloseServiceHandle( service );
3079 return config;
3082 static enum fill_status fill_service( struct table *table, const struct expr *cond )
3084 struct record_service *rec;
3085 SC_HANDLE manager;
3086 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
3087 SERVICE_STATUS_PROCESS *status;
3088 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
3089 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
3090 UINT i, row = 0, offset = 0, size = 256, needed, count;
3091 enum fill_status fill_status = FILL_STATUS_FAILED;
3092 BOOL ret;
3094 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
3095 if (!(services = heap_alloc( size ))) goto done;
3097 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
3098 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
3099 &count, NULL, NULL );
3100 if (!ret)
3102 if (GetLastError() != ERROR_MORE_DATA) goto done;
3103 size = needed;
3104 if (!(tmp = heap_realloc( services, size ))) goto done;
3105 services = tmp;
3106 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
3107 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
3108 &count, NULL, NULL );
3109 if (!ret) goto done;
3111 if (!resize_table( table, count, sizeof(*rec) )) goto done;
3113 GetComputerNameW( sysnameW, &len );
3114 fill_status = FILL_STATUS_UNFILTERED;
3116 for (i = 0; i < count; i++)
3118 QUERY_SERVICE_CONFIGW *config;
3120 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
3122 status = &services[i].ServiceStatusProcess;
3123 rec = (struct record_service *)(table->data + offset);
3124 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
3125 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
3126 rec->displayname = heap_strdupW( services[i].lpDisplayName );
3127 rec->name = heap_strdupW( services[i].lpServiceName );
3128 rec->process_id = status->dwProcessId;
3129 rec->servicetype = get_service_type( status->dwServiceType );
3130 rec->startmode = get_service_startmode( config->dwStartType );
3131 rec->state = get_service_state( status->dwCurrentState );
3132 rec->systemname = heap_strdupW( sysnameW );
3133 rec->pause_service = service_pause_service;
3134 rec->resume_service = service_resume_service;
3135 rec->start_service = service_start_service;
3136 rec->stop_service = service_stop_service;
3137 heap_free( config );
3138 if (!match_row( table, row, cond, &fill_status ))
3140 free_row_values( table, row );
3141 continue;
3143 offset += sizeof(*rec);
3144 row++;
3147 TRACE("created %u rows\n", row);
3148 table->num_rows = row;
3150 done:
3151 CloseServiceHandle( manager );
3152 heap_free( services );
3153 return fill_status;
3156 static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
3158 if (!name || !name->Name.Buffer) return NULL;
3159 return heap_strdupW( name->Name.Buffer );
3161 static struct array *get_binaryrepresentation( PSID sid, UINT len )
3163 struct array *array = heap_alloc( sizeof(struct array) );
3164 if (array)
3166 UINT8 *ret = heap_alloc( len );
3167 if (ret)
3169 memcpy( ret, sid, len );
3170 array->count = len;
3171 array->ptr = ret;
3172 return array;
3174 heap_free( array );
3176 return NULL;
3178 static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
3180 if (!domain || !domain->Domains || !domain->Domains->Name.Buffer) return NULL;
3181 return heap_strdupW( domain->Domains->Name.Buffer );
3183 static const WCHAR *find_sid_str( const struct expr *cond )
3185 const struct expr *left, *right;
3186 const WCHAR *ret = NULL;
3188 if (!cond || cond->type != EXPR_COMPLEX || cond->u.expr.op != OP_EQ) return NULL;
3190 left = cond->u.expr.left;
3191 right = cond->u.expr.right;
3192 if (left->type == EXPR_PROPVAL && right->type == EXPR_SVAL && !strcmpiW( left->u.propval->name, prop_sidW ))
3194 ret = right->u.sval;
3196 else if (left->type == EXPR_SVAL && right->type == EXPR_PROPVAL && !strcmpiW( right->u.propval->name, prop_sidW ))
3198 ret = left->u.sval;
3200 return ret;
3203 static enum fill_status fill_sid( struct table *table, const struct expr *cond )
3205 PSID sid;
3206 LSA_REFERENCED_DOMAIN_LIST *domain;
3207 LSA_TRANSLATED_NAME *name;
3208 LSA_HANDLE handle;
3209 LSA_OBJECT_ATTRIBUTES attrs;
3210 const WCHAR *str;
3211 struct record_sid *rec;
3212 UINT len;
3214 if (!(str = find_sid_str( cond ))) return FILL_STATUS_FAILED;
3215 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
3217 if (!ConvertStringSidToSidW( str, &sid )) return FILL_STATUS_FAILED;
3218 len = GetLengthSid( sid );
3220 memset( &attrs, 0, sizeof(attrs) );
3221 attrs.Length = sizeof(attrs);
3222 if (LsaOpenPolicy( NULL, &attrs, POLICY_ALL_ACCESS, &handle ))
3224 LocalFree( sid );
3225 return FILL_STATUS_FAILED;
3227 if (LsaLookupSids( handle, 1, &sid, &domain, &name ))
3229 LocalFree( sid );
3230 LsaClose( handle );
3231 return FILL_STATUS_FAILED;
3234 rec = (struct record_sid *)table->data;
3235 rec->accountname = get_accountname( name );
3236 rec->binaryrepresentation = get_binaryrepresentation( sid, len );
3237 rec->referenceddomainname = get_referenceddomainname( domain );
3238 rec->sid = heap_strdupW( str );
3239 rec->sidlength = len;
3241 TRACE("created 1 row\n");
3242 table->num_rows = 1;
3244 LsaFreeMemory( domain );
3245 LsaFreeMemory( name );
3246 LocalFree( sid );
3247 LsaClose( handle );
3248 return FILL_STATUS_FILTERED;
3251 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
3253 HDC hdc = GetDC( NULL );
3254 UINT32 ret;
3256 if (!hdc) return 32;
3257 ret = GetDeviceCaps( hdc, BITSPIXEL );
3258 *hres = GetDeviceCaps( hdc, HORZRES );
3259 *vres = GetDeviceCaps( hdc, VERTRES );
3260 ReleaseDC( NULL, hdc );
3261 return ret;
3263 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
3265 static const WCHAR fmtW[] =
3266 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
3267 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
3268 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
3269 WCHAR *ret;
3271 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
3272 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
3273 return ret;
3276 #define HW_VENDOR_AMD 0x1002
3277 #define HW_VENDOR_NVIDIA 0x10de
3278 #define HW_VENDOR_VMWARE 0x15ad
3279 #define HW_VENDOR_INTEL 0x8086
3281 static const WCHAR *get_installeddriver( UINT vendorid )
3283 static const WCHAR driver_amdW[] = {'a','t','i','c','f','x','3','2','.','d','l','l',0};
3284 static const WCHAR driver_intelW[] = {'i','g','d','u','m','d','i','m','3','2','.','d','l','l',0};
3285 static const WCHAR driver_nvidiaW[] = {'n','v','d','3','d','u','m','.','d','l','l',0};
3286 static const WCHAR driver_wineW[] = {'w','i','n','e','.','d','l','l',0};
3288 /* FIXME: wined3d has a better table, but we cannot access this information through dxgi */
3290 if (vendorid == HW_VENDOR_AMD)
3291 return driver_amdW;
3292 else if (vendorid == HW_VENDOR_NVIDIA)
3293 return driver_nvidiaW;
3294 else if (vendorid == HW_VENDOR_INTEL)
3295 return driver_intelW;
3296 return driver_wineW;
3299 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
3301 static const WCHAR fmtW[] = {'%','u',' ','x',' ','%','u',' ','x',' ','%','I','6','4','u',' ','c','o','l','o','r','s',0};
3302 struct record_videocontroller *rec;
3303 HRESULT hr;
3304 IDXGIFactory *factory = NULL;
3305 IDXGIAdapter *adapter = NULL;
3306 DXGI_ADAPTER_DESC desc;
3307 UINT row = 0, hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
3308 const WCHAR *name = videocontroller_deviceidW;
3309 enum fill_status status = FILL_STATUS_UNFILTERED;
3310 WCHAR mode[44];
3312 if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
3314 memset (&desc, 0, sizeof(desc));
3315 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
3316 if (FAILED(hr)) goto done;
3318 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
3319 if (FAILED(hr)) goto done;
3321 hr = IDXGIAdapter_GetDesc( adapter, &desc );
3322 if (SUCCEEDED(hr))
3324 vidmem = desc.DedicatedVideoMemory;
3325 name = desc.Description;
3328 done:
3329 rec = (struct record_videocontroller *)table->data;
3330 rec->adapter_dactype = videocontroller_dactypeW;
3331 rec->adapter_ram = vidmem;
3332 rec->availability = 3; /* Running or Full Power */
3333 rec->config_errorcode = 0; /* no error */
3334 rec->caption = heap_strdupW( name );
3335 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
3336 rec->current_horizontalres = hres;
3337 rec->current_refreshrate = 0; /* default refresh rate */
3338 rec->current_scanmode = 2; /* Unknown */
3339 rec->current_verticalres = vres;
3340 rec->description = heap_strdupW( name );
3341 rec->device_id = videocontroller_deviceidW;
3342 rec->driverdate = videocontroller_driverdateW;
3343 rec->driverversion = videocontroller_driverversionW;
3344 rec->installeddriver = get_installeddriver( desc.VendorId );
3345 rec->name = heap_strdupW( name );
3346 rec->pnpdevice_id = get_pnpdeviceid( &desc );
3347 rec->status = videocontroller_statusW;
3348 rec->videoarchitecture = 2; /* Unknown */
3349 rec->videomemorytype = 2; /* Unknown */
3350 wsprintfW( mode, fmtW, hres, vres, (UINT64)1 << rec->current_bitsperpixel );
3351 rec->videomodedescription = heap_strdupW( mode );
3352 rec->videoprocessor = heap_strdupW( name );
3353 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
3354 else row++;
3356 TRACE("created %u rows\n", row);
3357 table->num_rows = row;
3359 if (adapter) IDXGIAdapter_Release( adapter );
3360 if (factory) IDXGIFactory_Release( factory );
3361 return status;
3364 static struct table builtin_classes[] =
3366 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), 0, (BYTE *)data_baseboard },
3367 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), 0, (BYTE *)data_bios },
3368 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, 0, NULL, fill_cdromdrive },
3369 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, 0, NULL, fill_compsys },
3370 { class_compsysproductW, SIZEOF(col_compsysproduct), col_compsysproduct, 0, 0, NULL, fill_compsysproduct },
3371 { class_datafileW, SIZEOF(col_datafile), col_datafile, 0, 0, NULL, fill_datafile },
3372 { class_desktopmonitorW, SIZEOF(col_desktopmonitor), col_desktopmonitor, 0, 0, NULL, fill_desktopmonitor },
3373 { class_directoryW, SIZEOF(col_directory), col_directory, 0, 0, NULL, fill_directory },
3374 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, 0, 0, NULL, fill_diskdrive },
3375 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, 0, NULL, fill_diskpartition },
3376 { class_ip4routetableW, SIZEOF(col_ip4routetable), col_ip4routetable, 0, 0, NULL, fill_ip4routetable },
3377 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3378 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, 0, NULL, fill_logicaldisk },
3379 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, 0, NULL, fill_networkadapter },
3380 { class_networkadapterconfigW, SIZEOF(col_networkadapterconfig), col_networkadapterconfig, 0, 0, NULL, fill_networkadapterconfig },
3381 { class_osW, SIZEOF(col_os), col_os, 0, 0, NULL, fill_os },
3382 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
3383 { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
3384 { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
3385 { class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
3386 { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
3387 { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3388 { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
3389 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), 0, (BYTE *)data_qualifier },
3390 { class_serviceW, SIZEOF(col_service), col_service, 0, 0, NULL, fill_service },
3391 { class_sidW, SIZEOF(col_sid), col_sid, 0, 0, NULL, fill_sid },
3392 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), 0, (BYTE *)data_sounddevice },
3393 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), 0, (BYTE *)data_stdregprov },
3394 { class_systemsecurityW, SIZEOF(col_systemsecurity), col_systemsecurity, SIZEOF(data_systemsecurity), 0, (BYTE *)data_systemsecurity },
3395 { class_systemenclosureW, SIZEOF(col_systemenclosure), col_systemenclosure, SIZEOF(data_systemenclosure), 0, (BYTE *)data_systemenclosure },
3396 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, 0, NULL, fill_videocontroller }
3399 void init_table_list( void )
3401 static struct list tables = LIST_INIT( tables );
3402 UINT i;
3404 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
3405 table_list = &tables;