ReactOS 0.4.15-dev-7788-g1ad9096
setup.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Winlogon
4 * FILE: base/system/winlogon/setup.c
5 * PURPOSE: Setup support functions
6 * PROGRAMMERS: Eric Kohl
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include "winlogon.h"
12
13/* FUNCTIONS ****************************************************************/
14
17{
18 DWORD dwError;
19 HKEY hKey;
20 DWORD dwType;
22 DWORD dwSetupType;
23
24 TRACE("GetSetupType()\n");
25
26 /* Open key */
28 L"SYSTEM\\Setup",
29 0,
31 &hKey);
32 if (dwError != ERROR_SUCCESS)
33 return 0;
34
35 /* Read key */
36 dwSize = sizeof(DWORD);
37 dwError = RegQueryValueExW(hKey,
38 L"SetupType",
39 NULL,
40 &dwType,
41 (LPBYTE)&dwSetupType,
42 &dwSize);
43
44 /* Close key, and check if returned values are correct */
46 if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != sizeof(DWORD))
47 return 0;
48
49 TRACE("GetSetupType() returns %lu\n", dwSetupType);
50 return dwSetupType;
51}
52
53
54static
58 IN LPVOID lpParameter)
59{
60 PROCESS_INFORMATION ProcessInformation;
61 STARTUPINFOW StartupInfo;
63 WCHAR CommandLine[MAX_PATH];
65 DWORD dwError;
66 HKEY hKey;
67 DWORD dwType;
69 DWORD dwExitCode;
70
71 TRACE("RunSetup() called\n");
72
73 /* Open key */
75 L"SYSTEM\\Setup",
76 0,
78 &hKey);
79 if (dwError != ERROR_SUCCESS)
80 return FALSE;
81
82 /* Read key */
83 dwSize = sizeof(Shell);
84 dwError = RegQueryValueExW(hKey,
85 L"CmdLine",
86 NULL,
87 &dwType,
89 &dwSize);
91 if (dwError != ERROR_SUCCESS)
92 return FALSE;
93
94 /* Finish string */
95 Shell[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
96
97 /* Expand string (if applicable) */
98 if (dwType == REG_EXPAND_SZ)
99 ExpandEnvironmentStringsW(Shell, CommandLine, ARRAYSIZE(CommandLine));
100 else if (dwType == REG_SZ)
101 wcscpy(CommandLine, Shell);
102 else
103 return FALSE;
104
105 TRACE("Should run '%s' now\n", debugstr_w(CommandLine));
106
108
109 /* Start process */
110 StartupInfo.cb = sizeof(StartupInfo);
111 StartupInfo.lpReserved = NULL;
112 StartupInfo.lpDesktop = L"WinSta0\\Default";
113 StartupInfo.lpTitle = NULL;
114 StartupInfo.dwFlags = 0;
115 StartupInfo.cbReserved2 = 0;
116 StartupInfo.lpReserved2 = 0;
117
119 CommandLine,
120 NULL,
121 NULL,
122 FALSE,
124 NULL,
125 NULL,
126 &StartupInfo,
127 &ProcessInformation);
128 if (!Result)
129 {
130 TRACE("Failed to run setup process\n");
132 return FALSE;
133 }
134
135 /* Wait for process termination */
136 WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
137
138 GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);
139
140 /* Close handles */
141 CloseHandle(ProcessInformation.hThread);
142 CloseHandle(ProcessInformation.hProcess);
143
144 // SwitchDesktop(WLSession->WinlogonDesktop);
145
146 TRACE ("RunSetup() done\n");
147
148 return TRUE;
149}
150
151
152BOOL
154{
156
158 0,
160 NULL,
161 0,
162 NULL);
163 if (hThread != NULL)
165
166 return hThread != NULL;
167}
168
169/* EOF */
DWORD GetSetupType(VOID)
Definition: setup.c:16
BOOL RunSetup(VOID)
Definition: setup.c:153
static DWORD WINAPI RunSetupThreadProc(IN LPVOID lpParameter)
Definition: setup.c:57
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4132
#define CloseHandle
Definition: compat.h:739
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4592
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
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)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define debugstr_w
Definition: kernel32.h:32
#define REG_SZ
Definition: layer.c:22
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HANDLE hThread
Definition: wizard.c:28
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
#define REG_DWORD
Definition: sdbapi.c:596
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR lpDesktop
Definition: winbase.h:854
PBYTE lpReserved2
Definition: winbase.h:866
DWORD cb
Definition: winbase.h:852
DWORD dwFlags
Definition: winbase.h:863
LPWSTR lpTitle
Definition: winbase.h:855
WORD cbReserved2
Definition: winbase.h:865
LPWSTR lpReserved
Definition: winbase.h:853
HDESK WinlogonDesktop
Definition: winlogon.h:229
HDESK ApplicationDesktop
Definition: winlogon.h:228
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned char * LPBYTE
Definition: typedefs.h:53
#define IN
Definition: typedefs.h:39
static int Shell(const char **args)
Definition: vfdcmd.c:1020
#define DETACHED_PROCESS
Definition: winbase.h:179
#define WINAPI
Definition: msvc.h:6
PWLSESSION WLSession
Definition: winlogon.c:20
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
BOOL WINAPI SwitchDesktop(_In_ HDESK)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180