Commit 828304da authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

wbemprox: Use correct string id.

Don't use hard coded string indexes as one of the expected string can be absent, hence decreasing its index; nothing ensures that the strings are placed in the order of the fields in the smbios structure. So use, smbios structures' indexes instead. Wbemprox was also expecting one string too much. Signed-off-by: 's avatarEric Pouech <epouech@codeweavers.com>
parent ed674d63
......@@ -77,7 +77,7 @@ static const struct column col_bios[] =
{ L"Manufacturer", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"Name", CIM_STRING },
{ L"ReleaseDate", CIM_DATETIME|COL_FLAG_DYNAMIC },
{ L"SerialNumber", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"SerialNumber", CIM_STRING },
{ L"SMBIOSBIOSVersion", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"SMBIOSMajorVersion", CIM_UINT16 },
{ L"SMBIOSMinorVersion", CIM_UINT16 },
......@@ -1245,7 +1245,7 @@ static const struct smbios_header *find_smbios_entry( enum smbios_type type, con
return hdr;
}
static WCHAR *get_smbios_string( BYTE id, const char *buf, UINT offset, UINT buflen )
static WCHAR *get_smbios_string_by_id( BYTE id, const char *buf, UINT offset, UINT buflen )
{
const char *ptr = buf + offset;
UINT i = 0;
......@@ -1259,43 +1259,43 @@ static WCHAR *get_smbios_string( BYTE id, const char *buf, UINT offset, UINT buf
return NULL;
}
static WCHAR *get_baseboard_string( BYTE id, const char *buf, UINT len )
static WCHAR *get_smbios_string( enum smbios_type type, size_t field_offset, const char *buf, UINT len )
{
const struct smbios_header *hdr;
const struct smbios_baseboard *baseboard;
UINT offset;
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BASEBOARD, buf, len ))) return NULL;
if (!(hdr = find_smbios_entry( type, buf, len ))) return NULL;
baseboard = (const struct smbios_baseboard *)hdr;
offset = (const char *)baseboard - buf + baseboard->hdr.length;
return get_smbios_string( id, buf, offset, len );
if (field_offset + sizeof(BYTE) > hdr->length) return NULL;
offset = (const char *)hdr - buf + hdr->length;
return get_smbios_string_by_id( ((const BYTE *)hdr)[field_offset], buf, offset, len );
}
static WCHAR *get_baseboard_manufacturer( const char *buf, UINT len )
{
WCHAR *ret = get_baseboard_string( 1, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BASEBOARD, offsetof(struct smbios_baseboard, vendor), buf, len );
if (!ret) return wcsdup( L"Intel Corporation" );
return ret;
}
static WCHAR *get_baseboard_product( const char *buf, UINT len )
{
WCHAR *ret = get_baseboard_string( 2, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BASEBOARD, offsetof(struct smbios_baseboard, product), buf, len );
if (!ret) return wcsdup( L"Base Board" );
return ret;
}
static WCHAR *get_baseboard_serialnumber( const char *buf, UINT len )
{
WCHAR *ret = get_baseboard_string( 4, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BASEBOARD, offsetof(struct smbios_baseboard, serial), buf, len );
if (!ret) return wcsdup( L"None" );
return ret;
}
static WCHAR *get_baseboard_version( const char *buf, UINT len )
{
WCHAR *ret = get_baseboard_string( 3, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BASEBOARD, offsetof(struct smbios_baseboard, version), buf, len );
if (!ret) return wcsdup( L"1.0" );
return ret;
}
......@@ -1344,23 +1344,9 @@ static UINT16 get_bios_smbiosminorversion( const char *buf, UINT len )
if (len < sizeof(*prologue)) return 0;
return prologue->minor_version;
}
static WCHAR *get_bios_string( BYTE id, const char *buf, UINT len )
{
const struct smbios_header *hdr;
const struct smbios_bios *bios;
UINT offset;
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BIOS, buf, len ))) return NULL;
bios = (const struct smbios_bios *)hdr;
offset = (const char *)bios - buf + bios->hdr.length;
return get_smbios_string( id, buf, offset, len );
}
static WCHAR *get_bios_manufacturer( const char *buf, UINT len )
{
WCHAR *ret = get_bios_string( 1, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BIOS, offsetof(struct smbios_bios, vendor), buf, len );
if (!ret) return wcsdup( L"The Wine Project" );
return ret;
}
......@@ -1398,22 +1384,15 @@ static WCHAR *convert_bios_date( const WCHAR *str )
static WCHAR *get_bios_releasedate( const char *buf, UINT len )
{
WCHAR *ret, *date = get_bios_string( 3, buf, len );
WCHAR *ret, *date = get_smbios_string( SMBIOS_TYPE_BIOS, offsetof(struct smbios_bios, date), buf, len );
if (!date || !(ret = convert_bios_date( date ))) ret = wcsdup( L"20120608000000.000000+000" );
free( date );
return ret;
}
static WCHAR *get_bios_serialnumber( const char *buf, UINT len )
{
WCHAR *ret = get_bios_string( 4, buf, len );
if (!ret) return wcsdup( L"0" );
return ret;
}
static WCHAR *get_bios_smbiosbiosversion( const char *buf, UINT len )
{
WCHAR *ret = get_bios_string( 2, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_BIOS, offsetof(struct smbios_bios, version), buf, len );
if (!ret) return wcsdup( L"Wine" );
return ret;
}
......@@ -1488,7 +1467,7 @@ static enum fill_status fill_bios( struct table *table, const struct expr *cond
rec->manufacturer = get_bios_manufacturer( buf, len );
rec->name = L"Default System BIOS";
rec->releasedate = get_bios_releasedate( buf, len );
rec->serialnumber = get_bios_serialnumber( buf, len );
rec->serialnumber = L"Serial number";
rec->smbiosbiosversion = get_bios_smbiosbiosversion( buf, len );
rec->smbiosmajorversion = get_bios_smbiosmajorversion( buf, len );
rec->smbiosminorversion = get_bios_smbiosminorversion( buf, len );
......@@ -1669,29 +1648,16 @@ 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 );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_SYSTEM, offsetof(struct smbios_system, product), 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 );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_SYSTEM, offsetof(struct smbios_system, vendor), buf, len );
if (!ret) return wcsdup( L"The Wine Project" );
return ret;
}
......@@ -1733,7 +1699,7 @@ static enum fill_status fill_compsys( struct table *table, const struct expr *co
static WCHAR *get_compsysproduct_identifyingnumber( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 4, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_SYSTEM, offsetof(struct smbios_system, serial), buf, len );
if (!ret) return wcsdup( L"0" );
return ret;
}
......@@ -1761,7 +1727,7 @@ done:
static WCHAR *get_compsysproduct_version( const char *buf, UINT len )
{
WCHAR *ret = get_compsysproduct_string( 3, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_SYSTEM, offsetof(struct smbios_system, version), buf, len );
if (!ret) return wcsdup( L"1.0" );
return ret;
}
......@@ -4054,22 +4020,9 @@ static enum fill_status fill_sid( struct table *table, const struct expr *cond )
return FILL_STATUS_FILTERED;
}
static WCHAR *get_systemenclosure_string( BYTE id, const char *buf, UINT len )
{
const struct smbios_header *hdr;
const struct smbios_chassis *chassis;
UINT offset;
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_CHASSIS, buf, len ))) return NULL;
chassis = (const struct smbios_chassis *)hdr;
offset = (const char *)chassis - buf + chassis->hdr.length;
return get_smbios_string( id, buf, offset, len );
}
static WCHAR *get_systemenclosure_manufacturer( const char *buf, UINT len )
{
WCHAR *ret = get_systemenclosure_string( 1, buf, len );
WCHAR *ret = get_smbios_string( SMBIOS_TYPE_CHASSIS, offsetof(struct smbios_chassis, vendor), buf, len );
if (!ret) return wcsdup( L"Wine" );
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment