From: Bernhard Subject: Re: [PATCH] netprofm: Fix connection_GetAdapterId return wrong GUID. Message-Id: Date: Wed, 24 Feb 2021 20:27:19 +0100 In-Reply-To: <20210208220355.225975-1-besentv@gmail.com> References: <20210208220355.225975-1-besentv@gmail.com> Hey everyone, I submitted this recently and just wanted to ask for an official feedback/review on this patch. I'm not really familiar with the Wine codebase, so good advice is appreciated. Greetings Bernhard On Mon, Feb 8, 2021 at 11:03 PM Bernhard Kölbl wrote: > The index of a network interface is not a valid GUID. > AdapterName holds the correct GUID and should be used instead. > > Signed-off-by: Bernhard Kölbl > --- > dlls/netprofm/Makefile.in | 2 +- > dlls/netprofm/list.c | 12 ++++++++---- > 2 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/dlls/netprofm/Makefile.in b/dlls/netprofm/Makefile.in > index d57d1d60c45..3d1d225d3df 100644 > --- a/dlls/netprofm/Makefile.in > +++ b/dlls/netprofm/Makefile.in > @@ -1,5 +1,5 @@ > MODULE = netprofm.dll > -IMPORTS = iphlpapi > +IMPORTS = iphlpapi ole32 > > EXTRADLLFLAGS = -mno-cygwin > > diff --git a/dlls/netprofm/list.c b/dlls/netprofm/list.c > index f9b9e2ea312..b37d7e2943e 100644 > --- a/dlls/netprofm/list.c > +++ b/dlls/netprofm/list.c > @@ -1587,9 +1587,10 @@ static HRESULT WINAPI connection_GetAdapterId( > { > struct connection *connection = impl_from_INetworkConnection( iface ); > > - FIXME( "%p, %p\n", iface, pgdAdapterId ); > - > *pgdAdapterId = connection->id; > + > + TRACE("Iface: %p, AdapterId %s\n", iface, > wine_dbgstr_guid(pgdAdapterId)); > + > return S_OK; > } > > @@ -1736,8 +1737,11 @@ static void init_networks( struct list_manager *mgr > ) > { > struct network *network; > struct connection *connection; > - > - id.Data1 = aa->u.s.IfIndex; > + OLECHAR adapter_guid_string[39]; > + > + /* Convert AdapterName (a GUID string) to a GUID struct */ > + MultiByteToWideChar(CP_ACP, 0, aa->AdapterName, -1, > adapter_guid_string, 39); > + if(CLSIDFromString(adapter_guid_string, &id)) goto done; > > /* assume a one-to-one mapping between networks and connections */ > if (!(network = create_network( &id ))) goto done; > -- > 2.30.0 > >
Hey everyone,

I submitted this recently and just wanted to ask for an official feedback/review on this patch.
I'm not really familiar with the Wine codebase, so good advice is appreciated.

Greetings
Bernhard

On Mon, Feb 8, 2021 at 11:03 PM Bernhard Kölbl <besentv@gmail.com> wrote:
The index of a network interface is not a valid GUID.
AdapterName holds the correct GUID and should be used instead.

Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
---
 dlls/netprofm/Makefile.in |  2 +-
 dlls/netprofm/list.c      | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/dlls/netprofm/Makefile.in b/dlls/netprofm/Makefile.in
index d57d1d60c45..3d1d225d3df 100644
--- a/dlls/netprofm/Makefile.in
+++ b/dlls/netprofm/Makefile.in
@@ -1,5 +1,5 @@
 MODULE    = netprofm.dll
-IMPORTS   = iphlpapi
+IMPORTS   = iphlpapi ole32

 EXTRADLLFLAGS = -mno-cygwin

diff --git a/dlls/netprofm/list.c b/dlls/netprofm/list.c
index f9b9e2ea312..b37d7e2943e 100644
--- a/dlls/netprofm/list.c
+++ b/dlls/netprofm/list.c
@@ -1587,9 +1587,10 @@ static HRESULT WINAPI connection_GetAdapterId(
 {
     struct connection *connection = impl_from_INetworkConnection( iface );

-    FIXME( "%p, %p\n", iface, pgdAdapterId );
-
     *pgdAdapterId = connection->id;
+
+    TRACE("Iface: %p, AdapterId %s\n", iface, wine_dbgstr_guid(pgdAdapterId));
+
     return S_OK;
 }

@@ -1736,8 +1737,11 @@ static void init_networks( struct list_manager *mgr )
     {
         struct network *network;
         struct connection *connection;
-
-        id.Data1 = aa->u.s.IfIndex;
+        OLECHAR adapter_guid_string[39];
+       
+        /* Convert AdapterName (a GUID string) to a GUID struct */
+        MultiByteToWideChar(CP_ACP, 0, aa->AdapterName, -1, adapter_guid_string, 39);
+        if(CLSIDFromString(adapter_guid_string, &id)) goto done;

         /* assume a one-to-one mapping between networks and connections */
         if (!(network = create_network( &id ))) goto done;
--
2.30.0