if (ScreenSaverThread)
CloseHandle(ScreenSaverThread);
else
- WARN("WL: Unable to start screen saver thread\n");
+ ERR("WL: Unable to start screen saver thread\n");
return TRUE;
}
StartScreenSaver(
IN PWLSESSION Session)
{
- HKEY hKey = NULL;
+ HKEY hKey = NULL, hCurrentUser = NULL;
WCHAR szApplicationName[MAX_PATH];
WCHAR szCommandLine[MAX_PATH + 3];
DWORD bufferSize = sizeof(szApplicationName) - sizeof(WCHAR);
if (!ImpersonateLoggedOnUser(Session->UserToken))
{
- ERR("ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
+ ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", GetLastError());
+ goto cleanup;
+ }
+
+ rc = RegOpenCurrentUser(
+ KEY_READ,
+ &hCurrentUser);
+ if (rc != ERROR_SUCCESS)
+ {
+ ERR("WL: RegOpenCurrentUser Error!\n");
goto cleanup;
}
rc = RegOpenKeyExW(
- HKEY_CURRENT_USER,
+ hCurrentUser,
L"Control Panel\\Desktop",
0,
KEY_QUERY_VALUE,
&hKey);
if (rc != ERROR_SUCCESS)
+ {
+ ERR("WL: RegOpenKeyEx Error!\n");
goto cleanup;
+ }
rc = RegQueryValueExW(
hKey,
(LPBYTE)szApplicationName,
&bufferSize);
if (rc != ERROR_SUCCESS || dwType != REG_SZ)
+ {
+ ERR("WL: RegQueryValueEx Error!\n");
goto cleanup;
+ }
if (bufferSize == 0)
+ {
+ ERR("WL: Buffer size is NULL!\n");
goto cleanup;
+ }
szApplicationName[bufferSize / sizeof(WCHAR)] = 0; /* Terminate the string */
if (wcslen(szApplicationName) == 0)
+ {
+ ERR("WL: Application Name length is zero!\n");
goto cleanup;
+ }
wsprintfW(szCommandLine, L"%s /s", szApplicationName);
TRACE("WL: Executing %S\n", szCommandLine);
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
StartupInfo.cb = sizeof(STARTUPINFOW);
+ StartupInfo.dwFlags = STARTF_SCRNSAVER;
/* FIXME: run the screen saver on the screen saver desktop */
ret = CreateProcessW(
szApplicationName,
&ProcessInformation);
if (!ret)
{
- WARN("WL: Unable to start %S, error %lu\n", szApplicationName, GetLastError());
+ ERR("WL: Unable to start %S, error %lu\n", szApplicationName, GetLastError());
goto cleanup;
}
CloseHandle(ProcessInformation.hThread);
RevertToSelf();
if (hKey)
RegCloseKey(hKey);
+ if (hCurrentUser)
+ RegCloseKey(hCurrentUser);
if (!ret)
{
PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_ACTIVITY, 0);