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
20 #define NONAMELESSUNION
21 #define NONAMELESSSTRUCT
27 #define WIN32_NO_STATUS
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_diskdriveW[] =
55 {'W','i','n','3','2','_','D','i','s','k','D','r','i','v','e',0};
56 static const WCHAR class_diskpartitionW[] =
57 {'W','i','n','3','2','_','D','i','s','k','P','a','r','t','i','t','i','o','n',0};
58 static const WCHAR class_logicaldiskW[] =
59 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
60 static const WCHAR class_networkadapterW[] =
61 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
62 static const WCHAR class_osW[] =
63 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
64 static const WCHAR class_paramsW[] =
65 {'_','_','P','A','R','A','M','E','T','E','R','S',0};
66 static const WCHAR class_qualifiersW[] =
67 {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
68 static const WCHAR class_process_getowner_outW[] =
69 {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
70 'N','E','R','_','O','U','T',0};
71 static const WCHAR class_processorW[] =
72 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
73 static const WCHAR class_sounddeviceW[] =
74 {'W','i','n','3','2','_','S','o','u','n','d','D','e','v','i','c','e',0};
75 static const WCHAR class_videocontrollerW[] =
76 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
78 static const WCHAR prop_adaptertypeW[] =
79 {'A','d','a','p','t','e','r','T','y','p','e',0};
80 static const WCHAR prop_acceptpauseW[] =
81 {'A','c','c','e','p','t','P','a','u','s','e',0};
82 static const WCHAR prop_acceptstopW[] =
83 {'A','c','c','e','p','t','S','t','o','p',0};
84 static const WCHAR prop_adapterramW[] =
85 {'A','d','a','p','t','e','r','R','A','M',0};
86 static const WCHAR prop_bootableW[] =
87 {'B','o','o','t','a','b','l','e',0};
88 static const WCHAR prop_bootpartitionW[] =
89 {'B','o','o','t','P','a','r','t','i','t','i','o','n',0};
90 static const WCHAR prop_captionW[] =
91 {'C','a','p','t','i','o','n',0};
92 static const WCHAR prop_classW[] =
93 {'C','l','a','s','s',0};
94 static const WCHAR prop_commandlineW[] =
95 {'C','o','m','m','a','n','d','L','i','n','e',0};
96 static const WCHAR prop_cpustatusW[] =
97 {'C','p','u','S','t','a','t','u','s',0};
98 static const WCHAR prop_csdversionW[] =
99 {'C','S','D','V','e','r','s','i','o','n',0};
100 static const WCHAR prop_currentbitsperpixelW[] =
101 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
102 static const WCHAR prop_currenthorizontalresW[] =
103 {'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};
104 static const WCHAR prop_currentverticalresW[] =
105 {'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};
106 static const WCHAR prop_defaultvalueW[] =
107 {'D','e','f','a','u','l','t','V','a','l','u','e',0};
108 static const WCHAR prop_descriptionW[] =
109 {'D','e','s','c','r','i','p','t','i','o','n',0};
110 static const WCHAR prop_deviceidW[] =
111 {'D','e','v','i','c','e','I','d',0};
112 static const WCHAR prop_directionW[] =
113 {'D','i','r','e','c','t','i','o','n',0};
114 static const WCHAR prop_displaynameW[] =
115 {'D','i','s','p','l','a','y','N','a','m','e',0};
116 static const WCHAR prop_diskindexW[] =
117 {'D','i','s','k','I','n','d','e','x',0};
118 static const WCHAR prop_domainW[] =
119 {'D','o','m','a','i','n',0};
120 static const WCHAR prop_domainroleW[] =
121 {'D','o','m','a','i','n','R','o','l','e',0};
122 static const WCHAR prop_driveW[] =
123 {'D','r','i','v','e',0};
124 static const WCHAR prop_drivetypeW[] =
125 {'D','r','i','v','e','T','y','p','e',0};
126 static const WCHAR prop_filesystemW[] =
127 {'F','i','l','e','S','y','s','t','e','m',0};
128 static const WCHAR prop_flavorW[] =
129 {'F','l','a','v','o','r',0};
130 static const WCHAR prop_freespaceW[] =
131 {'F','r','e','e','S','p','a','c','e',0};
132 static const WCHAR prop_handleW[] =
133 {'H','a','n','d','l','e',0};
134 static const WCHAR prop_idW[] =
136 static const WCHAR prop_indexW[] =
137 {'I','n','d','e','x',0};
138 static const WCHAR prop_interfaceindexW[] =
139 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
140 static const WCHAR prop_intvalueW[] =
141 {'I','n','t','e','g','e','r','V','a','l','u','e',0};
142 static const WCHAR prop_lastbootuptimeW[] =
143 {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
144 static const WCHAR prop_macaddressW[] =
145 {'M','A','C','A','d','d','r','e','s','s',0};
146 static const WCHAR prop_manufacturerW[] =
147 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
148 static const WCHAR prop_maxclockspeedW[] =
149 {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
150 static const WCHAR prop_memberW[] =
151 {'M','e','m','b','e','r',0};
152 static const WCHAR prop_methodW[] =
153 {'M','e','t','h','o','d',0};
154 static const WCHAR prop_modelW[] =
155 {'M','o','d','e','l',0};
156 static const WCHAR prop_netconnectionstatusW[] =
157 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
158 static const WCHAR prop_numlogicalprocessorsW[] =
159 {'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};
160 static const WCHAR prop_numprocessorsW[] =
161 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
162 static const WCHAR prop_osarchitectureW[] =
163 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
164 static const WCHAR prop_oslanguageW[] =
165 {'O','S','L','a','n','g','u','a','g','e',0};
166 static const WCHAR prop_parameterW[] =
167 {'P','a','r','a','m','e','t','e','r',0};
168 static const WCHAR prop_pnpdeviceidW[] =
169 {'P','N','P','D','e','v','i','c','e','I','D',0};
170 static const WCHAR prop_pprocessidW[] =
171 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
172 static const WCHAR prop_processidW[] =
173 {'P','r','o','c','e','s','s','I','D',0};
174 static const WCHAR prop_processoridW[] =
175 {'P','r','o','c','e','s','s','o','r','I','d',0};
176 static const WCHAR prop_productnameW[] =
177 {'P','r','o','d','u','c','t','N','a','m','e',0};
178 static const WCHAR prop_releasedateW[] =
179 {'R','e','l','e','a','s','e','D','a','t','e',0};
180 static const WCHAR prop_serialnumberW[] =
181 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
182 static const WCHAR prop_servicetypeW[] =
183 {'S','e','r','v','i','c','e','T','y','p','e',0};
184 static const WCHAR prop_startmodeW[] =
185 {'S','t','a','r','t','M','o','d','e',0};
186 static const WCHAR prop_sizeW[] =
188 static const WCHAR prop_speedW[] =
189 {'S','p','e','e','d',0};
190 static const WCHAR prop_startingoffsetW[] =
191 {'S','t','a','r','t','i','n','g','O','f','f','s','e','t',0};
192 static const WCHAR prop_stateW[] =
193 {'S','t','a','t','e',0};
194 static const WCHAR prop_strvalueW[] =
195 {'S','t','r','i','n','g','V','a','l','u','e',0};
196 static const WCHAR prop_systemdirectoryW[] =
197 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
198 static const WCHAR prop_systemnameW[] =
199 {'S','y','s','t','e','m','N','a','m','e',0};
200 static const WCHAR prop_tagW[] =
202 static const WCHAR prop_threadcountW[] =
203 {'T','h','r','e','a','d','C','o','u','n','t',0};
204 static const WCHAR prop_totalphysicalmemoryW[] =
205 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
206 static const WCHAR prop_typeW[] =
208 static const WCHAR prop_uniqueidW[] =
209 {'U','n','i','q','u','e','I','d',0};
210 static const WCHAR prop_varianttypeW[] =
211 {'V','a','r','i','a','n','t','T','y','p','e',0};
212 static const WCHAR prop_versionW[] =
213 {'V','e','r','s','i','o','n',0};
215 /* column definitions must be kept in sync with record structures below */
216 static const struct column col_baseboard[] =
218 { prop_manufacturerW, CIM_STRING },
219 { prop_serialnumberW, CIM_STRING },
220 { prop_tagW, CIM_STRING|COL_FLAG_KEY }
222 static const struct column col_bios[] =
224 { prop_descriptionW, CIM_STRING },
225 { prop_manufacturerW, CIM_STRING },
226 { prop_releasedateW, CIM_DATETIME },
227 { prop_serialnumberW, CIM_STRING },
228 { prop_versionW, CIM_STRING|COL_FLAG_KEY }
230 static const struct column col_cdromdrive[] =
232 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
233 { prop_driveW, CIM_STRING|COL_FLAG_DYNAMIC },
234 { prop_nameW, CIM_STRING },
235 { prop_pnpdeviceidW, CIM_STRING }
237 static const struct column col_compsys[] =
239 { prop_descriptionW, CIM_STRING },
240 { prop_domainW, CIM_STRING },
241 { prop_domainroleW, CIM_UINT16 },
242 { prop_manufacturerW, CIM_STRING },
243 { prop_modelW, CIM_STRING },
244 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
245 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
246 { prop_numprocessorsW, CIM_UINT32, VT_I4 },
247 { prop_totalphysicalmemoryW, CIM_UINT64 }
249 static const struct column col_diskdrive[] =
251 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
252 { prop_indexW, CIM_UINT32, VT_I4 },
253 { prop_manufacturerW, CIM_STRING },
254 { prop_modelW, CIM_STRING },
255 { prop_serialnumberW, CIM_STRING }
257 static const struct column col_diskpartition[] =
259 { prop_bootableW, CIM_BOOLEAN },
260 { prop_bootpartitionW, CIM_BOOLEAN },
261 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
262 { prop_diskindexW, CIM_UINT32, VT_I4 },
263 { prop_indexW, CIM_UINT32, VT_I4 },
264 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC },
265 { prop_sizeW, CIM_UINT64 },
266 { prop_startingoffsetW, CIM_UINT64 },
267 { prop_typeW, CIM_STRING|COL_FLAG_DYNAMIC }
269 static const struct column col_logicaldisk[] =
271 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
272 { prop_drivetypeW, CIM_UINT32, VT_I4 },
273 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
274 { prop_freespaceW, CIM_UINT64 },
275 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
276 { prop_sizeW, CIM_UINT64 }
278 static const struct column col_networkadapter[] =
280 { prop_adaptertypeW, CIM_STRING },
281 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
282 { prop_interfaceindexW, CIM_UINT32, VT_I4 },
283 { prop_macaddressW, CIM_STRING|COL_FLAG_DYNAMIC },
284 { prop_manufacturerW, CIM_STRING },
285 { prop_netconnectionstatusW, CIM_UINT16, VT_I4 },
286 { prop_pnpdeviceidW, CIM_STRING },
287 { prop_speedW, CIM_UINT64 }
289 static const struct column col_os[] =
291 { prop_captionW, CIM_STRING },
292 { prop_csdversionW, CIM_STRING },
293 { prop_lastbootuptimeW, CIM_DATETIME|COL_FLAG_DYNAMIC },
294 { prop_osarchitectureW, CIM_STRING },
295 { prop_oslanguageW, CIM_UINT32, VT_I4 },
296 { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC }
298 static const struct column col_param[] =
300 { prop_classW, CIM_STRING },
301 { prop_methodW, CIM_STRING },
302 { prop_directionW, CIM_SINT32 },
303 { prop_parameterW, CIM_STRING },
304 { prop_typeW, CIM_UINT32 },
305 { prop_varianttypeW, CIM_UINT32 },
306 { prop_defaultvalueW, CIM_UINT32 }
308 static const struct column col_process[] =
310 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
311 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
312 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
313 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
314 { prop_pprocessidW, CIM_UINT32, VT_I4 },
315 { prop_processidW, CIM_UINT32, VT_I4 },
316 { prop_threadcountW, CIM_UINT32, VT_I4 },
318 { method_getownerW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
320 static const struct column col_processor[] =
322 { prop_cpustatusW, CIM_UINT16 },
323 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
324 { prop_manufacturerW, CIM_STRING|COL_FLAG_DYNAMIC },
325 { prop_maxclockspeedW, CIM_UINT32, VT_I4 },
326 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
327 { prop_numlogicalprocessorsW, CIM_UINT32, VT_I4 },
328 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC },
329 { prop_uniqueidW, CIM_STRING }
331 static const struct column col_qualifier[] =
333 { prop_classW, CIM_STRING },
334 { prop_memberW, CIM_STRING },
335 { prop_typeW, CIM_UINT32 },
336 { prop_flavorW, CIM_SINT32 },
337 { prop_nameW, CIM_STRING },
338 { prop_intvalueW, CIM_SINT32 },
339 { prop_strvalueW, CIM_STRING }
341 static const struct column col_service[] =
343 { prop_acceptpauseW, CIM_BOOLEAN },
344 { prop_acceptstopW, CIM_BOOLEAN },
345 { prop_displaynameW, CIM_STRING|COL_FLAG_DYNAMIC },
346 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
347 { prop_processidW, CIM_UINT32 },
348 { prop_servicetypeW, CIM_STRING },
349 { prop_startmodeW, CIM_STRING },
350 { prop_stateW, CIM_STRING },
351 { prop_systemnameW, CIM_STRING|COL_FLAG_DYNAMIC },
353 { method_pauseserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
354 { method_resumeserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
355 { method_startserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
356 { method_stopserviceW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
358 static const struct column col_sounddevice[] =
360 { prop_productnameW, CIM_STRING }
362 static const struct column col_stdregprov[] =
364 { method_enumkeyW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
365 { method_enumvaluesW, CIM_FLAG_ARRAY|COL_FLAG_METHOD },
366 { method_getstringvalueW, CIM_FLAG_ARRAY|COL_FLAG_METHOD }
368 static const struct column col_videocontroller[] =
370 { prop_adapterramW, CIM_UINT32 },
371 { prop_currentbitsperpixelW, CIM_UINT32 },
372 { prop_currenthorizontalresW, CIM_UINT32 },
373 { prop_currentverticalresW, CIM_UINT32 },
374 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
375 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
376 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
377 { prop_pnpdeviceidW, CIM_STRING|COL_FLAG_DYNAMIC }
380 static const WCHAR baseboard_manufacturerW[] =
381 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
382 static const WCHAR baseboard_serialnumberW[] =
384 static const WCHAR baseboard_tagW[] =
385 {'B','a','s','e',' ','B','o','a','r','d',0};
386 static const WCHAR bios_descriptionW[] =
387 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
388 static const WCHAR bios_manufacturerW[] =
389 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
390 static const WCHAR bios_releasedateW[] =
391 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
392 static const WCHAR bios_serialnumberW[] =
394 static const WCHAR bios_versionW[] =
395 {'W','I','N','E',' ',' ',' ','-',' ','1',0};
396 static const WCHAR cdromdrive_nameW[] =
397 {'W','i','n','e',' ','C','D','-','R','O','M',' ','A','T','A',' ','D','e','v','i','c','e',0};
398 static const WCHAR cdromdrive_pnpdeviceidW[]=
399 {'I','D','E','\\','C','D','R','O','M','W','I','N','E','_','C','D','-','R','O','M',
400 '_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_','_',
401 '_','_','_','_','_','_','_','1','.','0','_','_','_','_','_','\\','5','&','3','A','2',
402 'A','5','8','5','4','&','0','&','1','.','0','.','0',0};
403 static const WCHAR compsys_descriptionW[] =
404 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
405 static const WCHAR compsys_domainW[] =
406 {'W','O','R','K','G','R','O','U','P',0};
407 static const WCHAR compsys_manufacturerW[] =
408 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
409 static const WCHAR compsys_modelW[] =
411 static const WCHAR diskdrive_deviceidW[] =
412 {'\\','\\','\\','\\','.','\\','\\','P','H','Y','S','I','C','A','L','D','R','I','V','E','0',0};
413 static const WCHAR diskdrive_modelW[] =
414 {'W','i','n','e',' ','D','i','s','k',' ','D','r','i','v','e',0};
415 static const WCHAR diskdrive_manufacturerW[] =
416 {'(','S','t','a','n','d','a','r','d',' ','d','i','s','k',' ','d','r','i','v','e','s',')',0};
417 static const WCHAR diskdrive_serialW[] =
418 {'W','I','N','E','H','D','I','S','K',0};
419 static const WCHAR networkadapter_pnpdeviceidW[]=
420 {'P','C','I','\\','V','E','N','_','8','0','8','6','&','D','E','V','_','1','0','0','E','&',
421 'S','U','B','S','Y','S','_','0','0','1','E','8','0','8','6','&','R','E','V','_','0','2','\\',
422 '3','&','2','6','7','A','6','1','6','A','&','1','&','1','8',0};
423 static const WCHAR os_captionW[] =
424 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
425 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
426 static const WCHAR os_csdversionW[] =
427 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
428 static const WCHAR os_32bitW[] =
429 {'3','2','-','b','i','t',0};
430 static const WCHAR os_64bitW[] =
431 {'6','4','-','b','i','t',0};
432 static const WCHAR sounddevice_productnameW[] =
433 {'W','i','n','e',' ','A','u','d','i','o',' ','D','e','v','i','c','e',0};
434 static const WCHAR videocontroller_deviceidW[] =
435 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
437 #include "pshpack1.h"
438 struct record_baseboard
440 const WCHAR *manufacturer;
441 const WCHAR *serialnumber;
446 const WCHAR *description;
447 const WCHAR *manufacturer;
448 const WCHAR *releasedate;
449 const WCHAR *serialnumber;
450 const WCHAR *version;
452 struct record_cdromdrive
454 const WCHAR *device_id;
457 const WCHAR *pnpdevice_id;
459 struct record_computersystem
461 const WCHAR *description;
464 const WCHAR *manufacturer;
467 UINT32 num_logical_processors;
468 UINT32 num_processors;
469 UINT64 total_physical_memory;
471 struct record_diskdrive
473 const WCHAR *device_id;
475 const WCHAR *manufacturer;
477 const WCHAR *serialnumber;
479 struct record_diskpartition
483 const WCHAR *device_id;
486 const WCHAR *pnpdevice_id;
488 UINT64 startingoffset;
491 struct record_logicaldisk
493 const WCHAR *device_id;
495 const WCHAR *filesystem;
500 struct record_networkadapter
502 const WCHAR *adaptertype;
503 const WCHAR *device_id;
504 INT32 interface_index;
505 const WCHAR *mac_address;
506 const WCHAR *manufacturer;
507 UINT16 netconnection_status;
508 const WCHAR *pnpdevice_id;
511 struct record_operatingsystem
513 const WCHAR *caption;
514 const WCHAR *csdversion;
515 const WCHAR *lastbootuptime;
516 const WCHAR *osarchitecture;
518 const WCHAR *systemdirectory;
525 const WCHAR *parameter;
530 struct record_process
532 const WCHAR *caption;
533 const WCHAR *commandline;
534 const WCHAR *description;
540 class_method *get_owner;
542 struct record_processor
545 const WCHAR *device_id;
546 const WCHAR *manufacturer;
547 UINT32 maxclockspeed;
549 UINT32 num_logical_processors;
550 const WCHAR *processor_id;
551 const WCHAR *unique_id;
553 struct record_qualifier
561 const WCHAR *strvalue;
563 struct record_service
567 const WCHAR *displayname;
570 const WCHAR *servicetype;
571 const WCHAR *startmode;
573 const WCHAR *systemname;
575 class_method *pause_service;
576 class_method *resume_service;
577 class_method *start_service;
578 class_method *stop_service;
580 struct record_sounddevice
582 const WCHAR *productname;
584 struct record_stdregprov
586 class_method *enumkey;
587 class_method *enumvalues;
588 class_method *getstringvalue;
590 struct record_videocontroller
593 UINT32 current_bitsperpixel;
594 UINT32 current_horizontalres;
595 UINT32 current_verticalres;
596 const WCHAR *description;
597 const WCHAR *device_id;
599 const WCHAR *pnpdevice_id;
603 static const struct record_baseboard data_baseboard[] =
605 { baseboard_manufacturerW, baseboard_serialnumberW, baseboard_tagW }
607 static const struct record_bios data_bios[] =
609 { bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW, bios_versionW }
611 static const struct record_diskdrive data_diskdrive[] =
613 { diskdrive_deviceidW, 0, diskdrive_manufacturerW, diskdrive_modelW, diskdrive_serialW }
615 static const struct record_param data_param[] =
617 { class_processW, method_getownerW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
618 { class_processW, method_getownerW, -1, param_userW, CIM_STRING },
619 { class_processW, method_getownerW, -1, param_domainW, CIM_STRING },
620 { class_serviceW, method_pauseserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
621 { class_serviceW, method_resumeserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
622 { class_serviceW, method_startserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
623 { class_serviceW, method_stopserviceW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
624 { class_stdregprovW, method_enumkeyW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
625 { class_stdregprovW, method_enumkeyW, 1, param_subkeynameW, CIM_STRING },
626 { class_stdregprovW, method_enumkeyW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
627 { class_stdregprovW, method_enumkeyW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
628 { class_stdregprovW, method_enumvaluesW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
629 { class_stdregprovW, method_enumvaluesW, 1, param_subkeynameW, CIM_STRING },
630 { class_stdregprovW, method_enumvaluesW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
631 { class_stdregprovW, method_enumvaluesW, -1, param_namesW, CIM_STRING|CIM_FLAG_ARRAY },
632 { class_stdregprovW, method_enumvaluesW, -1, param_typesW, CIM_SINT32|CIM_FLAG_ARRAY },
633 { class_stdregprovW, method_getstringvalueW, 1, param_defkeyW, CIM_SINT32, 0, 0x80000002 },
634 { class_stdregprovW, method_getstringvalueW, 1, param_subkeynameW, CIM_STRING },
635 { class_stdregprovW, method_getstringvalueW, 1, param_valuenameW, CIM_STRING },
636 { class_stdregprovW, method_getstringvalueW, -1, param_returnvalueW, CIM_UINT32, VT_I4 },
637 { class_stdregprovW, method_getstringvalueW, -1, param_valueW, CIM_STRING }
640 #define FLAVOR_ID (WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE | WBEM_FLAVOR_NOT_OVERRIDABLE |\
641 WBEM_FLAVOR_ORIGIN_PROPAGATED)
643 static const struct record_qualifier data_qualifier[] =
645 { class_process_getowner_outW, param_userW, CIM_SINT32, FLAVOR_ID, prop_idW, 0 },
646 { class_process_getowner_outW, param_domainW, CIM_SINT32, FLAVOR_ID, prop_idW, 1 }
648 static const struct record_sounddevice data_sounddevice[] =
650 { sounddevice_productnameW }
652 static const struct record_stdregprov data_stdregprov[] =
654 { reg_enum_key, reg_enum_values, reg_get_stringvalue }
657 static void fill_cdromdrive( struct table *table )
659 static const WCHAR fmtW[] = {'%','c',':',0};
660 WCHAR drive[3], root[] = {'A',':','\\',0};
661 struct record_cdromdrive *rec;
662 UINT i, num_rows = 0, offset = 0, count = 1;
663 DWORD drives = GetLogicalDrives();
665 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return;
667 for (i = 0; i < sizeof(drives); i++)
669 if (drives & (1 << i))
672 if (GetDriveTypeW( root ) != DRIVE_CDROM)
675 if (num_rows > count)
679 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return;
682 rec = (struct record_cdromdrive *)(table->data + offset);
683 rec->device_id = cdromdrive_pnpdeviceidW;
684 sprintfW( drive, fmtW, 'A' + i );
685 rec->drive = heap_strdupW( drive );
686 rec->name = cdromdrive_nameW;
687 rec->pnpdevice_id = cdromdrive_pnpdeviceidW;
688 offset += sizeof(*rec);
692 TRACE("created %u rows\n", num_rows);
693 table->num_rows = num_rows;
696 static UINT get_processor_count(void)
698 SYSTEM_BASIC_INFORMATION info;
700 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
701 return info.NumberOfProcessors;
704 static UINT get_logical_processor_count(void)
706 SYSTEM_LOGICAL_PROCESSOR_INFORMATION *info;
707 UINT i, j, count = 0;
711 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, NULL, 0, &len );
712 if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count();
714 if (!(info = heap_alloc( len ))) return get_processor_count();
715 status = NtQuerySystemInformation( SystemLogicalProcessorInformation, info, len, &len );
716 if (status != STATUS_SUCCESS)
719 return get_processor_count();
721 for (i = 0; i < len / sizeof(*info); i++)
723 if (info[i].Relationship != RelationProcessorCore) continue;
724 for (j = 0; j < sizeof(ULONG_PTR); j++) if (info[i].ProcessorMask & (1 << j)) count++;
730 static UINT64 get_total_physical_memory(void)
732 MEMORYSTATUSEX status;
734 status.dwLength = sizeof(status);
735 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
736 return status.ullTotalPhys;
739 static WCHAR *get_computername(void)
742 DWORD size=MAX_COMPUTERNAME_LENGTH;
744 if (!(ret = heap_alloc( size * sizeof(WCHAR) ))) return NULL;
745 GetComputerNameW( ret, &size );
749 static void fill_compsys( struct table *table )
751 struct record_computersystem *rec;
753 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
755 rec = (struct record_computersystem *)table->data;
756 rec->description = compsys_descriptionW;
757 rec->domain = compsys_domainW;
758 rec->domainrole = 0; /* standalone workstation */
759 rec->manufacturer = compsys_manufacturerW;
760 rec->model = compsys_modelW;
761 rec->name = get_computername();
762 rec->num_logical_processors = get_logical_processor_count();
763 rec->num_processors = get_processor_count();
764 rec->total_physical_memory = get_total_physical_memory();
766 TRACE("created 1 row\n");
770 static WCHAR *get_filesystem( const WCHAR *root )
772 static const WCHAR ntfsW[] = {'N','T','F','S',0};
773 WCHAR buffer[MAX_PATH + 1];
775 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
776 return heap_strdupW( buffer );
777 return heap_strdupW( ntfsW );
780 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
782 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
784 DISK_GEOMETRY_EX info;
787 free.QuadPart = 512 * 1024 * 1024;
788 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
791 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
792 if (handle != INVALID_HANDLE_VALUE)
794 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), NULL, NULL ))
795 *disksize = info.DiskSize.QuadPart;
796 CloseHandle( handle );
798 return free.QuadPart;
801 static void fill_diskpartition( struct table *table )
803 static const WCHAR fmtW[] =
804 {'D','i','s','k',' ','#','%','u',',',' ','P','a','r','t','i','t','i','o','n',' ','#','0',0};
805 WCHAR device_id[32], root[] = {'A',':','\\',0};
806 struct record_diskpartition *rec;
807 UINT i, num_rows = 0, offset = 0, count = 4, type, index = 0;
808 UINT64 size = 1024 * 1024 * 1024;
809 DWORD drives = GetLogicalDrives();
811 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return;
813 for (i = 0; i < sizeof(drives); i++)
815 if (drives & (1 << i))
818 type = GetDriveTypeW( root );
819 if (type != DRIVE_FIXED && type != DRIVE_REMOVABLE)
822 if (num_rows > count)
826 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return;
829 rec = (struct record_diskpartition *)(table->data + offset);
830 rec->bootable = (i == 2) ? -1 : 0;
831 rec->bootpartition = (i == 2) ? -1 : 0;
832 sprintfW( device_id, fmtW, index );
833 rec->device_id = heap_strdupW( device_id );
834 rec->diskindex = index;
836 rec->pnpdevice_id = heap_strdupW( device_id );
837 get_freespace( root, &size );
839 rec->startingoffset = 0;
840 rec->type = get_filesystem( root );
841 offset += sizeof(*rec);
846 TRACE("created %u rows\n", num_rows);
847 table->num_rows = num_rows;
850 static void fill_logicaldisk( struct table *table )
852 static const WCHAR fmtW[] = {'%','c',':',0};
853 WCHAR device_id[3], root[] = {'A',':','\\',0};
854 struct record_logicaldisk *rec;
855 UINT i, num_rows = 0, offset = 0, count = 4, type;
856 UINT64 size = 1024 * 1024 * 1024;
857 DWORD drives = GetLogicalDrives();
859 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return;
861 for (i = 0; i < sizeof(drives); i++)
863 if (drives & (1 << i))
866 type = GetDriveTypeW( root );
867 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
870 if (num_rows > count)
874 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return;
877 rec = (struct record_logicaldisk *)(table->data + offset);
878 sprintfW( device_id, fmtW, 'A' + i );
879 rec->device_id = heap_strdupW( device_id );
880 rec->drivetype = type;
881 rec->filesystem = get_filesystem( root );
882 rec->freespace = get_freespace( root, &size );
883 rec->name = heap_strdupW( device_id );
885 offset += sizeof(*rec);
889 TRACE("created %u rows\n", num_rows);
890 table->num_rows = num_rows;
893 static UINT16 get_connection_status( IF_OPER_STATUS status )
897 case IfOperStatusDown:
898 return 0; /* Disconnected */
900 return 2; /* Connected */
902 ERR("unhandled status %u\n", status);
907 static WCHAR *get_mac_address( const BYTE *addr, DWORD len )
909 static const WCHAR fmtW[] =
910 {'%','0','2','x',':','%','0','2','x',':','%','0','2','x',':',
911 '%','0','2','x',':','%','0','2','x',':','%','0','2','x',0};
914 if (len != 6 || !(ret = heap_alloc( 18 * sizeof(WCHAR) ))) return NULL;
915 sprintfW( ret, fmtW, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
918 static const WCHAR *get_adaptertype( DWORD type )
920 static const WCHAR ethernetW[] = {'E','t','h','e','r','n','e','t',' ','8','0','2','.','3',0};
921 static const WCHAR wirelessW[] = {'W','i','r','e','l','e','s','s',0};
922 static const WCHAR firewireW[] = {'1','3','9','4',0};
923 static const WCHAR tunnelW[] = {'T','u','n','n','e','l',0};
927 case IF_TYPE_ETHERNET_CSMACD: return ethernetW;
928 case IF_TYPE_IEEE80211: return wirelessW;
929 case IF_TYPE_IEEE1394: return firewireW;
930 case IF_TYPE_TUNNEL: return tunnelW;
936 static void fill_networkadapter( struct table *table )
938 static const WCHAR fmtW[] = {'%','u',0};
940 struct record_networkadapter *rec;
941 IP_ADAPTER_ADDRESSES *aa, *buffer;
942 UINT num_rows = 0, offset = 0;
945 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
946 if (ret != ERROR_BUFFER_OVERFLOW) return;
948 if (!(buffer = heap_alloc( size ))) return;
949 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
954 for (aa = buffer; aa; aa = aa->Next) num_rows++;
955 if (!(table->data = heap_alloc( sizeof(*rec) * num_rows )))
960 for (aa = buffer; aa; aa = aa->Next)
962 rec = (struct record_networkadapter *)(table->data + offset);
963 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
964 rec->adaptertype = get_adaptertype( aa->IfType );
965 rec->device_id = heap_strdupW( device_id );
966 rec->interface_index = aa->u.s.IfIndex;
967 rec->mac_address = get_mac_address( aa->PhysicalAddress, aa->PhysicalAddressLength );
968 rec->manufacturer = compsys_manufacturerW;
969 rec->netconnection_status = get_connection_status( aa->OperStatus );
970 rec->pnpdevice_id = networkadapter_pnpdeviceidW;
971 rec->speed = 1000000;
972 offset += sizeof(*rec);
974 TRACE("created %u rows\n", num_rows);
975 table->num_rows = num_rows;
980 static WCHAR *get_cmdline( DWORD process_id )
982 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
983 return NULL; /* FIXME handle different process case */
986 static void fill_process( struct table *table )
988 static const WCHAR fmtW[] = {'%','u',0};
990 struct record_process *rec;
991 PROCESSENTRY32W entry;
993 UINT num_rows = 0, offset = 0, count = 8;
995 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
996 if (snap == INVALID_HANDLE_VALUE) return;
998 entry.dwSize = sizeof(entry);
999 if (!Process32FirstW( snap, &entry )) goto done;
1000 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) goto done;
1004 if (num_rows > count)
1008 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) goto done;
1011 rec = (struct record_process *)(table->data + offset);
1012 rec->caption = heap_strdupW( entry.szExeFile );
1013 rec->commandline = get_cmdline( entry.th32ProcessID );
1014 rec->description = heap_strdupW( entry.szExeFile );
1015 sprintfW( handle, fmtW, entry.th32ProcessID );
1016 rec->handle = heap_strdupW( handle );
1017 rec->process_id = entry.th32ProcessID;
1018 rec->pprocess_id = entry.th32ParentProcessID;
1019 rec->thread_count = entry.cntThreads;
1020 rec->get_owner = process_get_owner;
1021 offset += sizeof(*rec);
1023 } while (Process32NextW( snap, &entry ));
1025 TRACE("created %u rows\n", num_rows);
1026 table->num_rows = num_rows;
1029 CloseHandle( snap );
1032 static inline void do_cpuid( unsigned int ax, unsigned int *p )
1035 __asm__("pushl %%ebx\n\t"
1037 "movl %%ebx, %%esi\n\t"
1039 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
1044 static void get_processor_id( WCHAR *processor_id )
1046 static const WCHAR fmtW[] = {'%','0','8','X','%','0','8','X',0};
1047 unsigned int regs[4] = {0, 0, 0, 0};
1049 do_cpuid( 1, regs );
1050 sprintfW( processor_id, fmtW, regs[3], regs[0] );
1052 static void regs_to_str( unsigned int *regs, unsigned int len, WCHAR *buffer )
1055 unsigned char *p = (unsigned char *)regs;
1057 for (i = 0; i < len; i++)
1063 static void get_processor_manufacturer( WCHAR *manufacturer )
1065 unsigned int tmp, regs[4] = {0, 0, 0, 0};
1067 do_cpuid( 0, regs );
1068 tmp = regs[2]; /* swap edx and ecx */
1072 regs_to_str( regs + 1, 12, manufacturer );
1074 static void get_processor_name( WCHAR *name )
1076 unsigned int regs[4] = {0, 0, 0, 0};
1078 do_cpuid( 0x80000000, regs );
1079 if (regs[0] >= 0x80000004)
1081 do_cpuid( 0x80000002, regs );
1082 regs_to_str( regs, 16, name );
1083 do_cpuid( 0x80000003, regs );
1084 regs_to_str( regs, 16, name + 16 );
1085 do_cpuid( 0x80000004, regs );
1086 regs_to_str( regs, 16, name + 32 );
1089 static UINT get_processor_maxclockspeed( void )
1091 PROCESSOR_POWER_INFORMATION *info;
1092 UINT ret = 1000, size = get_processor_count() * sizeof(PROCESSOR_POWER_INFORMATION);
1095 if ((info = heap_alloc( size )))
1097 status = NtPowerInformation( ProcessorInformation, NULL, 0, info, size );
1098 if (!status) ret = info[0].MaxMhz;
1104 static void fill_processor( struct table *table )
1106 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
1107 WCHAR device_id[14], processor_id[17], manufacturer[13], name[49] = {0};
1108 struct record_processor *rec;
1109 UINT i, offset = 0, maxclockspeed, num_logical_processors, count = get_processor_count();
1111 if (!(table->data = heap_alloc( sizeof(*rec) * count ))) return;
1113 get_processor_id( processor_id );
1114 get_processor_manufacturer( manufacturer );
1115 get_processor_name( name );
1117 maxclockspeed = get_processor_maxclockspeed();
1118 num_logical_processors = get_logical_processor_count() / count;
1120 for (i = 0; i < count; i++)
1122 rec = (struct record_processor *)(table->data + offset);
1123 rec->cpu_status = 1; /* CPU Enabled */
1124 sprintfW( device_id, fmtW, i );
1125 rec->device_id = heap_strdupW( device_id );
1126 rec->manufacturer = heap_strdupW( manufacturer );
1127 rec->maxclockspeed = maxclockspeed;
1128 rec->name = heap_strdupW( name );
1129 rec->num_logical_processors = num_logical_processors;
1130 rec->processor_id = heap_strdupW( processor_id );
1131 rec->unique_id = NULL;
1132 offset += sizeof(*rec);
1135 TRACE("created %u rows\n", count);
1136 table->num_rows = count;
1139 static WCHAR *get_lastbootuptime(void)
1141 static const WCHAR fmtW[] =
1142 {'%','0','4','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u','%','0','2','u',
1143 '.','%','0','6','u','+','0','0','0',0};
1144 SYSTEM_TIMEOFDAY_INFORMATION ti;
1148 if (!(ret = heap_alloc( 26 * sizeof(WCHAR) ))) return NULL;
1150 NtQuerySystemInformation( SystemTimeOfDayInformation, &ti, sizeof(ti), NULL );
1151 RtlTimeToTimeFields( &ti.liKeBootTime, &tf );
1152 sprintfW( ret, fmtW, tf.Year, tf.Month, tf.Day, tf.Hour, tf.Minute, tf.Second, tf.Milliseconds * 1000 );
1155 static const WCHAR *get_osarchitecture(void)
1158 GetNativeSystemInfo( &info );
1159 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) return os_64bitW;
1162 static WCHAR *get_systemdirectory(void)
1167 if (!(ret = heap_alloc( MAX_PATH * sizeof(WCHAR) ))) return NULL;
1168 Wow64DisableWow64FsRedirection( &redir );
1169 GetSystemDirectoryW( ret, MAX_PATH );
1170 Wow64RevertWow64FsRedirection( redir );
1174 static void fill_os( struct table *table )
1176 struct record_operatingsystem *rec;
1178 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
1180 rec = (struct record_operatingsystem *)table->data;
1181 rec->caption = os_captionW;
1182 rec->csdversion = os_csdversionW;
1183 rec->lastbootuptime = get_lastbootuptime();
1184 rec->osarchitecture = get_osarchitecture();
1185 rec->oslanguage = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
1186 rec->systemdirectory = get_systemdirectory();
1188 TRACE("created 1 row\n");
1189 table->num_rows = 1;
1192 static const WCHAR *get_service_type( DWORD type )
1194 static const WCHAR filesystem_driverW[] =
1195 {'F','i','l','e',' ','S','y','s','t','e','m',' ','D','r','i','v','e','r',0};
1196 static const WCHAR kernel_driverW[] =
1197 {'K','e','r','n','e','l',' ','D','r','i','v','e','r',0};
1198 static const WCHAR own_processW[] =
1199 {'O','w','n',' ','P','r','o','c','e','s','s',0};
1200 static const WCHAR share_processW[] =
1201 {'S','h','a','r','e',' ','P','r','o','c','e','s','s',0};
1203 if (type & SERVICE_KERNEL_DRIVER) return kernel_driverW;
1204 else if (type & SERVICE_FILE_SYSTEM_DRIVER) return filesystem_driverW;
1205 else if (type & SERVICE_WIN32_OWN_PROCESS) return own_processW;
1206 else if (type & SERVICE_WIN32_SHARE_PROCESS) return share_processW;
1207 else ERR("unhandled type 0x%08x\n", type);
1210 static const WCHAR *get_service_state( DWORD state )
1212 static const WCHAR runningW[] =
1213 {'R','u','n','n','i','n','g',0};
1214 static const WCHAR start_pendingW[] =
1215 {'S','t','a','r','t',' ','P','e','n','d','i','n','g',0};
1216 static const WCHAR stop_pendingW[] =
1217 {'S','t','o','p',' ','P','e','n','d','i','n','g',0};
1218 static const WCHAR stoppedW[] =
1219 {'S','t','o','p','p','e','d',0};
1220 static const WCHAR unknownW[] =
1221 {'U','n','k','n','o','w','n',0};
1225 case SERVICE_STOPPED: return stoppedW;
1226 case SERVICE_START_PENDING: return start_pendingW;
1227 case SERVICE_STOP_PENDING: return stop_pendingW;
1228 case SERVICE_RUNNING: return runningW;
1230 ERR("unknown state %u\n", state);
1235 static const WCHAR *get_service_startmode( DWORD mode )
1237 static const WCHAR bootW[] = {'B','o','o','t',0};
1238 static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
1239 static const WCHAR autoW[] = {'A','u','t','o',0};
1240 static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
1241 static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
1242 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
1246 case SERVICE_BOOT_START: return bootW;
1247 case SERVICE_SYSTEM_START: return systemW;
1248 case SERVICE_AUTO_START: return autoW;
1249 case SERVICE_DEMAND_START: return manualW;
1250 case SERVICE_DISABLED: return disabledW;
1252 ERR("unknown mode 0x%x\n", mode);
1257 static QUERY_SERVICE_CONFIGW *query_service_config( SC_HANDLE manager, const WCHAR *name )
1259 QUERY_SERVICE_CONFIGW *config = NULL;
1263 if (!(service = OpenServiceW( manager, name, SERVICE_QUERY_CONFIG ))) return NULL;
1264 QueryServiceConfigW( service, NULL, 0, &size );
1265 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) goto done;
1266 if (!(config = heap_alloc( size ))) goto done;
1267 if (QueryServiceConfigW( service, config, size, &size )) goto done;
1268 heap_free( config );
1272 CloseServiceHandle( service );
1276 static void fill_service( struct table *table )
1278 struct record_service *rec;
1280 ENUM_SERVICE_STATUS_PROCESSW *tmp, *services = NULL;
1281 SERVICE_STATUS_PROCESS *status;
1282 WCHAR sysnameW[MAX_COMPUTERNAME_LENGTH + 1];
1283 DWORD len = sizeof(sysnameW) / sizeof(sysnameW[0]);
1284 UINT i, num_rows = 0, offset = 0, size = 256, needed, count;
1287 if (!(manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE ))) return;
1288 if (!(services = heap_alloc( size ))) goto done;
1290 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
1291 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
1292 &count, NULL, NULL );
1295 if (GetLastError() != ERROR_MORE_DATA) goto done;
1297 if (!(tmp = heap_realloc( services, size ))) goto done;
1299 ret = EnumServicesStatusExW( manager, SC_ENUM_PROCESS_INFO, SERVICE_TYPE_ALL,
1300 SERVICE_STATE_ALL, (BYTE *)services, size, &needed,
1301 &count, NULL, NULL );
1302 if (!ret) goto done;
1304 if (!(table->data = heap_alloc( sizeof(*rec) * count ))) goto done;
1306 GetComputerNameW( sysnameW, &len );
1308 for (i = 0; i < count; i++)
1310 QUERY_SERVICE_CONFIGW *config;
1312 if (!(config = query_service_config( manager, services[i].lpServiceName ))) continue;
1314 status = &services[i].ServiceStatusProcess;
1315 rec = (struct record_service *)(table->data + offset);
1316 rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
1317 rec->accept_stop = (status->dwControlsAccepted & SERVICE_ACCEPT_STOP) ? -1 : 0;
1318 rec->displayname = heap_strdupW( services[i].lpDisplayName );
1319 rec->name = heap_strdupW( services[i].lpServiceName );
1320 rec->process_id = status->dwProcessId;
1321 rec->servicetype = get_service_type( status->dwServiceType );
1322 rec->startmode = get_service_startmode( config->dwStartType );
1323 rec->state = get_service_state( status->dwCurrentState );
1324 rec->systemname = heap_strdupW( sysnameW );
1325 rec->pause_service = service_pause_service;
1326 rec->resume_service = service_resume_service;
1327 rec->start_service = service_start_service;
1328 rec->stop_service = service_stop_service;
1329 heap_free( config );
1330 offset += sizeof(*rec);
1334 TRACE("created %u rows\n", num_rows);
1335 table->num_rows = num_rows;
1338 CloseServiceHandle( manager );
1339 heap_free( services );
1342 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
1344 HDC hdc = GetDC( NULL );
1347 if (!hdc) return 32;
1348 ret = GetDeviceCaps( hdc, BITSPIXEL );
1349 *hres = GetDeviceCaps( hdc, HORZRES );
1350 *vres = GetDeviceCaps( hdc, VERTRES );
1351 ReleaseDC( NULL, hdc );
1355 static WCHAR *get_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
1357 static const WCHAR fmtW[] =
1358 {'P','C','I','\\','V','E','N','_','%','0','4','X','&','D','E','V','_','%','0','4','X',
1359 '&','S','U','B','S','Y','S','_','%','0','8','X','&','R','E','V','_','%','0','2','X','\\',
1360 '0','&','D','E','A','D','B','E','E','F','&','0','&','D','E','A','D',0};
1363 if (!(ret = heap_alloc( sizeof(fmtW) + 2 * sizeof(WCHAR) ))) return NULL;
1364 sprintfW( ret, fmtW, desc->VendorId, desc->DeviceId, desc->SubSysId, desc->Revision );
1368 static void fill_videocontroller( struct table *table )
1371 struct record_videocontroller *rec;
1373 IDXGIFactory *factory = NULL;
1374 IDXGIAdapter *adapter = NULL;
1375 DXGI_ADAPTER_DESC desc;
1376 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
1377 const WCHAR *name = videocontroller_deviceidW;
1379 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
1381 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
1382 if (FAILED(hr)) goto done;
1384 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
1385 if (FAILED(hr)) goto done;
1387 hr = IDXGIAdapter_GetDesc( adapter, &desc );
1390 vidmem = desc.DedicatedVideoMemory;
1391 name = desc.Description;
1395 rec = (struct record_videocontroller *)table->data;
1396 rec->adapter_ram = vidmem;
1397 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
1398 rec->current_horizontalres = hres;
1399 rec->current_verticalres = vres;
1400 rec->description = heap_strdupW( name );
1401 rec->device_id = videocontroller_deviceidW;
1402 rec->name = heap_strdupW( name );
1403 rec->pnpdevice_id = get_pnpdeviceid( &desc );
1405 TRACE("created 1 row\n");
1406 table->num_rows = 1;
1408 if (adapter) IDXGIAdapter_Release( adapter );
1409 if (factory) IDXGIFactory_Release( factory );
1412 static struct table builtin_classes[] =
1414 { class_baseboardW, SIZEOF(col_baseboard), col_baseboard, SIZEOF(data_baseboard), (BYTE *)data_baseboard },
1415 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), (BYTE *)data_bios },
1416 { class_cdromdriveW, SIZEOF(col_cdromdrive), col_cdromdrive, 0, NULL, fill_cdromdrive },
1417 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, NULL, fill_compsys },
1418 { class_diskdriveW, SIZEOF(col_diskdrive), col_diskdrive, SIZEOF(data_diskdrive), (BYTE *)data_diskdrive },
1419 { class_diskpartitionW, SIZEOF(col_diskpartition), col_diskpartition, 0, NULL, fill_diskpartition },
1420 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, NULL, fill_logicaldisk },
1421 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, NULL, fill_networkadapter },
1422 { class_osW, SIZEOF(col_os), col_os, 0, NULL, fill_os },
1423 { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), (BYTE *)data_param },
1424 { class_processW, SIZEOF(col_process), col_process, 0, NULL, fill_process },
1425 { class_processorW, SIZEOF(col_processor), col_processor, 0, NULL, fill_processor },
1426 { class_qualifiersW, SIZEOF(col_qualifier), col_qualifier, SIZEOF(data_qualifier), (BYTE *)data_qualifier },
1427 { class_serviceW, SIZEOF(col_service), col_service, 0, NULL, fill_service },
1428 { class_sounddeviceW, SIZEOF(col_sounddevice), col_sounddevice, SIZEOF(data_sounddevice), (BYTE *)data_sounddevice },
1429 { class_stdregprovW, SIZEOF(col_stdregprov), col_stdregprov, SIZEOF(data_stdregprov), (BYTE *)data_stdregprov },
1430 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, NULL, fill_videocontroller }
1433 void init_table_list( void )
1435 static struct list tables = LIST_INIT( tables );
1438 for (i = 0; i < SIZEOF(builtin_classes); i++) list_add_tail( &tables, &builtin_classes[i].entry );
1439 table_list = &tables;