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.

87 lines
3.8 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: CInteractiveLogon.h
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // File that implements encapsulation of interactive logon information.
  7. //
  8. // History: 2000-12-07 vtan created
  9. // --------------------------------------------------------------------------
  10. #ifndef _CInteractiveLogon_
  11. #define _CInteractiveLogon_
  12. EXTERN_C BOOL WINAPI InitiateInteractiveLogon (const WCHAR *pszUsername, WCHAR *pszPassword, DWORD dwTimeout);
  13. // --------------------------------------------------------------------------
  14. // CInteractiveLogon
  15. //
  16. // Purpose: This class encapsulates interactive logon implementation.
  17. //
  18. // History: 2000-12-07 vtan created
  19. // --------------------------------------------------------------------------
  20. class CInteractiveLogon
  21. {
  22. private:
  23. static const int MAGIC_NUMBER = 48517;
  24. class CRequestData
  25. {
  26. public:
  27. CRequestData (void);
  28. ~CRequestData (void);
  29. void Set (const WCHAR *pszUsername, const WCHAR *pszDomain, WCHAR *pszPassword);
  30. DWORD Get (WCHAR *pszUsername, WCHAR *pszDomain, WCHAR *pszPassword) const;
  31. void SetErrorCode (DWORD dwErrorCode);
  32. DWORD GetErrorCode (void) const;
  33. HANDLE OpenEventReply (void) const;
  34. private:
  35. unsigned long _ulMagicNumber;
  36. DWORD _dwErrorCode;
  37. WCHAR _szEventReplyName[64];
  38. WCHAR _szUsername[UNLEN + sizeof('\0')];
  39. WCHAR _szDomain[DNLEN + sizeof('\0')];
  40. unsigned char _ucSeed;
  41. int _iPasswordLength;
  42. WCHAR _szPassword[PWLEN + sizeof('\0')];
  43. };
  44. public:
  45. CInteractiveLogon (void);
  46. ~CInteractiveLogon (void);
  47. void Start (void);
  48. void Stop (void);
  49. void SetHostWindow (HWND hwndUIHost);
  50. static DWORD Initiate (const WCHAR *pszUsername, const WCHAR *pszDomain, WCHAR *pszPassword, DWORD dwTimeout);
  51. private:
  52. static DWORD CheckInteractiveLogonAllowed (DWORD dwTimeout);
  53. static DWORD CheckShutdown (void);
  54. static DWORD CheckMutex (DWORD dwTimeout);
  55. static bool FoundUserSessionID (HANDLE hToken, DWORD *pdwSessionID);
  56. static DWORD SendRequest (const WCHAR *pszUsername, const WCHAR *pszDomain, WCHAR *pszPassword);
  57. static void FormulateObjectBasePath (DWORD dwSessionID, WCHAR *pszObjectPath);
  58. static HANDLE CreateSessionNamedReplyEvent (DWORD dwSessionID);
  59. static HANDLE OpenSessionNamedSignalEvent (DWORD dwSessionID);
  60. static HANDLE CreateSessionNamedSection (DWORD dwSessionID);
  61. void WaitForInteractiveLogonRequest (void);
  62. static DWORD WINAPI CB_ThreadProc (void *pParameter);
  63. static void CALLBACK CB_APCProc (ULONG_PTR dwParam);
  64. private:
  65. HANDLE _hThread;
  66. bool _fContinue;
  67. HWND _hwndHost;
  68. static const TCHAR s_szEventReplyName[];
  69. static const TCHAR s_szEventSignalName[];
  70. static const TCHAR s_szSectionName[];
  71. };
  72. #endif /* _CInteractiveLogon_ */