15#ifndef USE_GETLASTINPUTINFO
52 WARN(
"WL: Unable to get screen saver timeout (error %lu). Disabling it\n",
GetLastError());
57 WARN(
"WL: Unable to check if screen saver is enabled (error %lu). Disabling it\n",
GetLastError());
62 TRACE(
"WL: Screen saver is disabled\n");
67 TRACE(
"WL: Screen saver timeout: %lu seconds\n", *
Timeout);
81#ifdef USE_GETLASTINPUTINFO
92 ERR(
"ImpersonateLoggedOnUser() failed with error %lu\n",
GetLastError());
116#ifndef USE_GETLASTINPUTINFO
124#ifndef USE_GETLASTINPUTINFO
151#ifndef USE_GETLASTINPUTINFO
188#ifndef USE_GETLASTINPUTINFO
189 if (Session->KeyboardHook)
192 if (Session->MouseHook)
209#ifndef USE_GETLASTINPUTINFO
212 if (!Session->KeyboardHook)
214 ERR(
"WL: Unable to register keyboard hook\n");
219 if (!Session->MouseHook)
221 ERR(
"WL: Unable to register mouse hook\n");
227 if (!Session->hScreenSaverParametersChanged)
229 WARN(
"WL: Unable to create screen saver event (error %lu)\n",
GetLastError());
234 if (!Session->hEndOfScreenSaverThread)
236 WARN(
"WL: Unable to create screen saver event (error %lu)\n",
GetLastError());
237 CloseHandle(Session->hScreenSaverParametersChanged);
247 if (ScreenSaverThread)
250 ERR(
"WL: Unable to start screen saver thread\n");
274 ERR(
"WL: ImpersonateLoggedOnUser() failed with error %lu\n",
GetLastError());
282 ERR(
"WL: RegOpenCurrentUser error %lu\n", rc);
287 L"Control Panel\\Desktop",
293 ERR(
"WL: RegOpenKeyEx error %lu\n", rc);
301 (
LPBYTE)szApplicationName,
306 ERR(
"WL: RegQueryValueEx error %lu\n", rc);
312 ERR(
"WL: Buffer size is NULL!\n");
318 if (
wcslen(szApplicationName) == 0)
320 ERR(
"WL: Application Name length is zero!\n");
324 wsprintfW(szCommandLine,
L"%s /s", szApplicationName);
325 TRACE(
"WL: Executing %S\n", szCommandLine);
345 &ProcessInformation);
348 ERR(
"WL: Unable to start %S, error %lu\n", szApplicationName,
GetLastError());
360 HandleArray[0] = ProcessInformation.
hProcess;
361 HandleArray[1] = Session->hUserActivity;
369 SetEvent(Session->hEndOfScreenSaver);
387#ifndef USE_GETLASTINPUTINFO
#define InterlockedExchange
VOID CallNotificationDlls(PWLSESSION pSession, NOTIFICATION_TYPE Type)
static DWORD WINAPI ScreenSaverThreadMain(IN LPVOID lpParameter)
static VOID LoadScreenSaverParameters(OUT LPDWORD Timeout)
BOOL InitializeScreenSaver(IN OUT PWLSESSION Session)
VOID StartScreenSaver(IN PWLSESSION Session)
#define RegCloseKey(hKey)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
BOOL WINAPI ImpersonateLoggedOnUser(HANDLE hToken)
static void cleanup(void)
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
DWORD WINAPI GetTickCount(VOID)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define InterlockedCompareExchange
#define ERROR_FILE_NOT_FOUND
HANDLE hScreenSaverParametersChanged
HANDLE hEndOfScreenSaverThread
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
#define STARTF_SCREENSAVER
DWORD WINAPI GetLastError(void)
#define IDLE_PRIORITY_CLASS
BOOL WINAPI RevertToSelf(void)
struct _STARTUPINFOW STARTUPINFOW
struct _WLSESSION * PWLSESSION
@ StartScreenSaverHandler
BOOL WINAPI GetLastInputInfo(_Out_ PLASTINPUTINFO)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define SPI_GETSCREENSAVETIMEOUT
#define SPI_GETSCREENSAVEACTIVE
struct tagLASTINPUTINFO LASTINPUTINFO
#define WLX_SAS_TYPE_SCRNSVR_TIMEOUT
#define WLX_SAS_TYPE_SCRNSVR_ACTIVITY