mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Create a logon token and use it to start the shell process.
svn path=/trunk/; revision=8608
This commit is contained in:
parent
e380640f44
commit
282e78244f
1 changed files with 80 additions and 51 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: winlogon.c,v 1.26 2004/01/20 23:40:19 gvg Exp $
|
/* $Id: winlogon.c,v 1.27 2004/03/09 15:08:12 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -48,7 +48,8 @@ BOOL StartConsole = TRUE;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static void PrintString (WCHAR* fmt,...)
|
static void
|
||||||
|
PrintString (WCHAR* fmt,...)
|
||||||
{
|
{
|
||||||
WCHAR buffer[512];
|
WCHAR buffer[512];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -60,14 +61,12 @@ static void PrintString (WCHAR* fmt,...)
|
||||||
OutputDebugString(buffer);
|
OutputDebugString(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
|
||||||
CALLBACK
|
BOOL CALLBACK
|
||||||
ShutdownComputerProc(
|
ShutdownComputerProc (HWND hwndDlg,
|
||||||
HWND hwndDlg,
|
UINT uMsg,
|
||||||
UINT uMsg,
|
WPARAM wParam,
|
||||||
WPARAM wParam,
|
LPARAM lParam)
|
||||||
LPARAM lParam
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +90,8 @@ ShutdownComputerProc(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN StartServices(VOID)
|
static BOOLEAN
|
||||||
|
StartServices (VOID)
|
||||||
{
|
{
|
||||||
HANDLE ServicesInitEvent;
|
HANDLE ServicesInitEvent;
|
||||||
BOOLEAN Result;
|
BOOLEAN Result;
|
||||||
|
@ -161,7 +161,8 @@ static BOOLEAN StartServices(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if START_LSASS
|
#if START_LSASS
|
||||||
static BOOLEAN StartLsass(VOID)
|
static BOOLEAN
|
||||||
|
StartLsass (VOID)
|
||||||
{
|
{
|
||||||
HANDLE LsassInitEvent;
|
HANDLE LsassInitEvent;
|
||||||
BOOLEAN Result;
|
BOOLEAN Result;
|
||||||
|
@ -212,7 +213,10 @@ static BOOLEAN StartLsass(VOID)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
static BOOLEAN OpenRegistryKey(HANDLE *WinLogonKey)
|
|
||||||
|
|
||||||
|
static BOOLEAN
|
||||||
|
OpenRegistryKey (HANDLE *WinLogonKey)
|
||||||
{
|
{
|
||||||
return ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
return ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||||
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
|
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\WinLogon",
|
||||||
|
@ -221,6 +225,7 @@ static BOOLEAN OpenRegistryKey(HANDLE *WinLogonKey)
|
||||||
WinLogonKey);
|
WinLogonKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOLEAN StartProcess(PWCHAR ValueName)
|
static BOOLEAN StartProcess(PWCHAR ValueName)
|
||||||
{
|
{
|
||||||
BOOL StartIt;
|
BOOL StartIt;
|
||||||
|
@ -306,7 +311,9 @@ static BOOL StartIntoGUI(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PWCHAR GetShell(WCHAR *CommandLine)
|
|
||||||
|
static PWCHAR
|
||||||
|
GetShell (WCHAR *CommandLine)
|
||||||
{
|
{
|
||||||
HANDLE WinLogonKey;
|
HANDLE WinLogonKey;
|
||||||
BOOL GotCommandLine;
|
BOOL GotCommandLine;
|
||||||
|
@ -348,47 +355,69 @@ static PWCHAR GetShell(WCHAR *CommandLine)
|
||||||
return CommandLine;
|
return CommandLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL DoLoginUser(PWCHAR Name, PWCHAR Password)
|
|
||||||
|
static BOOL
|
||||||
|
DoLogonUser (PWCHAR Name,
|
||||||
|
PWCHAR Password)
|
||||||
{
|
{
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
STARTUPINFO StartupInfo;
|
STARTUPINFO StartupInfo;
|
||||||
BOOLEAN Result;
|
WCHAR CommandLine[MAX_PATH];
|
||||||
WCHAR CommandLine[MAX_PATH];
|
WCHAR CurrentDirectory[MAX_PATH];
|
||||||
WCHAR CurrentDirectory[MAX_PATH];
|
HANDLE hToken;
|
||||||
|
BOOL Result;
|
||||||
|
|
||||||
GetWindowsDirectory(CurrentDirectory, MAX_PATH);
|
Result = LogonUserW (Name,
|
||||||
|
NULL,
|
||||||
|
Password,
|
||||||
|
LOGON32_LOGON_INTERACTIVE,
|
||||||
|
LOGON32_PROVIDER_DEFAULT,
|
||||||
|
&hToken);
|
||||||
|
if (!Result)
|
||||||
|
{
|
||||||
|
DbgPrint ("WL: LogonUserW failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
StartupInfo.cb = sizeof(StartupInfo);
|
GetWindowsDirectoryW(CurrentDirectory, MAX_PATH);
|
||||||
StartupInfo.lpReserved = NULL;
|
|
||||||
StartupInfo.lpDesktop = NULL;
|
StartupInfo.cb = sizeof(StartupInfo);
|
||||||
StartupInfo.lpTitle = NULL;
|
StartupInfo.lpReserved = NULL;
|
||||||
StartupInfo.dwFlags = 0;
|
StartupInfo.lpDesktop = NULL;
|
||||||
StartupInfo.cbReserved2 = 0;
|
StartupInfo.lpTitle = NULL;
|
||||||
StartupInfo.lpReserved2 = 0;
|
StartupInfo.dwFlags = 0;
|
||||||
|
StartupInfo.cbReserved2 = 0;
|
||||||
Result = CreateProcess(NULL,
|
StartupInfo.lpReserved2 = 0;
|
||||||
GetShell(CommandLine),
|
|
||||||
NULL,
|
Result = CreateProcessAsUserW (hToken,
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
GetShell (CommandLine),
|
||||||
CREATE_NEW_CONSOLE,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
CurrentDirectory,
|
FALSE,
|
||||||
&StartupInfo,
|
CREATE_NEW_CONSOLE,
|
||||||
&ProcessInformation);
|
NULL,
|
||||||
|
CurrentDirectory,
|
||||||
|
&StartupInfo,
|
||||||
|
&ProcessInformation);
|
||||||
if (!Result)
|
if (!Result)
|
||||||
{
|
{
|
||||||
DbgPrint("WL: Failed to execute user shell %s\n", CommandLine);
|
DbgPrint ("WL: Failed to execute user shell %s\n", CommandLine);
|
||||||
return FALSE;
|
CloseHandle (hToken);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
|
|
||||||
CloseHandle( ProcessInformation.hProcess );
|
|
||||||
CloseHandle( ProcessInformation.hThread );
|
|
||||||
|
|
||||||
return TRUE;
|
WaitForSingleObject (ProcessInformation.hProcess, INFINITE);
|
||||||
|
CloseHandle (ProcessInformation.hProcess);
|
||||||
|
CloseHandle (ProcessInformation.hThread);
|
||||||
|
|
||||||
|
CloseHandle (hToken);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int STDCALL
|
int STDCALL
|
||||||
WinMain(HINSTANCE hInstance,
|
WinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
|
@ -396,8 +425,8 @@ WinMain(HINSTANCE hInstance,
|
||||||
int nShowCmd)
|
int nShowCmd)
|
||||||
{
|
{
|
||||||
#if SUPPORT_CONSOLESTART
|
#if SUPPORT_CONSOLESTART
|
||||||
WCHAR LoginName[255];
|
// WCHAR LoginName[255];
|
||||||
WCHAR Password[255];
|
// WCHAR Password[255];
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
LSA_STRING ProcessName, PackageName;
|
LSA_STRING ProcessName, PackageName;
|
||||||
|
@ -494,11 +523,10 @@ WinMain(HINSTANCE hInstance,
|
||||||
RunSetup ();
|
RunSetup ();
|
||||||
|
|
||||||
NtShutdownSystem (ShutdownReboot);
|
NtShutdownSystem (ShutdownReboot);
|
||||||
// NtShutdownSystem (ShutdownNoReboot);
|
|
||||||
ExitProcess (0);
|
ExitProcess (0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SUPPORT_CONSOLESTART
|
#if SUPPORT_CONSOLESTART
|
||||||
StartConsole = !StartIntoGUI();
|
StartConsole = !StartIntoGUI();
|
||||||
if(!StartConsole)
|
if(!StartConsole)
|
||||||
|
@ -510,7 +538,7 @@ WinMain(HINSTANCE hInstance,
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME - better solution needed */
|
/* FIXME - better solution needed */
|
||||||
hShutdownEvent = CreateEvent(NULL,
|
hShutdownEvent = CreateEvent(NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -642,7 +670,8 @@ WinMain(HINSTANCE hInstance,
|
||||||
#if SUPPORT_CONSOLESTART
|
#if SUPPORT_CONSOLESTART
|
||||||
if(StartConsole)
|
if(StartConsole)
|
||||||
{
|
{
|
||||||
if (! DoLoginUser(LoginName, Password))
|
// if (! DoLogonUser(LoginName, Password))
|
||||||
|
if (! DoLogonUser(L"Administrator", L"Secret"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue