wbemprox: Add a partial Win32_LogicalDisk class implementation.
[wine/multimedia.git] / dlls / wbemprox / builtin.c
blobb564f19c32e8672316f16e6ced447d7d18c3a985
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 "windef.h"
27 #include "winbase.h"
28 #include "wbemcli.h"
29 #include "winsock2.h"
30 #include "iphlpapi.h"
31 #include "tlhelp32.h"
32 #include "initguid.h"
33 #include "d3d10.h"
34 #include "winternl.h"
35 #include "winioctl.h"
37 #include "wine/debug.h"
38 #include "wbemprox_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
42 static const WCHAR class_biosW[] =
43 {'W','i','n','3','2','_','B','I','O','S',0};
44 static const WCHAR class_compsysW[] =
45 {'W','i','n','3','2','_','C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
46 static const WCHAR class_logicaldiskW[] =
47 {'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k',0};
48 static const WCHAR class_networkadapterW[] =
49 {'W','i','n','3','2','_','N','e','t','w','o','r','k','A','d','a','p','t','e','r',0};
50 static const WCHAR class_osW[] =
51 {'W','i','n','3','2','_','O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0};
52 static const WCHAR class_processW[] =
53 {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
54 static const WCHAR class_processorW[] =
55 {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
56 static const WCHAR class_videocontrollerW[] =
57 {'W','i','n','3','2','_','V','i','d','e','o','C','o','n','t','r','o','l','l','e','r',0};
59 static const WCHAR prop_adapterramW[] =
60 {'A','d','a','p','t','e','r','R','A','M',0};
61 static const WCHAR prop_captionW[] =
62 {'C','a','p','t','i','o','n',0};
63 static const WCHAR prop_csdversionW[] =
64 {'C','S','D','V','e','r','s','i','o','n',0};
65 static const WCHAR prop_commandlineW[] =
66 {'C','o','m','m','a','n','d','L','i','n','e',0};
67 static const WCHAR prop_cpustatusW[] =
68 {'C','p','u','S','t','a','t','u','s',0};
69 static const WCHAR prop_currentbitsperpixelW[] =
70 {'C','u','r','r','e','n','t','B','i','t','s','P','e','r','P','i','x','e','l',0};
71 static const WCHAR prop_currenthorizontalresW[] =
72 {'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};
73 static const WCHAR prop_currentverticalresW[] =
74 {'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};
75 static const WCHAR prop_descriptionW[] =
76 {'D','e','s','c','r','i','p','t','i','o','n',0};
77 static const WCHAR prop_deviceidW[] =
78 {'D','e','v','i','c','e','I','d',0};
79 static const WCHAR prop_drivetypeW[] =
80 {'D','r','i','v','e','T','y','p','e',0};
81 static const WCHAR prop_filesystemW[] =
82 {'F','i','l','e','S','y','s','t','e','m',0};
83 static const WCHAR prop_freespaceW[] =
84 {'F','r','e','e','S','p','a','c','e',0};
85 static const WCHAR prop_handleW[] =
86 {'H','a','n','d','l','e',0};
87 static const WCHAR prop_interfaceindexW[] =
88 {'I','n','t','e','r','f','a','c','e','I','n','d','e','x',0};
89 static const WCHAR prop_manufacturerW[] =
90 {'M','a','n','u','f','a','c','t','u','r','e','r',0};
91 static const WCHAR prop_modelW[] =
92 {'M','o','d','e','l',0};
93 static const WCHAR prop_nameW[] =
94 {'N','a','m','e',0};
95 static const WCHAR prop_netconnectionstatusW[] =
96 {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
97 static const WCHAR prop_numlogicalprocessorsW[] =
98 {'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};
99 static const WCHAR prop_numprocessorsW[] =
100 {'N','u','m','b','e','r','O','f','P','r','o','c','e','s','s','o','r','s',0};
101 static const WCHAR prop_osarchitectureW[] =
102 {'O','S','A','r','c','h','i','t','e','c','t','u','r','e',0};
103 static const WCHAR prop_oslanguageW[] =
104 {'O','S','L','a','n','g','u','a','g','e',0};
105 static const WCHAR prop_pprocessidW[] =
106 {'P','a','r','e','n','t','P','r','o','c','e','s','s','I','D',0};
107 static const WCHAR prop_processidW[] =
108 {'P','r','o','c','e','s','s','I','D',0};
109 static const WCHAR prop_processoridW[] =
110 {'P','r','o','c','e','s','s','o','r','I','d',0};
111 static const WCHAR prop_releasedateW[] =
112 {'R','e','l','e','a','s','e','D','a','t','e',0};
113 static const WCHAR prop_serialnumberW[] =
114 {'S','e','r','i','a','l','N','u','m','b','e','r',0};
115 static const WCHAR prop_sizeW[] =
116 {'S','i','z','e',0};
117 static const WCHAR prop_speedW[] =
118 {'S','p','e','e','d',0};
119 static const WCHAR prop_systemdirectoryW[] =
120 {'S','y','s','t','e','m','D','i','r','e','c','t','o','r','y',0};
121 static const WCHAR prop_threadcountW[] =
122 {'T','h','r','e','a','d','C','o','u','n','t',0};
123 static const WCHAR prop_totalphysicalmemoryW[] =
124 {'T','o','t','a','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
126 /* column definitions must be kept in sync with record structures below */
127 static const struct column col_bios[] =
129 { prop_descriptionW, CIM_STRING },
130 { prop_manufacturerW, CIM_STRING },
131 { prop_releasedateW, CIM_DATETIME },
132 { prop_serialnumberW, CIM_STRING }
134 static const struct column col_compsys[] =
136 { prop_descriptionW, CIM_STRING },
137 { prop_manufacturerW, CIM_STRING },
138 { prop_modelW, CIM_STRING },
139 { prop_numlogicalprocessorsW, CIM_UINT32 },
140 { prop_numprocessorsW, CIM_UINT32 },
141 { prop_totalphysicalmemoryW, CIM_UINT64 }
143 static const struct column col_logicaldisk[] =
145 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
146 { prop_drivetypeW, CIM_UINT32 },
147 { prop_filesystemW, CIM_STRING|COL_FLAG_DYNAMIC },
148 { prop_freespaceW, CIM_UINT64 },
149 { prop_sizeW, CIM_UINT64 }
151 static const struct column col_networkadapter[] =
153 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
154 { prop_interfaceindexW, CIM_UINT32 },
155 { prop_netconnectionstatusW, CIM_UINT16 },
156 { prop_speedW, CIM_UINT64 }
158 static const struct column col_os[] =
160 { prop_captionW, CIM_STRING },
161 { prop_csdversionW, CIM_STRING },
162 { prop_osarchitectureW, CIM_STRING },
163 { prop_oslanguageW, CIM_UINT32 },
164 { prop_systemdirectoryW, CIM_STRING }
166 static const struct column col_process[] =
168 { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
169 { prop_commandlineW, CIM_STRING|COL_FLAG_DYNAMIC },
170 { prop_descriptionW, CIM_STRING|COL_FLAG_DYNAMIC },
171 { prop_handleW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
172 { prop_pprocessidW, CIM_UINT32 },
173 { prop_processidW, CIM_UINT32 },
174 { prop_threadcountW, CIM_UINT32 }
176 static const struct column col_processor[] =
178 { prop_cpustatusW, CIM_UINT16 },
179 { prop_deviceidW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
180 { prop_manufacturerW, CIM_STRING },
181 { prop_processoridW, CIM_STRING|COL_FLAG_DYNAMIC }
183 static const struct column col_videocontroller[] =
185 { prop_adapterramW, CIM_UINT32 },
186 { prop_currentbitsperpixelW, CIM_UINT32 },
187 { prop_currenthorizontalresW, CIM_UINT32 },
188 { prop_currentverticalresW, CIM_UINT32 },
189 { prop_deviceidW, CIM_STRING|COL_FLAG_KEY },
190 { prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC }
193 static const WCHAR bios_descriptionW[] =
194 {'D','e','f','a','u','l','t',' ','S','y','s','t','e','m',' ','B','I','O','S',0};
195 static const WCHAR bios_manufacturerW[] =
196 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
197 static const WCHAR bios_releasedateW[] =
198 {'2','0','1','2','0','6','0','8','0','0','0','0','0','0','.','0','0','0','0','0','0','+','0','0','0',0};
199 static const WCHAR bios_serialnumberW[] =
200 {'0',0};
201 static const WCHAR compsys_descriptionW[] =
202 {'A','T','/','A','T',' ','C','O','M','P','A','T','I','B','L','E',0};
203 static const WCHAR compsys_manufacturerW[] =
204 {'T','h','e',' ','W','i','n','e',' ','P','r','o','j','e','c','t',0};
205 static const WCHAR compsys_modelW[] =
206 {'W','i','n','e',0};
207 static const WCHAR os_captionW[] =
208 {'M','i','c','r','o','s','o','f','t',' ','W','i','n','d','o','w','s',' ','X','P',' ',
209 'V','e','r','s','i','o','n',' ','=',' ','5','.','1','.','2','6','0','0',0};
210 static const WCHAR os_csdversionW[] =
211 {'S','e','r','v','i','c','e',' ','P','a','c','k',' ','3',0};
212 static const WCHAR os_32bitW[] =
213 {'3','2','-','b','i','t',0};
214 static const WCHAR os_64bitW[] =
215 {'6','4','-','b','i','t',0};
216 static const WCHAR processor_manufacturerW[] =
217 {'G','e','n','u','i','n','e','I','n','t','e','l',0};
218 static const WCHAR videocontroller_deviceidW[] =
219 {'V','i','d','e','o','C','o','n','t','r','o','l','l','e','r','1',0};
221 #include "pshpack1.h"
222 struct record_bios
224 const WCHAR *description;
225 const WCHAR *manufacturer;
226 const WCHAR *releasedate;
227 const WCHAR *serialnumber;
229 struct record_computersystem
231 const WCHAR *description;
232 const WCHAR *manufacturer;
233 const WCHAR *model;
234 UINT32 num_logical_processors;
235 UINT32 num_processors;
236 UINT64 total_physical_memory;
238 struct record_logicaldisk
240 const WCHAR *device_id;
241 UINT32 drivetype;
242 const WCHAR *filesystem;
243 UINT64 freespace;
244 UINT64 size;
246 struct record_networkadapter
248 const WCHAR *device_id;
249 INT32 interface_index;
250 UINT16 netconnection_status;
251 UINT64 speed;
253 struct record_operatingsystem
255 const WCHAR *caption;
256 const WCHAR *csdversion;
257 const WCHAR *osarchitecture;
258 UINT32 oslanguage;
259 const WCHAR *systemdirectory;
261 struct record_process
263 const WCHAR *caption;
264 const WCHAR *commandline;
265 const WCHAR *description;
266 const WCHAR *handle;
267 UINT32 pprocess_id;
268 UINT32 process_id;
269 UINT32 thread_count;
271 struct record_processor
273 UINT16 cpu_status;
274 const WCHAR *device_id;
275 const WCHAR *manufacturer;
276 const WCHAR *processor_id;
278 struct record_videocontroller
280 UINT32 adapter_ram;
281 UINT32 current_bitsperpixel;
282 UINT32 current_horizontalres;
283 UINT32 current_verticalres;
284 const WCHAR *device_id;
285 const WCHAR *name;
287 #include "poppack.h"
289 static const struct record_bios data_bios[] =
291 { bios_descriptionW, bios_manufacturerW, bios_releasedateW, bios_serialnumberW }
294 static UINT get_processor_count(void)
296 SYSTEM_BASIC_INFORMATION info;
298 if (NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )) return 1;
299 return info.NumberOfProcessors;
302 static UINT64 get_total_physical_memory(void)
304 MEMORYSTATUSEX status;
306 status.dwLength = sizeof(status);
307 if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024;
308 return status.ullTotalPhys;
311 static void fill_compsys( struct table *table )
313 struct record_computersystem *rec;
315 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
317 rec = (struct record_computersystem *)table->data;
318 rec->description = compsys_descriptionW;
319 rec->manufacturer = compsys_manufacturerW;
320 rec->model = compsys_modelW;
321 rec->num_logical_processors = get_processor_count();
322 rec->num_processors = rec->num_logical_processors;
323 rec->total_physical_memory = get_total_physical_memory();
325 TRACE("created 1 row\n");
326 table->num_rows = 1;
329 static WCHAR *get_filesystem( const WCHAR *root )
331 static const WCHAR ntfsW[] = {'N','T','F','S',0};
332 WCHAR buffer[MAX_PATH + 1];
334 if (GetVolumeInformationW( root, NULL, 0, NULL, NULL, NULL, buffer, MAX_PATH + 1 ))
335 return heap_strdupW( buffer );
336 return heap_strdupW( ntfsW );
339 static UINT64 get_freespace( const WCHAR *dir, UINT64 *disksize )
341 WCHAR root[] = {'\\','\\','.','\\','A',':',0};
342 ULARGE_INTEGER free;
343 DISK_GEOMETRY_EX info;
344 HANDLE handle;
346 free.QuadPart = 512 * 1024 * 1024;
347 GetDiskFreeSpaceExW( dir, NULL, NULL, &free );
349 root[4] = dir[0];
350 handle = CreateFileW( root, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
351 if (handle != INVALID_HANDLE_VALUE)
353 if (DeviceIoControl( handle, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &info, sizeof(info), NULL, NULL ))
354 *disksize = info.DiskSize.QuadPart;
355 CloseHandle( handle );
357 return free.QuadPart;
360 static void fill_logicaldisk( struct table *table )
362 static const WCHAR fmtW[] = {'%','c',':',0};
363 WCHAR device_id[3], root[] = {'A',':','\\',0};
364 struct record_logicaldisk *rec;
365 UINT i, num_rows = 0, offset = 0, count = 4, type;
366 UINT64 size = 1024 * 1024 * 1024;
367 DWORD drives = GetLogicalDrives();
369 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) return;
371 for (i = 0; i < sizeof(drives); i++)
373 if (drives & (1 << i))
375 root[0] = 'A' + i;
376 type = GetDriveTypeW( root );
377 if (type != DRIVE_FIXED && type != DRIVE_CDROM && type != DRIVE_REMOVABLE)
378 continue;
380 if (num_rows > count)
382 BYTE *data;
383 count *= 2;
384 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) return;
385 table->data = data;
387 rec = (struct record_logicaldisk *)(table->data + offset);
388 sprintfW( device_id, fmtW, 'A' + i );
389 rec->device_id = heap_strdupW( device_id );
390 rec->drivetype = type;
391 rec->filesystem = get_filesystem( root );
392 rec->freespace = get_freespace( root, &size );
393 rec->size = size;
394 offset += sizeof(*rec);
395 num_rows++;
398 TRACE("created %u rows\n", num_rows);
399 table->num_rows = num_rows;
402 static UINT16 get_connection_status( IF_OPER_STATUS status )
404 switch (status)
406 case IfOperStatusDown:
407 return 0; /* Disconnected */
408 case IfOperStatusUp:
409 return 2; /* Connected */
410 default:
411 ERR("unhandled status %u\n", status);
412 break;
414 return 0;
417 static void fill_networkadapter( struct table *table )
419 static const WCHAR fmtW[] = {'%','u',0};
420 WCHAR device_id[11];
421 struct record_networkadapter *rec;
422 IP_ADAPTER_ADDRESSES *aa, *buffer;
423 UINT num_rows = 0, offset = 0;
424 DWORD size = 0, ret;
426 ret = GetAdaptersAddresses( AF_UNSPEC, 0, NULL, NULL, &size );
427 if (ret != ERROR_BUFFER_OVERFLOW) return;
429 if (!(buffer = heap_alloc( size ))) return;
430 if (GetAdaptersAddresses( AF_UNSPEC, 0, NULL, buffer, &size ))
432 heap_free( buffer );
433 return;
435 for (aa = buffer; aa; aa = aa->Next) num_rows++;
436 if (!(table->data = heap_alloc( sizeof(*rec) * num_rows )))
438 heap_free( buffer );
439 return;
441 for (aa = buffer; aa; aa = aa->Next)
443 rec = (struct record_networkadapter *)(table->data + offset);
444 sprintfW( device_id, fmtW, aa->u.s.IfIndex );
445 rec->device_id = heap_strdupW( device_id );
446 rec->interface_index = aa->u.s.IfIndex;
447 rec->netconnection_status = get_connection_status( aa->OperStatus );
448 rec->speed = 1000000;
449 offset += sizeof(*rec);
451 TRACE("created %u rows\n", num_rows);
452 table->num_rows = num_rows;
454 heap_free( buffer );
457 static WCHAR *get_cmdline( DWORD process_id )
459 if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
460 return NULL; /* FIXME handle different process case */
463 static void fill_process( struct table *table )
465 static const WCHAR fmtW[] = {'%','u',0};
466 WCHAR handle[11];
467 struct record_process *rec;
468 PROCESSENTRY32W entry;
469 HANDLE snap;
470 UINT num_rows = 0, offset = 0, count = 8;
472 snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
473 if (snap == INVALID_HANDLE_VALUE) return;
475 entry.dwSize = sizeof(entry);
476 if (!Process32FirstW( snap, &entry )) goto done;
477 if (!(table->data = heap_alloc( count * sizeof(*rec) ))) goto done;
481 if (num_rows > count)
483 BYTE *data;
484 count *= 2;
485 if (!(data = heap_realloc( table->data, count * sizeof(*rec) ))) goto done;
486 table->data = data;
488 rec = (struct record_process *)(table->data + offset);
489 rec->caption = heap_strdupW( entry.szExeFile );
490 rec->commandline = get_cmdline( entry.th32ProcessID );
491 rec->description = heap_strdupW( entry.szExeFile );
492 sprintfW( handle, fmtW, entry.th32ProcessID );
493 rec->handle = heap_strdupW( handle );
494 rec->process_id = entry.th32ProcessID;
495 rec->pprocess_id = entry.th32ParentProcessID;
496 rec->thread_count = entry.cntThreads;
497 offset += sizeof(*rec);
498 num_rows++;
499 } while (Process32NextW( snap, &entry ));
501 TRACE("created %u rows\n", num_rows);
502 table->num_rows = num_rows;
504 done:
505 CloseHandle( snap );
508 static inline void do_cpuid( unsigned int ax, unsigned int *p )
510 #ifdef __i386__
511 __asm__("pushl %%ebx\n\t"
512 "cpuid\n\t"
513 "movl %%ebx, %%esi\n\t"
514 "popl %%ebx"
515 : "=a" (p[0]), "=S" (p[1]), "=c" (p[2]), "=d" (p[3])
516 : "0" (ax));
517 #endif
520 static void fill_processor( struct table *table )
522 static const WCHAR fmtW[] = {'C','P','U','%','u',0};
523 static const WCHAR fmt_cpuidW[] = {'%','0','8','X','%','0','8','X',0};
524 WCHAR device_id[14], cpu_id[17];
525 struct record_processor *rec;
526 UINT i, offset = 0, count = get_processor_count();
527 unsigned int regs[4] = {0, 0, 0, 0};
529 if (!(table->data = heap_alloc( sizeof(*rec) * count ))) return;
531 do_cpuid( 1, regs );
532 sprintfW( cpu_id, fmt_cpuidW, regs[3], regs[0] );
533 for (i = 0; i < count; i++)
535 rec = (struct record_processor *)(table->data + offset);
536 rec->cpu_status = 1; /* CPU Enabled */
537 rec->manufacturer = processor_manufacturerW;
538 sprintfW( device_id, fmtW, i );
539 rec->device_id = heap_strdupW( device_id );
540 rec->processor_id = heap_strdupW( cpu_id );
541 offset += sizeof(*rec);
544 TRACE("created %u rows\n", count);
545 table->num_rows = count;
548 static void fill_os( struct table *table )
550 struct record_operatingsystem *rec;
551 WCHAR path[MAX_PATH];
552 SYSTEM_INFO info;
553 void *redir;
555 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
557 rec = (struct record_operatingsystem *)table->data;
558 rec->caption = os_captionW;
559 rec->csdversion = os_csdversionW;
561 GetNativeSystemInfo( &info );
562 if (info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
563 rec->osarchitecture = os_64bitW;
564 else
565 rec->osarchitecture = os_32bitW;
567 rec->oslanguage = MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US );
569 Wow64DisableWow64FsRedirection( &redir );
570 GetSystemDirectoryW( path, MAX_PATH );
571 Wow64RevertWow64FsRedirection( redir );
572 rec->systemdirectory = heap_strdupW( path );
574 TRACE("created 1 row\n");
575 table->num_rows = 1;
578 static UINT32 get_bits_per_pixel( UINT *hres, UINT *vres )
580 HDC hdc = GetDC( NULL );
581 UINT32 ret;
583 if (!hdc) return 32;
584 ret = GetDeviceCaps( hdc, BITSPIXEL );
585 *hres = GetDeviceCaps( hdc, HORZRES );
586 *vres = GetDeviceCaps( hdc, VERTRES );
587 ReleaseDC( NULL, hdc );
588 return ret;
591 static void fill_videocontroller( struct table *table )
594 struct record_videocontroller *rec;
595 HRESULT hr;
596 IDXGIFactory *factory = NULL;
597 IDXGIAdapter *adapter = NULL;
598 DXGI_ADAPTER_DESC desc;
599 UINT hres = 1024, vres = 768, vidmem = 512 * 1024 * 1024;
600 const WCHAR *name = videocontroller_deviceidW;
602 if (!(table->data = heap_alloc( sizeof(*rec) ))) return;
604 hr = CreateDXGIFactory( &IID_IDXGIFactory, (void **)&factory );
605 if (FAILED(hr)) goto done;
607 hr = IDXGIFactory_EnumAdapters( factory, 0, &adapter );
608 if (FAILED(hr)) goto done;
610 hr = IDXGIAdapter_GetDesc( adapter, &desc );
611 if (SUCCEEDED(hr))
613 vidmem = desc.DedicatedVideoMemory;
614 name = desc.Description;
617 done:
618 rec = (struct record_videocontroller *)table->data;
619 rec->adapter_ram = vidmem;
620 rec->current_bitsperpixel = get_bits_per_pixel( &hres, &vres );
621 rec->current_horizontalres = hres;
622 rec->current_verticalres = vres;
623 rec->device_id = videocontroller_deviceidW;
624 rec->name = heap_strdupW( name );
626 TRACE("created 1 row\n");
627 table->num_rows = 1;
629 if (adapter) IDXGIAdapter_Release( adapter );
630 if (factory) IDXGIFactory_Release( factory );
633 static struct table classtable[] =
635 { class_biosW, SIZEOF(col_bios), col_bios, SIZEOF(data_bios), (BYTE *)data_bios, NULL },
636 { class_compsysW, SIZEOF(col_compsys), col_compsys, 0, NULL, fill_compsys },
637 { class_logicaldiskW, SIZEOF(col_logicaldisk), col_logicaldisk, 0, NULL, fill_logicaldisk },
638 { class_networkadapterW, SIZEOF(col_networkadapter), col_networkadapter, 0, NULL, fill_networkadapter },
639 { class_osW, SIZEOF(col_os), col_os, 0, NULL, fill_os },
640 { class_processW, SIZEOF(col_process), col_process, 0, NULL, fill_process },
641 { class_processorW, SIZEOF(col_processor), col_processor, 0, NULL, fill_processor },
642 { class_videocontrollerW, SIZEOF(col_videocontroller), col_videocontroller, 0, NULL, fill_videocontroller }
645 struct table *get_table( const WCHAR *name )
647 UINT i;
648 struct table *table = NULL;
650 for (i = 0; i < SIZEOF(classtable); i++)
652 if (!strcmpiW( classtable[i].name, name ))
654 table = &classtable[i];
655 if (table->fill && !table->data) table->fill( table );
656 break;
659 return table;