Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: structs.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 7-19-94 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. //
  18. // Arraysize macro
  19. //
  20. #define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
  21. //
  22. // Define the input timeout delay for the security options dialog (seconds)
  23. //
  24. #define OPTIONS_TIMEOUT 120
  25. //
  26. // Define the number of days warning we give the user before their password expires
  27. //
  28. #define PASSWORD_EXPIRY_WARNING_DAYS 14
  29. //
  30. // Define the maximum time we display the 'wait for user to be logged off'
  31. // dialog. This dialog should be interrupted by the user being logged off.
  32. // This timeout is a safety measure in case that doesn't happen because
  33. // of some system error.
  34. //
  35. #define WAIT_FOR_USER_LOGOFF_DLG_TIMEOUT 120 // seconds
  36. //
  37. // Define the account lockout limits
  38. //
  39. // A delay of LOCKOUT_BAD_LOGON_DELAY seconds will be added to
  40. // each failed logon if more than LOCKOUT_BAD_LOGON_COUNT failed logons
  41. // have occurred in the last LOCKOUT_BAD_LOGON_PERIOD seconds.
  42. //
  43. #define LOCKOUT_BAD_LOGON_COUNT 5
  44. #define LOCKOUT_BAD_LOGON_PERIOD 60 // seconds
  45. #define LOCKOUT_BAD_LOGON_DELAY 30 // seconds
  46. //
  47. // Define the maximum length of strings we'll use in winlogon
  48. //
  49. #define MAX_STRING_LENGTH 511
  50. #define MAX_STRING_BYTES (MAX_STRING_LENGTH + 1)
  51. //
  52. // Define the typical length of a string
  53. // This is used as an initial allocation size for most string routines.
  54. // If this is insufficient, the block is reallocated larger and
  55. // the operation retried. i.e. Make this big enough for most strings
  56. // to fit first time.
  57. //
  58. #define TYPICAL_STRING_LENGTH 60
  59. //
  60. // Define the structure that contains information used when starting
  61. // user processes.
  62. // This structure should only be modified by SetUserProcessData()
  63. //
  64. typedef struct {
  65. HANDLE UserToken; // NULL if no user logged on
  66. HANDLE RestrictedToken ;
  67. PSID UserSid; // == WinlogonSid if no user logged on
  68. PSECURITY_DESCRIPTOR NewThreadTokenSD;
  69. QUOTA_LIMITS Quotas;
  70. PVOID pEnvironment;
  71. HKEY hCurrentUser ;
  72. ULONG Flags ;
  73. } USER_PROCESS_DATA;
  74. typedef USER_PROCESS_DATA *PUSER_PROCESS_DATA;
  75. #define USER_FLAG_LOCAL 0x00000001
  76. //
  77. // Define the structure that contains information about the user's profile.
  78. // This is used in SetupUserEnvironment and ResetEnvironment (in usrenv.c)
  79. // This data is only valid while a user is logged on.
  80. //
  81. typedef struct {
  82. LPTSTR ProfilePath;
  83. } USER_PROFILE_INFO;
  84. typedef USER_PROFILE_INFO *PUSER_PROFILE_INFO;
  85. //
  86. // Get any data types defined in module headers and used in GLOBALS
  87. //
  88. #define DATA_TYPES_ONLY
  89. #include "lockout.h"
  90. #include "domain.h"
  91. #undef DATA_TYPES_ONLY
  92. //
  93. // Multi User Global Structure
  94. //
  95. typedef struct _MUGLOBALS {
  96. //
  97. // Current SessionId
  98. //
  99. ULONG SessionId;
  100. //
  101. // Auto logon information
  102. //
  103. PWLX_CLIENT_CREDENTIALS_INFO_V2_0 pAutoLogon;
  104. //
  105. // TS-specific data passed to us from WinLogon via WlxPassTerminalServicesData().
  106. //
  107. WLX_TERMINAL_SERVICES_DATA TSData;
  108. //
  109. // For CLIENTNAME environment variable
  110. //
  111. TCHAR ClientName[CLIENTNAME_LENGTH + 1];
  112. //
  113. // Flag indicating a slower rate of animation is requested to optimize
  114. // for slow TS clients
  115. //
  116. BOOL fSlowAnimationRate;
  117. } MUGLOBALS, *PMUGLOBALS;
  118. //
  119. // Non paged chunk for passwords and similar goodies
  120. //
  121. typedef struct _NP_GLOBALS {
  122. WCHAR UserName[MAX_STRING_BYTES]; // e.g. Justinm
  123. WCHAR Domain[MAX_STRING_BYTES];
  124. WCHAR Password[MAX_STRING_BYTES];
  125. WCHAR OldPassword[MAX_STRING_BYTES];
  126. } NP_GLOBALS, * PNP_GLOBALS ;
  127. //
  128. // Reasons why we may not have performed an optimized - cached logon
  129. // by default.
  130. //
  131. typedef enum _OPTIMIZED_LOGON_STATUS {
  132. OLS_LogonIsCached = 0,
  133. OLS_Unspecified = 1,
  134. OLS_UnsupportedSKU = 2,
  135. OLS_LogonFailed = 3,
  136. OLS_InsufficientResources = 4,
  137. OLS_NonCachedLogonType = 5,
  138. OLS_SyncUserPolicy = 6,
  139. OLS_SyncMachinePolicy = 7,
  140. OLS_ProfileDisallows = 8,
  141. OLS_SyncLogonScripts = 9,
  142. OLS_NextLogonNotCacheable = 10,
  143. OLS_MachineIsNotDomainMember = 11,
  144. } OPTIMIZED_LOGON_STATUS, *POPTIMIZED_LOGON_STATUS;
  145. //
  146. // Define the winlogon global structure.
  147. //
  148. typedef struct _GINAFONTS
  149. {
  150. HFONT hWelcomeFont; // font used for painting the welcome text
  151. HFONT hCopyrightFont; // used to paint copyright notice
  152. HFONT hBuiltOnNtFont; // used to paint the "Built on NT" line
  153. HFONT hBetaFont; // used to paint the release notice on the welcome page
  154. } GINAFONTS, *PGINAFONTS;
  155. #define PASSWORD_HASH_SIZE 16
  156. typedef struct _GLOBALS {
  157. struct _GLOBALS *pNext;
  158. HANDLE hGlobalWlx;
  159. HDESK hdeskParent;
  160. RTL_CRITICAL_SECTION csGlobals;
  161. // Filled in by InitializeGlobals at startup
  162. PSID WinlogonSid;
  163. //
  164. PSID LogonSid;
  165. PVOID LockedMemory ;
  166. HANDLE hEventLog;
  167. HANDLE hMPR;
  168. HWND hwndLogon;
  169. BOOL LogonInProgress;
  170. // Filled in during startup
  171. HANDLE LsaHandle; // Lsa authentication handle
  172. LSA_OPERATIONAL_MODE SecurityMode;
  173. ULONG AuthenticationPackage;
  174. BOOL AuditLogFull;
  175. BOOL AuditLogNearFull;
  176. // Always valid, indicates if we have a user logged on
  177. BOOL UserLoggedOn;
  178. // Always valid - used to start new processes and screen-saver
  179. USER_PROCESS_DATA UserProcessData;
  180. // Filled in by a successful logon
  181. TCHAR UserFullName[MAX_STRING_BYTES]; // e.g. Magaram, Justin
  182. UNICODE_STRING UserNameString;
  183. LPWSTR UserName ;
  184. UNICODE_STRING DomainString;
  185. LPWSTR Domain ;
  186. UNICODE_STRING FlatUserName ;
  187. UNICODE_STRING FlatDomain;
  188. LPWSTR DnsDomain ;
  189. UCHAR Seed;
  190. UCHAR OldSeed;
  191. UCHAR OldPasswordPresent;
  192. UCHAR Reserved;
  193. LUID LogonId;
  194. TIME LogonTime;
  195. TIME LockTime;
  196. PMSV1_0_INTERACTIVE_PROFILE Profile;
  197. ULONG ProfileLength;
  198. LPWSTR MprLogonScripts;
  199. UNICODE_STRING PasswordString; // Run-encoded for password privacy
  200. // (points to Password buffer below)
  201. LPWSTR Password ;
  202. UNICODE_STRING OldPasswordString;
  203. LPWSTR OldPassword ;
  204. UCHAR PasswordHash[ PASSWORD_HASH_SIZE ]; // Hash of password
  205. // Filled in during SetupUserEnvironment, and used in ResetEnvironment.
  206. // Valid only when a user is logged on.
  207. USER_PROFILE_INFO UserProfile;
  208. BOOL BlockForLogon;
  209. FILETIME LastNotification;
  210. //
  211. // Advanced Logon Stuff:
  212. //
  213. ULONG PasswordLogonPackage ;
  214. ULONG SmartCardLogonPackage ;
  215. OPTIMIZED_LOGON_STATUS OptimizedLogonStatus;
  216. //
  217. // Account lockout data
  218. //
  219. // Manipulated only by LockInitialize, LockoutHandleFailedLogon
  220. // and LockoutHandleSuccessfulLogon.
  221. //
  222. LOCKOUT_DATA LockoutData;
  223. //
  224. // Flags controlling unlock behavior
  225. //
  226. DWORD UnlockBehavior ;
  227. //
  228. // Trusted domain cache
  229. //
  230. PDOMAIN_CACHE Cache ;
  231. PDOMAIN_CACHE_ARRAY ActiveArray ;
  232. BOOL ListPopulated ;
  233. //
  234. // Hydra specific part of winlogon globals struct
  235. //
  236. MUGLOBALS MuGlobals;
  237. //
  238. // Folding options state
  239. //
  240. BOOL ShowRasBox;
  241. BOOL RasUsed;
  242. BOOL SmartCardLogon;
  243. ULONG SmartCardOption ;
  244. BOOL LogonOptionsShown;
  245. BOOL UnlockOptionsShown;
  246. BOOL AutoAdminLogon;
  247. BOOL IgnoreAutoAdminLogon;
  248. INT xBandOffset; // used for animated band in dialog
  249. INT cxBand; // width of band being displayed, used for wrapping
  250. // fonts
  251. GINAFONTS GinaFonts;
  252. // Flag indicating whether we are showing the domain box
  253. BOOL ShowDomainBox;
  254. // Coordinates of upper-left hand corner of the Welcome screen
  255. // - We want to position the logon dialog here also!
  256. RECT rcWelcome;
  257. // Size of the original "Log On To Windows" dialog
  258. RECT rcDialog;
  259. // Status UI information
  260. HANDLE hStatusInitEvent;
  261. HANDLE hStatusTermEvent;
  262. HANDLE hStatusThread;
  263. HDESK hStatusDesktop;
  264. HWND hStatusDlg;
  265. INT cxStatusBand;
  266. INT xStatusBandOffset;
  267. DWORD dwStatusOptions;
  268. // flag indicating if user credentials were passed on from an other session
  269. BOOL TransderedCredentials;
  270. TCHAR Smartcard[64];
  271. TCHAR SmartcardReader[64];
  272. BOOL fLocalDomain;
  273. } GLOBALS, *PGLOBALS;
  274. //
  275. // Unlock behavior bits:
  276. //
  277. #define UNLOCK_FORCE_AUTHENTICATION 0x00000001
  278. #define UNLOCK_NO_NETWORK 0x00000002
  279. //
  280. // Define a macro to determine if we're a workstation or not
  281. // This allows easy changes as new product types are added.
  282. //
  283. #define IsDomainController(prodtype) (((prodtype) == NtProductWinNt) \
  284. || ((prodtype) == NtProductServer))
  285. #define IsWorkstation(prodtype) ((prodtype) == NtProductWinNt)
  286. // A WM_HANDLEFAILEDLOGON message was already sent - this message
  287. // will in turn send a WM_LOGONCOMPLETE with the result.
  288. #define MSGINA_DLG_FAILEDMSGSENT 0x10000001
  289. //
  290. // Define common return code groupings
  291. //
  292. #define DLG_TIMEOUT(Result) ((Result == MSGINA_DLG_INPUT_TIMEOUT) || (Result == MSGINA_DLG_SCREEN_SAVER_TIMEOUT))
  293. #define DLG_LOGOFF(Result) ((Result & ~MSGINA_DLG_FLAG_MASK) == MSGINA_DLG_USER_LOGOFF)
  294. #define DLG_SHUTDOWNEX(Result) ((Result & ~MSGINA_DLG_FLAG_MASK) == MSGINA_DLG_SHUTDOWN)
  295. // #define DLG_INTERRUPTED(Result) (DLG_TIMEOUT(Result) || DLG_LOGOFF(Result))
  296. #define DLG_SHUTDOWN(Result) ((DLG_LOGOFF(Result) || DLG_SHUTDOWNEX(Result)) && (Result & (MSGINA_DLG_SHUTDOWN_FLAG | MSGINA_DLG_REBOOT_FLAG | MSGINA_DLG_POWEROFF_FLAG | MSGINA_DLG_SLEEP_FLAG | MSGINA_DLG_SLEEP2_FLAG | MSGINA_DLG_HIBERNATE_FLAG)))
  297. #define SetInterruptFlag(Result) ((Result) | MSGINA_DLG_INTERRUPTED )
  298. #define ClearInterruptFlag(Result) ((Result) & (~MSGINA_DLG_INTERRUPTED ))
  299. #define ResultNoFlags(Result) ((Result) & (~MSGINA_DLG_INTERRUPTED ))
  300. #define DLG_FAILED(Result) (ResultNoFlags( Result ) == MSGINA_DLG_FAILURE)
  301. #define DLG_SUCCEEDED(Result) (ResultNoFlags( Result ) == MSGINA_DLG_SUCCESS)
  302. #define DLG_INTERRUPTED( Result ) ((Result & MSGINA_DLG_INTERRUPTED) == (MSGINA_DLG_INTERRUPTED) )