Stefan Rentsch : wbemprox: Provide more accurate system information.

Alexandre Julliard julliard at winehq.org
Thu Jul 7 17:04:37 CDT 2022


Module: wine
Branch: master
Commit: fefe108e2043d8a9d993b4e2cb129c851ca5e795
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fefe108e2043d8a9d993b4e2cb129c851ca5e795

Author: Stefan Rentsch <et14rest at gmail.com>
Date:   Tue Jul  5 14:28:30 2022 +0200

wbemprox: Provide more accurate system information.

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

---

 dlls/wbemprox/builtin.c | 67 +++++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 4ac52918f6f..820fb61930f 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -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();
@@ -1647,24 +1679,13 @@ 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 );
@@ -1672,13 +1693,6 @@ static WCHAR *get_compsysproduct_identifyingnumber( const char *buf, UINT len )
     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};
@@ -1700,13 +1714,6 @@ done:
     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 );




More information about the wine-cvs mailing list