Source code of Windows XP (NT5)
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.

390 lines
11 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. } MUGLOBALS, *PMUGLOBALS;
  113. //
  114. // Non paged chunk for passwords and similar goodies
  115. //
  116. typedef struct _NP_GLOBALS {
  117. WCHAR UserName[MAX_STRING_BYTES]; // e.g. Justinm
  118. WCHAR Domain[MAX_STRING_BYTES];
  119. WCHAR Password[MAX_STRING_BYTES];
  120. WCHAR OldPassword[MAX_STRING_BYTES];
  121. } NP_GLOBALS, * PNP_GLOBALS ;
  122. //
  123. // Reasons why we may not have performed an optimized - cached logon
  124. // by default.
  125. //
  126. typedef enum _OPTIMIZED_LOGON_STATUS {
  127. OLS_LogonIsCached = 0,
  128. OLS_Unspecified = 1,
  129. OLS_UnsupportedSKU = 2,
  130. OLS_LogonFailed = 3,
  131. OLS_InsufficientResources = 4,
  132. OLS_NonCachedLogonType = 5,
  133. OLS_SyncUserPolicy = 6,
  134. OLS_SyncMachinePolicy = 7,
  135. OLS_ProfileDisallows = 8,
  136. OLS_SyncLogonScripts = 9,
  137. OLS_NextLogonNotCacheable = 10,
  138. OLS_MachineIsNotDomainMember = 11,
  139. } OPTIMIZED_LOGON_STATUS, *POPTIMIZED_LOGON_STATUS;
  140. //
  141. // Define the winlogon global structure.
  142. //
  143. typedef struct _GINAFONTS
  144. {
  145. HFONT hWelcomeFont; // font used for painting the welcome text
  146. HFONT hCopyrightFont; // used to paint copyright notice
  147. HFONT hBuiltOnNtFont; // used to paint the "Built on NT" line
  148. HFONT hBetaFont; // used to paint the release notice on the welcome page
  149. } GINAFONTS, *PGINAFONTS;
  150. #define PASSWORD_HASH_SIZE 16
  151. typedef struct _GLOBALS {
  152. struct _GLOBALS *pNext;
  153. HANDLE hGlobalWlx;
  154. HDESK hdeskParent;
  155. RTL_CRITICAL_SECTION csGlobals;
  156. // Filled in by InitializeGlobals at startup
  157. PSID WinlogonSid;
  158. //
  159. PSID LogonSid;
  160. PVOID LockedMemory ;
  161. HANDLE hEventLog;
  162. HANDLE hMPR;
  163. HWND hwndLogon;
  164. BOOL LogonInProgress;
  165. // Filled in during startup
  166. HANDLE LsaHandle; // Lsa authentication handle
  167. LSA_OPERATIONAL_MODE SecurityMode;
  168. ULONG AuthenticationPackage;
  169. BOOL AuditLogFull;
  170. BOOL AuditLogNearFull;
  171. // Always valid, indicates if we have a user logged on
  172. BOOL UserLoggedOn;
  173. // Always valid - used to start new processes and screen-saver
  174. USER_PROCESS_DATA UserProcessData;
  175. // Filled in by a successful logon
  176. TCHAR UserFullName[MAX_STRING_BYTES]; // e.g. Magaram, Justin
  177. UNICODE_STRING UserNameString;
  178. LPWSTR UserName ;
  179. UNICODE_STRING DomainString;
  180. LPWSTR Domain ;
  181. UNICODE_STRING FlatUserName ;
  182. UNICODE_STRING FlatDomain;
  183. LPWSTR DnsDomain ;
  184. UCHAR Seed;
  185. UCHAR OldSeed;
  186. UCHAR OldPasswordPresent;
  187. UCHAR Reserved;
  188. LUID LogonId;
  189. TIME LogonTime;
  190. TIME LockTime;
  191. PMSV1_0_INTERACTIVE_PROFILE Profile;
  192. ULONG ProfileLength;
  193. LPWSTR MprLogonScripts;
  194. UNICODE_STRING PasswordString; // Run-encoded for password privacy
  195. // (points to Password buffer below)
  196. LPWSTR Password ;
  197. UNICODE_STRING OldPasswordString;
  198. LPWSTR OldPassword ;
  199. UCHAR PasswordHash[ PASSWORD_HASH_SIZE ]; // Hash of password
  200. // Filled in during SetupUserEnvironment, and used in ResetEnvironment.
  201. // Valid only when a user is logged on.
  202. USER_PROFILE_INFO UserProfile;
  203. PWSTR ExtraApps;
  204. BOOL BlockForLogon;
  205. FILETIME LastNotification;
  206. //
  207. // Advanced Logon Stuff:
  208. //
  209. ULONG PasswordLogonPackage ;
  210. ULONG SmartCardLogonPackage ;
  211. OPTIMIZED_LOGON_STATUS OptimizedLogonStatus;
  212. //
  213. // Account lockout data
  214. //
  215. // Manipulated only by LockInitialize, LockoutHandleFailedLogon
  216. // and LockoutHandleSuccessfulLogon.
  217. //
  218. LOCKOUT_DATA LockoutData;
  219. //
  220. // Flags controlling unlock behavior
  221. //
  222. DWORD UnlockBehavior ;
  223. //
  224. // Trusted domain cache
  225. //
  226. PDOMAIN_CACHE Cache ;
  227. PDOMAIN_CACHE_ARRAY ActiveArray ;
  228. BOOL ListPopulated ;
  229. //
  230. // Hydra specific part of winlogon globals struct
  231. //
  232. MUGLOBALS MuGlobals;
  233. //
  234. // Folding options state
  235. //
  236. BOOL ShowRasBox;
  237. BOOL RasUsed;
  238. BOOL SmartCardLogon;
  239. ULONG SmartCardOption ;
  240. BOOL LogonOptionsShown;
  241. BOOL UnlockOptionsShown;
  242. BOOL AutoAdminLogon;
  243. BOOL IgnoreAutoAdminLogon;
  244. INT xBandOffset; // used for animated band in dialog
  245. INT cxBand; // width of band being displayed, used for wrapping
  246. // fonts
  247. GINAFONTS GinaFonts;
  248. // Flag indicating whether we are showing the domain box
  249. BOOL ShowDomainBox;
  250. // Coordinates of upper-left hand corner of the Welcome screen
  251. // - We want to position the logon dialog here also!
  252. RECT rcWelcome;
  253. // Size of the original "Log On To Windows" dialog
  254. RECT rcDialog;
  255. // Status UI information
  256. HANDLE hStatusInitEvent;
  257. HANDLE hStatusTermEvent;
  258. HANDLE hStatusThread;
  259. HDESK hStatusDesktop;
  260. HWND hStatusDlg;
  261. INT cxStatusBand;
  262. INT xStatusBandOffset;
  263. DWORD dwStatusOptions;
  264. // flag indicating if user credentials were passed on from an other session
  265. BOOL TransderedCredentials;
  266. TCHAR Smartcard[64];
  267. TCHAR SmartcardReader[64];
  268. } GLOBALS, *PGLOBALS;
  269. //
  270. // Unlock behavior bits:
  271. //
  272. #define UNLOCK_FORCE_AUTHENTICATION 0x00000001
  273. #define UNLOCK_NO_NETWORK 0x00000002
  274. //
  275. // Define a macro to determine if we're a workstation or not
  276. // This allows easy changes as new product types are added.
  277. //
  278. #define IsDomainController(prodtype) (((prodtype) == NtProductWinNt) \
  279. || ((prodtype) == NtProductServer))
  280. #define IsWorkstation(prodtype) ((prodtype) == NtProductWinNt)
  281. // A WM_HANDLEFAILEDLOGON message was already sent - this message
  282. // will in turn send a WM_LOGONCOMPLETE with the result.
  283. #define MSGINA_DLG_FAILEDMSGSENT 0x10000001
  284. //
  285. // Define common return code groupings
  286. //
  287. #define DLG_TIMEOUT(Result) ((Result == MSGINA_DLG_INPUT_TIMEOUT) || (Result == MSGINA_DLG_SCREEN_SAVER_TIMEOUT))
  288. #define DLG_LOGOFF(Result) ((Result & ~MSGINA_DLG_FLAG_MASK) == MSGINA_DLG_USER_LOGOFF)
  289. #define DLG_SHUTDOWNEX(Result) ((Result & ~MSGINA_DLG_FLAG_MASK) == MSGINA_DLG_SHUTDOWN)
  290. // #define DLG_INTERRUPTED(Result) (DLG_TIMEOUT(Result) || DLG_LOGOFF(Result))
  291. #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)))
  292. #define SetInterruptFlag(Result) ((Result) | MSGINA_DLG_INTERRUPTED )
  293. #define ClearInterruptFlag(Result) ((Result) & (~MSGINA_DLG_INTERRUPTED ))
  294. #define ResultNoFlags(Result) ((Result) & (~MSGINA_DLG_INTERRUPTED ))
  295. #define DLG_FAILED(Result) (ResultNoFlags( Result ) == MSGINA_DLG_FAILURE)
  296. #define DLG_SUCCEEDED(Result) (ResultNoFlags( Result ) == MSGINA_DLG_SUCCESS)
  297. #define DLG_INTERRUPTED( Result ) ((Result & MSGINA_DLG_INTERRUPTED) == (MSGINA_DLG_INTERRUPTED) )