mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 05:22:57 +00:00
Cleanup WlxInitialize(), WlxStartApplication() and WlxActivateUserShell()
Allocate and return a valid PWLX_PROFILE structure in DoLoginTasks Fix some warnings svn path=/trunk/; revision=28315
This commit is contained in:
parent
c13edbee03
commit
e65bdff8a0
5 changed files with 178 additions and 104 deletions
|
@ -18,7 +18,7 @@ END
|
||||||
|
|
||||||
IDD_LOGGEDOUT_DLG DIALOGEX 0,0,275,147
|
IDD_LOGGEDOUT_DLG DIALOGEX 0,0,275,147
|
||||||
STYLE NOT WS_VISIBLE | DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP
|
STYLE NOT WS_VISIBLE | DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SETFONT | DS_FIXEDSYS | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP
|
||||||
CAPTION "Connection"
|
CAPTION "Connexion"
|
||||||
FONT 8,"MS Shell Dlg 2",400,0,1
|
FONT 8,"MS Shell Dlg 2",400,0,1
|
||||||
BEGIN
|
BEGIN
|
||||||
PUSHBUTTON "OK",IDOK,51,122,50,14,BS_DEFPUSHBUTTON
|
PUSHBUTTON "OK",IDOK,51,122,50,14,BS_DEFPUSHBUTTON
|
||||||
|
|
|
@ -66,6 +66,10 @@ ReadRegSzKey(
|
||||||
DWORD cbData = 0;
|
DWORD cbData = 0;
|
||||||
LPWSTR Value;
|
LPWSTR Value;
|
||||||
|
|
||||||
|
if (!pValue)
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
*pValue = NULL;
|
||||||
rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
|
rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -147,33 +151,38 @@ WlxInitialize(
|
||||||
{
|
{
|
||||||
PGINA_CONTEXT pgContext;
|
PGINA_CONTEXT pgContext;
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(pvReserved);
|
||||||
|
|
||||||
pgContext = (PGINA_CONTEXT)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, sizeof(GINA_CONTEXT));
|
pgContext = (PGINA_CONTEXT)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, sizeof(GINA_CONTEXT));
|
||||||
if(!pgContext)
|
if(!pgContext)
|
||||||
|
{
|
||||||
|
WARN("LocalAlloc() failed\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* return the context to winlogon */
|
/* Return the context to winlogon */
|
||||||
*pWlxContext = (PVOID)pgContext;
|
*pWlxContext = (PVOID)pgContext;
|
||||||
|
|
||||||
pgContext->hDllInstance = hDllInstance;
|
pgContext->hDllInstance = hDllInstance;
|
||||||
|
|
||||||
/* save pointer to dispatch table */
|
/* Save pointer to dispatch table */
|
||||||
pgContext->pWlxFuncs = (PWLX_DISPATCH_VERSION_1_3)pWinlogonFunctions;
|
pgContext->pWlxFuncs = (PWLX_DISPATCH_VERSION_1_3)pWinlogonFunctions;
|
||||||
|
|
||||||
/* save the winlogon handle used to call the dispatch functions */
|
/* Save the winlogon handle used to call the dispatch functions */
|
||||||
pgContext->hWlx = hWlx;
|
pgContext->hWlx = hWlx;
|
||||||
|
|
||||||
/* save window station */
|
/* Save window station */
|
||||||
pgContext->station = lpWinsta;
|
pgContext->station = lpWinsta;
|
||||||
|
|
||||||
/* clear status window handle */
|
/* Clear status window handle */
|
||||||
pgContext->hStatusWindow = 0;
|
pgContext->hStatusWindow = 0;
|
||||||
|
|
||||||
/* notify winlogon that we will use the default SAS */
|
/* Notify winlogon that we will use the default SAS */
|
||||||
pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx);
|
pgContext->pWlxFuncs->WlxUseCtrlAltDel(hWlx);
|
||||||
|
|
||||||
/* Locates the authentification package */
|
/* Locates the authentification package */
|
||||||
//LsaRegisterLogonProcess(...);
|
//LsaRegisterLogonProcess(...);
|
||||||
|
|
||||||
|
/* Check autologon settings the first time */
|
||||||
pgContext->AutoLogonState = AUTOLOGON_CHECK_REGISTRY;
|
pgContext->AutoLogonState = AUTOLOGON_CHECK_REGISTRY;
|
||||||
|
|
||||||
ChooseGinaUI();
|
ChooseGinaUI();
|
||||||
|
@ -194,20 +203,25 @@ WlxStartApplication(
|
||||||
STARTUPINFOW StartupInfo;
|
STARTUPINFOW StartupInfo;
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
WCHAR CurrentDirectory[MAX_PATH];
|
WCHAR CurrentDirectory[MAX_PATH];
|
||||||
BOOL Ret;
|
UINT len;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
||||||
StartupInfo.cb = sizeof(STARTUPINFOW);
|
StartupInfo.cb = sizeof(STARTUPINFOW);
|
||||||
StartupInfo.lpReserved = NULL;
|
|
||||||
StartupInfo.lpTitle = pszCmdLine;
|
StartupInfo.lpTitle = pszCmdLine;
|
||||||
StartupInfo.dwX = StartupInfo.dwY = StartupInfo.dwXSize = StartupInfo.dwYSize = 0L;
|
StartupInfo.dwX = StartupInfo.dwY = StartupInfo.dwXSize = StartupInfo.dwYSize = 0L;
|
||||||
StartupInfo.dwFlags = 0;
|
StartupInfo.dwFlags = 0;
|
||||||
StartupInfo.wShowWindow = SW_SHOW;
|
StartupInfo.wShowWindow = SW_SHOW;
|
||||||
StartupInfo.lpReserved2 = NULL;
|
|
||||||
StartupInfo.cbReserved2 = 0;
|
|
||||||
StartupInfo.lpDesktop = pszDesktopName;
|
StartupInfo.lpDesktop = pszDesktopName;
|
||||||
|
|
||||||
GetWindowsDirectoryW (CurrentDirectory, MAX_PATH);
|
len = GetWindowsDirectoryW(CurrentDirectory, MAX_PATH);
|
||||||
Ret = CreateProcessAsUserW(pgContext->UserToken,
|
if (len > MAX_PATH)
|
||||||
|
{
|
||||||
|
WARN("GetWindowsDirectoryW() failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ret = CreateProcessAsUserW(
|
||||||
|
pgContext->UserToken,
|
||||||
pszCmdLine,
|
pszCmdLine,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -218,12 +232,11 @@ WlxStartApplication(
|
||||||
CurrentDirectory,
|
CurrentDirectory,
|
||||||
&StartupInfo,
|
&StartupInfo,
|
||||||
&ProcessInformation);
|
&ProcessInformation);
|
||||||
|
if (!ret)
|
||||||
//VirtualFree(pEnvironment, 0, MEM_RELEASE);
|
WARN("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
|
||||||
return Ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -236,36 +249,56 @@ WlxActivateUserShell(
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD BufSize, ValueType;
|
DWORD BufSize, ValueType;
|
||||||
WCHAR pszUserInitApp[MAX_PATH];
|
WCHAR pszUserInitApp[MAX_PATH + 1];
|
||||||
WCHAR pszExpUserInitApp[MAX_PATH];
|
WCHAR pszExpUserInitApp[MAX_PATH];
|
||||||
TRACE("WlxActivateUserShell()\n");
|
DWORD len;
|
||||||
/* get the path of userinit */
|
LONG rc;
|
||||||
if(RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
||||||
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
|
|
||||||
0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
|
|
||||||
{ERR("GINA: Failed: 1\n");
|
|
||||||
VirtualFree(pEnvironment, 0, MEM_RELEASE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
BufSize = MAX_PATH * sizeof(WCHAR);
|
|
||||||
if((RegQueryValueExW(hKey, L"Userinit", NULL, &ValueType, (LPBYTE)pszUserInitApp,
|
|
||||||
&BufSize) != ERROR_SUCCESS) ||
|
|
||||||
!((ValueType == REG_SZ) || (ValueType == REG_EXPAND_SZ)))
|
|
||||||
{ERR("GINA: Failed: 2\n");
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
VirtualFree(pEnvironment, 0, MEM_RELEASE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
ExpandEnvironmentStringsW(pszUserInitApp, pszExpUserInitApp, MAX_PATH);
|
|
||||||
|
|
||||||
/* Start userinit */
|
TRACE("WlxActivateUserShell()\n");
|
||||||
/* FIXME - allow to start more applications that are comma-separated */
|
|
||||||
/* FIXME: Call VirtualFree(pEnvironment, 0, MEM_RELEASE); ? */
|
UNREFERENCED_PARAMETER(pszMprLogonScript);
|
||||||
|
|
||||||
|
/* Get the path of userinit */
|
||||||
|
rc = RegOpenKeyExW(
|
||||||
|
HKEY_LOCAL_MACHINE,
|
||||||
|
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
|
||||||
|
0,
|
||||||
|
KEY_QUERY_VALUE,
|
||||||
|
&hKey);
|
||||||
|
if (rc != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
WARN("RegOpenKeyExW() failed with error %lu\n", rc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Query userinit application */
|
||||||
|
BufSize = sizeof(pszUserInitApp) - sizeof(UNICODE_NULL);
|
||||||
|
rc = RegQueryValueExW(
|
||||||
|
hKey,
|
||||||
|
L"Userinit",
|
||||||
|
NULL,
|
||||||
|
&ValueType,
|
||||||
|
(LPBYTE)pszUserInitApp,
|
||||||
|
&BufSize);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
if (rc != ERROR_SUCCESS || (ValueType != REG_SZ && ValueType != REG_EXPAND_SZ))
|
||||||
|
{
|
||||||
|
WARN("RegQueryValueExW() failed with error %lu\n", rc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
pszUserInitApp[MAX_PATH] = UNICODE_NULL;
|
||||||
|
|
||||||
|
len = ExpandEnvironmentStringsW(pszUserInitApp, pszExpUserInitApp, MAX_PATH);
|
||||||
|
if (len > MAX_PATH)
|
||||||
|
{
|
||||||
|
WARN("ExpandEnvironmentStringsW() failed. Required size %lu\n", len);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Start userinit app */
|
||||||
return WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
|
return WlxStartApplication(pWlxContext, pszDesktopName, pEnvironment, pszExpUserInitApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -280,6 +313,8 @@ WlxLoggedOnSAS(
|
||||||
|
|
||||||
TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
|
TRACE("WlxLoggedOnSAS(0x%lx)\n", dwSasType);
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(pReserved);
|
||||||
|
|
||||||
switch (dwSasType)
|
switch (dwSasType)
|
||||||
{
|
{
|
||||||
case WLX_SAS_TYPE_CTRL_ALT_DEL:
|
case WLX_SAS_TYPE_CTRL_ALT_DEL:
|
||||||
|
@ -361,8 +396,11 @@ DoLoginTasks(
|
||||||
IN PWSTR Domain,
|
IN PWSTR Domain,
|
||||||
IN PWSTR Password)
|
IN PWSTR Password)
|
||||||
{
|
{
|
||||||
|
LPWSTR ProfilePath = NULL;
|
||||||
TOKEN_STATISTICS Stats;
|
TOKEN_STATISTICS Stats;
|
||||||
DWORD cbStats;
|
PWLX_PROFILE_V1_0 pProfile = NULL;
|
||||||
|
DWORD cbStats, cbSize;
|
||||||
|
BOOL bResult;
|
||||||
|
|
||||||
if (!LogonUserW(UserName, Domain, Password,
|
if (!LogonUserW(UserName, Domain, Password,
|
||||||
LOGON32_LOGON_INTERACTIVE, /* FIXME - use LOGON32_LOGON_UNLOCK instead! */
|
LOGON32_LOGON_INTERACTIVE, /* FIXME - use LOGON32_LOGON_UNLOCK instead! */
|
||||||
|
@ -370,17 +408,37 @@ DoLoginTasks(
|
||||||
&pgContext->UserToken))
|
&pgContext->UserToken))
|
||||||
{
|
{
|
||||||
WARN("LogonUserW() failed\n");
|
WARN("LogonUserW() failed\n");
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pgContext->UserToken)
|
/* Get profile path */
|
||||||
|
cbSize = 0;
|
||||||
|
bResult = GetProfilesDirectoryW(NULL, &cbSize);
|
||||||
|
if (!bResult && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
WARN("UserToken == NULL!\n");
|
ProfilePath = HeapAlloc(GetProcessHeap(), 0, cbSize * sizeof(WCHAR));
|
||||||
return FALSE;
|
if (!ProfilePath)
|
||||||
|
{
|
||||||
|
WARN("HeapAlloc() failed\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
bResult = GetProfilesDirectoryW(ProfilePath, &cbSize);
|
||||||
|
}
|
||||||
|
if (!bResult)
|
||||||
|
{
|
||||||
|
WARN("GetUserProfileDirectoryW() failed\n");
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pgContext->pdwOptions = 0;
|
/* Allocate memory for profile */
|
||||||
*pgContext->pProfile = NULL;
|
pProfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WLX_PROFILE_V1_0));
|
||||||
|
if (!pProfile)
|
||||||
|
{
|
||||||
|
WARN("HeapAlloc() failed\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
pProfile->dwType = WLX_PROFILE_TYPE_V1_0;
|
||||||
|
pProfile->pszProfile = ProfilePath;
|
||||||
|
|
||||||
if (!GetTokenInformation(pgContext->UserToken,
|
if (!GetTokenInformation(pgContext->UserToken,
|
||||||
TokenStatistics,
|
TokenStatistics,
|
||||||
|
@ -389,14 +447,21 @@ DoLoginTasks(
|
||||||
&cbStats))
|
&cbStats))
|
||||||
{
|
{
|
||||||
WARN("Couldn't get Authentication id from user token!\n");
|
WARN("Couldn't get Authentication id from user token!\n");
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
*pgContext->pAuthenticationId = Stats.AuthenticationId;
|
*pgContext->pAuthenticationId = Stats.AuthenticationId;
|
||||||
pgContext->pNprNotifyInfo->pszUserName = DuplicationString(UserName);
|
pgContext->pNprNotifyInfo->pszUserName = DuplicationString(UserName);
|
||||||
pgContext->pNprNotifyInfo->pszDomain = DuplicationString(Domain);
|
pgContext->pNprNotifyInfo->pszDomain = DuplicationString(Domain);
|
||||||
pgContext->pNprNotifyInfo->pszPassword = DuplicationString(Password);
|
pgContext->pNprNotifyInfo->pszPassword = DuplicationString(Password);
|
||||||
pgContext->pNprNotifyInfo->pszOldPassword = NULL;
|
pgContext->pNprNotifyInfo->pszOldPassword = NULL;
|
||||||
|
*pgContext->pdwOptions = 0;
|
||||||
|
*pgContext->pProfile = pProfile;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
HeapFree(GetProcessHeap(), 0, pProfile);
|
||||||
|
HeapFree(GetProcessHeap(), 0, ProfilePath);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
|
@ -543,12 +608,15 @@ WlxLoggedOutSAS(
|
||||||
|
|
||||||
TRACE("WlxLoggedOutSAS()\n");
|
TRACE("WlxLoggedOutSAS()\n");
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(dwSasType);
|
||||||
|
UNREFERENCED_PARAMETER(pLogonSid);
|
||||||
|
|
||||||
pgContext->pAuthenticationId = pAuthenticationId;
|
pgContext->pAuthenticationId = pAuthenticationId;
|
||||||
pgContext->pdwOptions = pdwOptions;
|
pgContext->pdwOptions = pdwOptions;
|
||||||
pgContext->pNprNotifyInfo = pNprNotifyInfo;
|
pgContext->pNprNotifyInfo = pNprNotifyInfo;
|
||||||
pgContext->pProfile = pProfile;
|
pgContext->pProfile = pProfile;
|
||||||
|
|
||||||
if (!GetSystemMetrics(SM_REMOTESESSION) &&
|
if (0 == GetSystemMetrics(SM_REMOTESESSION) &&
|
||||||
DoAutoLogon(pgContext))
|
DoAutoLogon(pgContext))
|
||||||
{
|
{
|
||||||
/* User is local and registry contains information
|
/* User is local and registry contains information
|
||||||
|
@ -574,6 +642,8 @@ WlxWkstaLockedSAS(
|
||||||
|
|
||||||
TRACE("WlxWkstaLockedSAS()\n");
|
TRACE("WlxWkstaLockedSAS()\n");
|
||||||
|
|
||||||
|
UNREFERENCED_PARAMETER(dwSasType);
|
||||||
|
|
||||||
return pGinaUI->LockedSAS(pgContext);
|
return pGinaUI->LockedSAS(pgContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,6 +653,8 @@ DllMain(
|
||||||
IN DWORD dwReason,
|
IN DWORD dwReason,
|
||||||
IN LPVOID lpvReserved)
|
IN LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(lpvReserved);
|
||||||
|
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
hDllInstance = hinstDLL;
|
hDllInstance = hinstDLL;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __MSGINA_H
|
#define __MSGINA_H
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <userenv.h>
|
||||||
#include <winwlx.h>
|
#include <winwlx.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<library>advapi32</library>
|
<library>advapi32</library>
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>gdi32</library>
|
<library>gdi32</library>
|
||||||
|
<library>userenv</library>
|
||||||
<file>gui.c</file>
|
<file>gui.c</file>
|
||||||
<file>msgina.c</file>
|
<file>msgina.c</file>
|
||||||
<file>stubs.c</file>
|
<file>stubs.c</file>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue