[PATCH 3/5] mountmgr.sys: Create network card registry keys.

Zebediah Figura zfigura at codeweavers.com
Wed Aug 26 10:05:12 CDT 2020


Hello Isabella, thanks for the patch! I have a few comments inlined.

On 8/25/20 9:32 AM, Isabella Bosia wrote:
> This really belongs to ndis.sys, but it's in mountmgr to reduce the
> number of winedevice processes.

Perhaps a better way to avoid this would be to use service groups? I.e.
LoadOrderGroup, set by the service registry information in wine.inf.

> 
> Signed-off-by: Isabella Bosia <ibosia at codeweavers.com>
> ---
>  dlls/mountmgr.sys/Makefile.in |  3 +-
>  dlls/mountmgr.sys/mountmgr.c  |  4 ++
>  dlls/mountmgr.sys/mountmgr.h  |  1 +
>  dlls/mountmgr.sys/ndis.c      | 98 +++++++++++++++++++++++++++++++++++
>  4 files changed, 105 insertions(+), 1 deletion(-)
>  create mode 100644 dlls/mountmgr.sys/ndis.c
> 
> diff --git a/dlls/mountmgr.sys/Makefile.in b/dlls/mountmgr.sys/Makefile.in
> index e229164280..fe3871366b 100644
> --- a/dlls/mountmgr.sys/Makefile.in
> +++ b/dlls/mountmgr.sys/Makefile.in
> @@ -9,4 +9,5 @@ C_SRCS = \
>  	dbus.c \
>  	device.c \
>  	diskarb.c \
> -	mountmgr.c
> +	mountmgr.c \
> +	ndis.c
> diff --git a/dlls/mountmgr.sys/mountmgr.c b/dlls/mountmgr.sys/mountmgr.c
> index 1961eab983..4962e11596 100644
> --- a/dlls/mountmgr.sys/mountmgr.c
> +++ b/dlls/mountmgr.sys/mountmgr.c
> @@ -583,6 +583,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
>      static const WCHAR harddiskW[] = {'\\','D','r','i','v','e','r','\\','H','a','r','d','d','i','s','k',0};
>      static const WCHAR driver_serialW[] = {'\\','D','r','i','v','e','r','\\','S','e','r','i','a','l',0};
>      static const WCHAR driver_parallelW[] = {'\\','D','r','i','v','e','r','\\','P','a','r','a','l','l','e','l',0};
> +    static const WCHAR driver_ndisW[] = {'\\','D','r','i','v','e','r','\\','N','D','I','S',0};
>      static const WCHAR devicemapW[] = {'H','A','R','D','W','A','R','E','\\','D','E','V','I','C','E','M','A','P','\\','S','c','s','i',0};
>  
>  #ifdef _WIN64
> @@ -643,5 +644,8 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
>      RtlInitUnicodeString( &nameW, driver_parallelW );
>      IoCreateDriver( &nameW, parallel_driver_entry );
>  
> +    RtlInitUnicodeString( &nameW, driver_ndisW );
> +    IoCreateDriver( &nameW, ndis_driver_entry );
> +
>      return status;
>  }
> diff --git a/dlls/mountmgr.sys/mountmgr.h b/dlls/mountmgr.sys/mountmgr.h
> index 5fb43119c6..4ee2ba16e8 100644
> --- a/dlls/mountmgr.sys/mountmgr.h
> +++ b/dlls/mountmgr.sys/mountmgr.h
> @@ -65,6 +65,7 @@ extern NTSTATUS query_unix_device( ULONGLONG unix_dev, enum device_type *type,
>  extern NTSTATUS WINAPI harddisk_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
>  extern NTSTATUS WINAPI serial_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
>  extern NTSTATUS WINAPI parallel_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
> +extern NTSTATUS WINAPI ndis_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path ) DECLSPEC_HIDDEN;
>  
>  /* SCSI entry functions */
>  
> diff --git a/dlls/mountmgr.sys/ndis.c b/dlls/mountmgr.sys/ndis.c
> new file mode 100644
> index 0000000000..0a3f87d410
> --- /dev/null
> +++ b/dlls/mountmgr.sys/ndis.c
> @@ -0,0 +1,98 @@
> +/*
> + * NDIS Ioctl support
> + *
> + * Copyright 2020 Isabella Bosia
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
> + */
> +
> +#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 char *guidstr, const MIB_IF_ROW2 *netdev)
> +{
> +    HKEY card_key;
> +    char keyname[100];
> +    char description[MAX_ADAPTER_NAME_LENGTH + 4];
> +
> +    snprintf( keyname, sizeof(keyname),
> +              "Software\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\%d", netdev->InterfaceIndex );
> +    WideCharToMultiByte( CP_ACP, 0, netdev->Description, -1, description, sizeof(description), NULL, NULL );
> +
> +    if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, keyname, 0, NULL,
> +                 REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &card_key, NULL ) == ERROR_SUCCESS)
> +    {
> +        RegSetValueExA( card_key, "Description", 0, REG_SZ, (unsigned char *)description, strlen(description) );
> +        RegSetValueExA( card_key, "ServiceName", 0, REG_SZ, (unsigned char *)guidstr, strlen(guidstr) );

As annoying as it is, we probably want these to be W APIs. [On the other
hand, if we do put this in ndis.sys, it gets probably much less annoying.]

> +        RegCloseKey( card_key );
> +    }
> +}
> +
> +static int add_device(DRIVER_OBJECT *driver, const char *guidstr, MIB_IF_ROW2 *netdev)
> +{
> +    return 1;
> +}

I think this function would be better introduced in the following patch.

> +
> +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;
> +        char guidstr[39];
> +
> +        sprintf( guidstr, "{%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] );
> +        if (add_device( driver, guidstr, &table->Table[i] ))
> +            add_key( guidstr, &table->Table[i] );
> +    }
> +
> +    FreeMibTable( table );
> +}
> +
> +NTSTATUS WINAPI ndis_driver_entry(DRIVER_OBJECT *driver, UNICODE_STRING *path)
> +{
> +    TRACE("(%p, %s)\n", driver, debugstr_w(path->Buffer));
> +
> +    create_network_devices( driver );
> +
> +    return STATUS_SUCCESS;
> +}
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200826/f05481c7/attachment.sig>


More information about the wine-devel mailing list