From 1d5bff3624dcccb4e95e5ba8112ccf131fe6b264 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 12 Jul 2006 21:33:14 +0000 Subject: [PATCH] - Fix a mistake with outputting always non-initialized buffer in a DPRINT1 - Add a branch for stopping the screensaver - Prettify the tracing debug message (it shows now if it's a start or a stop request) - Add a success-check for RegOpenKeyExW too svn path=/trunk/; revision=23032 --- .../subsystems/win32/csrss/win32csr/conio.c | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/reactos/subsystems/win32/csrss/win32csr/conio.c b/reactos/subsystems/win32/csrss/win32csr/conio.c index 267271b0f23..7b210e8be71 100644 --- a/reactos/subsystems/win32/csrss/win32csr/conio.c +++ b/reactos/subsystems/win32/csrss/win32csr/conio.c @@ -3326,22 +3326,23 @@ CSR_API(CsrGetProcessList) } CSR_API(CsrStartScreenSaver) -{ +{ + + DPRINT("CsrStartScreenSaver : %s Screen Saver \n", + (Request->Data.StartScreenSaver.Start) ? "Start" : "Stop"); - DPRINT("CsrStartScreenSaver : Start Screen Saver \n"); - if (Request->Data.StartScreenSaver.Start == TRUE) { STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR szCmdline[MAX_PATH]; - + HKEY hKey; WCHAR szBuffer[MAX_PATH]; DWORD bufferSize = sizeof(szBuffer); DWORD varType = REG_SZ; LONG result; - + /* FIXME : 1. Make it unicode and ansi compatible with TCHAR @@ -3356,32 +3357,43 @@ CSR_API(CsrStartScreenSaver) 4. Move the code to winlogon SAS and screen saver must run in the secuar desktop. But current our Winlogon does not working well with SAS and with Secure desktop, So I (Magnus Olsen aka GreatLord) - add the code here as w3seek recomandete + add the code here as w3seek recommended */ - - - RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_ALL_ACCESS, &hKey); - result = RegQueryValueExW(hKey, L"SCRNSAVE.EXE", 0, &varType, (LPBYTE)szBuffer, &bufferSize); - if(result == ERROR_SUCCESS) - { - swprintf(szCmdline, L"%s /s",szBuffer); - DPRINT1("CsrStartScreenSaver : OK %S\n",szCmdline); - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - if(CreateProcessW( NULL, szCmdline, NULL, NULL, FALSE, 0, NULL,NULL,&si, &pi )) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - } - else - { - DPRINT1("CsrStartScreenSaver : FAIL %S\n",szBuffer); - } - RegCloseKey(hKey); - } - return Request->Status = STATUS_SUCCESS; + + result = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_ALL_ACCESS, &hKey); + if (result == ERROR_SUCCESS) + { + result = RegQueryValueExW(hKey, L"SCRNSAVE.EXE", 0, &varType, (LPBYTE)szBuffer, &bufferSize); + if(result == ERROR_SUCCESS) + { + swprintf(szCmdline, L"%s /s",szBuffer); + DPRINT1("CsrStartScreenSaver : OK %S, Name %S\n", szCmdline, szBuffer); + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + if(CreateProcessW( NULL, szCmdline, NULL, NULL, FALSE, 0, NULL,NULL,&si, &pi )) + { + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + } + } + else + { + DPRINT1("CsrStartScreenSaver : failed 0x%08X\n", result); + } + RegCloseKey(hKey); + } + else + { + DPRINT1("CsrStartScreenSaver : failed to RegOpenKeyExW 0x%08X\n", result); + } + return Request->Status = STATUS_SUCCESS; + } + else + { + /* TODO: Stopping the screensaver */ + return Request->Status = STATUS_NOT_IMPLEMENTED; + } } /* EOF */