[PATCH v2 2/2] wbemprox: Get the device ID of the network adapter from the registry.
Haoyang Chen
chenhaoyang at uniontech.com
Mon Jul 19 21:50:20 CDT 2021
Signed-off-by: Haoyang Chen <chenhaoyang at uniontech.com>
---
dlls/wbemprox/builtin.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 862c461d8b7..69bd548e032 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -2712,6 +2712,32 @@ static WCHAR *get_networkadapter_guid( const IF_LUID *luid )
return guid_to_str( &guid );
}
+static WCHAR *get_networkadapter_deviceid(const WCHAR *guid)
+{
+ HKEY key;
+ WCHAR keynameW[256];
+ WCHAR *ret;
+ DWORD size = 256;
+
+ if (!guid) return NULL;
+
+ swprintf( keynameW, ARRAY_SIZE(keynameW), L"System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", guid);
+ if (RegOpenKeyW( HKEY_LOCAL_MACHINE, keynameW, &key )) return NULL;
+ if (!(ret = heap_alloc( size * sizeof(WCHAR) )))
+ {
+ RegCloseKey(key);
+ return NULL;
+ }
+
+ if(RegQueryValueExW(key, L"PnpInstanceID", NULL, NULL, (BYTE *)ret, &size))
+ {
+ heap_free(ret);
+ ret = NULL;
+ }
+ RegCloseKey(key);
+ return ret;
+}
+
static enum fill_status fill_networkadapter( struct table *table, const struct expr *cond )
{
WCHAR device_id[11];
@@ -2758,7 +2784,7 @@ static enum fill_status fill_networkadapter( struct table *table, const struct e
rec->name = heap_strdupW( aa->FriendlyName );
rec->netconnection_status = get_connection_status( aa->OperStatus );
rec->physicaladapter = physical;
- rec->pnpdevice_id = L"PCI\\VEN_8086&DEV_100E&SUBSYS_001E8086&REV_02\\3&267A616A&1&18";
+ rec->pnpdevice_id = get_networkadapter_deviceid(rec->guid);
rec->servicename = heap_strdupW( aa->FriendlyName );
rec->speed = 1000000;
if (!match_row( table, row, cond, &status ))
--
2.20.1
More information about the wine-devel
mailing list