{************************************************************************}
{ }
{ Borland Delphi Runtime Library }
{ WinLogon eXtension (WLX) API interface unit }
{ }
{ Portions created by Microsoft are }
{ Copyright (C) 1985-1999 Microsoft Corporation. }
{ All Rights Reserved. }
{ }
{ The original file is: winwlx.h, released 02 Feb 2000. }
{ The original Pascal code is: WinWlx.pas, released 01 May 2001. }
{ The initial developer of the Pascal code is Nico Bendlin }
{ (nico@bendlin.de). }
{ }
{ Portions created by Nico Bendlin are }
{ Copyright (C) 2001 Nico Bendlin. }
{ }
{ Obtained through: }
{ }
{ Joint Endeavour of Delphi Innovators (Project JEDI) }
{ }
{ You may retrieve the latest version of this file at the Project }
{ JEDI home page, located at http://delphi-jedi.org }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{************************************************************************}

unit WinWlx;

interface

uses
Windows, Messages;


////////////////////////////////////////////////////////////////////////
// //
// #defines //
// //
////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// Revisions of Winlogon API available for use by GINAs
// Version is two parts: Major revision and minor revision.
// Major revision is the upper 16-bits, minor is the lower
// 16-bits.
//

const
WLX_VERSION_1_0 = $00010000;
{$EXTERNALSYM WLX_VERSION_1_0}
WLX_VERSION_1_1 = $00010001;
{$EXTERNALSYM WLX_VERSION_1_1}
WLX_VERSION_1_2 = $00010002;
{$EXTERNALSYM WLX_VERSION_1_2}
WLX_VERSION_1_3 = $00010003;
{$EXTERNALSYM WLX_VERSION_1_3}
WLX_CURRENT_VERSION = WLX_VERSION_1_3;
{$EXTERNALSYM WLX_CURRENT_VERSION}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// Secure attention sequence types
// These values are passed to routines that have a dwSasType
// parameter.
//
// ALL VALUES FROM 0 TO 127 ARE RESERVED FOR MICROSOFT DEFINITION.
// VALUES ABOVE 127 ARE RESERVED FOR CUSTOMER DEFINITION.
//
// CTRL_ALT_DEL - used to indicate that the standard ctrl-alt-del
// secure attention sequence has been entered.
//
// SCRNSVR_TIMEOUT - used to indicate that keyboard/mouse inactivity
// has lead to a screensaver activation. It is up to the GINA
// DLL whether this constitutes a workstation locking event.
//
// SCRNSVR_ACTIVITY - used to indicate that keyboard or mouse
// activity occured while a secure screensaver was active.
//
// SC_Insert - used to indicate that a smart card has been inserted
// to a compatible device
//
// SC_REMOVE - used to indicate that a smart card has been removed
// from a compatible device
//

const
WLX_SAS_TYPE_TIMEOUT = 0;
{$EXTERNALSYM WLX_SAS_TYPE_TIMEOUT}
WLX_SAS_TYPE_CTRL_ALT_DEL = 1;
{$EXTERNALSYM WLX_SAS_TYPE_CTRL_ALT_DEL}
WLX_SAS_TYPE_SCRNSVR_TIMEOUT = 2;
{$EXTERNALSYM WLX_SAS_TYPE_SCRNSVR_TIMEOUT}
WLX_SAS_TYPE_SCRNSVR_ACTIVITY = 3;
{$EXTERNALSYM WLX_SAS_TYPE_SCRNSVR_ACTIVITY}
WLX_SAS_TYPE_USER_LOGOFF = 4;
{$EXTERNALSYM WLX_SAS_TYPE_USER_LOGOFF}
WLX_SAS_TYPE_SC_Insert = 5;
{$EXTERNALSYM WLX_SAS_TYPE_SC_Insert}
WLX_SAS_TYPE_SC_REMOVE = 6;
{$EXTERNALSYM WLX_SAS_TYPE_SC_REMOVE}
WLX_SAS_TYPE_MAX_MSFT_VALUE = 127;
{$EXTERNALSYM WLX_SAS_TYPE_MAX_MSFT_VALUE}

//
// This structure is available through WlxGetOption, and is
// passed as the lParam for any S/C SAS notices sent to windows
//

type
PWlxScNotificationInfo = ^TWlxScNotificationInfo;
PWLX_SC_NOTIFICATION_INFO = PWlxScNotificationInfo;
{$EXTERNALSYM PWLX_SC_NOTIFICATION_INFO}
_WLX_SC_NOTIFICATION_INFO = record
pszCard : PWideChar;
pszReader : PWideChar;
pszContainer : PWideChar;
pszCryptoProvider: PWideChar;
end;
{$EXTERNALSYM _WLX_SC_NOTIFICATION_INFO}
TWlxScNotificationInfo = _WLX_SC_NOTIFICATION_INFO;
WLX_SC_NOTIFICATION_INFO = _WLX_SC_NOTIFICATION_INFO;
{$EXTERNALSYM WLX_SC_NOTIFICATION_INFO}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// Upon successful logon, the GINA DLL may specify any of the following
// options to Winlogon (via the dwOptions parameter of the WlxLoggedOutSas()
// api). When set, these options specify:
//
// NO_PROFILE - Winlogon must NOT load a profile for the logged
// on user. Either the GINA DLL will take care of
// this activity, or the user does not need a profile.
//

const
WLX_LOGON_OPT_NO_PROFILE = $00000001;
{$EXTERNALSYM WLX_LOGON_OPT_NO_PROFILE}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// GINA DLLs are expected to return account information to Winlogon
// following a successful logon. This information allows Winlogon
// to support profile loading and supplemental network providers.
//
// To allow different sets of profile information to be returned
// by GINAs over time, the first DWORD of each profile structure
// is expected to contain a type-identifier. The following constants
// are the defined profile type identifiers.
//

//
// Standard profile is V2_0
//

const
WLX_PROFILE_TYPE_V1_0 = 1;
{$EXTERNALSYM WLX_PROFILE_TYPE_V1_0}
WLX_PROFILE_TYPE_V2_0 = 2;
{$EXTERNALSYM WLX_PROFILE_TYPE_V2_0}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// WlxLoggedOnSas() and WlxWkstaLockedSas() return an action
// value to Winlogon directing Winlogon to either remain unchanged
// or to perform some action (such as force-log the user off).
// These are the values that may be returned. Note, however, that
// not all of the values may be returned by both of these api. See
// the description of each api to see which values are expected from
// each.
//
// LOGON - User has logged on
// NONE - Don't change the state of the window station.
// LOCK_WKSTA - Lock the workstation, wait for next SAS.
// LOGOFF - Log the user off of the workstation.
// SHUTDOWN - Log the user off and shutdown the machine.
// PWD_CHANGED - Indicates that the user changed their password. Notify network providers.
// TASKLIST - Invoke the task list.
// UNLOCK_WKSTA - Unlock the workstation.
// FORCE_LOGOFF - Forcibly log the user off.
// SHUTDOWN_POWER_OFF - Turn off machine after shutting down.
// SHUTDOWN_REBOOT - Reboot machine after shutting down.
// SHUTDOWN_SLEEP - Put the machine to sleep
// SHUTDOWN_SLEEP2 - Put the machine to sleep and disable wakeup events
// SHUTDOWN_HIBERNATE - Hibernate the machine
// RECONNECTED - Session was reconnected to an earlier session
//

const
WLX_SAS_ACTION_LOGON = 1;
{$EXTERNALSYM WLX_SAS_ACTION_LOGON}
WLX_SAS_ACTION_NONE = 2;
{$EXTERNALSYM WLX_SAS_ACTION_NONE}
WLX_SAS_ACTION_LOCK_WKSTA = 3;
{$EXTERNALSYM WLX_SAS_ACTION_LOCK_WKSTA}
WLX_SAS_ACTION_LOGOFF = 4;
{$EXTERNALSYM WLX_SAS_ACTION_LOGOFF}
WLX_SAS_ACTION_SHUTDOWN = 5;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN}
WLX_SAS_ACTION_PWD_CHANGED = 6;
{$EXTERNALSYM WLX_SAS_ACTION_PWD_CHANGED}
WLX_SAS_ACTION_TASKLIST = 7;
{$EXTERNALSYM WLX_SAS_ACTION_TASKLIST}
WLX_SAS_ACTION_UNLOCK_WKSTA = 8;
{$EXTERNALSYM WLX_SAS_ACTION_UNLOCK_WKSTA}
WLX_SAS_ACTION_FORCE_LOGOFF = 9;
{$EXTERNALSYM WLX_SAS_ACTION_FORCE_LOGOFF}
WLX_SAS_ACTION_SHUTDOWN_POWER_OFF = 10;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN_POWER_OFF}
WLX_SAS_ACTION_SHUTDOWN_REBOOT = 11;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN_REBOOT}
WLX_SAS_ACTION_SHUTDOWN_SLEEP = 12;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN_SLEEP}
WLX_SAS_ACTION_SHUTDOWN_SLEEP2 = 13;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN_SLEEP2}
WLX_SAS_ACTION_SHUTDOWN_HIBERNATE = 14;
{$EXTERNALSYM WLX_SAS_ACTION_SHUTDOWN_HIBERNATE}
WLX_SAS_ACTION_RECONNECTED = 15;
{$EXTERNALSYM WLX_SAS_ACTION_RECONNECTED}
WLX_SAS_ACTION_DELAYED_FORCE_LOGOFF = 16;
{$EXTERNALSYM WLX_SAS_ACTION_DELAYED_FORCE_LOGOFF}


////////////////////////////////////////////////////////////////////////
// //
// Window Messages //
// //
////////////////////////////////////////////////////////////////////////


//
// The WM_SAS is defined as follows
//
// The wParam parameter has the SAS Type (above)
//

const
WLX_WM_SAS = WM_USER + 601;
{$EXTERNALSYM WLX_WM_SAS}

//
// Dialog return values
//
// These may be returned by dialogs started by a GINA dll.
//

const
WLX_DLG_SAS = 101;
{$EXTERNALSYM WLX_DLG_SAS}
WLX_DLG_INPUT_TIMEOUT = 102; // Input (keys, etc) timed out
{$EXTERNALSYM WLX_DLG_INPUT_TIMEOUT}
WLX_DLG_SCREEN_SAVER_TIMEOUT = 103; // Screen Saver activated
{$EXTERNALSYM WLX_DLG_SCREEN_SAVER_TIMEOUT}
WLX_DLG_USER_LOGOFF = 104; // User logged off
{$EXTERNALSYM WLX_DLG_USER_LOGOFF}


////////////////////////////////////////////////////////////////////////
// //
// #data types //
// //
////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// The WLX_PROFILE_* structure is returned from a GINA DLL
// following authentication. This information is used by Winlogon
// to support supplemental Network Providers and to load the
// newly logged-on user's profile.
//
// Winlogon is responsible for freeing both the profile structure
// and the fields within the structure that are marked as separately
// deallocatable.
//

type
PWlxProfileV10 = ^TWlxProfileV10;
PWLX_PROFILE_V1_0 = PWlxProfileV10;
{$EXTERNALSYM PWLX_PROFILE_V1_0}
_WLX_PROFILE_V1_0 = record
//
// This field identifies the type of profile being returned by a
// GINA DLL. Profile types are defined with the prefix
// WLX_PROFILE_TYPE_xxx. It allows Winlogon to typecast the
// structure so the remainder of the structure may be referenced.
//
dwType : DWORD;
//
// pathname of profile to load for user.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
pszProfile: PWideChar;
end;
{$EXTERNALSYM _WLX_PROFILE_V1_0}
TWlxProfileV10 = _WLX_PROFILE_V1_0;
WLX_PROFILE_V1_0 = _WLX_PROFILE_V1_0;
{$EXTERNALSYM WLX_PROFILE_V1_0}

type
PWlxProfileV20 = ^TWlxProfileV20;
PWLX_PROFILE_V2_0 = PWlxProfileV20;
{$EXTERNALSYM PWLX_PROFILE_V2_0}
_WLX_PROFILE_V2_0 = record
//
// This field identifies the type of profile being returned by a
// GINA DLL. Profile types are defined with the prefix
// WLX_PROFILE_TYPE_xxx. It allows Winlogon to typecast the
// structure so the remainder of the structure may be referenced.
//
dwType : DWORD;
//
// pathname of profile to load for user.
//
// This parameter can be NULL. If so, the user has a local
// profile only.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
//
pszProfile : PWideChar;
//
// pathname of policy to load for user.
//
// This parameter can be NULL which prevents network wide policy
// from being applied.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
pszPolicy : PWideChar;
//
// pathname of network default user profile
//
// This parameter can be NULL, which causes the Default User
// profile on the local machine to be used.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
pszNetworkDefaultUserProfile: PWideChar;
//
// name of the server which validated the user account
//
// This is used to enumerate globals groups the user belongs
// to for policy support. This parameter can be NULL.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
//
pszServerName : PWideChar;
//
// pointer to a series of null terminated environment variables
//
// envname=environment variable value
// - or -
// envname=%OtherVar%\more text
//
// Each environment variable is NULL terminated with the last
// environment variable double NULL terminated. These variables
// are set into the user's initial environment. The environment
// variable value can contain other environment variables wrapped
// in "%" signs. This parameter can be NULL.
//
// The buffer pointed to by this field must be separately allocated.
// Winlogon will free the buffer when it is no longer needed.
//
//
pszEnvironment : PWideChar;
end;
{$EXTERNALSYM _WLX_PROFILE_V2_0}
TWlxProfileV20 = _WLX_PROFILE_V2_0;
WLX_PROFILE_V2_0 = _WLX_PROFILE_V2_0;
{$EXTERNALSYM WLX_PROFILE_V2_0}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// The WLX_NPR_NOTIFICATION_INFO structure is returned
// from a GINA DLL following successful authentication.
// This information is used by Winlogon to provide
// identification and authentication information already
// collected to network providers. Winlogon is
// responsible for freeing both the main structure and all
// string and other buffers pointed to from within the
// structure.
//

type
PWlxMprNotifyInfo = ^TWlxMprNotifyInfo;
PWLX_MPR_NOTIFY_INFO = PWlxMprNotifyInfo;
{$EXTERNALSYM PWLX_MPR_NOTIFY_INFO}
_WLX_MPR_NOTIFY_INFO = record
//
// The name of the account logged onto (e.g. REDMOND\Joe).
// The string pointed to by this field must be separately
// allocated and will be separately deallocated by Winlogon.
//
pszUserName : PWideChar;
//
// The string pointed to by this field must be separately
// allocated and will be separately deallocated by Winlogon.
//
pszDomain : PWideChar;
//
// Cleartext password of the user account. If the OldPassword
// field is non-null, then this field contains the new password
// in a password change operation. The string pointed to by
// this field must be separately allocated and will be seperately
// deallocated by Winlogon.
//
pszPassword : PWideChar;
//
// Cleartext old password of the user account whose password
// has just been changed. The Password field contains the new
// password. The string pointed to by this field must be
// separately allocated and will be separately deallocated by
// Winlogon.
//
pszOldPassword: PWideChar;
end;
{$EXTERNALSYM _WLX_MPR_NOTIFY_INFO}
TWlxMprNotifyInfo = _WLX_MPR_NOTIFY_INFO;
WLX_MPR_NOTIFY_INFO = _WLX_MPR_NOTIFY_INFO;
{$EXTERNALSYM WLX_MPR_NOTIFY_INFO}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// WLX_TERMINAL_SERVICES_DATA is used by the GINA during a
// WlxQueryTerminalServicesData() callback into WinLogon from the
// WlxLoggedOutSAS() context, after the user name and domain are known.
// This structure relates to TS user configuration information which is
// retrieved from the Domain Controller and SAM database. Having WinLogon
// pass this information means the GINA does not need to do the same
// off-machines lookups again.
//

const
WLX_DIRECTORY_LENGTH = 256;
{$EXTERNALSYM WLX_DIRECTORY_LENGTH}

type
PWlxTerminalServicesData = ^TWlxTerminalServicesData;
PWLX_TERMINAL_SERVICES_DATA = PWlxTerminalServicesData;
{$EXTERNALSYM PWLX_TERMINAL_SERVICES_DATA}
_WLX_TERMINAL_SERVICES_DATA = record
//
// TS profile path, overrides the standard profile path.
//
ProfilePath : array [0..WLX_DIRECTORY_LENGTH] of WCHAR;
//
// TS home directory, overrides standard home directory.
//
HomeDir : array [0..WLX_DIRECTORY_LENGTH] of WCHAR;
//
// TS home directory drive, overrides standard drive.
//
HomeDirDrive: array [0..3] of WCHAR;
end;
{$EXTERNALSYM _WLX_TERMINAL_SERVICES_DATA}
TWlxTerminalServicesData = _WLX_TERMINAL_SERVICES_DATA;
WLX_TERMINAL_SERVICES_DATA = _WLX_TERMINAL_SERVICES_DATA;
{$EXTERNALSYM WLX_TERMINAL_SERVICES_DATA}

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// The WLX_CLIENT_CREDENTIALS_INFO structure is returned
// from winlogon from the WlxQueryClientCredentials() call.
//
// This allows a network client WinStation to pass client
// credentials for automatic logon.
//
// The MSGINA DLL is responsible for freeing the memory
// and substrings with LocalFree().
//

const
WLX_CREDENTIAL_TYPE_V1_0 = 1;
{$EXTERNALSYM WLX_CREDENTIAL_TYPE_V1_0}

type
PWlxClientCredentialsInfoV10 = ^TWlxClientCredentialsInfoV10;
PWLX_CLIENT_CREDENTIALS_INFO_V1_0 = PWlxClientCredentialsInfoV10;
{$EXTERNALSYM PWLX_CLIENT_CREDENTIALS_INFO_V1_0}
_WLX_CLIENT_CREDENTIALS_INFO = record
//
// This field identifies the type of credentials structure being allocated
// by GINA DLL. Credential types are defined with the prefix
// WLX_CREDENTIAL_TYPE_xxx. It allows Winlogon to typecast the
// structure so the remainder of the structure may be referenced.
//
dwType : DWORD;

pszUserName : PWideChar;
pszDomain : PWideChar;
pszPassword : PWideChar;
//
// This field forces a prompt for the password. This
// is due to an administrator override.
//
// This allows the distinguishing of autologon
// with no password.
//
fPromptForPassword: BOOL;
end;
{$EXTERNALSYM _WLX_CLIENT_CREDENTIALS_INFO}
TWlxClientCredentialsInfoV10 = _WLX_CLIENT_CREDENTIALS_INFO;
WLX_CLIENT_CREDENTIALS_INFO_V1_0 = _WLX_CLIENT_CREDENTIALS_INFO;
{$EXTERNALSYM WLX_CLIENT_CREDENTIALS_INFO_V1_0}


////////////////////////////////////////////////////////////////////////
// //
// Services that replacement GINAs ** MUST ** provide //
// //
////////////////////////////////////////////////////////////////////////

{ Forward declarations changed to prototypes.
original was written to enforce implementation--keep this in mind!.
IMHO This is not common in Object Pascal, NicoDE }

type
TFNWlxNegotiate = function(
dwWinlogonVersion: DWORD;
pdwDllVersion : PDWORD
): BOOL; stdcall;

type
TFNWlxInitialize = function(
lpWinsta : LPWSTR;
hWlx : THandle;
pvReserved : Pointer;
pWinlogonFunctions: Pointer;
out pWlxContext : Pointer
): BOOL; stdcall;

type
TFNWlxDisplaySASNotice = procedure(
pWlxContext: Pointer
); stdcall;

type
TFNWlxLoggedOutSAS = function(
pWlxContext : Pointer;
dwSasType : DWORD;
pAuthenticationId: PLargeInteger;
pLogonSid : PSID;
pdwOptions : PDWORD;
phToken : PHandle;
pNprNotifyInfo : PWlxMprNotifyInfo;
out pProfile : Pointer
): Integer; stdcall;

type
TFNWlxActivateUserShell = function(
pWlxContext : Pointer;
pszDesktopName : PWideChar;
pszMprLogonScript: PWideChar;
pEnvironment : Pointer
): BOOL; stdcall;

type
TFNWlxLoggedOnSAS = function(
pWlxContext: Pointer;
dwSasType : DWORD;
pReserved : Pointer
): Integer; stdcall;

type
TFNWlxDisplayLockedNotice = procedure(
pWlxContext: Pointer
); stdcall;

type
TFNWlxWkstaLockedSAS = function(
pWlxContext: Pointer;
dwSasType : DWORD
): Integer; stdcall;

type
TFNWlxIsLockOk = function(
pWlxContext: Pointer
): BOOL; stdcall;

type
TFNWlxIsLogoffOk = function(
pWlxContext: Pointer
): BOOL; stdcall;

type
TFNWlxLogoff = procedure(
pWlxContext: Pointer
); stdcall;

type
TFNWlxShutdown = procedure(
pWlxContext : Pointer;
ShutdownType: DWORD
); stdcall;

//
// NEW for version 1.1
//

type
TFNWlxScreenSaverNotify = function(
pWlxContext: Pointer;
var pSecure: BOOL
): BOOL; stdcall;

type
TFNWlxStartApplication = function(
pWlxContext : Pointer;
pszDesktopName: PWideChar;
pEnvironment : Pointer;
pszCmdLine : PWideChar
): BOOL; stdcall;

//
// New for 1.2
//

{ none, only dipatch table extended, NicoDE }

//
// New for 1.3
//

type
TFNWlxNetworkProviderLoad = function(
pWlxContext : Pointer;
pNprNotifyInfo: PWlxMprNotifyInfo
): BOOL; stdcall;

const
STATUSMSG_OPTION_NOANIMATION = $00000001;
{$EXTERNALSYM STATUSMSG_OPTION_NOANIMATION}
STATUSMSG_OPTION_SETFOREGROUND = $00000002;
{$EXTERNALSYM STATUSMSG_OPTION_SETFOREGROUND}

type
TFNWlxDisplayStatusMessage = function(
pWlxContext: Pointer;
hDesktop : HDESK;
dwOptions : DWORD;
pTitle : PWideChar;
pMessage : PWideChar
): BOOL; stdcall;

type
TFNWlxGetStatusMessage = function(
pWlxContext : Pointer;
out pdwOptions: DWORD;
pMessage : PWideChar;
dwBufferSize : DWORD
): BOOL; stdcall;

type
TFNWlxRemoveStatusMessage = function(
pWlxContext: Pointer
): BOOL; stdcall;


////////////////////////////////////////////////////////////////////////
// //
// Services that Winlogon provides //
// //
////////////////////////////////////////////////////////////////////////


type
PWlxDesktop = ^TWlxDesktop;
PWLX_DESKTOP = PWlxDesktop;
{$EXTERNALSYM PWLX_DESKTOP}
_WLX_DESKTOP = record
Size : DWORD;
Flags : DWORD;
hDesktop : HDESK;
pszDesktopName: PWideChar;
end;
{$EXTERNALSYM _WLX_DESKTOP}
TWlxDesktop = _WLX_DESKTOP;
WLX_DESKTOP = _WLX_DESKTOP;
{$EXTERNALSYM WLX_DESKTOP}

const
WLX_DESKTOP_NAME = $00000001; // Name present
{$EXTERNALSYM WLX_DESKTOP_NAME}
WLX_DESKTOP_HANDLE = $00000002; // Handle present
{$EXTERNALSYM WLX_DESKTOP_HANDLE}

type
TFNWlxUseCtrlAltDel = procedure(
hWlx: THandle
); stdcall;
PWLX_USE_CTRL_ALT_DEL = TFNWlxUseCtrlAltDel;
{$EXTERNALSYM PWLX_USE_CTRL_ALT_DEL}

type
TFNWlxSetContextPointer = procedure(
hWlx : THandle;
pWlxContext: Pointer
); stdcall;
PWLX_SET_CONTEXT_POINTER = TFNWlxSetContextPointer;
{$EXTERNALSYM PWLX_SET_CONTEXT_POINTER}

type
TFNWlxSasNotify = procedure(
hWlx : THandle;
dwSasType: DWORD
); stdcall;
PWLX_SAS_NOTIFY = TFNWlxSasNotify;
{$EXTERNALSYM PWLX_SAS_NOTIFY}

type
TFNWlxSetTimeout = function(
hWlx : THandle;
Timeout: DWORD
): BOOL; stdcall;
PWLX_SET_TIMEOUT = TFNWlxSetTimeout;
{$EXTERNALSYM PWLX_SET_TIMEOUT}

type
TFNWlxAssignShellProtection = function(
hWlx : THandle;
hToken : THandle;
hProcess: THandle;
hThread : THandle
): Integer; stdcall;
PWLX_ASSIGN_SHELL_PROTECTION = TFNWlxAssignShellProtection;
{$EXTERNALSYM PWLX_ASSIGN_SHELL_PROTECTION}

type
TFNWlxMessageBox = function(
hWlx : THandle;
hwndOwner: HWND;
lpszText : LPWSTR;
lpszTitle: LPWSTR;
fuStyle : UINT
): Integer; stdcall;
PWLX_MESSAGE_BOX = TFNWlxMessageBox;
{$EXTERNALSYM PWLX_MESSAGE_BOX}

type
TFNWlxDialogBox = function(
hWlx : THandle;
hInst : THandle;
lpszTemplate: LPWSTR;
hwndOwner : HWND;
dlgprc : TFNDlgProc
): Integer; stdcall;
PWLX_DIALOG_BOX = TFNWlxDialogBox;
{$EXTERNALSYM PWLX_DIALOG_BOX}

type
TFNWlxDialogBoxIndirect = function(
hWlx : THandle;
hInst : THandle;
hDialogTemplate: PDlgTemplate;
hwndOwner : HWND;
dlgprc : TFNDlgProc
): Integer; stdcall;
PWLX_DIALOG_BOX_INDIRECT = TFNWlxDialogBoxIndirect;
{$EXTERNALSYM PWLX_DIALOG_BOX_INDIRECT}

type
TFNWlxDialogBoxParam = function(
hWlx : THandle;
hInst : THandle;
lpszTemplate: LPWSTR;
hwndOwner : HWND;
dlgprc : TFNDlgProc;
dwInitParam : LPARAM
): Integer; stdcall;
PWLX_DIALOG_BOX_PARAM = TFNWlxDialogBoxParam;
{$EXTERNALSYM PWLX_DIALOG_BOX_PARAM}

type
TFNWlxDialogBoxIndirectParam = function(
hWlx : THandle;
hInst : THandle;
hDialogTemplate: PDlgTemplate;
hwndOwner : HWND;
dlgprc : TFNDlgProc;
dwInitParam : LPARAM
): Integer; stdcall;
PWLX_DIALOG_BOX_INDIRECT_PARAM = TFNWlxDialogBoxIndirectParam;
{$EXTERNALSYM PWLX_DIALOG_BOX_INDIRECT_PARAM}

type
TFNWlxSwitchDesktopToUser = function(
hWlx: THandle
): Integer; stdcall;
PWLX_SWITCH_DESKTOP_TO_USER = TFNWlxSwitchDesktopToUser;
{$EXTERNALSYM PWLX_SWITCH_DESKTOP_TO_USER}

type
TFNWlxSwitchDesktopToWinlogon = function(
hWlx: THandle
): Integer; stdcall;
PWLX_SWITCH_DESKTOP_TO_WINLOGON = TFNWlxSwitchDesktopToWinlogon;
{$EXTERNALSYM PWLX_SWITCH_DESKTOP_TO_WINLOGON}

type
TFNWlxChangePasswordNotify = function(
hWlx : THandle;
pMprInfo : PWlxMprNotifyInfo;
dwChangeInfo: DWORD
): Integer; stdcall;
PWLX_CHANGE_PASSWORD_NOTIFY = TFNWlxChangePasswordNotify;
{$EXTERNALSYM PWLX_CHANGE_PASSWORD_NOTIFY}

//
// NEW for version 1.1
//

type
TFNWlxGetSourceDesktop = function(
hWlx : THandle;
out ppDesktop: PWlxDesktop
): BOOL; stdcall;
PWLX_GET_SOURCE_DESKTOP = TFNWlxGetSourceDesktop;
{$EXTERNALSYM PWLX_GET_SOURCE_DESKTOP}

type
TFNWlxSetReturnDesktop = function(
hWlx : THandle;
pDesktop: PWlxDesktop
): BOOL; stdcall;
PWLX_SET_RETURN_DESKTOP = TFNWlxSetReturnDesktop;
{$EXTERNALSYM PWLX_SET_RETURN_DESKTOP}

type
TFNWlxCreateUserDesktop = function(
hWlx : THandle;
hToken : THandle;
Flags : DWORD;
pszDesktopName: PWideChar;
out ppDesktop : PWlxDesktop
): BOOL; stdcall;
PWLX_Create_USER_DESKTOP = TFNWlxCreateUserDesktop;
{$EXTERNALSYM PWLX_Create_USER_DESKTOP}

const
WLX_Create_INSTANCE_ONLY = $00000001;
{$EXTERNALSYM WLX_Create_INSTANCE_ONLY}
WLX_Create_USER = $00000002;
{$EXTERNALSYM WLX_Create_USER}

type
TFNWlxChangePasswordNotifyEx = function(
hWlx : THandle;
pMprInfo : PWlxMprNotifyInfo;
dwChangeInfo: DWORD;
ProviderName: PWideChar;
Reserved : Pointer
): Integer; stdcall;
PWLX_CHANGE_PASSWORD_NOTIFY_EX = TFNWlxChangePasswordNotifyEx;
{$EXTERNALSYM PWLX_CHANGE_PASSWORD_NOTIFY_EX}

//
// New for 1.2
//

type
TFNWlxCloseUserDesktop = function(
hWlx : THandle;
pDesktop: PWlxDesktop;
hToken : THandle
): BOOL; stdcall;
PWLX_CLOSE_USER_DESKTOP = TFNWlxCloseUserDesktop;
{$EXTERNALSYM PWLX_CLOSE_USER_DESKTOP}

//
// New for 1.3
//

type
TFNWlxSetOption = function(
hWlx : THandle;
Option : DWORD;
Value : Cardinal;
out OldValue: Cardinal
): BOOL; stdcall;
PWLX_SET_OPTION = TFNWlxSetOption;
{$EXTERNALSYM PWLX_SET_OPTION}

type
TFNWlxGetOption = function(
hWlx : THandle;
Option : DWORD;
out Value: Cardinal
): BOOL; stdcall;
PWLX_GET_OPTION = TFNWlxGetOption;
{$EXTERNALSYM PWLX_GET_OPTION}

type
TFNWlxWin31Migrate = procedure(
hWlx: THandle
); stdcall;
PWLX_WIN31_MIGRATE = TFNWlxWin31Migrate;
{$EXTERNALSYM PWLX_WIN31_MIGRATE}

type
TFNWlxQueryClientCredentials = function(
pCred: PWlxClientCredentialsInfoV10
): BOOL; stdcall;
PWLX_QUERY_CLIENT_CREDENTIALS = TFNWlxQueryClientCredentials;
{$EXTERNALSYM PWLX_QUERY_CLIENT_CREDENTIALS}

type
TFNWlxQueryIcCredentials = function(
pCred: PWlxClientCredentialsInfoV10
): BOOL; stdcall;
PWLX_QUERY_IC_CREDENTIALS = TFNWlxQueryIcCredentials;
{$EXTERNALSYM PWLX_QUERY_IC_CREDENTIALS}

type
TFNWlxDisconnect = function(): BOOL; stdcall;
PWLX_DISCONNECT = TFNWlxDisconnect;
{$EXTERNALSYM PWLX_DISCONNECT}

type
TFNWlxQueryTerminalServicesData = function(
hWlx : THandle;
pTSData : PWlxTerminalServicesData;
UserName: PWideChar;
Domain : PWideChar
): DWORD; stdcall;
PWLX_QUERY_TERMINAL_SERVICES_DATA = TFNWlxQueryTerminalServicesData;
{$EXTERNALSYM PWLX_QUERY_TERMINAL_SERVICES_DATA}

//
// Options that can be get or set:
//

const
WLX_OPTION_USE_CTRL_ALT_DEL = $00000001;
{$EXTERNALSYM WLX_OPTION_USE_CTRL_ALT_DEL}
WLX_OPTION_CONTEXT_POINTER = $00000002;
{$EXTERNALSYM WLX_OPTION_CONTEXT_POINTER}
WLX_OPTION_USE_SMART_CARD = $00000003;
{$EXTERNALSYM WLX_OPTION_USE_SMART_CARD}
WLX_OPTION_FORCE_LOGOFF_TIME = $00000004;
{$EXTERNALSYM WLX_OPTION_FORCE_LOGOFF_TIME}
WLX_OPTION_IGNORE_AUTO_LOGON = $00000008;
{$EXTERNALSYM WLX_OPTION_IGNORE_AUTO_LOGON}

//
// Options that can be queried only:
//

const
WLX_OPTION_SMART_CARD_PRESENT = $00010001;
{$EXTERNALSYM WLX_OPTION_SMART_CARD_PRESENT}
WLX_OPTION_SMART_CARD_INFO = $00010002;
{$EXTERNALSYM WLX_OPTION_SMART_CARD_INFO}
WLX_OPTION_DISPATCH_TABLE_SIZE = $00010003;
{$EXTERNALSYM WLX_OPTION_DISPATCH_TABLE_SIZE}


////////////////////////////////////////////////////////////////////////
// //
// Function dispatch tables. //
// One of the following tables will be passed to the GINA DLL //
// in the WlxInitialize() call during initialization. //
// //
////////////////////////////////////////////////////////////////////////


type
PWlxDispatchVersion10 = ^TWlxDispatchVersion10;
PWLX_DISPATCH_VERSION_1_0 = PWlxDispatchVersion10;
{$EXTERNALSYM PWLX_DISPATCH_VERSION_1_0}
_WLX_DISPATCH_VERSION_1_0 = record
WlxUseCtrlAltDel : TFNWlxUseCtrlAltDel;
WlxSetContextPointer : TFNWlxSetContextPointer;
WlxSasNotify : TFNWlxSasNotify;
WlxSetTimeout : TFNWlxSetTimeout;
WlxAssignShellProtection : TFNWlxAssignShellProtection;
WlxMessageBox : TFNWlxMessageBox;
WlxDialogBox : TFNWlxDialogBox;
WlxDialogBoxParam : TFNWlxDialogBoxParam;
WlxDialogBoxIndirect : TFNWlxDialogBoxIndirect;
WlxDialogBoxIndirectParam : TFNWlxDialogBoxIndirectParam;
WlxSwitchDesktopToUser : TFNWlxSwitchDesktopToUser;
WlxSwitchDesktopToWinlogon: TFNWlxSwitchDesktopToWinlogon;
WlxChangePasswordNotify : TFNWlxChangePasswordNotify;
end;
{$EXTERNALSYM _WLX_DISPATCH_VERSION_1_0}
TWlxDispatchVersion10 = _WLX_DISPATCH_VERSION_1_0;
WLX_DISPATCH_VERSION_1_0 = _WLX_DISPATCH_VERSION_1_0;
{$EXTERNALSYM WLX_DISPATCH_VERSION_1_0}

type
PWlxDispatchVersion11 = ^TWlxDispatchVersion11;
PWLX_DISPATCH_VERSION_1_1 = PWlxDispatchVersion11;
{$EXTERNALSYM PWLX_DISPATCH_VERSION_1_1}
_WLX_DISPATCH_VERSION_1_1 = record
WlxUseCtrlAltDel : TFNWlxUseCtrlAltDel;
WlxSetContextPointer : TFNWlxSetContextPointer;
WlxSasNotify : TFNWlxSasNotify;
WlxSetTimeout : TFNWlxSetTimeout;
WlxAssignShellProtection : TFNWlxAssignShellProtection;
WlxMessageBox : TFNWlxMessageBox;
WlxDialogBox : TFNWlxDialogBox;
WlxDialogBoxParam : TFNWlxDialogBoxParam;
WlxDialogBoxIndirect : TFNWlxDialogBoxIndirect;
WlxDialogBoxIndirectParam : TFNWlxDialogBoxIndirectParam;
WlxSwitchDesktopToUser : TFNWlxSwitchDesktopToUser;
WlxSwitchDesktopToWinlogon: TFNWlxSwitchDesktopToWinlogon;
WlxChangePasswordNotify : TFNWlxChangePasswordNotify;
WlxGetSourceDesktop : TFNWlxGetSourceDesktop;
WlxSetReturnDesktop : TFNWlxSetReturnDesktop;
WlxCreateUserDesktop : TFNWlxCreateUserDesktop;
WlxChangePasswordNotifyEx : TFNWlxChangePasswordNotifyEx;
end;
{$EXTERNALSYM _WLX_DISPATCH_VERSION_1_1}
TWlxDispatchVersion11 = _WLX_DISPATCH_VERSION_1_1;
WLX_DISPATCH_VERSION_1_1 = _WLX_DISPATCH_VERSION_1_1;
{$EXTERNALSYM WLX_DISPATCH_VERSION_1_1}

type
PWlxDispatchVersion12 = ^TWlxDispatchVersion12;
PWLX_DISPATCH_VERSION_1_2 = PWlxDispatchVersion12;
{$EXTERNALSYM PWLX_DISPATCH_VERSION_1_2}
_WLX_DISPATCH_VERSION_1_2 = record
WlxUseCtrlAltDel : TFNWlxUseCtrlAltDel;
WlxSetContextPointer : TFNWlxSetContextPointer;
WlxSasNotify : TFNWlxSasNotify;
WlxSetTimeout : TFNWlxSetTimeout;
WlxAssignShellProtection : TFNWlxAssignShellProtection;
WlxMessageBox : TFNWlxMessageBox;
WlxDialogBox : TFNWlxDialogBox;
WlxDialogBoxParam : TFNWlxDialogBoxParam;
WlxDialogBoxIndirect : TFNWlxDialogBoxIndirect;
WlxDialogBoxIndirectParam : TFNWlxDialogBoxIndirectParam;
WlxSwitchDesktopToUser : TFNWlxSwitchDesktopToUser;
WlxSwitchDesktopToWinlogon: TFNWlxSwitchDesktopToWinlogon;
WlxChangePasswordNotify : TFNWlxChangePasswordNotify;
WlxGetSourceDesktop : TFNWlxGetSourceDesktop;
WlxSetReturnDesktop : TFNWlxSetReturnDesktop;
WlxCreateUserDesktop : TFNWlxCreateUserDesktop;
WlxChangePasswordNotifyEx : TFNWlxChangePasswordNotifyEx;
WlxCloseUserDesktop : TFNWlxCloseUserDesktop;
end;
{$EXTERNALSYM _WLX_DISPATCH_VERSION_1_2}
TWlxDispatchVersion12 = _WLX_DISPATCH_VERSION_1_2;
WLX_DISPATCH_VERSION_1_2 = _WLX_DISPATCH_VERSION_1_2;
{$EXTERNALSYM WLX_DISPATCH_VERSION_1_2}

type
PWlxDispatchVersion13 = ^TWlxDispatchVersion13;
PWLX_DISPATCH_VERSION_1_3 = PWlxDispatchVersion13;
{$EXTERNALSYM PWLX_DISPATCH_VERSION_1_3}
_WLX_DISPATCH_VERSION_1_3 = record
WlxUseCtrlAltDel : TFNWlxUseCtrlAltDel;
WlxSetContextPointer : TFNWlxSetContextPointer;
WlxSasNotify : TFNWlxSasNotify;
WlxSetTimeout : TFNWlxSetTimeout;
WlxAssignShellProtection : TFNWlxAssignShellProtection;
WlxMessageBox : TFNWlxMessageBox;
WlxDialogBox : TFNWlxDialogBox;
WlxDialogBoxParam : TFNWlxDialogBoxParam;
WlxDialogBoxIndirect : TFNWlxDialogBoxIndirect;
WlxDialogBoxIndirectParam : TFNWlxDialogBoxIndirectParam;
WlxSwitchDesktopToUser : TFNWlxSwitchDesktopToUser;
WlxSwitchDesktopToWinlogon : TFNWlxSwitchDesktopToWinlogon;
WlxChangePasswordNotify : TFNWlxChangePasswordNotify;
WlxGetSourceDesktop : TFNWlxGetSourceDesktop;
WlxSetReturnDesktop : TFNWlxSetReturnDesktop;
WlxCreateUserDesktop : TFNWlxCreateUserDesktop;
WlxChangePasswordNotifyEx : TFNWlxChangePasswordNotifyEx;
WlxCloseUserDesktop : TFNWlxCloseUserDesktop;
WlxSetOption : TFNWlxSetOption;
WlxGetOption : TFNWlxGetOption;
WlxWin31Migrate : TFNWlxWin31Migrate;
WlxQueryClientCredentials : TFNWlxQueryClientCredentials;
WlxQueryInetConnectorCredentials: TFNWlxQueryIcCredentials;
WlxDisconnect : TFNWlxDisconnect;
WlxQueryTerminalServicesData : TFNWlxQueryTerminalServicesData;
end;
{$EXTERNALSYM _WLX_DISPATCH_VERSION_1_3}
TWlxDispatchVersion13 = _WLX_DISPATCH_VERSION_1_3;
WLX_DISPATCH_VERSION_1_3 = _WLX_DISPATCH_VERSION_1_3;
{$EXTERNALSYM WLX_DISPATCH_VERSION_1_3}

//
// Non-GINA notification DLLs
//

type
TFNMsgECallback = function(bVerbose: BOOL; lpMessage: LPWSTR): DWORD; stdcall;
PFNMSGECALLBACK = TFNMsgECallback;
{$EXTERNALSYM PFNMSGECALLBACK}

type
PWlxNotificationInfo = ^TWlxNotificationInfo;
PWLX_NOTIFICATION_INFO = PWlxNotificationInfo;
{$EXTERNALSYM PWLX_NOTIFICATION_INFO}
_WLX_NOTIFICATION_INFO = record
Size : ULONG;
Flags : ULONG;
UserName : PWideChar;
Domain : PWideChar;
WindowStation : PWideChar;
hToken : THandle;
hDesktop : HDESK;
pStatusCallback: TFNMsgECallback;
end;
{$EXTERNALSYM _WLX_NOTIFICATION_INFO}
TWlxNotificationInfo = _WLX_NOTIFICATION_INFO;
WLX_NOTIFICATION_INFO = _WLX_NOTIFICATION_INFO;
{$EXTERNALSYM WLX_NOTIFICATION_INFO}

implementation

end.