Adding Your Logo to Winlogon's Dialog

Environment: NT4, Win2000 (for development file system should be fat32)

Caution: Use this code at your own risk!!

Restoring Your Windows (fat32)

Reboot your Window with the boot disk, copy msgina.dll to xgina.dll, and reboot again.

Details

For details about this program, please look for gina in the MS MSDN.

Installation

  1. Add the GinaDLL key to "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows BT\CurrentVersion\Winlogon".
  2. The value of key GinaDLL is xgina.dll.
  3. Reboot.

Using the GINA Export Functions

The DLL must implement and export a set of functions that Winlogon will call to identify and authenticate the user. The following topics show examples of how to implement some of these functions. For a complete list of the functions that the GINA must implement and export, see the Winlogon and GINA references.

GINA Export Functions

A GINA DLL must export the following functions:

Function Description
WlxActivateUserShell Activates the user shell program.
WlxDisplayLockedNotice Allows the GINA DLL to display lock information.
WlxDisplaySASNotice Winlogon calls this function when no user is logged on.
WlxDisplayStatusMessage Winlogon calls this function with a status message to display.
WlxGetConsoleSwitchCredentials Winlogon calls this function to read the currently logged-on user's credentials to transparently transfer them to a target session.
WlxGetStatusMessage Winlogon calls this function to get the current status message.
WlxInitialize Initializes the GINA DLL for a specific window station.
WlxIsLockOk Verifies that the workstation lock is okay.
WlxIslogoffOk Verifies that the logoff is okay.
WlxLoggedOnSAS Winlogon calls this function when it receives a secure attention sequence (SAS) event while the user is logged on and the workstation is not locked.
WlxLoggedOutSAS Winlogon calls this function when it receives an SAS event while no user is logged on.
WlxLogoff Notifies the GINA DLL that a logoff operation was requested.
WlxNegotiate Indicates whether the current version of Winlogon can be used with the GINA DLL.
WlxNetworkProviderLoad Winlogon calls this function after it loads a network provider to collect valid authentication and identification information.
WlxRemoveStatusMessage Winlogon calls this function to tell the GINA DLL to stop displaying the status message.
WlxScreensaverNotify Allows the GINA to interact with the screen saver operation.
WlxShutdown Winlogon calls this function just before shutting down, allowing the GINA to perform any shutdown tasks, such as ejecting a smart card from a reader.
WlxStartApplication Winlogon calls this function when the system needs an application started in the user's context.
WlxWkstaLockedSAS Winlogon calls this function when it receives an SAS while the workstation is locked.

The WlxNegotiate function must be implemented by a replacement GINA DLL. This is the first call made by Winlogon to the GINA DLL.

Winlogon determines which dispatch table is passed to the GINA in subsequent calls to WlxInitialize.

HookWlxDialogBoxParam is called from WlxInitialize to hook your dialog box procedure by ((PWLX_DISPATCH_VERSION_X_X) pWinlogonFunctions)->WlxDialogBoxParam = MyWlxDialogBoxParam;.

Here is the redirected WlxDialogBoxParam() function by MyWlxDialogBoxparam function:

int WINAPI MyWlxDialogBoxParam (HANDLE  hWlx,
                                HANDLE  hInst,
                                LPWSTR  lpszTemplate,
                                HWND    hwndOwner,
                                DLGPROC dlgprc,
                                LPARAM  dwInitParam)
{
  //
  // Sanity check.
  //
  assert(pfWlxDialogBoxParam != NULL);

  //
  // We only know MSGINA dialogs by identifiers.
  //

  if (!HIWORD(lpszTemplate))
  {
    //
    // Hook appropriate dialog boxes as necessary.
    //
#ifdef _DEBUG
  DEBUG_MSG("WlxDialogBoxParam :%ld",(DWORD) lpszTemplate);
#endif
    switch ((DWORD) lpszTemplate)
    {
    case IDD_WLXDIAPLAYSASNOTICE_DIALOG:
    {
#ifdef _DEBUG
      DEBUG_MSG("WlxDialogBoxParam : WLXDIAPLAYSASNOTICE_DIALOG");
#endif
      pfWlxDisplaySASDlgProc = dlgprc;
      return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                                 hwndOwner,
                                 MyWlxDisplaySASDlgProc,
                                 dwInitParam);
    }

    case 1500:
      case IDD_WLXLOGGEDOUTSAS_DIALOG:
        {
#ifdef _DEBUG
      DEBUG_MSG("WlxDialogBoxParam : WLXLOGGEDOUTSAS_DIALOG");
#endif
      pfWlxLoggedOutSASDlgProc = dlgprc;
      return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                                 hwndOwner,
                                 MyWlxLoggedOutSASDlgProc,
dwInitParam);
         }
    case 1900:
         case IDD_WLXWKSTALOCKEDSAS_DIALOG:
         {
#ifdef _DEBUG
        DEBUG_MSG("WlxDialogBoxParam : WLXWKSTALOCKEDSAS_DIALOG");
#endif
            pfWlxWkstaLockedSASDlgProc = dlgprc;
            return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                                       hwndOwner,
                                       MyWlxWkstaLockedSASDlgProc,
dwInitParam);
         }
    case 1950:
    case IDD_WLXLOGGEDONSAS_DIALOG:
    {
#ifdef _DEBUG
      DEBUG_MSG("WlxDialogBoxParam : WLXLOGGEDONSAS_DIALOG");
#endif
      pfWlxLoggedOnSASDlgProc = dlgprc;
      return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                                 hwndOwner,
                                 MyWlxLoggedOnSASDlgProc,
dwInitParam);
    }
    case 1700:
         case IDD_CHANGE_PASSWORD_DIALOG:
         {
#ifdef _DEBUG
        DEBUG_MSG("WlxDialogBoxParam : CHANGE_PASSWORD_DIALOG");
#endif
            pfChangePasswordDlgProc = dlgprc;
            return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                                       hwndOwner,
                                       MyChangePasswordDlgProc,
dwInitParam);
         }
      }
   }

   //
   // The rest will not be redirected.
   //
   return pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate,
                              hwndOwner, dlgprc, dwInitParam);
}


BOOL CALLBACK  MyWlxLoggedOutSASDlgProc (HWND   hwndDlg,
                                        // handle to dialog box
                       UINT   uMsg,     // message
                       WPARAM wParam,   // first message parameter
                       LPARAM lParam)   // second message parameter
{
  BOOL bResult;

  //
  // Sanity check.
  //
  assert(pfWlxLoggedOutSASDlgProc != NULL);

  //
  // Pass on to MSGINA first.
  //
  bResult = pfWlxLoggedOutSASDlgProc(hwndDlg, uMsg, wParam,
                                     lParam);

#ifdef _DEBUG
  DEBUG_MSG("Logout dlg msg id : %ld" , uMsg);
#endif
  if (uMsg == WM_INITDIALOG)
  {
    DWORD dwIndex;
    HWND hwndDomain;
    NET_API_STATUS netstatus;
    LPWKSTA_INFO_100 lpWkstaInfo;

#ifdef _DEBUG
    DEBUG_MSG("Logout state init");
#endif

    //
    // Get local machine name.
    //
    netstatus = NetWkstaGetInfo(NULL, 100, (LPBYTE *)
                &lpWkstaInfo);
    if (netstatus != NERR_Success)
    {
      return bResult;
    }

    //
    // Convert to ANSI.
    //
    wcstombs(g_szLocalMachineName,
             lpWkstaInfo->wki100_computername,
        sizeof(g_szLocalMachineName));

    //
    // and free the buffer.
    //
    NetApiBufferFree((LPVOID) lpWkstaInfo);

    //
    // Manipulate the domain combo box so that only some
    // predetermined trusted domains are included in the list.
    //
    // In our case, we restrict logon to local machine only.
    //
    hwndDomain = GetDlgItem(hwndDlg, IDC_WLXLOGGEDOUTSAS_DOMAIN);
    if (hwndDomain == NULL)
    {
      return bResult;
    }

    dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRING,
                0, (LPARAM) g_szLocalMachineName);
    if (dwIndex != CB_ERR)
    {
      SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0);
      EnableWindow(hwndDomain, FALSE);
    }
  }
  else if ( uMsg == WM_PAINT)
  {
    RECT rect;
    GetClientRect( hwndDlg , &rect);
    rect.top = rect.bottom - 33;
    DrawLogo(hwndDlg,IMAGE_FILE,rect.left , rect.top);
  }

   return bResult;
}

Downloads

Download source - 24 Kb


Comments

  • gina and memory cards

    Posted by maxsoft on 12/27/2005 03:09pm

    I'm tryin to start a my gina.dll to use a memory card (sle4442) to logon on win2000/xp systems, but I have not some good staff to begin. Can anyone help me with some basica code?I'm experienced on smart card and memory card and I can give you my help

    Reply
  • Problem With SAS_SC_INSERT on Windows XP

    Posted by Legacy on 12/29/2003 12:00am

    Originally posted by: Stefano Valore

    Hi ,
    I've problem in the WlxInitialize export function,
    try to set with the WlxSetOption the Smart Card SAS event and i could not get the SAS_SC_INSERT with Windows XP.
    There is any work around?
    Thanks very much
    Stefano

    • smart card

      Posted by maxsoft on 12/27/2005 03:37pm

      Salve stefano, mi chiamo Massimiliano e sono un programmatore freelance. Scusa la sfacciatagine ma ho visto che hai implementato giC_ qualcosa a cui vorrei arrivare anch'io. Vorrei implementere una mia dll (gina.dll) per l'accesso a win2000/xp con l'ausilio di una memory card. Sto studiando pGina.dll e vorrei implementare la funzionalitC_ per il logon da memory card (sle4442: sulla quale memorizzo nome utente in chiaro e l'hash a 32 bit della password): la dll legge prima nome utente e l'hash della pasword dalla carta quindi tramite nome utente legge la password dal sistema, la confronta com l'MD5 della password ripescata su windows e se la funzione C( verificata si viene autenticati. Conosco bene le memory card e le smart card e le chiamate alle API della winscard.dll, ma non so da dove cominciare con Wlx. Sapresti darmi un aiuto per partire?Potrei fare altrettanto con l'uso delle smart card. SAluti, Max.

      Reply
    Reply
  • WlxDisplaySASNotice

    Posted by Legacy on 12/07/2003 12:00am

    Originally posted by: Agenor

    Using the XGina.DLL on Windows 2000:
    When I turn on the PC I get the following calls during the log on
    WlxNegotiate
    MyInitialize
    WlxInitialize
    WlxDisplayStatusMessage
    WlxDisplayStatusMessage
    WlxDisplayStatusMessage
    WlxRemoveStatusMessage
    WlxRemoveStatusMessage
    WlxRemoveStatusMessage
    WlxLoggedOutSAS
    WlxActivateUserShell

    I have expected the "WlxDisplaySASNotice" after "WlxInitialize".
    But this call comes first time when I logoff the user (not Shutdown or Restart!).

    Background for this: I need to implement a welcome message (i.e. "Press Ctrl+Alt+Del to logon").
    Therefore I thought to do this in the "WlxDisplaySASNotice" function.

    Can anyone tell me where to find my mistake? Maybe I misunderstand the standard GINA procedure.

    Thanks
    Agenor

    Reply
  • Problem with Smart Cards on WIn XP

    Posted by Legacy on 09/05/2003 12:00am

    Originally posted by: bfadi

    Hi ,
    I just finished an Authentication Solution that use Smart Card to logon to windows. It work very well on win 2000 BUT in WinXP I could not get the SAS_SC_INSERT. And the dialog on the initial logon say "Press CAD" BUT in Win2K it sayes "Inser Smart Card OR Press CAD" !
    Is there any Registry key that make WinXP use SmartCardLogon ?
    Thanks very much

    Reply
  • Bypassing LogonUser( ) in GINAL.DLL

    Posted by Legacy on 07/10/2003 12:00am

    Originally posted by: Jayesh Suthar

    I have created Gina.dll and used it.

    In WlxLoggedOutSAS() i am checking Pin number in one device and after verifing that number i am reding user name and password from the device and then doing login with LononUser() function. Its working fine.

    Now i want to bypass LogonUser() function with inputs username and password. Means after verifing Pin number i don't want to doLogonUser() with username and password.

    Any solution??

    Reply
  • Click Event

    Posted by Legacy on 07/02/2003 12:00am

    Originally posted by: F. Rahman

    XGina.dll is by far the best sample code!!!

    Is it possible to add a Click Event on the Logo? To display a MessageBox?

    Thanks.

    Reply
  • GINA and windows services

    Posted by Legacy on 05/16/2003 12:00am

    Originally posted by: Irda

    Dear All,

    Probably this is the BEST online help that i can figure out at this moment, and hopefully it will assist me in getting to start on how essentially to set the start parameter for a fingerprint reader to system.

    Shall i create a new windows service in order to ensure that the driver is loaded by the time the GINA is invoke?

    Please assist me on this stumbled situation. THNX Q!

    Irda

    Reply
  • test program

    Posted by Legacy on 05/14/2003 12:00am

    Originally posted by: pappu

    Where is the code for test program

    Reply
  • Change the shutdown dialog

    Posted by Legacy on 05/09/2003 12:00am

    Originally posted by: martho

    Hello!

    Nice code! But I got one additional question: How can I add my logo to the shutdown dialog? I managed to add the code to do so (the dlgId of the shutdown-dialog is 2200) and it works when the user calls taskmanager->shutdown. But it DOESN'T work when the user calls start->shutdown! Then the "normal" windows dialogbox is displayed (Windows 2000, VC++ 6). Why? Anyone who has managed this?

    Reply
  • why GetDlgItem(hwndDlg, IDC_WLXWKSTALOCKEDSAS_DOMAIN) returns NULL?

    Posted by Legacy on 04/21/2003 12:00am

    Originally posted by: zouruzhai

    Could anybody explain? thanks in advance

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date