[PATCH v2 4/7] ndis.sys: Create network card registry keys.
Isabella Bosia
ibosia at codeweavers.com
Tue Sep 1 06:41:17 CDT 2020
Signed-off-by: Isabella Bosia <ibosia at codeweavers.com>
---
dlls/ndis.sys/Makefile.in | 1 +
dlls/ndis.sys/main.c | 50 +++++++++++++++++++++++++++++++++++++++
2 files changed, 51 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..6dd444a657 100644
--- a/dlls/ndis.sys/main.c
+++ b/dlls/ndis.sys/main.c
@@ -21,21 +21,71 @@
#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 "ntddndis.h"
#include "ddk/wdm.h"
#include "ddk/ndis.h"
+#include "winreg.h"
#include "wine/debug.h"
+#include <winsock2.h>
+#include <ws2ipdef.h>
+#include <iphlpapi.h>
+#include <netioapi.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;
}
--
2.25.1
More information about the wine-devel
mailing list