https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4cf87fdb2c3df5eb21a7eb86f943386c008da52c

commit 4cf87fdb2c3df5eb21a7eb86f943386c008da52c
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Sat Nov 17 21:58:04 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Sat Nov 17 22:13:34 2018 +0100

    [WINLOGON] Restore saved connections on session opening
    
    This avoids using a nasty hack in MPR.
    
    CORE-15310
---
 base/system/winlogon/sas.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/base/system/winlogon/sas.c b/base/system/winlogon/sas.c
index d914bebefc..c510a1111e 100644
--- a/base/system/winlogon/sas.c
+++ b/base/system/winlogon/sas.c
@@ -508,6 +508,70 @@ Cleanup:
     return bSuccess;
 }
 
+static
+VOID
+RestoreAllConnections(PWLSESSION Session)
+{
+    DWORD dRet;
+    HANDLE hEnum;
+    LPNETRESOURCE lpRes;
+    DWORD dSize = 0x1000;
+    DWORD dCount = -1;
+    LPNETRESOURCE lpCur;
+    BOOL UserProfile;
+
+    UserProfile = (Session && Session->UserToken);
+    if (!UserProfile)
+    {
+        return;
+    }
+
+    if (!ImpersonateLoggedOnUser(Session->UserToken))
+    {
+        ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", 
GetLastError());
+        return;
+    }
+
+    dRet = WNetOpenEnum(RESOURCE_REMEMBERED, RESOURCETYPE_DISK, 0, NULL, 
&hEnum);
+    if (dRet != WN_SUCCESS)
+    {
+        ERR("Failed to open enumeration: %lu\n", dRet);
+        goto quit;
+    }
+
+    lpRes = HeapAlloc(GetProcessHeap(), 0, dSize);
+    if (!lpRes)
+    {
+        ERR("Failed to allocate memory\n");
+        WNetCloseEnum(hEnum);
+        goto quit;
+    }
+
+    do
+    {
+        dSize = 0x1000;
+        dCount = -1;
+
+        memset(lpRes, 0, dSize);
+        dRet = WNetEnumResource(hEnum, &dCount, lpRes, &dSize);
+        if (dRet == WN_SUCCESS || dRet == WN_MORE_DATA)
+        {
+            lpCur = lpRes;
+            for (; dCount; dCount--)
+            {
+                WNetAddConnection(lpCur->lpRemoteName, NULL, 
lpCur->lpLocalName);
+                lpCur++;
+            }
+        }
+    } while (dRet != WN_NO_MORE_ENTRIES);
+
+    HeapFree(GetProcessHeap(), 0, lpRes);
+    WNetCloseEnum(hEnum);
+
+quit:
+    RevertToSelf();
+}
+
 static
 BOOL
 HandleLogon(
@@ -570,6 +634,9 @@ HandleLogon(
 
     AllowWinstaAccess(Session);
 
+    /* Connect remote resources */
+    RestoreAllConnections(Session);
+
     if (!StartUserShell(Session))
     {
         //WCHAR StatusMsg[256];

Reply via email to