diff --git a/base/system/winlogon/notify.c b/base/system/winlogon/notify.c index 56ef94b5001..5dbdad2eb3f 100644 --- a/base/system/winlogon/notify.c +++ b/base/system/winlogon/notify.c @@ -190,16 +190,13 @@ AddSfcNotification(VOID) if (!NotificationDll) return; // If needed: dwError = ERROR_OUTOFMEMORY; - NotificationDll->pszDllName = RtlAllocateHeap(RtlGetProcessHeap(), 0, - (wcslen(szSfcPath) + 1) * sizeof(WCHAR)); + NotificationDll->pszDllName = WlStrDup(szSfcPath); if (NotificationDll->pszDllName == NULL) { dwError = ERROR_OUTOFMEMORY; goto done; } - wcscpy(NotificationDll->pszDllName, szSfcPath); - NotificationDll->bEnabled = TRUE; NotificationDll->dwMaxWait = 30; /* FIXME: ??? */ NotificationDll->bSfcNotification = TRUE; @@ -290,16 +287,13 @@ AddNotificationDll( goto done; } - NotificationDll->pszKeyName = RtlAllocateHeap(RtlGetProcessHeap(), 0, - (wcslen(pszKeyName) + 1) * sizeof(WCHAR)); + NotificationDll->pszKeyName = WlStrDup(pszKeyName); if (NotificationDll->pszKeyName == NULL) { lError = ERROR_OUTOFMEMORY; goto done; } - wcscpy(NotificationDll->pszKeyName, pszKeyName); - dwSize = 0; lError = RegQueryValueExW(hDllKey, L"DllName", @@ -560,8 +554,8 @@ CallNotificationDlls( break; } - Info.UserName = NULL; //UserName; - Info.Domain = NULL; //Domain; + Info.UserName = pSession->UserName; + Info.Domain = pSession->Domain; Info.WindowStation = pSession->InteractiveWindowStationName; Info.hToken = pSession->UserToken; diff --git a/base/system/winlogon/sas.c b/base/system/winlogon/sas.c index 975acce1592..8a23b01d562 100644 --- a/base/system/winlogon/sas.c +++ b/base/system/winlogon/sas.c @@ -621,6 +621,10 @@ HandleLogon( Session->hProfileInfo = ProfileInfo.hProfile; } + /* Cache the username and domain */ + Session->UserName = WlStrDup(Session->MprNotifyInfo.pszUserName); + Session->Domain = WlStrDup(Session->MprNotifyInfo.pszDomain); + /* Create environment block for the user */ if (!CreateUserEnvironment(Session)) { @@ -687,6 +691,10 @@ cleanup: if (!ret) { + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName); + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->Domain); + Session->UserName = Session->Domain = NULL; + if (Session->hProfileInfo) UnloadUserProfile(Session->UserToken, Session->hProfileInfo); Session->hProfileInfo = NULL; @@ -1050,6 +1058,10 @@ HandleLogoff( DisplayStatusMessage(Session, Session->WinlogonDesktop, IDS_SAVEYOURSETTINGS); + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName); + RtlFreeHeap(RtlGetProcessHeap(), 0, Session->Domain); + Session->UserName = Session->Domain = NULL; + if (Session->hProfileInfo) UnloadUserProfile(Session->UserToken, Session->hProfileInfo); Session->hProfileInfo = NULL; diff --git a/base/system/winlogon/winlogon.c b/base/system/winlogon/winlogon.c index 2f4f4177821..022d529149a 100644 --- a/base/system/winlogon/winlogon.c +++ b/base/system/winlogon/winlogon.c @@ -21,6 +21,27 @@ PWLSESSION WLSession = NULL; /* FUNCTIONS *****************************************************************/ +/** + * @brief + * Duplicates the given string, allocating a buffer on the heap. + **/ +PWSTR +WlStrDup( + _In_opt_ PCWSTR String) +{ + PWSTR ptr; + + if (!String) + return NULL; + + ptr = RtlAllocateHeap(RtlGetProcessHeap(), 0, + (wcslen(String) + 1) * sizeof(WCHAR)); + if (ptr) + wcscpy(ptr, String); + return ptr; +} + + static BOOL StartServicesManager(VOID) diff --git a/base/system/winlogon/winlogon.h b/base/system/winlogon/winlogon.h index 23272cf8995..e90d0a0031a 100644 --- a/base/system/winlogon/winlogon.h +++ b/base/system/winlogon/winlogon.h @@ -227,7 +227,9 @@ typedef struct _WLSESSION BOOL UtilManHotkey; HWND SASWindow; HWINSTA InteractiveWindowStation; - LPWSTR InteractiveWindowStationName; + PWSTR InteractiveWindowStationName; + PWSTR UserName; + PWSTR Domain; HDESK ApplicationDesktop; HDESK WinlogonDesktop; HDESK ScreenSaverDesktop; @@ -403,6 +405,10 @@ StartSystemShutdown( IN ULONG dwReason); /* winlogon.c */ +PWSTR +WlStrDup( + _In_opt_ PCWSTR String); + BOOL PlaySoundRoutine(IN LPCWSTR FileName, IN UINT Logon,