Skip to content

Commit

Permalink
wbemprox: Provide more accurate system information.
Browse files Browse the repository at this point in the history
This re-uses existing functions from Win32_ComputerSystemProduct to provide
more accurate values, which are helpful to system overview applications.

> wmic.exe computersystem GET Manufacturer
  • Loading branch information
Stefan Rentsch authored and julliard committed Jul 7, 2022
1 parent a6063f8 commit fefe108
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions dlls/wbemprox/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,20 +1625,52 @@ static WCHAR *get_username(void)
return ret;
}

static WCHAR *get_compsysproduct_string( BYTE id, const char *buf, UINT len )
{
const struct smbios_header *hdr;
const struct smbios_system *system;
UINT offset;

if (!(hdr = find_smbios_entry( SMBIOS_TYPE_SYSTEM, buf, len ))) return NULL;

system = (const struct smbios_system *)hdr;
offset = (const char *)system - buf + system->hdr.length;
return get_smbios_string( id, buf, offset, len );
}

static WCHAR *get_compsysproduct_name( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 2, buf, len );
if (!ret) return wcsdup( L"Wine" );
return ret;
}

static WCHAR *get_compsysproduct_vendor( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 1, buf, len );
if (!ret) return wcsdup( L"The Wine Project" );
return ret;
}

static enum fill_status fill_compsys( struct table *table, const struct expr *cond )
{
struct record_computersystem *rec;
enum fill_status status = FILL_STATUS_UNFILTERED;
UINT row = 0;
UINT row = 0, len;
char *buf;

if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED;

len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
if (!(buf = malloc( len ))) return FILL_STATUS_FAILED;
GetSystemFirmwareTable( RSMB, 0, buf, len );

rec = (struct record_computersystem *)table->data;
rec->description = L"AT/AT COMPATIBLE";
rec->domain = L"WORKGROUP";
rec->domainrole = 0; /* standalone workstation */
rec->manufacturer = L"The Wine Project";
rec->model = L"Wine";
rec->manufacturer = get_compsysproduct_vendor( buf, len );
rec->model = get_compsysproduct_name( buf, len );
rec->name = get_computername();
rec->num_logical_processors = get_logical_processor_count( NULL, &rec->num_processors );
rec->systemtype = get_systemtype();
Expand All @@ -1647,38 +1679,20 @@ static enum fill_status fill_compsys( struct table *table, const struct expr *co
if (!match_row( table, row, cond, &status )) free_row_values( table, row );
else row++;

free( buf );

TRACE("created %u rows\n", row);
table->num_rows = row;
return status;
}

static WCHAR *get_compsysproduct_string( BYTE id, const char *buf, UINT len )
{
const struct smbios_header *hdr;
const struct smbios_system *system;
UINT offset;

if (!(hdr = find_smbios_entry( SMBIOS_TYPE_SYSTEM, buf, len ))) return NULL;

system = (const struct smbios_system *)hdr;
offset = (const char *)system - buf + system->hdr.length;
return get_smbios_string( id, buf, offset, len );
}

static WCHAR *get_compsysproduct_identifyingnumber( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 4, buf, len );
if (!ret) return wcsdup( L"0" );
return ret;
}

static WCHAR *get_compsysproduct_name( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 2, buf, len );
if (!ret) return wcsdup( L"Wine" );
return ret;
}

static WCHAR *get_compsysproduct_uuid( const char *buf, UINT len )
{
static const BYTE none[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
Expand All @@ -1700,13 +1714,6 @@ static WCHAR *get_compsysproduct_uuid( const char *buf, UINT len )
return ret;
}

static WCHAR *get_compsysproduct_vendor( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 1, buf, len );
if (!ret) return wcsdup( L"The Wine Project" );
return ret;
}

static WCHAR *get_compsysproduct_version( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 3, buf, len );
Expand Down

0 comments on commit fefe108

Please sign in to comment.