Module: wine Branch: master Commit: de6db1154330a0a6b58c703c9c504c1058ef4faa URL: https://source.winehq.org/git/wine.git/?a=commit;h=de6db1154330a0a6b58c703c9...
Author: Isabella Bosia ibosia@codeweavers.com Date: Tue Sep 1 12:41:17 2020 +0100
ndis.sys: Create network card registry keys.
Signed-off-by: Isabella Bosia ibosia@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ndis.sys/Makefile.in | 1 + dlls/ndis.sys/main.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)
diff --git a/dlls/ndis.sys/Makefile.in b/dlls/ndis.sys/Makefile.in index fa69910f16..0d58cb0d38 100644 --- a/dlls/ndis.sys/Makefile.in +++ b/dlls/ndis.sys/Makefile.in @@ -1,4 +1,5 @@ MODULE = ndis.sys +IMPORTS = advapi32 ntoskrnl iphlpapi EXTRADLLFLAGS = -Wl,--subsystem,native -mno-cygwin
C_SRCS = \ diff --git a/dlls/ndis.sys/main.c b/dlls/ndis.sys/main.c index 90c8c3cc88..3004f6e76f 100644 --- a/dlls/ndis.sys/main.c +++ b/dlls/ndis.sys/main.c @@ -21,21 +21,70 @@
#include <stdarg.h>
+#define NONAMELESSUNION #include "ntstatus.h" #define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" #include "winternl.h" +#include "winioctl.h" +#include "winsock2.h" +#include "ws2ipdef.h" +#include "iphlpapi.h" +#include "netioapi.h" +#include "ntddndis.h" #include "ddk/wdm.h" #include "ddk/ndis.h" +#include "winreg.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ndis);
+static void add_key(const WCHAR *guidstrW, const MIB_IF_ROW2 *netdev) +{ + HKEY card_key; + WCHAR keynameW[100]; + + swprintf( keynameW, ARRAY_SIZE(keynameW), L"Software\Microsoft\Windows NT\CurrentVersion\NetworkCards\%d", netdev->InterfaceIndex ); + if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, keynameW, 0, NULL, + REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &card_key, NULL ) == ERROR_SUCCESS) + { + RegSetValueExW( card_key, L"Description", 0, REG_SZ, (BYTE *)netdev->Description, (lstrlenW(netdev->Description) + 1) * sizeof(WCHAR) ); + RegSetValueExW( card_key, L"ServiceName", 0, REG_SZ, (BYTE *)guidstrW, (lstrlenW(guidstrW) + 1) * sizeof(WCHAR) ); + RegCloseKey( card_key ); + } +} + +static void create_network_devices(DRIVER_OBJECT *driver) +{ + MIB_IF_TABLE2 *table; + ULONG i; + + if (GetIfTable2( &table ) != NO_ERROR) + return; + + for (i = 0; i < table->NumEntries; i++) + { + GUID *guid = &table->Table[i].InterfaceGuid; + WCHAR guidstrW[39]; + + swprintf( guidstrW, ARRAY_SIZE(guidstrW), L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", + guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], + guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], + guid->Data4[6], guid->Data4[7] ); + + add_key( guidstrW, &table->Table[i] ); + } + + FreeMibTable( table ); +} + NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) { TRACE("(%p, %s)\n", driver, debugstr_w(path->Buffer));
+ create_network_devices( driver ); + return STATUS_SUCCESS; }