Author: hpoussin Date: Fri Dec 21 13:06:46 2007 New Revision: 31366
URL: http://svn.reactos.org/svn/reactos?rev=31366&view=rev Log: [FORMATTING] Fix indentation
Modified: trunk/reactos/base/system/winlogon/setup.c
Modified: trunk/reactos/base/system/winlogon/setup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/setup.... ============================================================================== --- trunk/reactos/base/system/winlogon/setup.c (original) +++ trunk/reactos/base/system/winlogon/setup.c Fri Dec 21 13:06:46 2007 @@ -19,135 +19,137 @@ DWORD GetSetupType(VOID) { - DWORD dwError; - HKEY hKey; - DWORD dwType; - DWORD dwSize; - DWORD dwSetupType; + DWORD dwError; + HKEY hKey; + DWORD dwType; + DWORD dwSize; + DWORD dwSetupType;
- dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE, - L"SYSTEM\Setup", //TEXT("SYSTEM\Setup"), - 0, - KEY_QUERY_VALUE, - &hKey); - if (dwError != ERROR_SUCCESS) - { - return 0; - } + TRACE("GetSetupType()\n");
- dwSize = sizeof(DWORD); - dwError = RegQueryValueExW (hKey, - L"SetupType", //TEXT("SetupType"), - NULL, - &dwType, - (LPBYTE)&dwSetupType, - &dwSize); - RegCloseKey (hKey); - if (dwError != ERROR_SUCCESS || dwType != REG_DWORD) - { - return 0; - } + /* Open key */ + dwError = RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + L"SYSTEM\Setup", + 0, + KEY_QUERY_VALUE, + &hKey); + if (dwError != ERROR_SUCCESS) + return 0;
- return dwSetupType; + /* Read key */ + dwSize = sizeof(DWORD); + dwError = RegQueryValueExW( + hKey, + L"SetupType", + NULL, + &dwType, + (LPBYTE)&dwSetupType, + &dwSize); + + /* Close key, and check if returned values are correct */ + RegCloseKey(hKey); + if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != sizeof(DWORD)) + return 0; + + TRACE("GetSetupType() returns %lu\n", dwSetupType); + return dwSetupType; }
+static DWORD WINAPI +RunSetupThreadProc( + IN LPVOID lpParameter) +{ + PROCESS_INFORMATION ProcessInformation; + STARTUPINFOW StartupInfo; + WCHAR Shell[MAX_PATH]; + WCHAR CommandLine[MAX_PATH]; + BOOL Result; + DWORD dwError; + HKEY hKey; + DWORD dwType; + DWORD dwSize; + DWORD dwExitCode;
-static DWORD WINAPI -RunSetupThreadProc (IN LPVOID lpParameter) -{ - PROCESS_INFORMATION ProcessInformation; - STARTUPINFOW StartupInfo; - WCHAR Shell[MAX_PATH]; - WCHAR CommandLine[MAX_PATH]; - BOOL Result; - DWORD dwError; - HKEY hKey; - DWORD dwType; - DWORD dwSize; - DWORD dwExitCode; + TRACE("RunSetup() called\n");
- TRACE ("RunSetup() called\n"); + /* Open key */ + dwError = RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + L"SYSTEM\Setup", + 0, + KEY_QUERY_VALUE, + &hKey); + if (dwError != ERROR_SUCCESS) + return FALSE;
- dwError = RegOpenKeyExW (HKEY_LOCAL_MACHINE, - L"SYSTEM\Setup", - 0, - KEY_QUERY_VALUE, - &hKey); - if (dwError != ERROR_SUCCESS) - { - return FALSE; - } + /* Read key */ + dwSize = (sizeof(Shell) / sizeof(Shell[0])) - 1; + dwError = RegQueryValueExW( + hKey, + L"CmdLine", + NULL, + &dwType, + (LPBYTE)Shell, + &dwSize); + RegCloseKey(hKey); + if (dwError != ERROR_SUCCESS) + return FALSE;
- dwSize = MAX_PATH; - dwError = RegQueryValueExW (hKey, - L"CmdLine", - NULL, - &dwType, - (LPBYTE)Shell, - &dwSize); - RegCloseKey (hKey); - if (dwError != ERROR_SUCCESS) - { - return FALSE; - } + /* Finish string */ + Shell[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
- if (dwType == REG_EXPAND_SZ) - { - ExpandEnvironmentStringsW(Shell, CommandLine, MAX_PATH); - } - else if (dwType == REG_SZ) - { - wcscpy(CommandLine, Shell); - } - else - { - return FALSE; - } + /* Expand string (if applicable) */ + if (dwType == REG_EXPAND_SZ) + ExpandEnvironmentStringsW(Shell, CommandLine, MAX_PATH); + else if (dwType == REG_SZ) + wcscpy(CommandLine, Shell); + else + return FALSE;
- TRACE ("Should run '%S' now.\n", CommandLine); + TRACE("Should run '%s' now\n", debugstr_w(CommandLine));
- StartupInfo.cb = sizeof(StartupInfo); - StartupInfo.lpReserved = NULL; - StartupInfo.lpDesktop = NULL; - StartupInfo.lpTitle = NULL; - StartupInfo.dwFlags = 0; - StartupInfo.cbReserved2 = 0; - StartupInfo.lpReserved2 = 0; + /* Start process */ + StartupInfo.cb = sizeof(StartupInfo); + StartupInfo.lpReserved = NULL; + StartupInfo.lpDesktop = NULL; + StartupInfo.lpTitle = NULL; + StartupInfo.dwFlags = 0; + StartupInfo.cbReserved2 = 0; + StartupInfo.lpReserved2 = 0; + Result = CreateProcessW( + NULL, + CommandLine, + NULL, + NULL, + FALSE, + DETACHED_PROCESS, + NULL, + NULL, + &StartupInfo, + &ProcessInformation); + if (!Result) + { + TRACE("Failed to run setup process\n"); + return FALSE; + }
- TRACE ("Creating new setup process\n"); + /* Wait for process termination */ + WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
- Result = CreateProcessW (NULL, - CommandLine, - NULL, - NULL, - FALSE, - DETACHED_PROCESS, - NULL, - NULL, - &StartupInfo, - &ProcessInformation); - if (!Result) - { - TRACE ("Failed to run setup process\n"); - return FALSE; - } + GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);
- /* Wait for process termination */ - WaitForSingleObject (ProcessInformation.hProcess, INFINITE); + /* Close handles */ + CloseHandle(ProcessInformation.hThread); + CloseHandle(ProcessInformation.hProcess);
- GetExitCodeProcess (ProcessInformation.hProcess, &dwExitCode); + TRACE ("RunSetup() done\n");
- CloseHandle (ProcessInformation.hThread); - CloseHandle (ProcessInformation.hProcess); - - TRACE ("RunSetup() done.\n"); - - return TRUE; + return TRUE; }
- BOOL -RunSetup (VOID) +RunSetup(VOID) { HANDLE hThread;