wbemprox: Add a partial implementation of Win32_Directory.
[wine.git] / dlls / wbemprox / builtin.c
blobfc7741977b8e294769f24a2ec301a8502670f1c3
1 /*
2 * Copyright 2012 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
23 #include "config.h"
24 #include <stdarg.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "initguid.h"
31 #include "wbemcli.h"
32 #include "wbemprov.h"
33 #include "winsock2.h"
34 #include "iphlpapi.h"
35 #include "tlhelp32.h"
36 #include "d3d10.h"
37 #include "winternl.h"
38 #include "winioctl.h"
39 #include "winsvc.h"
41 #include "wine/debug.h"
42 #include "wbemprox_private.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
46 static const WCHAR class_baseboardW[] =
47 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
48 static const WCHAR class_biosW[] =
49 {'W','i','n','3','2','_','B','I','O','S',0};
50 static const WCHAR class_cdromdriveW[] =
51 {'W','i','n','3','2','_','C','D','R','O','M','D','r','i','v','e',0};
52 static const WCHAR class_compsysW[] =
53 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
54 static const WCHAR class_directoryW[] =
55 {'W','i','n','3','2','_','D','i','r','e','c','t','o','r','y',0};
56 static const WCHAR class_diskdriveW[] =
57 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
58 static const WCHAR class_diskpartitionW[] =
59 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
60 static const WCHAR class_logicaldiskW[] =
61 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
62 static const WCHAR class_logicaldisk2W[] =
63 {'C','I','M','_','L','o','g','i','c','a','l','D','i','s','k',0};
64 static const WCHAR class_networkadapterW[] =
65 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
66 static const WCHAR class_osW[] =
67 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
68 static const WCHAR class_paramsW[] =
69 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
70 static const WCHAR class_qualifiersW[] =
71 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
72 static const WCHAR class_process_getowner_outW[] =
73 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
74 'N','E','R','_','O','U','T',0};
75 static const WCHAR class_processorW[] =
76 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
77 static const WCHAR class_sounddeviceW[] =
78 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
79 static const WCHAR class_videocontrollerW[] =
80 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
82 static const WCHAR prop_acceptpauseW[] =
83 {'A','c','c','e','p','t','P','a','u','s','e',0};
84 static const WCHAR prop_acceptstopW[] =
85 {'A','c','c','e','p','t','S','t','o','p',0};
86 static const WCHAR prop_accessmaskW[] =
87 {'A','c','c','e','s','s','M','a','s','k',0};
88 static const WCHAR prop_adapterramW[] =
89 {'A','d','a','p','t','e','r','R','A','M',0};
90 static const WCHAR prop_adaptertypeW[] =
91 {'A','d','a','p','t','e','r','T','y','p','e',0};
92 static const WCHAR prop_bootableW[] =
93 {'B','o','o','t','a','b','l','e',0};
94 static const WCHAR prop_bootpartitionW[] =
95 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
96 static const WCHAR prop_captionW[] =
97 {'C','a','p','t','i','o','n',0};
98 static const WCHAR prop_classW[] =
99 {'C','l','a','s','s',0};
100 static const WCHAR prop_commandlineW[] =
101 {'C','o','m','m','a','n','d','L','i','n','e',0};
102 static const WCHAR prop_cpustatusW[] =
103 {'C','p','u','S','t','a','t','u','s',0};
104 static const WCHAR prop_csdversionW[] =
105 {'C','S','D','V','e','r','s','i','o','n',0};
106 static const WCHAR prop_currentbitsperpixelW[] =
107 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
108 static const WCHAR prop_currenthorizontalresW[] =
109 {'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};
110 static const WCHAR prop_currentverticalresW[] =
111 {'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};
112 static const WCHAR prop_defaultvalueW[] =
113 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
114 static const WCHAR prop_descriptionW[] =
115 {'D','e','s','c','r','i','p','t','i','o','n',0};
116 static const WCHAR prop_deviceidW[] =
117 {'D','e','v','i','c','e','I','d',0};
118 static const WCHAR prop_directionW[] =
119 {'D','i','r','e','c','t','i','o','n',0};
120 static const WCHAR prop_displaynameW[] =
121 {'D','i','s','p','l','a','y','N','a','m','e',0};
122 static const WCHAR prop_diskindexW[] =
123 {'D','i','s','k','I','n','d','e','x',0};
124 static const WCHAR prop_domainW[] =
125 {'D','o','m','a','i','n',0};
126 static const WCHAR prop_domainroleW[] =
127 {'D','o','m','a','i','n','R','o','l','e',0};
128 static const WCHAR prop_driveW[] =
129 {'D','r','i','v','e',0};
130 static const WCHAR prop_drivetypeW[] =
131 {'D','r','i','v','e','T','y','p','e',0};
132 static const WCHAR prop_familyW[] =
133 {'F','a','m','i','l','y',0};
134 static const WCHAR prop_filesystemW[] =
135 {'F','i','l','e','S','y','s','t','e','m',0};
136 static const WCHAR prop_flavorW[] =
137 {'F','l','a','v','o','r',0};
138 static const WCHAR prop_freespaceW[] =
139 {'F','r','e','e','S','p','a','c','e',0};
140 static const WCHAR prop_handleW[] =
141 {'H','a','n','d','l','e',0};
142 static const WCHAR prop_idW[] =
143 {'I','D',0};
144 static const WCHAR prop_indexW[] =
145 {'I','n','d','e','x',0};
146 static const WCHAR prop_interfaceindexW[] =
147 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
148 static const WCHAR prop_intvalueW[] =
149 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
150 static const WCHAR prop_lastbootuptimeW[] =
151 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
152 static const WCHAR prop_macaddressW[] =
153 {'M','A','C','A','d','d','r','e','s','s',0};
154 static const WCHAR prop_manufacturerW[] =
155 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
156 static const WCHAR prop_maxclockspeedW[] =
157 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
158 static const WCHAR prop_memberW[] =
159 {'M','e','m','b','e','r',0};
160 static const WCHAR prop_methodW[] =
161 {'M','e','t','h','o','d',0};
162 static const WCHAR prop_modelW[] =
163 {'M','o','d','e','l',0};
164 static const WCHAR prop_netconnectionstatusW[] =
165 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
166 static const WCHAR prop_numlogicalprocessorsW[] =
167 {'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};
168 static const WCHAR prop_numprocessorsW[] =
169 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
170 static const WCHAR prop_osarchitectureW[] =
171 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
172 static const WCHAR prop_oslanguageW[] =
173 {'O','S','L','a','n','g','u','a','g','e',0};
174 static const WCHAR prop_osproductsuiteW[] =
175 {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0};
176 static const WCHAR prop_ostypeW[] =
177 {'O','S','T','y','p','e',0};
178 static const WCHAR prop_parameterW[] =
179 {'P','a','r','a','m','e','t','e','r',0};
180 static const WCHAR prop_pnpdeviceidW[] =
181 {'P','N','P','D','e','v','i','c','e','I','D',0};
182 static const WCHAR prop_pprocessidW[] =
183 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
184 static const WCHAR prop_processidW[] =
185 {'P','r','o','c','e','s','s','I','D',0};
186 static const WCHAR prop_processoridW[] =
187 {'P','r','o','c','e','s','s','o','r','I','d',0};
188 static const WCHAR prop_productnameW[] =
189 {'P','r','o','d','u','c','t','N','a','m','e',0};
190 static const WCHAR prop_releasedateW[] =
191 {'R','e','l','e','a','s','e','D','a','t','e',0};
192 static const WCHAR prop_serialnumberW[] =
193 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
194 static const WCHAR prop_servicepackmajorW[] =
195 {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0};
196 static const WCHAR prop_servicetypeW[] =
197 {'S','e','r','v','i','c','e','T','y','p','e',0};
198 static const WCHAR prop_startmodeW[] =
199 {'S','t','a','r','t','M','o','d','e',0};
200 static const WCHAR prop_sizeW[] =
201 {'S','i','z','e',0};
202 static const WCHAR prop_speedW[] =
203 {'S','p','e','e','d',0};
204 static const WCHAR prop_startingoffsetW[] =
205 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
206 static const WCHAR prop_stateW[] =
207 {'S','t','a','t','e',0};
208 static const WCHAR prop_strvalueW[] =
209 {'S','t','r','i','n','g','V','a','l','u','e',0};
210 static const WCHAR prop_suitemaskW[] =
211 {'S','u','i','t','e','M','a','s','k',0};
212 static const WCHAR prop_systemdirectoryW[] =
213 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
214 static const WCHAR prop_systemnameW[] =
215 {'S','y','s','t','e','m','N','a','m','e',0};
216 static const WCHAR prop_tagW[] =
217 {'T','a','g',0};
218 static const WCHAR prop_threadcountW[] =
219 {'T','h','r','e','a','d','C','o','u','n','t',0};
220 static const WCHAR prop_totalphysicalmemoryW[] =
221 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
222 static const WCHAR prop_typeW[] =
223 {'T','y','p','e',0};
224 static const WCHAR prop_uniqueidW[] =
225 {'U','n','i','q','u','e','I','d',0};
226 static const WCHAR prop_varianttypeW[] =
227 {'V','a','r','i','a','n','t','T','y','p','e',0};
228 static const WCHAR prop_versionW[] =
229 {'V','e','r','s','i','o','n',0};
231 /* column definitions must be kept in sync with record structures below */
232 static const struct column col_baseboard[] =
234 { prop_manufacturerW, CIM_STRING },
235 { prop_serialnumberW, CIM_STRING },
236 { prop_tagW, CIM_STRING|COL_FLAG_KEY }
238 static const struct column col_bios[] =
240 { prop_descriptionW, CIM_STRING },
241 { prop_manufacturerW, CIM_STRING },
242 { prop_releasedateW, CIM_DATETIME },
243 { prop_serialnumberW, CIM_STRING },
244 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
246 static const struct column col_cdromdrive[] =
248 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
249 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
250 { prop_nameW, CIM_STRING },
251 { prop_pnpdeviceidW, CIM_STRING }
253 static const struct column col_compsys[] =
255 { prop_descriptionW, CIM_STRING },
256 { prop_domainW, CIM_STRING },
257 { prop_domainroleW, CIM_UINT16 },
258 { prop_manufacturerW, CIM_STRING },
259 { prop_modelW, CIM_STRING },
260 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
261 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
262 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
263 { prop_totalphysicalmemoryW, CIM_UINT64 }
265 static const struct column col_directory[] =
267 { prop_accessmaskW, CIM_UINT32 },
268 { prop_nameW, CIM_STRING|COL_FLAG_KEY }
270 static const struct column col_diskdrive[] =
272 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
273 { prop_indexW, CIM_UINT32, VT_I4 },
274 { prop_manufacturerW, CIM_STRING },
275 { prop_modelW, CIM_STRING },
276 { prop_serialnumberW, CIM_STRING }
278 static const struct column col_diskpartition[] =
280 { prop_bootableW, CIM_BOOLEAN },
281 { prop_bootpartitionW, CIM_BOOLEAN },
282 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
283 { prop_diskindexW, CIM_UINT32, VT_I4 },
284 { prop_indexW, CIM_UINT32, VT_I4 },
285 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
286 { prop_sizeW, CIM_UINT64 },
287 { prop_startingoffsetW, CIM_UINT64 },
288 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
290 static const struct column col_logicaldisk[] =
292 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
293 { prop_drivetypeW, CIM_UINT32, VT_I4 },
294 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
295 { prop_freespaceW, CIM_UINT64 },
296 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
297 { prop_sizeW, CIM_UINT64 }
299 static const struct column col_networkadapter[] =
301 { prop_adaptertypeW, CIM_STRING },
302 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
303 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
304 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
305 { prop_manufacturerW, CIM_STRING },
306 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
307 { prop_pnpdeviceidW, CIM_STRING },
308 { prop_speedW, CIM_UINT64 }
310 static const struct column col_os[] =
312 { prop_captionW, CIM_STRING },
313 { prop_csdversionW, CIM_STRING },
314 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
315 { prop_osarchitectureW, CIM_STRING },
316 { prop_oslanguageW, CIM_UINT32, VT_I4 },
317 { prop_osproductsuiteW, CIM_UINT32, VT_I4 },
318 { prop_ostypeW, CIM_UINT16, VT_I4 },
319 { prop_servicepackmajorW, CIM_UINT16, VT_I4 },
320 { prop_suitemaskW, CIM_UINT32, VT_I4 },
321 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC },
322 { prop_versionW, CIM_STRING }
324 static const struct column col_param[] =
326 { prop_classW, CIM_STRING },
327 { prop_methodW, CIM_STRING },
328 { prop_directionW, CIM_SINT32 },
329 { prop_parameterW, CIM_STRING },
330 { prop_typeW, CIM_UINT32 },
331 { prop_varianttypeW, CIM_UINT32 },
332 { prop_defaultvalueW, CIM_UINT32 }
334 static const struct column col_process[] =
336 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
337 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
338 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
339 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
340 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
341 { prop_pprocessidW, CIM_UINT32, VT_I4 },
342 { prop_processidW, CIM_UINT32, VT_I4 },
343 { prop_threadcountW, CIM_UINT32, VT_I4 },
344 /* methods */
345 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
347 static const struct column col_processor[] =
349 { prop_cpustatusW, CIM_UINT16 },
350 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
351 { prop_familyW, CIM_UINT16, VT_I4 },
352 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
353 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
354 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
355 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
356 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
357 { prop_uniqueidW, CIM_STRING }
359 static const struct column col_qualifier[] =
361 { prop_classW, CIM_STRING },
362 { prop_memberW, CIM_STRING },
363 { prop_typeW, CIM_UINT32 },
364 { prop_flavorW, CIM_SINT32 },
365 { prop_nameW, CIM_STRING },
366 { prop_intvalueW, CIM_SINT32 },
367 { prop_strvalueW, CIM_STRING }
369 static const struct column col_service[] =
371 { prop_acceptpauseW, CIM_BOOLEAN },
372 { prop_acceptstopW, CIM_BOOLEAN },
373 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
374 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
375 { prop_processidW, CIM_UINT32 },
376 { prop_servicetypeW, CIM_STRING },
377 { prop_startmodeW, CIM_STRING },
378 { prop_stateW, CIM_STRING },
379 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
380 /* methods */
381 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
382 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
383 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
384 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
386 static const struct column col_sounddevice[] =
388 { prop_productnameW, CIM_STRING }
390 static const struct column col_stdregprov[] =
392 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
393 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
394 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
396 static const struct column col_videocontroller[] =
398 { prop_adapterramW, CIM_UINT32 },
399 { prop_currentbitsperpixelW, CIM_UINT32 },
400 { prop_currenthorizontalresW, CIM_UINT32 },
401 { prop_currentverticalresW, CIM_UINT32 },
402 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
403 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
404 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
405 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC }
408 static const WCHAR baseboard_manufacturerW[] =
409 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
410 static const WCHAR baseboard_serialnumberW[] =
411 {'N','o','n','e',0};
412 static const WCHAR baseboard_tagW[] =
413 {'B','a','s','e',' ','B','o','a','r','d',0};
414 static const WCHAR bios_descriptionW[] =
415 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
416 static const WCHAR bios_manufacturerW[] =
417 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
418 static const WCHAR bios_releasedateW[] =
419 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
420 static const WCHAR bios_serialnumberW[] =
421 {'0',0};
422 static const WCHAR bios_versionW[] =
423 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
424 static const WCHAR cdromdrive_nameW[] =
425 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
426 static const WCHAR cdromdrive_pnpdeviceidW[]=
427 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
428 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
429 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
430 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
431 static const WCHAR compsys_descriptionW[] =
432 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
433 static const WCHAR compsys_domainW[] =
434 {'W','O','R','K','G','R','O','U','P',0};
435 static const WCHAR compsys_manufacturerW[] =
436 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
437 static const WCHAR compsys_modelW[] =
438 {'W','i','n','e',0};
439 static const WCHAR diskdrive_deviceidW[] =
440 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
441 static const WCHAR diskdrive_modelW[] =
442 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
443 static const WCHAR diskdrive_manufacturerW[] =
444 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
445 static const WCHAR diskdrive_serialW[] =
446 {'W','I','N','E','H','D','I','S','K',0};
447 static const WCHAR networkadapter_pnpdeviceidW[]=
448 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
449 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
450 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
451 static const WCHAR os_captionW[] =
452 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
453 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
454 static const WCHAR os_csdversionW[] =
455 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
456 static const WCHAR os_32bitW[] =
457 {'3','2','-','b','i','t',0};
458 static const WCHAR os_64bitW[] =
459 {'6','4','-','b','i','t',0};
460 static const WCHAR os_versionW[] =
461 {'5','.','1','.','2','6','0','0',0};
462 static const WCHAR sounddevice_productnameW[] =
463 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
464 static const WCHAR videocontroller_deviceidW[] =
465 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
467 #include "pshpack1.h"
468 struct record_baseboard
470 const WCHAR *manufacturer;
471 const WCHAR *serialnumber;
472 const WCHAR *tag;
474 struct record_bios
476 const WCHAR *description;
477 const WCHAR *manufacturer;
478 const WCHAR *releasedate;
479 const WCHAR *serialnumber;
480 const WCHAR *version;
482 struct record_cdromdrive
484 const WCHAR *device_id;
485 const WCHAR *drive;
486 const WCHAR *name;
487 const WCHAR *pnpdevice_id;
489 struct record_computersystem
491 const WCHAR *description;
492 const WCHAR *domain;
493 UINT16 domainrole;
494 const WCHAR *manufacturer;
495 const WCHAR *model;
496 const WCHAR *name;
497 UINT32 num_logical_processors;
498 UINT32 num_processors;
499 UINT64 total_physical_memory;
501 struct record_directory
503 UINT32 accessmask;
504 const WCHAR *name;
506 struct record_diskdrive
508 const WCHAR *device_id;
509 UINT32 index;
510 const WCHAR *manufacturer;
511 const WCHAR *name;
512 const WCHAR *serialnumber;
514 struct record_diskpartition
516 int bootable;
517 int bootpartition;
518 const WCHAR *device_id;
519 UINT32 diskindex;
520 UINT32 index;
521 const WCHAR *pnpdevice_id;
522 UINT64 size;
523 UINT64 startingoffset;
524 const WCHAR *type;
526 struct record_logicaldisk
528 const WCHAR *device_id;
529 UINT32 drivetype;
530 const WCHAR *filesystem;
531 UINT64 freespace;
532 const WCHAR *name;
533 UINT64 size;
535 struct record_networkadapter
537 const WCHAR *adaptertype;
538 const WCHAR *device_id;
539 INT32 interface_index;
540 const WCHAR *mac_address;
541 const WCHAR *manufacturer;
542 UINT16 netconnection_status;
543 const WCHAR *pnpdevice_id;
544 UINT64 speed;
546 struct record_operatingsystem
548 const WCHAR *caption;
549 const WCHAR *csdversion;
550 const WCHAR *lastbootuptime;
551 const WCHAR *osarchitecture;
552 UINT32 oslanguage;
553 UINT32 osproductsuite;
554 UINT16 ostype;
555 UINT16 servicepackmajor;
556 UINT32 suitemask;
557 const WCHAR *systemdirectory;
558 const WCHAR *version;
560 struct record_param
562 const WCHAR *class;
563 const WCHAR *method;
564 INT32 direction;
565 const WCHAR *parameter;
566 UINT32 type;
567 UINT32 varianttype;
568 UINT32 defaultvalue;
570 struct record_process
572 const WCHAR *caption;
573 const WCHAR *commandline;
574 const WCHAR *description;
575 const WCHAR *handle;
576 const WCHAR *name;
577 UINT32 pprocess_id;
578 UINT32 process_id;
579 UINT32 thread_count;
580 /* methods */
581 class_method *get_owner;
583 struct record_processor
585 UINT16 cpu_status;
586 const WCHAR *device_id;
587 UINT16 family;
588 const WCHAR *manufacturer;
589 UINT32 maxclockspeed;
590 const WCHAR *name;
591 UINT32 num_logical_processors;
592 const WCHAR *processor_id;
593 const WCHAR *unique_id;
595 struct record_qualifier
597 const WCHAR *class;
598 const WCHAR *member;
599 UINT32 type;
600 INT32 flavor;
601 const WCHAR *name;
602 INT32 intvalue;
603 const WCHAR *strvalue;
605 struct record_service
607 int accept_pause;
608 int accept_stop;
609 const WCHAR *displayname;
610 const WCHAR *name;
611 UINT32 process_id;
612 const WCHAR *servicetype;
613 const WCHAR *startmode;
614 const WCHAR *state;
615 const WCHAR *systemname;
616 /* methods */
617 class_method *pause_service;
618 class_method *resume_service;
619 class_method *start_service;
620 class_method *stop_service;
622 struct record_sounddevice
624 const WCHAR *productname;
626 struct record_stdregprov
628 class_method *enumkey;
629 class_method *enumvalues;
630 class_method *getstringvalue;
632 struct record_videocontroller
634 UINT32 adapter_ram;
635 UINT32 current_bitsperpixel;
636 UINT32 current_horizontalres;
637 UINT32 current_verticalres;
638 const WCHAR *description;
639 const WCHAR *device_id;
640 const WCHAR *name;
641 const WCHAR *pnpdevice_id;
643 #include "poppack.h"
645 static const struct record_baseboard data_baseboard[] =
647 { baseboard_manufacturerW, baseboard_serialnumberW, baseboard_tagW }
649 static const struct record_bios data_bios[] =
651 { bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW, bios_versionW }
653 static const struct record_diskdrive data_diskdrive[] =
655 { diskdrive_deviceidW, 0, diskdrive_manufacturerW, diskdrive_modelW, diskdrive_serialW }
657 static const struct record_param data_param[] =
659 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
660 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
661 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
662 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
663 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
664 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
665 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
666 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
667 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
668 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
669 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
670 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
671 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
672 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
673 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
674 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
675 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
676 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
677 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
678 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
679 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING }
682 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
683 WBEM_FLAVOR_ORIGIN_PROPAGATED)
685 static const struct record_qualifier data_qualifier[] =
687 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
688 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
690 static const struct record_sounddevice data_sounddevice[] =
692 { sounddevice_productnameW }
694 static const struct record_stdregprov data_stdregprov[] =
696 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
699 /* check if row matches condition and update status */
700 static BOOL match_row( const struct table *table, UINT row, const struct expr *cond, enum fill_status *status )
702 LONGLONG val;
703 if (!cond)
705 *status = FILL_STATUS_UNFILTERED;
706 return TRUE;
708 if (eval_cond( table, row, cond, &val ) != S_OK)
710 *status = FILL_STATUS_FAILED;
711 return FALSE;
713 *status = FILL_STATUS_FILTERED;
714 return val != 0;
717 static enum fill_status fill_cdromdrive( struct table *table, const struct expr *cond )
719 static const WCHAR fmtW[] = {'%','c',':',0};
720 WCHAR drive[3], root[] = {'A',':','\\',0};
721 struct record_cdromdrive *rec;
722 UINT i, row = 0, offset = 0, count = 1;
723 DWORD drives = GetLogicalDrives();
724 enum fill_status status = FILL_STATUS_UNFILTERED;
726 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
728 for (i = 0; i < sizeof(drives); i++)
730 if (drives & (1 << i))
732 root[0] = 'A' + i;
733 if (GetDriveTypeW( root ) != DRIVE_CDROM)
734 continue;
736 if (row > count)
738 BYTE *data;
739 count *= 2;
740 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
741 table->data = data;
743 rec = (struct record_cdromdrive *)(table->data + offset);
744 rec->device_id = cdromdrive_pnpdeviceidW;
745 sprintfW( drive, fmtW, 'A' + i );
746 rec->drive = heap_strdupW( drive );
747 rec->name = cdromdrive_nameW;
748 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
749 if (!match_row( table, row, cond, &status ))
751 free_row_values( table, row );
752 continue;
754 offset += sizeof(*rec);
755 row++;
758 TRACE("created %u rows\n", row);
759 table->num_rows = row;
760 return status;
763 static UINT get_processor_count(void)
765 SYSTEM_BASIC_INFORMATION info;
767 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
768 return info.NumberOfProcessors;
771 static UINT get_logical_processor_count(void)
773 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
774 UINT i, j, count = 0;
775 NTSTATUS status;
776 ULONG len;
778 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
779 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
781 if (!(info = heap_alloc( len ))) return get_processor_count();
782 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
783 if (status != STATUS_SUCCESS)
785 heap_free( info );
786 return get_processor_count();
788 for (i = 0; i < len / sizeof(*info); i++)
790 if (info[i].Relationship != RelationProcessorCore) continue;
791 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
793 heap_free( info );
794 return count;
797 static UINT64 get_total_physical_memory(void)
799 MEMORYSTATUSEX status;
801 status.dwLength = sizeof(status);
802 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
803 return status.ullTotalPhys;
806 static WCHAR *get_computername(void)
808 WCHAR *ret;
809 DWORD size = MAX_COMPUTERNAME_LENGTH;
811 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
812 GetComputerNameW( ret, &size );
813 return ret;
816 static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
818 struct record_computersystem *rec;
819 enum fill_status status = FILL_STATUS_UNFILTERED;
820 UINT row = 0;
822 if (!(table->data = heap_alloc( sizeof(*rec) ))) return FILL_STATUS_FAILED;
824 rec = (struct record_computersystem *)table->data;
825 rec->description = compsys_descriptionW;
826 rec->domain = compsys_domainW;
827 rec->domainrole = 0; /* standalone workstation */
828 rec->manufacturer = compsys_manufacturerW;
829 rec->model = compsys_modelW;
830 rec->name = get_computername();
831 rec->num_logical_processors = get_logical_processor_count();
832 rec->num_processors = get_processor_count();
833 rec->total_physical_memory = get_total_physical_memory();
834 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
835 else row++;
837 TRACE("created %u rows\n", row);
838 table->num_rows = row;
839 return status;
842 static WCHAR *get_filesystem( const WCHAR *root )
844 static const WCHAR ntfsW[] = {'N','T','F','S',0};
845 WCHAR buffer[MAX_PATH + 1];
847 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
848 return heap_strdupW( buffer );
849 return heap_strdupW( ntfsW );
852 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
854 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
855 ULARGE_INTEGER free;
856 DISK_GEOMETRY_EX info;
857 HANDLE handle;
859 free.QuadPart = 512 * 1024 * 1024;
860 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
862 root[4] = dir[0];
863 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
864 if (handle != INVALID_HANDLE_VALUE)
866 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), NULL, NULL ))
867 *disksize = info.DiskSize.QuadPart;
868 CloseHandle( handle );
870 return free.QuadPart;
873 struct dirstack
875 WCHAR **dirs;
876 UINT *len_dirs;
877 UINT num_dirs;
878 UINT num_allocated;
881 static struct dirstack *alloc_dirstack( UINT size )
883 struct dirstack *dirstack;
885 if (!(dirstack = heap_alloc( sizeof(*dirstack) ))) return NULL;
886 if (!(dirstack->dirs = heap_alloc( sizeof(WCHAR *) * size )))
888 heap_free( dirstack );
889 return NULL;
891 if (!(dirstack->len_dirs = heap_alloc( sizeof(UINT) * size )))
893 heap_free( dirstack->dirs );
894 heap_free( dirstack );
895 return NULL;
897 dirstack->num_dirs = 0;
898 dirstack->num_allocated = size;
899 return dirstack;
902 static void free_dirstack( struct dirstack *dirstack )
904 UINT i;
905 for (i = 0; i < dirstack->num_dirs; i++) heap_free( dirstack->dirs[i] );
906 heap_free( dirstack->dirs );
907 heap_free( dirstack->len_dirs );
908 heap_free( dirstack );
911 static BOOL push_dir( struct dirstack *dirstack, WCHAR *dir, UINT len )
913 UINT size, i = dirstack->num_dirs;
915 if (i == dirstack->num_allocated)
917 WCHAR **tmp;
918 UINT *len_tmp;
920 size = dirstack->num_allocated * 2;
921 if (!(tmp = heap_realloc( dirstack->dirs, size * sizeof(WCHAR *) ))) return FALSE;
922 dirstack->dirs = tmp;
923 if (!(len_tmp = heap_realloc( dirstack->len_dirs, size * sizeof(UINT) ))) return FALSE;
924 dirstack->len_dirs = len_tmp;
925 dirstack->num_allocated = size;
927 dirstack->dirs[i] = dir;
928 dirstack->len_dirs[i] = len;
929 dirstack->num_dirs++;
930 return TRUE;
933 static WCHAR *pop_dir( struct dirstack *dirstack, UINT *len )
935 if (!dirstack->num_dirs)
937 *len = 0;
938 return NULL;
940 dirstack->num_dirs--;
941 *len = dirstack->len_dirs[dirstack->num_dirs];
942 return dirstack->dirs[dirstack->num_dirs];
945 static const WCHAR *peek_dir( struct dirstack *dirstack )
947 if (!dirstack->num_dirs) return NULL;
948 return dirstack->dirs[dirstack->num_dirs - 1];
951 static WCHAR *build_glob( WCHAR drive, const WCHAR *path, UINT len )
953 UINT i = 0;
954 WCHAR *ret;
956 if (!(ret = heap_alloc( (len + 6) * sizeof(WCHAR) ))) return NULL;
957 ret[i++] = drive;
958 ret[i++] = ':';
959 ret[i++] = '\\';
960 if (path)
962 memcpy( ret + i, path, len * sizeof(WCHAR) );
963 i += len;
964 ret[i++] = '\\';
966 ret[i++] = '*';
967 ret[i] = 0;
968 return ret;
971 static WCHAR *build_dirname( WCHAR drive, const WCHAR *path )
973 UINT i = 0, len = 0;
974 const WCHAR *p;
975 WCHAR *ret;
977 for (p = path; *p; p++)
979 if (*p == '\\') len += 2;
980 else len++;
982 if (!(ret = heap_alloc( (len + 5) * sizeof(WCHAR) ))) return NULL;
983 ret[i++] = drive;
984 ret[i++] = ':';
985 ret[i++] = '\\';
986 ret[i++] = '\\';
987 for (p = path; *p; p++)
989 if (*p != '\\') ret[i++] = *p;
990 else
992 ret[i++] = '\\';
993 ret[i++] = '\\';
996 ret[i] = 0;
997 return ret;
1000 static WCHAR *append_path( const WCHAR *path, const WCHAR *segment, UINT *len )
1002 UINT len_path = 0, len_segment = strlenW( segment );
1003 WCHAR *ret;
1005 *len = 0;
1006 if (path) len_path = strlenW( path );
1007 if (!(ret = heap_alloc( (len_path + len_segment + 2) * sizeof(WCHAR) ))) return NULL;
1008 if (path)
1010 memcpy( ret, path, len_path * sizeof(WCHAR) );
1011 ret[len_path] = '\\';
1012 *len += len_path + 1;
1014 memcpy( ret + *len, segment, len_segment * sizeof(WCHAR) );
1015 *len += len_segment;
1016 ret[*len] = 0;
1017 return ret;
1020 static enum fill_status fill_directory( struct table *table, const struct expr *cond )
1022 static const WCHAR dotW[] = {'.',0}, dotdotW[] = {'.','.',0};
1023 struct record_directory *rec;
1024 UINT i, len, row = 0, offset = 0, count = 4;
1025 WCHAR *glob = NULL, *path = NULL, *new_path, root[] = {'A',':','\\',0};
1026 DWORD drives = GetLogicalDrives();
1027 WIN32_FIND_DATAW data;
1028 HANDLE handle;
1029 struct dirstack *dirstack = alloc_dirstack(2);
1030 enum fill_status status = FILL_STATUS_UNFILTERED;
1032 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
1034 for (i = 0; i < sizeof(drives); i++)
1036 if (!(drives & (1 << i))) continue;
1038 root[0] = 'A' + i;
1039 if (GetDriveTypeW( root ) != DRIVE_FIXED) continue;
1041 for (;;)
1043 path = pop_dir( dirstack, &len );
1044 if (!(glob = build_glob( root[0], path, len )))
1046 status = FILL_STATUS_FAILED;
1047 goto done;
1049 if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
1053 if (row > count)
1055 BYTE *data;
1056 count *= 2;
1057 if (!(data = heap_realloc( table->data, count * sizeof(*rec) )))
1059 status = FILL_STATUS_FAILED;
1060 goto done;
1062 table->data = data;
1064 if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
1065 !strcmpW( data.cFileName, dotW ) || !strcmpW( data.cFileName, dotdotW ))
1066 continue;
1068 new_path = append_path( path, data.cFileName, &len );
1069 if (!(push_dir( dirstack, new_path, len )))
1071 heap_free( new_path );
1072 status = FILL_STATUS_FAILED;
1073 goto done;
1075 rec = (struct record_directory *)(table->data + offset);
1076 rec->accessmask = FILE_ALL_ACCESS;
1077 rec->name = build_dirname( root[0], new_path );
1078 if (!match_row( table, row, cond, &status ))
1080 free_row_values( table, row );
1081 continue;
1083 offset += sizeof(*rec);
1084 row++;
1086 while (FindNextFileW( handle, &data ));
1087 FindClose( handle );
1089 if (!peek_dir( dirstack )) break;
1090 heap_free( glob );
1091 heap_free( path );
1095 done:
1096 free_dirstack( dirstack );
1097 heap_free( glob );
1098 heap_free( path );
1100 TRACE("created %u rows\n", row);
1101 table->num_rows = row;
1102 return status;
1105 static enum fill_status fill_diskpartition( struct table *table, const struct expr *cond )
1107 static const WCHAR fmtW[] =
1108 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
1109 WCHAR device_id[32], root[] = {'A',':','\\',0};
1110 struct record_diskpartition *rec;
1111 UINT i, row = 0, offset = 0, count = 4, type, index = 0;
1112 UINT64 size = 1024 * 1024 * 1024;
1113 DWORD drives = GetLogicalDrives();
1114 enum fill_status status = FILL_STATUS_UNFILTERED;
1116 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
1118 for (i = 0; i < sizeof(drives); i++)
1120 if (drives & (1 << i))
1122 root[0] = 'A' + i;
1123 type = GetDriveTypeW( root );
1124 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
1125 continue;
1127 if (row > count)
1129 BYTE *data;
1130 count *= 2;
1131 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
1132 table->data = data;
1134 rec = (struct record_diskpartition *)(table->data + offset);
1135 rec->bootable = (i == 2) ? -1 : 0;
1136 rec->bootpartition = (i == 2) ? -1 : 0;
1137 sprintfW( device_id, fmtW, index );
1138 rec->device_id = heap_strdupW( device_id );
1139 rec->diskindex = index;
1140 rec->index = 0;
1141 rec->pnpdevice_id = heap_strdupW( device_id );
1142 get_freespace( root, &size );
1143 rec->size = size;
1144 rec->startingoffset = 0;
1145 rec->type = get_filesystem( root );
1146 if (!match_row( table, row, cond, &status ))
1148 free_row_values( table, row );
1149 continue;
1151 offset += sizeof(*rec);
1152 row++;
1153 index++;
1156 TRACE("created %u rows\n", row);
1157 table->num_rows = row;
1158 return status;
1161 static enum fill_status fill_logicaldisk( struct table *table, const struct expr *cond )
1163 static const WCHAR fmtW[] = {'%','c',':',0};
1164 WCHAR device_id[3], root[] = {'A',':','\\',0};
1165 struct record_logicaldisk *rec;
1166 UINT i, row = 0, offset = 0, count = 4, type;
1167 UINT64 size = 1024 * 1024 * 1024;
1168 DWORD drives = GetLogicalDrives();
1169 enum fill_status status = FILL_STATUS_UNFILTERED;
1171 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
1173 for (i = 0; i < sizeof(drives); i++)
1175 if (drives & (1 << i))
1177 root[0] = 'A' + i;
1178 type = GetDriveTypeW( root );
1179 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
1180 continue;
1182 if (row > count)
1184 BYTE *data;
1185 count *= 2;
1186 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return FILL_STATUS_FAILED;
1187 table->data = data;
1189 rec = (struct record_logicaldisk *)(table->data + offset);
1190 sprintfW( device_id, fmtW, 'A' + i );
1191 rec->device_id = heap_strdupW( device_id );
1192 rec->drivetype = type;
1193 rec->filesystem = get_filesystem( root );
1194 rec->freespace = get_freespace( root, &size );
1195 rec->name = heap_strdupW( device_id );
1196 rec->size = size;
1197 if (!match_row( table, row, cond, &status ))
1199 free_row_values( table, row );
1200 continue;
1202 offset += sizeof(*rec);
1203 row++;
1206 TRACE("created %u rows\n", row);
1207 table->num_rows = row;
1208 return status;
1211 static UINT16 get_connection_status( IF_OPER_STATUS status )
1213 switch (status)
1215 case IfOperStatusDown:
1216 return 0; /* Disconnected */
1217 case IfOperStatusUp:
1218 return 2; /* Connected */
1219 default:
1220 ERR("unhandled status %u\n", status);
1221 break;
1223 return 0;
1225 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
1227 static const WCHAR fmtW[] =
1228 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
1229 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
1230 WCHAR *ret;
1232 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
1233 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
1234 return ret;
1236 static const WCHAR *get_adaptertype( DWORD type )
1238 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
1239 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
1240 static const WCHAR firewireW[] = {'1','3','9','4',0};
1241 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
1243 switch (type)
1245 case IF_TYPE_ETHERNET_CSMACD: return ethernetW;
1246 case IF_TYPE_IEEE80211: return wirelessW;
1247 case IF_TYPE_IEEE1394: return firewireW;
1248 case IF_TYPE_TUNNEL: return tunnelW;
1249 default: break;
1251 return NULL;
1254 static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
1256 static const WCHAR fmtW[] = {'%','u',0};
1257 WCHAR device_id[11];
1258 struct record_networkadapter *rec;
1259 IP_ADAPTER_ADDRESSES *aa, *buffer;
1260 UINT row = 0, offset = 0, count = 0;
1261 DWORD size = 0, ret;
1262 enum fill_status status = FILL_STATUS_UNFILTERED;
1264 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
1265 if (ret != ERROR_BUFFER_OVERFLOW) return FILL_STATUS_FAILED;
1267 if (!(buffer = heap_alloc( size ))) return FILL_STATUS_FAILED;
1268 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
1270 heap_free( buffer );
1271 return FILL_STATUS_FAILED;
1273 for (aa = buffer; aa; aa = aa->Next) count++;
1274 if (!(table->data = heap_alloc( sizeof(*rec) * count )))
1276 heap_free( buffer );
1277 return FILL_STATUS_FAILED;
1279 for (aa = buffer; aa; aa = aa->Next)
1281 rec = (struct record_networkadapter *)(table->data + offset);
1282 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
1283 rec->adaptertype = get_adaptertype( aa->IfType );
1284 rec->device_id = heap_strdupW( device_id );
1285 rec->interface_index = aa->u.s.IfIndex;
1286 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
1287 rec->manufacturer = compsys_manufacturerW;
1288 rec->netconnection_status = get_connection_status( aa->OperStatus );
1289 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
1290 rec->speed = 1000000;
1291 if (!match_row( table, row, cond, &status ))
1293 free_row_values( table, row );
1294 continue;
1296 offset += sizeof(*rec);
1297 row++;
1299 TRACE("created %u rows\n", row);
1300 table->num_rows = row;
1302 heap_free( buffer );
1303 return status;
1306 static WCHAR *get_cmdline( DWORD process_id )
1308 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
1309 return NULL; /* FIXME handle different process case */
1312 static enum fill_status fill_process( struct table *table, const struct expr *cond )
1314 static const WCHAR fmtW[] = {'%','u',0};
1315 WCHAR handle[11];
1316 struct record_process *rec;
1317 PROCESSENTRY32W entry;
1318 HANDLE snap;
1319 enum fill_status status = FILL_STATUS_FAILED;
1320 UINT row = 0, offset = 0, count = 8;
1322 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
1323 if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED;
1325 entry.dwSize = sizeof(entry);
1326 if (!Process32FirstW( snap, &entry )) goto done;
1327 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) goto done;
1331 if (row > count)
1333 BYTE *data;
1334 count *= 2;
1335 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) goto done;
1336 table->data = data;
1338 rec = (struct record_process *)(table->data + offset);
1339 rec->caption = heap_strdupW( entry.szExeFile );
1340 rec->commandline = get_cmdline( entry.th32ProcessID );
1341 rec->description = heap_strdupW( entry.szExeFile );
1342 sprintfW( handle, fmtW, entry.th32ProcessID );
1343 rec->handle = heap_strdupW( handle );
1344 rec->name = heap_strdupW( entry.szExeFile );
1345 rec->process_id = entry.th32ProcessID;
1346 rec->pprocess_id = entry.th32ParentProcessID;
1347 rec->thread_count = entry.cntThreads;
1348 rec->get_owner = process_get_owner;
1349 if (!match_row( table, row, cond, &status ))
1351 free_row_values( table, row );
1352 continue;
1354 offset += sizeof(*rec);
1355 row++;
1356 } while (Process32NextW( snap, &entry ));
1358 TRACE("created %u rows\n", row);
1359 table->num_rows = row;
1360 status = FILL_STATUS_UNFILTERED;
1362 done:
1363 CloseHandle( snap );
1364 return status;
1367 static inline void do_cpuid( unsigned int ax, unsigned int *p )
1369 #ifdef __i386__
1370 __asm__("pushl %%ebx\n\t"
1371 "cpuid\n\t"
1372 "movl %%ebx, %%esi\n\t"
1373 "popl %%ebx"
1374 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
1375 : "0" (ax));
1376 #endif
1379 static void get_processor_id( WCHAR *processor_id )
1381 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
1382 unsigned int regs[4] = {0, 0, 0, 0};
1384 do_cpuid( 1, regs );
1385 sprintfW( processor_id, fmtW, regs[3], regs[0] );
1387 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
1389 unsigned int i;
1390 unsigned char *p = (unsigned char *)regs;
1392 for (i = 0; i < len; i++) { buffer[i] = *p++; }
1393 buffer[i] = 0;
1395 static void get_processor_manufacturer( WCHAR *manufacturer )
1397 unsigned int tmp, regs[4] = {0, 0, 0, 0};
1399 do_cpuid( 0, regs );
1400 tmp = regs[2]; /* swap edx and ecx */
1401 regs[2] = regs[3];
1402 regs[3] = tmp;
1404 regs_to_str( regs + 1, 12, manufacturer );
1406 static void get_processor_name( WCHAR *name )
1408 unsigned int regs[4] = {0, 0, 0, 0};
1410 do_cpuid( 0x80000000, regs );
1411 if (regs[0] >= 0x80000004)
1413 do_cpuid( 0x80000002, regs );
1414 regs_to_str( regs, 16, name );
1415 do_cpuid( 0x80000003, regs );
1416 regs_to_str( regs, 16, name + 16 );
1417 do_cpuid( 0x80000004, regs );
1418 regs_to_str( regs, 16, name + 32 );
1421 static UINT get_processor_maxclockspeed( void )
1423 PROCESSOR_POWER_INFORMATION *info;
1424 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
1425 NTSTATUS status;
1427 if ((info = heap_alloc( size )))
1429 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
1430 if (!status) ret = info[0].MaxMhz;
1431 heap_free( info );
1433 return ret;
1436 static enum fill_status fill_processor( struct table *table, const struct expr *cond )
1438 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
1439 WCHAR device_id[14], processor_id[17], manufacturer[13], name[49] = {0};
1440 struct record_processor *rec;
1441 UINT i, offset = 0, maxclockspeed, num_logical_processors, count = get_processor_count();
1442 enum fill_status status = FILL_STATUS_UNFILTERED;
1444 if (!(table->data = heap_alloc( sizeof(*rec) * count ))) return FILL_STATUS_FAILED;
1446 get_processor_id( processor_id );
1447 get_processor_manufacturer( manufacturer );
1448 get_processor_name( name );
1450 maxclockspeed = get_processor_maxclockspeed();
1451 num_logical_processors = get_logical_processor_count() / count;
1453 for (i = 0; i < count; i++)
1455 rec = (struct record_processor *)(table->data + offset);
1456 rec->cpu_status = 1; /* CPU Enabled */
1457 sprintfW( device_id, fmtW, i );
1458 rec->device_id = heap_strdupW( device_id );
1459 rec->family = 2; /* Unknown */
1460 rec->manufacturer = heap_strdupW( manufacturer );
1461 rec->maxclockspeed = maxclockspeed;
1462 rec->name = heap_strdupW( name );
1463 rec->num_logical_processors = num_logical_processors;
1464 rec->processor_id = heap_strdupW( processor_id );
1465 rec->unique_id = NULL;
1466 if (!match_row( table, i, cond, &status ))
1468 free_row_values( table, i );
1469 continue;
1471 offset += sizeof(*rec);
1474 TRACE("created %u rows\n", count);
1475 table->num_rows = count;
1476 return status;
1479 static WCHAR *get_lastbootuptime(void)
1481 static const WCHAR fmtW[] =
1482 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1483 '.','%','0','6','u','+','0','0','0',0};
1484 SYSTEM_TIMEOFDAY_INFORMATION ti;
1485 TIME_FIELDS tf;
1486 WCHAR *ret;
1488 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
1490 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
1491 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
1492 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
1493 return ret;
1495 static const WCHAR *get_osarchitecture(void)
1497 SYSTEM_INFO info;
1498 GetNativeSystemInfo( &info );
1499 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
1500 return os_32bitW;
1502 static WCHAR *get_systemdirectory(void)
1504 void *redir;
1505 WCHAR *ret;
1507 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
1508 Wow64DisableWow64FsRedirection( &redir );
1509 GetSystemDirectoryW( ret, MAX_PATH );
1510 Wow64RevertWow64FsRedirection( redir );
1511 return ret;
1514 static enum fill_status fill_os( struct table *table, const struct expr *cond )
1516 struct record_operatingsystem *rec;
1517 enum fill_status status = FILL_STATUS_UNFILTERED;
1518 UINT row = 0;
1520 if (!(table->data = heap_alloc( sizeof(*rec) ))) return FILL_STATUS_FAILED;
1522 rec = (struct record_operatingsystem *)table->data;
1523 rec->caption = os_captionW;
1524 rec->csdversion = os_csdversionW;
1525 rec->lastbootuptime = get_lastbootuptime();
1526 rec->osarchitecture = get_osarchitecture();
1527 rec->oslanguage = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
1528 rec->osproductsuite = 2461140; /* Windows XP Professional */
1529 rec->ostype = 18; /* WINNT */
1530 rec->servicepackmajor = 3;
1531 rec->suitemask = 272; /* Single User + Terminal */
1532 rec->systemdirectory = get_systemdirectory();
1533 rec->version = os_versionW;
1534 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1535 else row++;
1537 TRACE("created %u rows\n", row);
1538 table->num_rows = row;
1539 return status;
1542 static const WCHAR *get_service_type( DWORD type )
1544 static const WCHAR filesystem_driverW[] =
1545 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
1546 static const WCHAR kernel_driverW[] =
1547 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
1548 static const WCHAR own_processW[] =
1549 {'O','w','n',' ','P','r','o','c','e','s','s',0};
1550 static const WCHAR share_processW[] =
1551 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
1553 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
1554 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
1555 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
1556 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
1557 else ERR("unhandled type 0x%08x\n", type);
1558 return NULL;
1560 static const WCHAR *get_service_state( DWORD state )
1562 static const WCHAR runningW[] =
1563 {'R','u','n','n','i','n','g',0};
1564 static const WCHAR start_pendingW[] =
1565 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
1566 static const WCHAR stop_pendingW[] =
1567 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
1568 static const WCHAR stoppedW[] =
1569 {'S','t','o','p','p','e','d',0};
1570 static const WCHAR unknownW[] =
1571 {'U','n','k','n','o','w','n',0};
1573 switch (state)
1575 case SERVICE_STOPPED: return stoppedW;
1576 case SERVICE_START_PENDING: return start_pendingW;
1577 case SERVICE_STOP_PENDING: return stop_pendingW;
1578 case SERVICE_RUNNING: return runningW;
1579 default:
1580 ERR("unknown state %u\n", state);
1581 return unknownW;
1584 static const WCHAR *get_service_startmode( DWORD mode )
1586 static const WCHAR bootW[] = {'B','o','o','t',0};
1587 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
1588 static const WCHAR autoW[] = {'A','u','t','o',0};
1589 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
1590 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
1591 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
1593 switch (mode)
1595 case SERVICE_BOOT_START: return bootW;
1596 case SERVICE_SYSTEM_START: return systemW;
1597 case SERVICE_AUTO_START: return autoW;
1598 case SERVICE_DEMAND_START: return manualW;
1599 case SERVICE_DISABLED: return disabledW;
1600 default:
1601 ERR("unknown mode 0x%x\n", mode);
1602 return unknownW;
1605 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
1607 QUERY_SERVICE_CONFIGW *config = NULL;
1608 SC_HANDLE service;
1609 DWORD size;
1611 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
1612 QueryServiceConfigW( service, NULL, 0, &size );
1613 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
1614 if (!(config = heap_alloc( size ))) goto done;
1615 if (QueryServiceConfigW( service, config, size, &size )) goto done;
1616 heap_free( config );
1617 config = NULL;
1619 done:
1620 CloseServiceHandle( service );
1621 return config;
1624 static enum fill_status fill_service( struct table *table, const struct expr *cond )
1626 struct record_service *rec;
1627 SC_HANDLE manager;
1628 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
1629 SERVICE_STATUS_PROCESS *status;
1630 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
1631 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
1632 UINT i, row = 0, offset = 0, size = 256, needed, count;
1633 enum fill_status fill_status = FILL_STATUS_FAILED;
1634 BOOL ret;
1636 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return FILL_STATUS_FAILED;
1637 if (!(services = heap_alloc( size ))) goto done;
1639 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
1640 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
1641 &count, NULL, NULL );
1642 if (!ret)
1644 if (GetLastError() != ERROR_MORE_DATA) goto done;
1645 size = needed;
1646 if (!(tmp = heap_realloc( services, size ))) goto done;
1647 services = tmp;
1648 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
1649 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
1650 &count, NULL, NULL );
1651 if (!ret) goto done;
1653 if (!(table->data = heap_alloc( sizeof(*rec) * count ))) goto done;
1655 GetComputerNameW( sysnameW, &len );
1656 fill_status = FILL_STATUS_UNFILTERED;
1658 for (i = 0; i < count; i++)
1660 QUERY_SERVICE_CONFIGW *config;
1662 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
1664 status = &services[i].ServiceStatusProcess;
1665 rec = (struct record_service *)(table->data + offset);
1666 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
1667 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
1668 rec->displayname = heap_strdupW( services[i].lpDisplayName );
1669 rec->name = heap_strdupW( services[i].lpServiceName );
1670 rec->process_id = status->dwProcessId;
1671 rec->servicetype = get_service_type( status->dwServiceType );
1672 rec->startmode = get_service_startmode( config->dwStartType );
1673 rec->state = get_service_state( status->dwCurrentState );
1674 rec->systemname = heap_strdupW( sysnameW );
1675 rec->pause_service = service_pause_service;
1676 rec->resume_service = service_resume_service;
1677 rec->start_service = service_start_service;
1678 rec->stop_service = service_stop_service;
1679 heap_free( config );
1680 if (!match_row( table, row, cond, &fill_status ))
1682 free_row_values( table, row );
1683 continue;
1685 offset += sizeof(*rec);
1686 row++;
1689 TRACE("created %u rows\n", row);
1690 table->num_rows = row;
1692 done:
1693 CloseServiceHandle( manager );
1694 heap_free( services );
1695 return fill_status;
1698 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
1700 HDC hdc = GetDC( NULL );
1701 UINT32 ret;
1703 if (!hdc) return 32;
1704 ret = GetDeviceCaps( hdc, BITSPIXEL );
1705 *hres = GetDeviceCaps( hdc, HORZRES );
1706 *vres = GetDeviceCaps( hdc, VERTRES );
1707 ReleaseDC( NULL, hdc );
1708 return ret;
1710 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
1712 static const WCHAR fmtW[] =
1713 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
1714 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
1715 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
1716 WCHAR *ret;
1718 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
1719 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
1720 return ret;
1723 static enum fill_status fill_videocontroller( struct table *table, const struct expr *cond )
1726 struct record_videocontroller *rec;
1727 HRESULT hr;
1728 IDXGIFactory *factory = NULL;
1729 IDXGIAdapter *adapter = NULL;
1730 DXGI_ADAPTER_DESC desc;
1731 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
1732 const WCHAR *name = videocontroller_deviceidW;
1733 enum fill_status status = FILL_STATUS_UNFILTERED;
1734 UINT row = 0;
1736 if (!(table->data = heap_alloc( sizeof(*rec) ))) return FILL_STATUS_FAILED;
1737 memset (&desc, 0, sizeof(desc));
1738 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
1739 if (FAILED(hr)) goto done;
1741 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
1742 if (FAILED(hr)) goto done;
1744 hr = IDXGIAdapter_GetDesc( adapter, &desc );
1745 if (SUCCEEDED(hr))
1747 vidmem = desc.DedicatedVideoMemory;
1748 name = desc.Description;
1751 done:
1752 rec = (struct record_videocontroller *)table->data;
1753 rec->adapter_ram = vidmem;
1754 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
1755 rec->current_horizontalres = hres;
1756 rec->current_verticalres = vres;
1757 rec->description = heap_strdupW( name );
1758 rec->device_id = videocontroller_deviceidW;
1759 rec->name = heap_strdupW( name );
1760 rec->pnpdevice_id = get_pnpdeviceid( &desc );
1761 if (!match_row( table, row, cond, &status )) free_row_values( table, row );
1762 else row++;
1764 TRACE("created %u rows\n", row);
1765 table->num_rows = row;
1767 if (adapter) IDXGIAdapter_Release( adapter );
1768 if (factory) IDXGIFactory_Release( factory );
1769 return status;
1772 static struct table builtin_classes[] =
1774 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), (BYTE *)data_baseboard },
1775 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), (BYTE *)data_bios },
1776 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, NULL, fill_cdromdrive },
1777 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, NULL, fill_compsys },
1778 { class_directoryW, SIZEOF(col_directory), col_directory, 0, NULL, fill_directory },
1779 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, SIZEOF(data_diskdrive), (BYTE *)data_diskdrive },
1780 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, NULL, fill_diskpartition },
1781 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, NULL, fill_logicaldisk },
1782 { class_logicaldisk2W, SIZEOF(col_logicaldisk), col_logicaldisk, 0, NULL, fill_logicaldisk },
1783 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, NULL, fill_networkadapter },
1784 { class_osW, SIZEOF(col_os), col_os, 0, NULL, fill_os },
1785 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), (BYTE *)data_param },
1786 { class_processW, SIZEOF(col_process), col_process, 0, NULL, fill_process },
1787 { class_processorW, SIZEOF(col_processor), col_processor, 0, NULL, fill_processor },
1788 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), (BYTE *)data_qualifier },
1789 { class_serviceW, SIZEOF(col_service), col_service, 0, NULL, fill_service },
1790 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), (BYTE *)data_sounddevice },
1791 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), (BYTE *)data_stdregprov },
1792 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, NULL, fill_videocontroller }
1795 void init_table_list( void )
1797 static struct list tables = LIST_INIT( tables );
1798 UINT i;
1800 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
1801 table_list = &tables;