mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Load user profile and create user environment upon user logon.
svn path=/trunk/; revision=8814
This commit is contained in:
parent
baaf29305f
commit
8b50600e95
2 changed files with 59 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.8 2003/12/01 18:21:04 weiden Exp $
|
# $Id: makefile,v 1.9 2004/03/20 15:58:16 ekohl Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../../..
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ TARGET_NAME = winlogon
|
||||||
|
|
||||||
TARGET_INSTALLDIR = system32
|
TARGET_INSTALLDIR = system32
|
||||||
|
|
||||||
TARGET_SDKLIBS = ntdll.a kernel32.a user32.a secur32.a
|
TARGET_SDKLIBS = ntdll.a kernel32.a user32.a advapi32.a userenv.a secur32.a
|
||||||
|
|
||||||
TARGET_OBJECTS = $(TARGET_NAME).o setup.o wlx.o
|
TARGET_OBJECTS = setup.o winlogon.o wlx.o
|
||||||
|
|
||||||
TARGET_CFLAGS = -Wall -Werror -DUNICODE -I./ -I../../../include
|
TARGET_CFLAGS = -Wall -Werror -DUNICODE -I./ -I../../../include
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: winlogon.c,v 1.27 2004/03/09 15:08:12 ekohl Exp $
|
/* $Id: winlogon.c,v 1.28 2004/03/20 15:58:16 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -11,11 +11,13 @@
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ntsecapi.h>
|
#include <ntsecapi.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <userenv.h>
|
||||||
|
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
#include "winlogon.h"
|
#include "winlogon.h"
|
||||||
|
@ -285,7 +287,7 @@ static BOOL RestartShell(void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if SUPPORT_CONSOLESTART
|
#if SUPPORT_CONSOLESTART
|
||||||
static BOOL StartIntoGUI(void)
|
static BOOL StartIntoGUI(VOID)
|
||||||
{
|
{
|
||||||
HANDLE WinLogonKey;
|
HANDLE WinLogonKey;
|
||||||
DWORD Type, Size, Value;
|
DWORD Type, Size, Value;
|
||||||
|
@ -365,7 +367,9 @@ DoLogonUser (PWCHAR Name,
|
||||||
WCHAR CommandLine[MAX_PATH];
|
WCHAR CommandLine[MAX_PATH];
|
||||||
WCHAR CurrentDirectory[MAX_PATH];
|
WCHAR CurrentDirectory[MAX_PATH];
|
||||||
HANDLE hToken;
|
HANDLE hToken;
|
||||||
|
PROFILEINFOW ProfileInfo;
|
||||||
BOOL Result;
|
BOOL Result;
|
||||||
|
LPVOID lpEnvironment = NULL;
|
||||||
|
|
||||||
Result = LogonUserW (Name,
|
Result = LogonUserW (Name,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -375,11 +379,39 @@ DoLogonUser (PWCHAR Name,
|
||||||
&hToken);
|
&hToken);
|
||||||
if (!Result)
|
if (!Result)
|
||||||
{
|
{
|
||||||
DbgPrint ("WL: LogonUserW failed\n");
|
DbgPrint ("WL: LogonUserW() failed\n");
|
||||||
|
RtlDestroyEnvironment (lpEnvironment);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetWindowsDirectoryW(CurrentDirectory, MAX_PATH);
|
/* Load the user profile */
|
||||||
|
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
||||||
|
ProfileInfo.dwFlags = 0;
|
||||||
|
ProfileInfo.lpUserName = Name;
|
||||||
|
ProfileInfo.lpProfilePath = NULL;
|
||||||
|
ProfileInfo.lpDefaultPath = NULL;
|
||||||
|
ProfileInfo.lpServerName = NULL;
|
||||||
|
ProfileInfo.lpPolicyPath = NULL;
|
||||||
|
ProfileInfo.hProfile = NULL;
|
||||||
|
|
||||||
|
if (!LoadUserProfileW (hToken,
|
||||||
|
&ProfileInfo))
|
||||||
|
{
|
||||||
|
DbgPrint ("WL: LoadUserProfileW() failed\n");
|
||||||
|
CloseHandle (hToken);
|
||||||
|
RtlDestroyEnvironment (lpEnvironment);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CreateEnvironmentBlock (&lpEnvironment,
|
||||||
|
hToken,
|
||||||
|
TRUE))
|
||||||
|
{
|
||||||
|
DbgPrint ("WL: CreateEnvironmentBlock() failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetWindowsDirectoryW (CurrentDirectory, MAX_PATH);
|
||||||
|
|
||||||
StartupInfo.cb = sizeof(StartupInfo);
|
StartupInfo.cb = sizeof(StartupInfo);
|
||||||
StartupInfo.lpReserved = NULL;
|
StartupInfo.lpReserved = NULL;
|
||||||
|
@ -395,24 +427,33 @@ DoLogonUser (PWCHAR Name,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
CREATE_NEW_CONSOLE,
|
CREATE_NEW_CONSOLE,// | CREATE_UNICODE_ENVIRONMENT,
|
||||||
NULL,
|
lpEnvironment, // NULL,
|
||||||
CurrentDirectory,
|
CurrentDirectory,
|
||||||
&StartupInfo,
|
&StartupInfo,
|
||||||
&ProcessInformation);
|
&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);
|
||||||
CloseHandle (hToken);
|
UnloadUserProfile (hToken,
|
||||||
return FALSE;
|
ProfileInfo.hProfile);
|
||||||
}
|
CloseHandle (hToken);
|
||||||
|
DestroyEnvironmentBlock (lpEnvironment);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
WaitForSingleObject (ProcessInformation.hProcess, INFINITE);
|
WaitForSingleObject (ProcessInformation.hProcess, INFINITE);
|
||||||
CloseHandle (ProcessInformation.hProcess);
|
CloseHandle (ProcessInformation.hProcess);
|
||||||
CloseHandle (ProcessInformation.hThread);
|
CloseHandle (ProcessInformation.hThread);
|
||||||
|
|
||||||
|
/* Unload user profile */
|
||||||
|
UnloadUserProfile (hToken,
|
||||||
|
ProfileInfo.hProfile);
|
||||||
|
|
||||||
CloseHandle (hToken);
|
CloseHandle (hToken);
|
||||||
|
|
||||||
|
RtlDestroyEnvironment (lpEnvironment);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue