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.

117 lines
4.7 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: CredentialTransfer.h
  3. //
  4. // Copyright (c) 2001, Microsoft Corporation
  5. //
  6. // Classes to handle credential transfer from one winlogon to another.
  7. //
  8. // History: 2001-01-11 vtan created
  9. // --------------------------------------------------------------------------
  10. #ifndef _CredentialTransfer_
  11. #define _CredentialTransfer_
  12. #include <ginaipc.h>
  13. #include "Thread.h"
  14. // --------------------------------------------------------------------------
  15. // CCredentials
  16. //
  17. // Purpose: Class to manage marshalling of credentials into a block of
  18. // memory that can be used in a named pipe.
  19. //
  20. // History: 2001-01-12 vtan created
  21. // --------------------------------------------------------------------------
  22. class CCredentials
  23. {
  24. private:
  25. typedef struct _CREDENTIALS
  26. {
  27. DWORD dwSize;
  28. unsigned char ucPasswordSeed;
  29. UNICODE_STRING username;
  30. UNICODE_STRING domain;
  31. UNICODE_STRING password;
  32. } CREDENTIALS, *PCREDENTIALS;
  33. private:
  34. CCredentials (void);
  35. ~CCredentials (void);
  36. public:
  37. static NTSTATUS OpenConduit (HANDLE *phPipe);
  38. static NTSTATUS CreateConduit (LPSECURITY_ATTRIBUTES pSecurityAttributes, HANDLE *phPipe);
  39. static NTSTATUS ClearConduit (void);
  40. static NTSTATUS Pack (LOGONIPC_CREDENTIALS *pLogonIPCCredentials, void* *ppvData, DWORD *pdwDataSize);
  41. static NTSTATUS Unpack (void *pvData, LOGONIPC_CREDENTIALS *pLogonIPCCredentials);
  42. static NTSTATUS StaticInitialize (bool fCreate);
  43. static NTSTATUS StaticTerminate (void);
  44. private:
  45. static NTSTATUS GetConduitName (TCHAR *pszName, DWORD dwNameSize);
  46. static NTSTATUS SetConduitName (const TCHAR *pszName);
  47. static NTSTATUS ClearConduitName (void);
  48. static NTSTATUS CreateConduitName (DWORD dwNumber, TCHAR *pszName);
  49. private:
  50. static HKEY s_hKeyCredentials;
  51. static const TCHAR s_szCredentialKeyName[];
  52. static const TCHAR s_szCredentialValueName[];
  53. };
  54. // --------------------------------------------------------------------------
  55. // CCredentialServer
  56. //
  57. // Purpose: Class to manage the server side of handing credentials from
  58. // one winlogon to another.
  59. //
  60. // History: 2001-01-11 vtan created
  61. // --------------------------------------------------------------------------
  62. class CCredentialServer : public CThread
  63. {
  64. private:
  65. CCredentialServer (void);
  66. CCredentialServer (DWORD dwTimeout, LOGONIPC_CREDENTIALS *pLogonIPCCredentials);
  67. virtual ~CCredentialServer (void);
  68. public:
  69. bool IsReady (void) const;
  70. static NTSTATUS Start (LOGONIPC_CREDENTIALS *pLogonIPCCredentials, DWORD dwWaitTime);
  71. static NTSTATUS Start (const WCHAR *pszUsername, const WCHAR *pszDomain, WCHAR *pszPassword, DWORD dwWaitTime);
  72. protected:
  73. virtual DWORD Entry (void);
  74. private:
  75. void ExecutePrematureTermination (void);
  76. static void CALLBACK CB_APCProc (ULONG_PTR dwParam);
  77. static void CALLBACK CB_FileIOCompletionRoutine (DWORD dwErrorCode, DWORD dwNumberOfBytesTransferred, LPOVERLAPPED lpOverlapped);
  78. private:
  79. DWORD _dwTimeout;
  80. bool _fTerminate;
  81. HANDLE _hPipe;
  82. OVERLAPPED _overlapped;
  83. void* _pvData;
  84. DWORD _dwSize;
  85. };
  86. // --------------------------------------------------------------------------
  87. // CCredentialClient
  88. //
  89. // Purpose: Class to manage the client side of handing credentials from
  90. // one winlogon to another.
  91. //
  92. // History: 2001-01-11 vtan created
  93. // --------------------------------------------------------------------------
  94. class CCredentialClient
  95. {
  96. private:
  97. CCredentialClient (void);
  98. ~CCredentialClient (void);
  99. public:
  100. static NTSTATUS Get (LOGONIPC_CREDENTIALS *pLogonIPCCredentials);
  101. };
  102. #endif /* _CredentialTransfer_ */