[WINLOGON] Restore saved connections on session opening

This avoids using a nasty hack in MPR.

CORE-15310
This commit is contained in:
Pierre Schweitzer 2018-11-17 21:58:04 +01:00
parent 8b0a126445
commit 4cf87fdb2c
No known key found for this signature in database
GPG Key ID: 7545556C3D585B0B

View File

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