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
37 #include "wine/debug.h"
38 #include "wbemprox_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
42 static const WCHAR class_baseboardW
[] =
43 {'W','i','n','3','2','_','B','a','s','e','B','o','a','r','d',0};
44 static const WCHAR class_biosW
[] =
45 {'W','i','n','3','2','_','B','I','O','S',0};
46 static const WCHAR class_compsysW
[] =
47 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
48 static const WCHAR class_logicaldiskW
[] =
49 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
50 static const WCHAR class_networkadapterW
[] =
51 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
52 static const WCHAR class_osW
[] =
53 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
54 static const WCHAR class_processW
[] =
55 {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
56 static const WCHAR class_processorW
[] =
57 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
58 static const WCHAR class_videocontrollerW
[] =
59 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
61 static const WCHAR prop_adapterramW
[] =
62 {'A','d','a','p','t','e','r','R','A','M',0};
63 static const WCHAR prop_captionW
[] =
64 {'C','a','p','t','i','o','n',0};
65 static const WCHAR prop_csdversionW
[] =
66 {'C','S','D','V','e','r','s','i','o','n',0};
67 static const WCHAR prop_commandlineW
[] =
68 {'C','o','m','m','a','n','d','L','i','n','e',0};
69 static const WCHAR prop_cpustatusW
[] =
70 {'C','p','u','S','t','a','t','u','s',0};
71 static const WCHAR prop_currentbitsperpixelW
[] =
72 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
73 static const WCHAR prop_currenthorizontalresW
[] =
74 {'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};
75 static const WCHAR prop_currentverticalresW
[] =
76 {'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};
77 static const WCHAR prop_descriptionW
[] =
78 {'D','e','s','c','r','i','p','t','i','o','n',0};
79 static const WCHAR prop_deviceidW
[] =
80 {'D','e','v','i','c','e','I','d',0};
81 static const WCHAR prop_drivetypeW
[] =
82 {'D','r','i','v','e','T','y','p','e',0};
83 static const WCHAR prop_filesystemW
[] =
84 {'F','i','l','e','S','y','s','t','e','m',0};
85 static const WCHAR prop_freespaceW
[] =
86 {'F','r','e','e','S','p','a','c','e',0};
87 static const WCHAR prop_handleW
[] =
88 {'H','a','n','d','l','e',0};
89 static const WCHAR prop_interfaceindexW
[] =
90 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
91 static const WCHAR prop_manufacturerW
[] =
92 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
93 static const WCHAR prop_modelW
[] =
94 {'M','o','d','e','l',0};
95 static const WCHAR prop_nameW
[] =
97 static const WCHAR prop_netconnectionstatusW
[] =
98 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
99 static const WCHAR prop_numlogicalprocessorsW
[] =
100 {'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};
101 static const WCHAR prop_numprocessorsW
[] =
102 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
103 static const WCHAR prop_osarchitectureW
[] =
104 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
105 static const WCHAR prop_oslanguageW
[] =
106 {'O','S','L','a','n','g','u','a','g','e',0};
107 static const WCHAR prop_pprocessidW
[] =
108 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
109 static const WCHAR prop_processidW
[] =
110 {'P','r','o','c','e','s','s','I','D',0};
111 static const WCHAR prop_processoridW
[] =
112 {'P','r','o','c','e','s','s','o','r','I','d',0};
113 static const WCHAR prop_releasedateW
[] =
114 {'R','e','l','e','a','s','e','D','a','t','e',0};
115 static const WCHAR prop_serialnumberW
[] =
116 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
117 static const WCHAR prop_sizeW
[] =
119 static const WCHAR prop_speedW
[] =
120 {'S','p','e','e','d',0};
121 static const WCHAR prop_systemdirectoryW
[] =
122 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
123 static const WCHAR prop_tagW
[] =
125 static const WCHAR prop_threadcountW
[] =
126 {'T','h','r','e','a','d','C','o','u','n','t',0};
127 static const WCHAR prop_totalphysicalmemoryW
[] =
128 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
130 /* column definitions must be kept in sync with record structures below */
131 static const struct column col_baseboard
[] =
133 { prop_manufacturerW
, CIM_STRING
},
134 { prop_serialnumberW
, CIM_STRING
},
135 { prop_tagW
, CIM_STRING
|COL_FLAG_KEY
}
137 static const struct column col_bios
[] =
139 { prop_descriptionW
, CIM_STRING
},
140 { prop_manufacturerW
, CIM_STRING
},
141 { prop_releasedateW
, CIM_DATETIME
},
142 { prop_serialnumberW
, CIM_STRING
}
144 static const struct column col_compsys
[] =
146 { prop_descriptionW
, CIM_STRING
},
147 { prop_manufacturerW
, CIM_STRING
},
148 { prop_modelW
, CIM_STRING
},
149 { prop_numlogicalprocessorsW
, CIM_UINT32
, VT_I4
},
150 { prop_numprocessorsW
, CIM_UINT32
, VT_I4
},
151 { prop_totalphysicalmemoryW
, CIM_UINT64
}
153 static const struct column col_logicaldisk
[] =
155 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
156 { prop_drivetypeW
, CIM_UINT32
, VT_I4
},
157 { prop_filesystemW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
158 { prop_freespaceW
, CIM_UINT64
},
159 { prop_sizeW
, CIM_UINT64
}
161 static const struct column col_networkadapter
[] =
163 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
164 { prop_interfaceindexW
, CIM_UINT32
, VT_I4
},
165 { prop_netconnectionstatusW
, CIM_UINT16
, VT_I4
},
166 { prop_speedW
, CIM_UINT64
}
168 static const struct column col_os
[] =
170 { prop_captionW
, CIM_STRING
},
171 { prop_csdversionW
, CIM_STRING
},
172 { prop_osarchitectureW
, CIM_STRING
},
173 { prop_oslanguageW
, CIM_UINT32
, VT_I4
},
174 { prop_systemdirectoryW
, CIM_STRING
}
176 static const struct column col_process
[] =
178 { prop_captionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
179 { prop_commandlineW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
180 { prop_descriptionW
, CIM_STRING
|COL_FLAG_DYNAMIC
},
181 { prop_handleW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
182 { prop_pprocessidW
, CIM_UINT32
, VT_I4
},
183 { prop_processidW
, CIM_UINT32
, VT_I4
},
184 { prop_threadcountW
, CIM_UINT32
, VT_I4
}
186 static const struct column col_processor
[] =
188 { prop_cpustatusW
, CIM_UINT16
},
189 { prop_deviceidW
, CIM_STRING
|COL_FLAG_DYNAMIC
|COL_FLAG_KEY
},
190 { prop_manufacturerW
, CIM_STRING
},
191 { prop_processoridW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
193 static const struct column col_videocontroller
[] =
195 { prop_adapterramW
, CIM_UINT32
},
196 { prop_currentbitsperpixelW
, CIM_UINT32
},
197 { prop_currenthorizontalresW
, CIM_UINT32
},
198 { prop_currentverticalresW
, CIM_UINT32
},
199 { prop_deviceidW
, CIM_STRING
|COL_FLAG_KEY
},
200 { prop_nameW
, CIM_STRING
|COL_FLAG_DYNAMIC
}
203 static const WCHAR baseboard_manufacturerW
[] =
204 {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
205 static const WCHAR baseboard_serialnumberW
[] =
207 static const WCHAR baseboard_tagW
[] =
208 {'B','a','s','e',' ','B','o','a','r','d',0};
209 static const WCHAR bios_descriptionW
[] =
210 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
211 static const WCHAR bios_manufacturerW
[] =
212 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
213 static const WCHAR bios_releasedateW
[] =
214 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
215 static const WCHAR bios_serialnumberW
[] =
217 static const WCHAR compsys_descriptionW
[] =
218 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
219 static const WCHAR compsys_manufacturerW
[] =
220 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
221 static const WCHAR compsys_modelW
[] =
223 static const WCHAR os_captionW
[] =
224 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
225 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
226 static const WCHAR os_csdversionW
[] =
227 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
228 static const WCHAR os_32bitW
[] =
229 {'3','2','-','b','i','t',0};
230 static const WCHAR os_64bitW
[] =
231 {'6','4','-','b','i','t',0};
232 static const WCHAR processor_manufacturerW
[] =
233 {'G','e','n','u','i','n','e','I','n','t','e','l',0};
234 static const WCHAR videocontroller_deviceidW
[] =
235 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
237 #include "pshpack1.h"
238 struct record_baseboard
240 const WCHAR
*manufacturer
;
241 const WCHAR
*serialnumber
;
246 const WCHAR
*description
;
247 const WCHAR
*manufacturer
;
248 const WCHAR
*releasedate
;
249 const WCHAR
*serialnumber
;
251 struct record_computersystem
253 const WCHAR
*description
;
254 const WCHAR
*manufacturer
;
256 UINT32 num_logical_processors
;
257 UINT32 num_processors
;
258 UINT64 total_physical_memory
;
260 struct record_logicaldisk
262 const WCHAR
*device_id
;
264 const WCHAR
*filesystem
;
268 struct record_networkadapter
270 const WCHAR
*device_id
;
271 INT32 interface_index
;
272 UINT16 netconnection_status
;
275 struct record_operatingsystem
277 const WCHAR
*caption
;
278 const WCHAR
*csdversion
;
279 const WCHAR
*osarchitecture
;
281 const WCHAR
*systemdirectory
;
283 struct record_process
285 const WCHAR
*caption
;
286 const WCHAR
*commandline
;
287 const WCHAR
*description
;
293 struct record_processor
296 const WCHAR
*device_id
;
297 const WCHAR
*manufacturer
;
298 const WCHAR
*processor_id
;
300 struct record_videocontroller
303 UINT32 current_bitsperpixel
;
304 UINT32 current_horizontalres
;
305 UINT32 current_verticalres
;
306 const WCHAR
*device_id
;
311 static const struct record_baseboard data_baseboard
[] =
313 { baseboard_manufacturerW
, baseboard_serialnumberW
, baseboard_tagW
}
315 static const struct record_bios data_bios
[] =
317 { bios_descriptionW
, bios_manufacturerW
, bios_releasedateW
, bios_serialnumberW
}
320 static UINT
get_processor_count(void)
322 SYSTEM_BASIC_INFORMATION info
;
324 if (NtQuerySystemInformation( SystemBasicInformation
, &info
, sizeof(info
), NULL
)) return 1;
325 return info
.NumberOfProcessors
;
328 static UINT64
get_total_physical_memory(void)
330 MEMORYSTATUSEX status
;
332 status
.dwLength
= sizeof(status
);
333 if (!GlobalMemoryStatusEx( &status
)) return 1024 * 1024 * 1024;
334 return status
.ullTotalPhys
;
337 static void fill_compsys( struct table
*table
)
339 struct record_computersystem
*rec
;
341 if (!(table
->data
= heap_alloc( sizeof(*rec
) ))) return;
343 rec
= (struct record_computersystem
*)table
->data
;
344 rec
->description
= compsys_descriptionW
;
345 rec
->manufacturer
= compsys_manufacturerW
;
346 rec
->model
= compsys_modelW
;
347 rec
->num_logical_processors
= get_processor_count();
348 rec
->num_processors
= rec
->num_logical_processors
;
349 rec
->total_physical_memory
= get_total_physical_memory();
351 TRACE("created 1 row\n");
355 static WCHAR
*get_filesystem( const WCHAR
*root
)
357 static const WCHAR ntfsW
[] = {'N','T','F','S',0};
358 WCHAR buffer
[MAX_PATH
+ 1];
360 if (GetVolumeInformationW( root
, NULL
, 0, NULL
, NULL
, NULL
, buffer
, MAX_PATH
+ 1 ))
361 return heap_strdupW( buffer
);
362 return heap_strdupW( ntfsW
);
365 static UINT64
get_freespace( const WCHAR
*dir
, UINT64
*disksize
)
367 WCHAR root
[] = {'\\','\\','.','\\','A',':',0};
369 DISK_GEOMETRY_EX info
;
372 free
.QuadPart
= 512 * 1024 * 1024;
373 GetDiskFreeSpaceExW( dir
, NULL
, NULL
, &free
);
376 handle
= CreateFileW( root
, GENERIC_READ
, FILE_SHARE_READ
|FILE_SHARE_WRITE
, NULL
, OPEN_EXISTING
, 0, 0 );
377 if (handle
!= INVALID_HANDLE_VALUE
)
379 if (DeviceIoControl( handle
, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX
, NULL
, 0, &info
, sizeof(info
), NULL
, NULL
))
380 *disksize
= info
.DiskSize
.QuadPart
;
381 CloseHandle( handle
);
383 return free
.QuadPart
;
386 static void fill_logicaldisk( struct table
*table
)
388 static const WCHAR fmtW
[] = {'%','c',':',0};
389 WCHAR device_id
[3], root
[] = {'A',':','\\',0};
390 struct record_logicaldisk
*rec
;
391 UINT i
, num_rows
= 0, offset
= 0, count
= 4, type
;
392 UINT64 size
= 1024 * 1024 * 1024;
393 DWORD drives
= GetLogicalDrives();
395 if (!(table
->data
= heap_alloc( count
* sizeof(*rec
) ))) return;
397 for (i
= 0; i
< sizeof(drives
); i
++)
399 if (drives
& (1 << i
))
402 type
= GetDriveTypeW( root
);
403 if (type
!= DRIVE_FIXED
&& type
!= DRIVE_CDROM
&& type
!= DRIVE_REMOVABLE
)
406 if (num_rows
> count
)
410 if (!(data
= heap_realloc( table
->data
, count
* sizeof(*rec
) ))) return;
413 rec
= (struct record_logicaldisk
*)(table
->data
+ offset
);
414 sprintfW( device_id
, fmtW
, 'A' + i
);
415 rec
->device_id
= heap_strdupW( device_id
);
416 rec
->drivetype
= type
;
417 rec
->filesystem
= get_filesystem( root
);
418 rec
->freespace
= get_freespace( root
, &size
);
420 offset
+= sizeof(*rec
);
424 TRACE("created %u rows\n", num_rows
);
425 table
->num_rows
= num_rows
;
428 static UINT16
get_connection_status( IF_OPER_STATUS status
)
432 case IfOperStatusDown
:
433 return 0; /* Disconnected */
435 return 2; /* Connected */
437 ERR("unhandled status %u\n", status
);
443 static void fill_networkadapter( struct table
*table
)
445 static const WCHAR fmtW
[] = {'%','u',0};
447 struct record_networkadapter
*rec
;
448 IP_ADAPTER_ADDRESSES
*aa
, *buffer
;
449 UINT num_rows
= 0, offset
= 0;
452 ret
= GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, NULL
, &size
);
453 if (ret
!= ERROR_BUFFER_OVERFLOW
) return;
455 if (!(buffer
= heap_alloc( size
))) return;
456 if (GetAdaptersAddresses( AF_UNSPEC
, 0, NULL
, buffer
, &size
))
461 for (aa
= buffer
; aa
; aa
= aa
->Next
) num_rows
++;
462 if (!(table
->data
= heap_alloc( sizeof(*rec
) * num_rows
)))
467 for (aa
= buffer
; aa
; aa
= aa
->Next
)
469 rec
= (struct record_networkadapter
*)(table
->data
+ offset
);
470 sprintfW( device_id
, fmtW
, aa
->u
.s
.IfIndex
);
471 rec
->device_id
= heap_strdupW( device_id
);
472 rec
->interface_index
= aa
->u
.s
.IfIndex
;
473 rec
->netconnection_status
= get_connection_status( aa
->OperStatus
);
474 rec
->speed
= 1000000;
475 offset
+= sizeof(*rec
);
477 TRACE("created %u rows\n", num_rows
);
478 table
->num_rows
= num_rows
;
483 static WCHAR
*get_cmdline( DWORD process_id
)
485 if (process_id
== GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
486 return NULL
; /* FIXME handle different process case */
489 static void fill_process( struct table
*table
)
491 static const WCHAR fmtW
[] = {'%','u',0};
493 struct record_process
*rec
;
494 PROCESSENTRY32W entry
;
496 UINT num_rows
= 0, offset
= 0, count
= 8;
498 snap
= CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS
, 0 );
499 if (snap
== INVALID_HANDLE_VALUE
) return;
501 entry
.dwSize
= sizeof(entry
);
502 if (!Process32FirstW( snap
, &entry
)) goto done
;
503 if (!(table
->data
= heap_alloc( count
* sizeof(*rec
) ))) goto done
;
507 if (num_rows
> count
)
511 if (!(data
= heap_realloc( table
->data
, count
* sizeof(*rec
) ))) goto done
;
514 rec
= (struct record_process
*)(table
->data
+ offset
);
515 rec
->caption
= heap_strdupW( entry
.szExeFile
);
516 rec
->commandline
= get_cmdline( entry
.th32ProcessID
);
517 rec
->description
= heap_strdupW( entry
.szExeFile
);
518 sprintfW( handle
, fmtW
, entry
.th32ProcessID
);
519 rec
->handle
= heap_strdupW( handle
);
520 rec
->process_id
= entry
.th32ProcessID
;
521 rec
->pprocess_id
= entry
.th32ParentProcessID
;
522 rec
->thread_count
= entry
.cntThreads
;
523 offset
+= sizeof(*rec
);
525 } while (Process32NextW( snap
, &entry
));
527 TRACE("created %u rows\n", num_rows
);
528 table
->num_rows
= num_rows
;
534 static inline void do_cpuid( unsigned int ax
, unsigned int *p
)
537 __asm__("pushl %%ebx\n\t"
539 "movl %%ebx, %%esi\n\t"
541 : "=a" (p
[0]), "=S" (p
[1]), "=c" (p
[2]), "=d" (p
[3])
546 static void fill_processor( struct table
*table
)
548 static const WCHAR fmtW
[] = {'C','P','U','%','u',0};
549 static const WCHAR fmt_cpuidW
[] = {'%','0','8','X','%','0','8','X',0};
550 WCHAR device_id
[14], cpu_id
[17];
551 struct record_processor
*rec
;
552 UINT i
, offset
= 0, count
= get_processor_count();
553 unsigned int regs
[4] = {0, 0, 0, 0};
555 if (!(table
->data
= heap_alloc( sizeof(*rec
) * count
))) return;
558 sprintfW( cpu_id
, fmt_cpuidW
, regs
[3], regs
[0] );
559 for (i
= 0; i
< count
; i
++)
561 rec
= (struct record_processor
*)(table
->data
+ offset
);
562 rec
->cpu_status
= 1; /* CPU Enabled */
563 rec
->manufacturer
= processor_manufacturerW
;
564 sprintfW( device_id
, fmtW
, i
);
565 rec
->device_id
= heap_strdupW( device_id
);
566 rec
->processor_id
= heap_strdupW( cpu_id
);
567 offset
+= sizeof(*rec
);
570 TRACE("created %u rows\n", count
);
571 table
->num_rows
= count
;
574 static void fill_os( struct table
*table
)
576 struct record_operatingsystem
*rec
;
577 WCHAR path
[MAX_PATH
];
581 if (!(table
->data
= heap_alloc( sizeof(*rec
) ))) return;
583 rec
= (struct record_operatingsystem
*)table
->data
;
584 rec
->caption
= os_captionW
;
585 rec
->csdversion
= os_csdversionW
;
587 GetNativeSystemInfo( &info
);
588 if (info
.u
.s
.wProcessorArchitecture
== PROCESSOR_ARCHITECTURE_AMD64
)
589 rec
->osarchitecture
= os_64bitW
;
591 rec
->osarchitecture
= os_32bitW
;
593 rec
->oslanguage
= MAKELANGID( LANG_ENGLISH
, SUBLANG_ENGLISH_US
);
595 Wow64DisableWow64FsRedirection( &redir
);
596 GetSystemDirectoryW( path
, MAX_PATH
);
597 Wow64RevertWow64FsRedirection( redir
);
598 rec
->systemdirectory
= heap_strdupW( path
);
600 TRACE("created 1 row\n");
604 static UINT32
get_bits_per_pixel( UINT
*hres
, UINT
*vres
)
606 HDC hdc
= GetDC( NULL
);
610 ret
= GetDeviceCaps( hdc
, BITSPIXEL
);
611 *hres
= GetDeviceCaps( hdc
, HORZRES
);
612 *vres
= GetDeviceCaps( hdc
, VERTRES
);
613 ReleaseDC( NULL
, hdc
);
617 static void fill_videocontroller( struct table
*table
)
620 struct record_videocontroller
*rec
;
622 IDXGIFactory
*factory
= NULL
;
623 IDXGIAdapter
*adapter
= NULL
;
624 DXGI_ADAPTER_DESC desc
;
625 UINT hres
= 1024, vres
= 768, vidmem
= 512 * 1024 * 1024;
626 const WCHAR
*name
= videocontroller_deviceidW
;
628 if (!(table
->data
= heap_alloc( sizeof(*rec
) ))) return;
630 hr
= CreateDXGIFactory( &IID_IDXGIFactory
, (void **)&factory
);
631 if (FAILED(hr
)) goto done
;
633 hr
= IDXGIFactory_EnumAdapters( factory
, 0, &adapter
);
634 if (FAILED(hr
)) goto done
;
636 hr
= IDXGIAdapter_GetDesc( adapter
, &desc
);
639 vidmem
= desc
.DedicatedVideoMemory
;
640 name
= desc
.Description
;
644 rec
= (struct record_videocontroller
*)table
->data
;
645 rec
->adapter_ram
= vidmem
;
646 rec
->current_bitsperpixel
= get_bits_per_pixel( &hres
, &vres
);
647 rec
->current_horizontalres
= hres
;
648 rec
->current_verticalres
= vres
;
649 rec
->device_id
= videocontroller_deviceidW
;
650 rec
->name
= heap_strdupW( name
);
652 TRACE("created 1 row\n");
655 if (adapter
) IDXGIAdapter_Release( adapter
);
656 if (factory
) IDXGIFactory_Release( factory
);
659 static struct table classtable
[] =
661 { class_baseboardW
, SIZEOF(col_baseboard
), col_baseboard
, SIZEOF(data_baseboard
), (BYTE
*)data_baseboard
},
662 { class_biosW
, SIZEOF(col_bios
), col_bios
, SIZEOF(data_bios
), (BYTE
*)data_bios
, NULL
},
663 { class_compsysW
, SIZEOF(col_compsys
), col_compsys
, 0, NULL
, fill_compsys
},
664 { class_logicaldiskW
, SIZEOF(col_logicaldisk
), col_logicaldisk
, 0, NULL
, fill_logicaldisk
},
665 { class_networkadapterW
, SIZEOF(col_networkadapter
), col_networkadapter
, 0, NULL
, fill_networkadapter
},
666 { class_osW
, SIZEOF(col_os
), col_os
, 0, NULL
, fill_os
},
667 { class_processW
, SIZEOF(col_process
), col_process
, 0, NULL
, fill_process
},
668 { class_processorW
, SIZEOF(col_processor
), col_processor
, 0, NULL
, fill_processor
},
669 { class_videocontrollerW
, SIZEOF(col_videocontroller
), col_videocontroller
, 0, NULL
, fill_videocontroller
}
672 struct table
*get_table( const WCHAR
*name
)
675 struct table
*table
= NULL
;
677 for (i
= 0; i
< SIZEOF(classtable
); i
++)
679 if (!strcmpiW( classtable
[i
].name
, name
))
681 table
= &classtable
[i
];
682 if (table
->fill
&& !table
->data
) table
->fill( table
);