ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

setup.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Winlogon
00004  * FILE:            base/system/winlogon/setup.c
00005  * PURPOSE:         Setup support functions
00006  * PROGRAMMERS:     Eric Kohl
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #include "winlogon.h"
00012 
00013 #include <wine/debug.h>
00014 
00015 WINE_DEFAULT_DEBUG_CHANNEL(winlogon);
00016 
00017 /* FUNCTIONS ****************************************************************/
00018 
00019 DWORD
00020 GetSetupType(VOID)
00021 {
00022     DWORD dwError;
00023     HKEY hKey;
00024     DWORD dwType;
00025     DWORD dwSize;
00026     DWORD dwSetupType;
00027 
00028     TRACE("GetSetupType()\n");
00029 
00030     /* Open key */
00031     dwError = RegOpenKeyExW(
00032         HKEY_LOCAL_MACHINE,
00033         L"SYSTEM\\Setup",
00034         0,
00035         KEY_QUERY_VALUE,
00036         &hKey);
00037     if (dwError != ERROR_SUCCESS)
00038         return 0;
00039 
00040     /* Read key */
00041     dwSize = sizeof(DWORD);
00042     dwError = RegQueryValueExW(
00043         hKey,
00044         L"SetupType",
00045         NULL,
00046         &dwType,
00047         (LPBYTE)&dwSetupType,
00048         &dwSize);
00049 
00050     /* Close key, and check if returned values are correct */
00051     RegCloseKey(hKey);
00052     if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != sizeof(DWORD))
00053         return 0;
00054 
00055     TRACE("GetSetupType() returns %lu\n", dwSetupType);
00056     return dwSetupType;
00057 }
00058 
00059 static DWORD WINAPI
00060 RunSetupThreadProc(
00061     IN LPVOID lpParameter)
00062 {
00063     PROCESS_INFORMATION ProcessInformation;
00064     STARTUPINFOW StartupInfo;
00065     WCHAR Shell[MAX_PATH];
00066     WCHAR CommandLine[MAX_PATH];
00067     BOOL Result;
00068     DWORD dwError;
00069     HKEY hKey;
00070     DWORD dwType;
00071     DWORD dwSize;
00072     DWORD dwExitCode;
00073 
00074     TRACE("RunSetup() called\n");
00075 
00076     /* Open key */
00077     dwError = RegOpenKeyExW(
00078         HKEY_LOCAL_MACHINE,
00079         L"SYSTEM\\Setup",
00080         0,
00081         KEY_QUERY_VALUE,
00082         &hKey);
00083     if (dwError != ERROR_SUCCESS)
00084         return FALSE;
00085 
00086     /* Read key */
00087     dwSize = (sizeof(Shell) / sizeof(Shell[0])) - 1;
00088     dwError = RegQueryValueExW(
00089         hKey,
00090         L"CmdLine",
00091         NULL,
00092         &dwType,
00093         (LPBYTE)Shell,
00094         &dwSize);
00095     RegCloseKey(hKey);
00096     if (dwError != ERROR_SUCCESS)
00097         return FALSE;
00098 
00099     /* Finish string */
00100     Shell[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
00101 
00102     /* Expand string (if applicable) */
00103     if (dwType == REG_EXPAND_SZ)
00104         ExpandEnvironmentStringsW(Shell, CommandLine, MAX_PATH);
00105     else if (dwType == REG_SZ)
00106         wcscpy(CommandLine, Shell);
00107     else
00108         return FALSE;
00109 
00110     TRACE("Should run '%s' now\n", debugstr_w(CommandLine));
00111 
00112     /* Start process */
00113     StartupInfo.cb = sizeof(StartupInfo);
00114     StartupInfo.lpReserved = NULL;
00115     StartupInfo.lpDesktop = NULL;
00116     StartupInfo.lpTitle = NULL;
00117     StartupInfo.dwFlags = 0;
00118     StartupInfo.cbReserved2 = 0;
00119     StartupInfo.lpReserved2 = 0;
00120     Result = CreateProcessW(
00121         NULL,
00122         CommandLine,
00123         NULL,
00124         NULL,
00125         FALSE,
00126         DETACHED_PROCESS,
00127         NULL,
00128         NULL,
00129         &StartupInfo,
00130         &ProcessInformation);
00131     if (!Result)
00132     {
00133         TRACE("Failed to run setup process\n");
00134         return FALSE;
00135     }
00136 
00137     /* Wait for process termination */
00138     WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
00139 
00140     GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);
00141 
00142     /* Close handles */
00143     CloseHandle(ProcessInformation.hThread);
00144     CloseHandle(ProcessInformation.hProcess);
00145 
00146     TRACE ("RunSetup() done\n");
00147 
00148     return TRUE;
00149 }
00150 
00151 BOOL
00152 RunSetup(VOID)
00153 {
00154     HANDLE hThread;
00155 
00156     hThread = CreateThread(NULL, 0, RunSetupThreadProc, NULL, 0, NULL);
00157     return hThread != NULL;
00158 }
00159 
00160 /* EOF */

Generated on Thu May 24 2012 04:18:00 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.