[MPR]
authorPierre Schweitzer <pierre@reactos.org>
Sat, 23 Jul 2016 19:52:23 +0000 (19:52 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 23 Jul 2016 19:52:23 +0000 (19:52 +0000)
Provide ReactOS specific implementation for WNetGetConnection(), we cannot use Wine's due to Wine specific MountMgr calls.

svn path=/trunk/; revision=71984

reactos/dll/win32/mpr/mpr_ros.diff
reactos/dll/win32/mpr/wnet.c

index d884b0d..6f3470a 100644 (file)
@@ -45,3 +45,68 @@ Index: mpr.spec
  22 stdcall @(long) MPR_Alloc\r
  23 stdcall @(ptr long) MPR_ReAlloc\r
  24 stdcall @(ptr) MPR_Free\r
+Index: wnet.c\r
+===================================================================\r
+--- wnet.c     (revision 71983)\r
++++ wnet.c     (working copy)\r
+@@ -48,6 +48,9 @@\r
+     PF_NPGetResourceInformation getResourceInformation;\r
+     PF_NPAddConnection addConnection;\r
+     PF_NPAddConnection3 addConnection3;\r
++#ifdef __REACTOS__\r
++    PF_NPGetConnection getConnection;\r
++#endif\r
+ } WNetProvider, *PWNetProvider;\r
\r
+ typedef struct _WNetProviderTable\r
+@@ -196,6 +199,9 @@\r
+                         }\r
+                         provider->addConnection = MPR_GETPROC(NPAddConnection);\r
+                         provider->addConnection3 = MPR_GETPROC(NPAddConnection3);\r
++#ifdef __REACTOS__\r
++                        provider->getConnection = MPR_GETPROC(NPGetConnection);\r
++#endif\r
+                         TRACE("NPAddConnection %p\n", provider->addConnection);\r
+                         TRACE("NPAddConnection3 %p\n", provider->addConnection3);\r
+                         providerTable->numProviders++;\r
+@@ -1949,6 +1955,7 @@\r
+ /* find the network connection for a given drive; helper for WNetGetConnection */\r
+ static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )\r
+ {\r
++#ifndef __REACTOS__\r
+     char buffer[1024];\r
+     struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;\r
+     HANDLE mgr;\r
+@@ -1991,6 +1998,32 @@\r
+     }\r
+     CloseHandle( mgr );\r
+     return ret;\r
++#else\r
++    DWORD ret = WN_NO_NETWORK;\r
++    DWORD index;\r
++    WCHAR local[3] = {letter, ':', 0};\r
++\r
++    if (providerTable != NULL)\r
++    {\r
++        for (index = 0; index < providerTable->numProviders; index++)\r
++        {\r
++            if(providerTable->table[index].getCaps(WNNC_CONNECTION) &\r
++                WNNC_CON_GETCONNECTIONS)\r
++            {\r
++                if (providerTable->table[index].getConnection)\r
++                    ret = providerTable->table[index].getConnection(\r
++                        local, remote, size);\r
++                else\r
++                    ret = WN_NO_NETWORK;\r
++                if (ret == WN_SUCCESS || ret == WN_MORE_DATA)\r
++                    break;\r
++            }\r
++        }\r
++    }\r
++    if (ret)\r
++        SetLastError(ret);\r
++    return ret;\r
++#endif\r
+ }\r
\r
+ /**************************************************************************\r
index 045e197..357c310 100644 (file)
@@ -48,6 +48,9 @@ typedef struct _WNetProvider
     PF_NPGetResourceInformation getResourceInformation;
     PF_NPAddConnection addConnection;
     PF_NPAddConnection3 addConnection3;
+#ifdef __REACTOS__
+    PF_NPGetConnection getConnection;
+#endif
 } WNetProvider, *PWNetProvider;
 
 typedef struct _WNetProviderTable
@@ -196,6 +199,9 @@ static void _tryLoadProvider(PCWSTR provider)
                         }
                         provider->addConnection = MPR_GETPROC(NPAddConnection);
                         provider->addConnection3 = MPR_GETPROC(NPAddConnection3);
+#ifdef __REACTOS__
+                        provider->getConnection = MPR_GETPROC(NPGetConnection);
+#endif
                         TRACE("NPAddConnection %p\n", provider->addConnection);
                         TRACE("NPAddConnection3 %p\n", provider->addConnection3);
                         providerTable->numProviders++;
@@ -1949,6 +1955,7 @@ DWORD WINAPI WNetGetConnectionA( LPCSTR lpLocalName,
 /* find the network connection for a given drive; helper for WNetGetConnection */
 static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )
 {
+#ifndef __REACTOS__
     char buffer[1024];
     struct mountmgr_unix_drive *data = (struct mountmgr_unix_drive *)buffer;
     HANDLE mgr;
@@ -1991,6 +1998,32 @@ static DWORD get_drive_connection( WCHAR letter, LPWSTR remote, LPDWORD size )
     }
     CloseHandle( mgr );
     return ret;
+#else
+    DWORD ret = WN_NO_NETWORK;
+    DWORD index;
+    WCHAR local[3] = {letter, ':', 0};
+
+    if (providerTable != NULL)
+    {
+        for (index = 0; index < providerTable->numProviders; index++)
+        {
+            if(providerTable->table[index].getCaps(WNNC_CONNECTION) &
+                WNNC_CON_GETCONNECTIONS)
+            {
+                if (providerTable->table[index].getConnection)
+                    ret = providerTable->table[index].getConnection(
+                        local, remote, size);
+                else
+                    ret = WN_NO_NETWORK;
+                if (ret == WN_SUCCESS || ret == WN_MORE_DATA)
+                    break;
+            }
+        }
+    }
+    if (ret)
+        SetLastError(ret);
+    return ret;
+#endif
 }
 
 /**************************************************************************