Winlogon

导读:
  Winlogon
  Winlogon处理独立于验证策略的接口函数。它为window station创建桌面,实现超时操作,并且为GINA提供一组支持函数。
  
  Initializing Winlogon
  当Winlogon初始化时,它会为系统注册CTRL+ALT+DEL安全验证序列(SAS),然后在WinStat0 window station 内创建三个桌面。
  
  注册CTRL+ALT+DEL 使得Winlogon初始化成为第一个进程,这就确保其他的应用程序不会钩到这个按键序列。(Registering CTRL+ALT+DELmakes this initialization the first process, thus ensuring that no other application has hooked that key sequence.)
  
  WinSta0是表现为物理屏幕、键盘和鼠标的window station对象的名字。Winlogon在WinStat0对象内创建下列的桌面:
  
  
  
  
   Desktop Description
  Winlogon desktop 这是Winlogon and GINA 以及其他安全对话框用户交互式验证和确认的桌面。当Winlogon收到SAS事件通知时,它自动地切换到该桌面。
  Application desktop 每次用户成功登录,就会为logon session创建一个应用程序桌面。应用程序桌面也称为默认或用户桌面。这个桌面就是用户动作发生的地方。该桌面是受保护的,只有系统和交互式登录会话有权限访问它。注意只有特殊的已登录用户的实体有权限访问该桌面,如果交互式用户使用服务控制器(service controller)激活一个进程,这个服务程序就没有权限访问应用程序桌面。
  Screen-saver desktop 当一个屏幕保护程序运行的时候,它就是当前桌面。如果一个用户已登录,系统和交互式登录会话都有权限访问它。否则的话只有系统有权限访问。
  作为这些桌面的拥有者,Winlogon可以在这三个桌面之间任意切换,并且允许GINA访问这个功能。通常情况下,GINA的开发者不需要改变当前的桌面,因为Winlogon与GINA通讯之前已经设置了恰当的桌面。每个GINA函数的描述都指明了哪个桌面是供当前调用的。
  Winlogon States
  Winlogon维护着GINA所使用的工作站状态,来决定需要什么验证动作。
  
  在任何时间,Winlogon都处在下列三种状态中的一种:
  
  Logged-Off State 注销状态
  Logged-On State 已登录状态
  Workstation-Locked State 工作站锁定状态
  三种状态在下面的图示中描述:
  Logged-Off State 注销状态
  当Winlogon处在注销状态中时,它会提示用户确认自身并且提供验证信息。如果用户提供了正确的帐号信息并且没有限制阻止它,用户就会登录并且一个外壳程序(像是Explorer.exe)就在应用程序桌面中执行。Winlogon就会转换到已登录状态。
  
  Logged-On State 已登录状态
  当Winlogon处在已登录状态中时,用户可以与shell交互,激活应用程序,并且做他们的工作。从已登录状态那里,用户既可以停止所有的工作并且注销,也可以锁定他们的工作站(适当地离开工作)。如果用户决定注销,Winlogon就会终止关联到登录会话上的全部进程,并且工作站等待其他用户登录。如果用户决定锁定工作站,Winlogon就会改变到工作站锁定状态。
  
  Workstation-Locked State 工作站锁定状态
  当Winlogon处在工作站锁定状态中时,就会显示一个安全桌面,直到初始登录的用户提供相同的验证和确认信息来解除锁定,或是管理员强迫注销。如果工作站被解除锁定,就会显示应用程序桌面,之前的工作就会继续。然而,如果一个管理员解除锁定(通过提供管理员帐号的确认和验证信息),已登录的用户进程就会被终止,并且Winlogon改变到注销状态。
  
  在每个Winlogon状态中都可以执行一些不同的操作。GINA DLL可能会实现不属于标准Windows OS 部分的操作。例如,一个高度安全的系统可能会每十分钟自动地锁定工作站并且强迫用户验证自身。
  Winlogon对话框服务由下列的支持函数提供:
   Support function Description
   WlxMessageBox Similar to the Windows MessageBoxfunction.
   WlxDialogBox Similar to the Windows DialogBoxfunction.
   WlxDialogBoxIndirect Similar to the Windows DialogBoxIndirectfunction.
   WlxDialogBoxParam Similar to the Windows DialogBoxParamfunction.
   WlxDialogBoxIndirectParam Similar to the Windows DialogBoxIndirectParamfunction.
  
  Supported Dialog Service Time-out Operations
  Winlogon实现了两个超时操作,一个用于安全对话,另一个用户屏幕保护程序的激活和终止。
  
  在安全对话的过程中,像是登录或是解锁工作站,Winlogon可以暂停一个对话框并且向对话框过程返回一个格式的结果代码。Winlogon为GINA提供一组对话支持函数。GINA必须使用这些函数而不是它们的Windows副本来保证GINA和Winlogon维护正确的对对话框的控制。错误地调用这些函数的Winlogon版本会导致未经过验证的用户有权访问系统。
  
  GINA DLLs 也可以从Winlogon 收到WLX_WM_SAS 消息。如果收到SAS,这个消息就会被发送到活动的对话框。当GINA正在提示为智能卡匹配PIN,但是智能卡已经从读卡器中取出,在此过程中这个消息时非常有用的。当在对话过程中发生一个SAS事件,Winlogon使用WLX_DLG_SAS 作为EndDialog的返回结果代码,对话框将会以合适的代码退出,来允许GINA开发者钩住time-out通知。
  GINA对话框可以被Winlogo对话框用WLX_DLG_USER_LOGOFF结束。它指明了在对话框运行期间用户已经注销(例如,其他线程调用了ExitWindowsEx 函数)
  
  Sending Messages to the GINA
  当对话框显示时,Winlogon会发送消息到GINA.下列的这些消息都被封装在WLX_WM_SAS消息中:
   SAS type in wParam parameter Description
  WLX_SAS_TYPE_CTRL_ALT_DEL Indicates that a CTRL+ALT+DELkey sequence was received.
  WLX_SAS_TYPE_SC_INSERT Indicates that a smart cardhas been inserted into a compatible device.
  WLX_SAS_TYPE_SC_REMOVE Indicates that a smart card has been removed from a compatible device.
  WLX_SAS_TYPE_USER_LOGOFF Indicates that a user requested log-off.
  WLX_SAS_TYPE_SCRNSVR_TIMEOUT Indicates that the screen saver should be run due to lack of user input.
  WLX_SAS_TYPE_TIMEOUT Indicates that no user input was received within the specified time-out period.
  
  Sending Messages to the GINA
  当对话框显示时,Winlogon会发送消息到GINA.下列的这些消息都被封装在WLX_WM_SAS消息中:
  
  对于超时和注销来说,Winlogon在消息发送完之后结束对话。对话接到消息之后就可以以有用的方式回应(例如,如果收到注销消息,就关闭自身)。
  对于超时来说,对话会以WLX_DLG_INPUT_TIMEOUT结束。
  对于屏保超时来说,对话会以WLX_DLG_SCREEN_SAVER_TIMEOUT结束。
  对于注销,对话以WLX_DLG_USER_LOGOFF结束。
  GINA
  GINA在Winlogon进程的上下文中操作,并且在引导阶段非常早期的时候加载。GINA DLL必须遵循规则才可以维护系统的完整性和与用户交互的精确性。
  The GINA operates in the context of the Winlogon process and, as such, the GINA DLL is loaded very early in the boot process. The GINA DLL must follow rules so that the integrity of the system is maintained, particularly with respect to interaction with the user.
  
  GINA最常见的用处是与一个外部设备,像是智能读卡器,进行通讯。设置系统设备驱动程序的初始参数是非常必要的,这可以确保设备在GINA被调用的时候加载。
  
  GINA DLL的目的是提供可订制的用户确认和验证过程。缺省的GINA DLL通过委托Winlogon监视SAM事件,DLL 接受和处理SAS。订制的GINA DLL 负责设置自身来接收SAM事件(不同于缺省的CTRL+ALT+DEL SAS 事件)并且通知Winlogon。Winlogon会评估它的状态来决定需要那些东西来处理GINA DLL的SAS. 这个处理通常包括调用GINA DLL的处理函数。
  
  Loading and Running a GINA DLL
  Windows NT加载并且执行标准的微软GINA DLL(MSGina.dll).你必须修改下列的键值
  
  HKEY_LOCAL_MACHINE
  Software
  Microsoft
  Windows NT
  CurrentVersion
  Winlogon
  GinaDLL
  如果GINA DLL键值已经存在,它必须包含Winlogon将要使用的加载的DLL名称。
  
  为了访问Winlogon支持函数,GINA DLL必须使用WLX_DISPATCH_VERSION_1_3结构。在gina的WlxNegotiage函数中,两个参数必须至少是WLX_DISPATCH_VERSION_1_3。
  Building and Testing a GINA DLL
  所有的函数,原形,结构和常量均定义在Winwlx.h头文件中。
  想要测试GinaDll, 需要使用checked version 操作系统中的Winlogon.exe,它可以从Windows NT DDK中得到。Checked version of Winlogon 支持以下方式调试GinaDlls:
  
  可以在Win.ini中创建一个段来指明Winlogon调试选项:
  [WinlogonDebug] LogFile=C:/Winlogon.log DebugFlags=Flag1 [, Flag2 …]
  如果指明的话,LogFile应该包含全文件名,该文件用户记录调试信息。如果文件不存在,则创建。
  
  DebugFlags 选项指明了那些调试信息会写到日志文件或调试器中。DebugFlags可以容纳一个多个下列标志:
   Debugging flag Description
  CoolSwitch The CTRL+ALT+SHIFT+TAB key combination will cause a debug break in Winlogon.
  Error Print errors.
  Init Print initialization and progress messages.
  Notify Print notification package messages.
  SAS Print information about SASnotifications.
  State Print messages when Winlogon changes state.
  Timeout Print messages when a time limit is set or a time limit is reached.
  Trace Print verbose trace information.
  Warn Print warnings.
  若要在调试器中启动Checked version of Winlogon, 在注册表中添加下列的键值
  HKEY_LOCAL_MACHINE
  Software
  Microsoft
  Windows NT
  CurrentVersion
  Image File Execution Options
  winlogon.exe
  Debugger = ntsd -d
  注意,你必须使用Windows NT symbolic debugger(NTSD) 来调试Winlogon.
  
  Responsibilities of Winlogon
  Winlogon 具有下列的责任:
  --- Window station and desktop protection
  Winlogon设置window sation和相应桌面的保护来确保每一个都有正确的访问权限。在通常情况下,这意味着本地系统对这些对象的全部访问权限,并且一个交互式登录的用户会拥有对window station 对象的读权限和对程序桌面对象的全部访问权限。
  
  --- Standard SAS recognition
  Winlogon在User32 服务中有一个特殊的钩子允许它监视SAS事件。Winlogon可以让Gina 得到这个消息来作为它们自己的,或是作为它们的SAS的一部分加以使用。通常情况下,Gina应该监视他们自己的SAS.然而,任何能够识别多个SAS、并且其中包括标准CTRL+ALT+DEL SAS的Gina, 都应该使用Winlogon.
  
  SAS routine dispatching
  当Winlogon检测到一个SAS事件,或当SAS由Gina 发送到Winlogon, Winlogon就会设置状态、切换桌面、并且调用Gina的某个SAS处理函数。
  
  User profile loading
  当用户登录的时候,他们的记录文件就会被加载到注册表中。按照这种方法,用户的进程就可以使用特殊的注册表键HKEY_CURRENT_USER。Winlogon在用户成功登录后但是在为新登录的用户激活外壳程序之前自动地完成这项工作。
  
  Assignment of security to user shell
  当用户登录时,Gina负责为用户创建一或多个初始进程。Winlogon会给Gina提供一个支持函数,将新登录用户的安全性应用到这些进程。
  然而,首选的方法是Gina调用Windows函数CreateProcessAsUser,并且让系统提供服务。
  
  Screen saver control
  Winloogn监视键盘和鼠标活动来决定何时启动屏保程序。在屏保启动之后,Winlogon继续监视键盘和鼠标活动来决定何时终止屏保。
  如果屏保被标记为安全的,Winlogon 就把Window station看作是被锁定的。当有键盘或鼠标活动,Winlogon就会调用Gina的WlxDisplayLockedNotice 函数and locked workstation behaviors resumes.如果屏保不时安全的,任何键片或鼠标活动都会终止屏保而不通知Gina.
  
  Multiple network provider support
  安装在系统中的多个网络可以被包含在验证过程和更新密码的操作中。它们可以使得额外的网络在正常登录中收集验证和确认信息、使用Winlogon的安全桌面。一些适用于Gina的Winlogon services 中所需的参数显示地支持这些额外的网络提供器。
  Multiple networks installed on a Windows system can be included in the authentication process and in password-updating operations. This inclusion lets additional networks gather identification and authentication information all at once during normal logon, using the secure desktop of Winlogon. Some of the parameters required in the Winlogon services available to GINAs explicitly support these additional network providers.
  
  Responsibilities of the GINA
  Gina DLL 有下列的责任:
  
  SAS monitoring
  Gina 负责识别SAS,监视SAS事件,并且当SAS发生时通知Winlogon.注意可能有多个SAS被定义,并且随着时间的推移,定义的SAS集合会改变。例如,在Winlogon处在注销状态时有一套SAS,在处在已登录状态时有另一套SAS.
  
  Winlogon 提供服务来辅助Gina使用CTRL+ALT+DEL SAS.
  Winlogon provides services to assist the GINA in using the CTRL+ALT+DEL SAS.
  
  SAS processing
  一个模块化Winlogon和使得Gina可替代的原因是提供可供选择的识别和验证信息。为了做到这点,Gina必须表现出由于识别SAS所产生的所有的用户接口。当没有用户登录时,Gina负责表现出识别和验证选项,即任何其他没有验证过的可允许的选项。当用户已经登录,Gina负责给用户表现出相应的选项,即接受已被确认为正确的所有的动作。例如,在包括一个智能卡的系统中,如果用户取出智能卡而自动地锁定工作站可能是合适的。
  
  
  Shell activation
  当用户登录时,Gina负责为给用户创建一或多个初始进程。(我们假设这些初始进程给用户表现出了一个界面。然而实际上,进程可以做任何处理,不必非与用户交互)。这些作为用户的外壳程序加以引用或就是外壳程序。作为外壳激活的一部分,Gina必须将新登录的用户令牌赋值给进程。Winlogon提供了一个服务来辅助Gina赋值令牌。
  
  Interaction Between Winlogon and GINA
  Winlogon 和Gina必须通信初始化信息、处理SAS监视和通知、允许注销和关闭活动。Winlogon的状态决定了调用哪个Gina函数来处理得到的SAS事件。通讯的顺序如下:
  
   Event Description
  Workstation boot: Winlogon calls the GINA's WlxNegotiate function to notify the GINA about the version of Winlogon in use.
  Winlogon calls the GINA's WlxInitializefunction to give the GINA the addresses of the support functions, a handle to Winlogon, and to obtain the contextinformation for the GINA (to be used in all future calls to the GINA).
  Winlogon is in the logged-out state.
  No one is logged on: (The GINA monitors devices for SAS events).
  The GINA calls Winlogon's WlxSasNotifyfunction when a SAS event has been received.
  Winlogon calls the GINA's WlxLoggedOutSASfunction, allowing the GINA to process a user's identification and authentication information.
  When logon is successful, Winlogon is in the logged-on state.
  The user is logged on: (The GINA monitors devices for SAS events).
  The GINA calls Winlogon's WlxSasNotifyfunction when a SAS event has been received.
  Winlogon calls the GINA's WlxLoggedOnSASfunction, allowing the GINA to present options to the user who is currently logged on.
  The user is logged on and wants to lock computer: (The GINA monitors devices for SAS events).
  The GINA calls the WlxSasNotifyfunction.
  Winlogon calls the GINA's WlxLoggedOnSASfunction.
  The GINA returns WLX_SAS_ACTION_LOCK_WKSTA.
  Winlogon is in the workstation-locked state
  The user is logged on; the workstation is locked; and the user wants to unlock computer: (The GINA monitors devices for SAS events).
  The GINA calls the WlxSasNotifyfunction.
  Winlogon calls the GINA's WlxWkstaLockedSASfunction.
  The GINA returns WLX_SAS_ACTION_UNLOCK_WKSTA.
  The user is logged on, and the program calls the ExitWindowsExfunction:
  Winlogon calls the GINA's WlxLogoff function.
  The user is logged on and wants to log off using SAS: (The GINA monitors devices for SAS events).
  The GINA calls the WlxSasNotifyfunction.
  Winlogon calls the GINA's WlxLoggedOnSASfunction.
  The GINA returns WLX_SAS_ACTION_LOGOFF.
  Winlogon calls the GINA's WlxLogofffunction.
  The user is logged on and wants to log off and shut down using ExitWindowsEx:
  Winlogon calls the GINA's WlxLogofffunction.
  Winlogon calls the GINA's WlxShutdownfunction.
  The user is logged on and wants to log off and shut down using SAS: (The GINA monitors devices for SAS events).
  The GINA calls the WlxSasNotifyfunction.
  Winlogon calls the GINA's WlxLoggedOnSASfunction.
  The GINA returns WLX_SAS_ACTION_SHUTDOWN.
  Winlogon calls the GINA's WlxLogofffunction.
  Winlogon calls the GINA's WlxShutdownfunction.
  
  
  Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1861710

本文转自
http://blog.csdn.net/2608/archive/2007/11/01/1861710.aspx
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值