ReactOS  0.4.13-dev-645-g69454b4
setup.c File Reference
#include "winlogon.h"
Include dependency graph for setup.c:

Go to the source code of this file.

Functions

DWORD GetSetupType (VOID)
 
static DWORD WINAPI RunSetupThreadProc (IN LPVOID lpParameter)
 
BOOL RunSetup (VOID)
 

Function Documentation

◆ GetSetupType()

DWORD GetSetupType ( VOID  )

Definition at line 16 of file setup.c.

17 {
18  DWORD dwError;
19  HKEY hKey;
20  DWORD dwType;
21  DWORD dwSize;
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 */
45  RegCloseKey(hKey);
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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by SASWindowProc(), and WinMain().

◆ RunSetup()

BOOL RunSetup ( VOID  )

Definition at line 153 of file setup.c.

154 {
155  HANDLE hThread;
156 
158  0,
160  NULL,
161  0,
162  NULL);
163  if (hThread != NULL)
165 
166  return hThread != NULL;
167 }
#define CloseHandle
Definition: compat.h:398
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:111
smooth NULL
Definition: ftsmooth.c:416
static DWORD WINAPI RunSetupThreadProc(IN LPVOID lpParameter)
Definition: setup.c:57
HANDLE hThread
Definition: wizard.c:27

Referenced by WinMain().

◆ RunSetupThreadProc()

static DWORD WINAPI RunSetupThreadProc ( IN LPVOID  lpParameter)
static

Definition at line 57 of file setup.c.

59 {
60  PROCESS_INFORMATION ProcessInformation;
61  STARTUPINFOW StartupInfo;
63  WCHAR CommandLine[MAX_PATH];
64  BOOL Result;
65  DWORD dwError;
66  HKEY hKey;
67  DWORD dwType;
68  DWORD dwSize;
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,
88  (LPBYTE)Shell,
89  &dwSize);
90  RegCloseKey(hKey);
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 }
PWLSESSION WLSession
Definition: winlogon.c:20
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
HDESK WinlogonDesktop
Definition: winlogon.h:224
LPWSTR lpReserved
Definition: winbase.h:818
PBYTE lpReserved2
Definition: winbase.h:831
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1198
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
WORD cbReserved2
Definition: winbase.h:830
HDESK ApplicationDesktop
Definition: winlogon.h:223
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
LPWSTR lpDesktop
Definition: winbase.h:819
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lpTitle
Definition: winbase.h:820
_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:426
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:4623
#define TRACE(s)
Definition: solgame.cpp:4
DWORD cb
Definition: winbase.h:817
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI SwitchDesktop(_In_ HDESK)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static int Shell(const char **args)
Definition: vfdcmd.c:1020
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define DETACHED_PROCESS
Definition: winbase.h:179
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
DWORD dwFlags
Definition: winbase.h:828
#define INFINITE
Definition: serial.h:102
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by RunSetup().