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.

125 lines
3.2 KiB

  1. //Copyright (c) Microsoft Corporation. All rights reserved.
  2. #ifndef _ClientInfo_h_
  3. #define _ClientInfo_h_
  4. #include <cmnhdr.h>
  5. #include <ntlsapi.h>
  6. #include <winsock2.h>
  7. #include <debug.h>
  8. #include <Ipc.h>
  9. #include <TelnetD.h>
  10. #include <TelntSrv.h>
  11. #include <TlntUtils.h>
  12. #define INVALID_LICENSE_HANDLE (0U - 1U)
  13. using namespace _Utils;
  14. using CDebugLevel::TRACE_DEBUGGING;
  15. using CDebugLevel::TRACE_HANDLE;
  16. using CDebugLevel::TRACE_SOCKET;
  17. static DWORD l =1;
  18. extern HANDLE g_hSyncCloseHandle;
  19. class CClientInfo
  20. {
  21. HANDLE hInPipe;
  22. HANDLE hOutPipe;
  23. public:
  24. SOCKET sSocket;
  25. DWORD dwPid;
  26. HANDLE hWritingPipe;
  27. HANDLE hReadingPipe;
  28. CHAR *szUserName;
  29. CHAR *szDomain;
  30. CHAR *szRemoteMachine;
  31. LPSYSTEMTIME lpLogonTime;
  32. LUID *pAuthId;
  33. UCHAR *m_ReadFromPipeBuffer;
  34. DWORD m_dwPosition;
  35. DWORD m_dwRequestedSize;
  36. bool bLicenseIssued;
  37. LS_HANDLE m_hLicense;
  38. DWORD m_dwIdleTime;
  39. HWINSTA window_station;
  40. HDESK desktop;
  41. CClientInfo(
  42. HANDLE hR,
  43. HANDLE hW,
  44. HANDLE hIn,
  45. HANDLE hOut,
  46. SOCKET sSok,
  47. DWORD dPid,
  48. HWINSTA winsta,
  49. HDESK dsktp
  50. ) :
  51. hReadingPipe( hR ), hWritingPipe( hW ), hInPipe( hIn ),
  52. hOutPipe( hOut ), sSocket( sSok ), dwPid( dPid ), szUserName( NULL ),
  53. m_dwPosition( 0 ), szDomain( NULL ), szRemoteMachine( NULL ),
  54. lpLogonTime( NULL ), pAuthId( NULL ), m_hLicense( INVALID_LICENSE_HANDLE ),
  55. window_station(winsta), desktop(dsktp)
  56. {
  57. m_ReadFromPipeBuffer = new UCHAR[ IPC_HEADER_SIZE ];
  58. m_dwRequestedSize = IPC_HEADER_SIZE;
  59. bLicenseIssued = false;
  60. m_dwIdleTime = 0;
  61. }
  62. virtual ~CClientInfo()
  63. {
  64. TELNET_SYNC_CLOSE_HANDLE( hReadingPipe );
  65. TELNET_SYNC_CLOSE_HANDLE( hWritingPipe );
  66. TELNET_SYNC_CLOSE_HANDLE( hInPipe );
  67. TELNET_SYNC_CLOSE_HANDLE( hOutPipe );
  68. if (desktop)
  69. {
  70. CloseDesktop(desktop);
  71. desktop = NULL;
  72. }
  73. if (window_station)
  74. {
  75. CloseWindowStation(window_station);
  76. window_station = NULL;
  77. }
  78. if (INVALID_SOCKET != sSocket)
  79. {
  80. _TRACE( TRACE_DEBUGGING, "~CClientInfo -- closesocket -- %p ",
  81. sSocket );
  82. closesocket( sSocket );
  83. sSocket = INVALID_SOCKET;
  84. }
  85. if (m_ReadFromPipeBuffer)
  86. delete[] m_ReadFromPipeBuffer;
  87. delete[] szUserName;
  88. delete[] szDomain;
  89. delete[] szRemoteMachine;
  90. delete lpLogonTime;
  91. delete pAuthId;
  92. if (INVALID_LICENSE_HANDLE != m_hLicense)
  93. {
  94. NtLSFreeHandle( m_hLicense );
  95. m_hLicense = INVALID_LICENSE_HANDLE;
  96. }
  97. }
  98. void CloseClientSocket()
  99. {
  100. _TRACE( TRACE_DEBUGGING, "CloseClientSocket -- closesocket -- %d ",
  101. (DWORD)sSocket );
  102. if (INVALID_SOCKET != sSocket)
  103. {
  104. closesocket( sSocket );
  105. sSocket = INVALID_SOCKET;
  106. }
  107. return;
  108. }
  109. };
  110. #endif _ClientInfo_h_