Dialog.cpp revision 8b63052c2c607c3d632a6945ce24d99a434b8e81
/** @file
*
* VBoxGINA -- Windows Logon DLL for VirtualBox Dialog Code
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <windows.h>
#include <stdio.h> /* Needed for swprintf() */
#include "Dialog.h"
#include "WinWlx.h"
#include "Helper.h"
#include "VBoxGINA.h"
//
// MSGINA dialog box IDs.
//
#define IDD_WLXDIAPLAYSASNOTICE_DIALOG 1400
#define IDD_WLXLOGGEDOUTSAS_DIALOG 1450
/* the Windows 2000 ID */
#define IDD_WLXLOGGEDOUTSAS_DIALOG2 1500
#define IDD_CHANGE_PASSWORD_DIALOG 1550
#define IDD_WLXLOGGEDONSAS_DIALOG 1650
#define IDD_WLXWKSTALOCKEDSAS_DIALOG 1850
//
// MSGINA control IDs
//
#define IDC_WLXLOGGEDOUTSAS_USERNAME 1453
#define IDC_WLXLOGGEDOUTSAS_USERNAME2 1502
#define IDC_WLXLOGGEDOUTSAS_PASSWORD 1454
#define IDC_WLXLOGGEDOUTSAS_PASSWORD2 1503
#define IDC_WLXLOGGEDOUTSAS_DOMAIN 1455
#define IDC_WLXLOGGEDOUTSAS_DOMAIN2 1504
#define IDC_WLXWKSTALOCKEDSAS_DOMAIN 1856
{
Log(("VBoxGINA::hookDialogBoxes\n"));
/* this is version dependent */
switch (dwWlxVersion)
{
case WLX_VERSION_1_0:
{
break;
}
case WLX_VERSION_1_1:
{
break;
}
case WLX_VERSION_1_2:
{
break;
}
case WLX_VERSION_1_3:
{
break;
}
case WLX_VERSION_1_4:
{
break;
}
default:
{
/* not good, don't do anything */
break;
}
}
}
//
// Redirected WlxLoggedOutSASDlgProc().
//
#define CREDPOLL_TIMERID 0x1243
{
/*Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc\n"));*/
//
// Pass on to MSGINA first.
//
//
// We are only interested in the WM_INITDIALOG message.
//
switch (uMsg)
{
case WM_INITDIALOG:
{
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: got WM_INITDIALOG\n"));
/* get the entry fields */
if (!hwndUserId)
if (!hwndPassword)
if (!hwndDomain)
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: hwndUserId: %x, hwndPassword: %d, hwndDomain: %d\n",
/* terminate the credentials poller thread, it's done is job */
if (credentialsAvailable())
{
/* query the credentials from VBox */
if (credentialsRetrieve())
{
if (hwndDomain)
{
/* search the domain combo box for our required domain and select it */
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Trying to find domain entry in combo box ...\n"));
{
}
else
{
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain not found in combo box ...\n"));
/* If the domain value has a dot (.) in it, it is a FQDN (Fully Qualified Domain Name)
* which will not work with the combo box selection because Windows only keeps the
* NETBIOS names to the left most part of the domain name there. Of course a FQDN
* then will not be found by the search in the block below.
*
* To solve this problem the FQDN domain value will be appended at the user name value
* (Kerberos style) using an "@", e.g. "<user-name>@full.qualified.domain".
*
*/
if (l > 255)
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Warning! FQDN is too long (max 255 bytes), will be truncated!\n"));
if ( l > 0
&& wcslen(g_Username) > 0
&& wcsstr(g_Domain, L".") != NULL) /* if we found a dot (.) in the domain name, this has to be a FQDN */
{
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: Domain seems to be a FQDN!\n"));
}
}
}
if (hwndUserId)
{
if (!bIsFQDN)
else
}
if (hwndPassword)
/* we got the credentials, null them out */
/* confirm the logon dialog, simulating the user pressing "OK" */
}
}
else
{
/*
* The dialog is there but we don't have any credentials.
* Create a timer and poll for them.
*/
if (!timer)
{
Log(("VBoxGINA::MyWlxLoggedOutSASDlgProc: failed creating timer! last error: %s\n",
GetLastError()));
}
}
break;
}
case WM_TIMER:
{
/* is it our credentials poller timer? */
if (wParam == CREDPOLL_TIMERID)
{
if (credentialsAvailable())
{
if (credentialsRetrieve())
{
if (hwndUserId)
if (hwndPassword)
if (hwndDomain)
/* we got the credentials, null them out */
/* confirm the logon dialog, simulating the user pressing "OK" */
/* we don't need the timer any longer */
/** @todo will we leak the timer when logging in manually? Should we kill it on WM_CLOSE? */
}
}
}
break;
}
}
return bResult;
}
{
//
// We only know MSGINA dialogs by identifiers.
//
if (!HIWORD((int)(void*)lpszTemplate))
{
//
// Hook appropriate dialog boxes as necessary.
//
switch ((DWORD) lpszTemplate)
{
{
Log(("VBoxGINA::MyWlxDialogBoxParam: returning hooked logged out dialog\n"));
}
}
}
//
// The rest will not be redirected.
//
}