Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

logon.c

Go to the documentation of this file.
00001 /**************************** Module Header ********************************\ 00002 * Module Name: logon.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * Logon Support Routines 00007 * 00008 * History: 00009 * 01-14-91 JimA Created. 00010 \***************************************************************************/ 00011 00012 #include "precomp.h" 00013 #pragma hdrstop 00014 00015 00016 /***************************************************************************\ 00017 * _RegisterLogonProcess 00018 * 00019 * Register the logon process and set secure mode flag 00020 * 00021 * History: 00022 * 07-01-91 JimA Created. 00023 \***************************************************************************/ 00024 00025 BOOL _RegisterLogonProcess( 00026 DWORD dwProcessId, 00027 BOOL fSecure) 00028 { 00029 UNREFERENCED_PARAMETER(fSecure); 00030 00031 /* 00032 * Allow only one logon process and then only if it has TCB 00033 * privilege. 00034 */ 00035 if (gpidLogon != 0 || !IsPrivileged(&psTcb)) { 00036 RIPERR0(ERROR_ACCESS_DENIED, 00037 RIP_WARNING, 00038 "Access denied in _RegisterLogonProcess"); 00039 00040 return FALSE; 00041 } 00042 00043 gpidLogon = (HANDLE)LongToHandle( dwProcessId ); 00044 return TRUE; 00045 } 00046 00047 00048 /***************************************************************************\ 00049 * _LockWindowStation 00050 * 00051 * Locks a windowstation and its desktops and returns the busy status. 00052 * 00053 * History: 00054 * 01-15-91 JimA Created. 00055 \***************************************************************************/ 00056 00057 UINT _LockWindowStation( 00058 PWINDOWSTATION pwinsta) 00059 { 00060 PDESKTOP pdesk; 00061 BOOL fBusy = FALSE; 00062 00063 /* 00064 * Make sure the caller is the logon process 00065 */ 00066 if (GetCurrentProcessId() != gpidLogon) { 00067 RIPERR0(ERROR_ACCESS_DENIED, 00068 RIP_WARNING, 00069 "Access denied in _LockWindowStation"); 00070 00071 return WSS_ERROR; 00072 } 00073 00074 /* 00075 * Prevent desktop switches 00076 */ 00077 pwinsta->dwWSF_Flags |= WSF_SWITCHLOCK; 00078 00079 /* 00080 * Determine whether the station is busy 00081 */ 00082 pdesk = pwinsta->rpdeskList; 00083 while (pdesk != NULL) { 00084 if (pdesk != grpdeskLogon && 00085 OBJECT_TO_OBJECT_HEADER(pdesk)->HandleCount != 0) { 00086 00087 /* 00088 * This desktop is open, thus the station is busy 00089 */ 00090 fBusy = TRUE; 00091 break; 00092 } 00093 pdesk = pdesk->rpdeskNext; 00094 } 00095 00096 if (pwinsta->dwWSF_Flags & WSF_SHUTDOWN) 00097 pwinsta->dwWSF_Flags |= WSF_OPENLOCK; 00098 00099 /* 00100 * Unlock opens if the station is busy and is not in the middle 00101 * of shutting down. 00102 */ 00103 if (fBusy) 00104 return WSS_BUSY; 00105 else 00106 return WSS_IDLE; 00107 } 00108 00109 00110 /***************************************************************************\ 00111 * _UnlockWindowStation 00112 * 00113 * Unlocks a windowstation locked by LogonLockWindowStation. 00114 * 00115 * History: 00116 * 01-15-91 JimA Created. 00117 \***************************************************************************/ 00118 00119 BOOL _UnlockWindowStation( 00120 PWINDOWSTATION pwinsta) 00121 { 00122 00123 /* 00124 * Make sure the caller is the logon process 00125 */ 00126 if (GetCurrentProcessId() != gpidLogon) { 00127 RIPERR0(ERROR_ACCESS_DENIED, 00128 RIP_WARNING, 00129 "Access denied in _UnlockWindowStation"); 00130 00131 return FALSE; 00132 } 00133 00134 /* 00135 * If shutdown is occuring, only remove the switch lock. 00136 */ 00137 if (pwinsta->dwWSF_Flags & WSF_SHUTDOWN) 00138 pwinsta->dwWSF_Flags &= ~WSF_SWITCHLOCK; 00139 else 00140 pwinsta->dwWSF_Flags &= ~(WSF_OPENLOCK | WSF_SWITCHLOCK); 00141 return TRUE; 00142 } 00143 00144 00145 /***************************************************************************\ 00146 * _SetLogonNotifyWindow 00147 * 00148 * Register the window to notify when logon related events occur. 00149 * 00150 * History: 00151 * 01-13-92 JimA Created. 00152 \***************************************************************************/ 00153 BOOL _SetLogonNotifyWindow( 00154 PWND pwnd) 00155 { 00156 /* 00157 * Make sure the caller is the logon process 00158 */ 00159 if (GetCurrentProcessId() != gpidLogon) { 00160 RIPERR0(ERROR_ACCESS_DENIED, 00161 RIP_WARNING, 00162 "Access denied in _SetLogonNotifyWindow"); 00163 00164 return FALSE; 00165 } 00166 00167 Lock(&gspwndLogonNotify, pwnd); 00168 00169 return TRUE; 00170 }

Generated on Sat May 15 19:40:39 2004 for test by doxygen 1.3.7