在 2021/7/19 下午3:16, Huw Davies 写道:
On Thu, Jul 15, 2021 at 03:09:41PM +0800, Haoyang Chen wrote:
Signed-off-by: Haoyang Chen chenhaoyang@uniontech.com
loader/wine.inf.in | 7 ++ programs/wineboot/Makefile.in | 2 +- programs/wineboot/wineboot.c | 119 ++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-)
diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 92276fcbe76..1d3a43fedff 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -79,6 +79,8 @@ #include <setupapi.h> #include <newdev.h> #include "resource.h" +#include "initguid.h" +#include <wbemcli.h>
WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
@@ -1586,6 +1588,122 @@ done: return ret; }
+static HRESULT query_property(IWbemClassObject *obj, const WCHAR *prop, WCHAR *buf, DWORD bufLen ) +{
- CIMTYPE type = 0xdeadbeef;
- VARIANT val;
- HRESULT hr = S_OK;
- if (!buf || !bufLen) return WBEM_E_INVALID_QUERY;
- VariantInit( &val );
- hr = IWbemClassObject_Get( obj, prop, 0, &val, &type, NULL );
- if (hr != S_OK) return hr;
- if (V_VT(&val) == VT_BSTR)
wcscpy(buf,V_BSTR(&val));
- else
hr = WBEM_E_INVALID_QUERY_TYPE;
- VariantClear( &val );
- return hr;
+}
+static void insert_adapter(HKEY hkey, IWbemClassObject *obj) +{
- WCHAR value[MAX_PATH];
- WCHAR connection[MAX_PATH];
- HKEY subhkey;
- LSTATUS status;
- static int index = 0;
- if (S_OK != query_property( obj, L"GUID", value, ARRAYSIZE(value)))
return;
- swprintf( connection, ARRAYSIZE(connection), L"%s\Connection", value);
- if ((status = RegCreateKeyExW( hkey, connection, 0, NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &subhkey, NULL )))
return;
- set_reg_value_dword(subhkey, L"DefaultNameIndex", index++);
- set_reg_value_dword(subhkey, L"DefaultNameResourceId", 0x709); /* FIXME */
- if (S_OK == query_property( obj, L"Name", value, ARRAYSIZE(value)))
set_reg_value(subhkey, L"Name", value);
- if (S_OK == query_property( obj, L"PNPDeviceID", value, ARRAYSIZE(value)))
set_reg_value(subhkey, L"PnpInstanceID", value);
- RegCloseKey( subhkey );
+}
We're already adding some network card keys in ndis.sys, so probably this should go there instead of wineboot.
Also, which is these does the app you're looking at actually need? I don't see DefaultNameIndex and DefaultNameResourceId in my Windows 10 VM and don't see PnpInstanceID on many of the adaptors in my Windows 7 VM.
Huw.
Hi,
There is an application which needs to query the "real" MAC address.
It first enumerates all the MAC addresses through the GetAdaptersInfo()
function, and then goes to the registry to look up the PnpInstanceID
value of the corresponding network card. It does not query the
ndis.sys key. I tested this on Windows 7.
Haoyang.