ndis.sys: Create network card registry keys.

Signed-off-by: Isabella Bosia <ibosia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Isabella Bosia 2020-09-01 12:41:17 +01:00 committed by Alexandre Julliard
parent 7c1dd57b4f
commit de6db11543
2 changed files with 50 additions and 0 deletions

View File

@ -1,4 +1,5 @@
MODULE = ndis.sys
IMPORTS = advapi32 ntoskrnl iphlpapi
EXTRADLLFLAGS = -Wl,--subsystem,native -mno-cygwin
C_SRCS = \

View File

@ -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;
}