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.

144 lines
4.2 KiB

  1. // TelntSrv.h : This file contains the
  2. // Created: Jan '98
  3. // Author : a-rakeba
  4. // History:
  5. // Copyright (C) 1998 Microsoft Corporation
  6. // All rights reserved.
  7. // Microsoft Confidential
  8. #ifndef _TELNTSRV_H_
  9. #define _TELNTSRV_H_
  10. #include <tchar.h>
  11. #include <winsock2.h>
  12. #ifdef WHISTLER_BUILD
  13. #include <ws2tcpip.h>
  14. #else
  15. #include "ws2tcpip.h"
  16. #endif
  17. #include <IpTypes.h>
  18. #include <TlntDynamicArray.h>
  19. #include <TlntSvr.h>
  20. #include <EnumData.h>
  21. #include <EncliSvr.h>
  22. #include <ClientInfo.h>
  23. #include <Queue.h>
  24. #define WAIT_TIME 5000
  25. DWORD WINAPI DoIPCWithClients( LPVOID );
  26. typedef struct _FAMILY {
  27. int iFamily;
  28. socklen_t iSocklen;
  29. SOCKET sListenSocket; // the socket that listens for ever
  30. WSAEVENT SocketAcceptEvent;
  31. } FAMILY;
  32. #define NUM_FAMILIES 2
  33. class CTelnetService
  34. {
  35. public:
  36. virtual ~CTelnetService();
  37. static CTelnetService* Instance();
  38. CQueue *CQList;
  39. bool Shutdown( void );
  40. bool Pause( void );
  41. bool Resume( void );
  42. void SystemShutdown( void );
  43. DWORD NeedAudit( void );
  44. friend class CEnumTelnetClientsSvr;
  45. friend DWORD WINAPI DoIPCWithClients( LPVOID );
  46. bool ListenerThread( );
  47. private:
  48. CTelnetService();
  49. enum{ SOCKET_CLOSE_EVENT = WAIT_OBJECT_0, FD_ACCEPT_EVENT_0,
  50. REG_CHANGE_EVENT, FD_ACCEPT_EVENT_1 };
  51. enum{ SERVER_PAUSED, SERVER_RUNNING };
  52. bool Init( void );
  53. void InitializeOverlappedStruct( LPOVERLAPPED );
  54. void GetPathOfTheExecutable( PCHAR * );
  55. void GetPathOfTheExecutable( LPTSTR * );
  56. PCHAR GetDefaultLoginScriptFullPath( void );
  57. bool GetRegistryValues( void );
  58. bool GetLicenseForWorkStation( SOCKET );
  59. bool CheckLicense( bool *, CClientInfo * );
  60. bool IssueLicense( bool, CClientInfo *);
  61. bool StartThreads( void );
  62. bool CreateClient( SOCKET , DWORD *, HANDLE *, CClientInfo **);
  63. bool SendSocketToClient( HANDLE, SOCKET, DWORD );
  64. bool HandleInProcMessages( DWORD );
  65. bool IPCDataDriver( CClientInfo* );
  66. bool HandleFarEastSpecificRegKeys( void );
  67. bool CreateSessionProcess( HANDLE, HANDLE, DWORD*, HANDLE *, HWINSTA *, HDESK * );
  68. bool ExitTheSession( CClientInfo * );
  69. bool AskSessionToShutdown( HANDLE, UCHAR );
  70. bool SendSessionIdToClient( HANDLE, LONG );
  71. bool InformTheClient( SOCKET, LPSTR );
  72. bool StopServicingClient( CClientInfo *, BOOL );
  73. void HandleSessionDetailsMessage( CClientInfo * );
  74. bool WatchRegistryKeys( void );
  75. bool HandleChangeInRegKeys( void );
  76. bool SetNewRegKeyValues( DWORD, DWORD, DWORD, LPWSTR, LPWSTR, DWORD );
  77. bool RegisterForNotification( void );
  78. bool GetInAddr( INT, SOCKADDR_STORAGE *, socklen_t * );
  79. bool CreateSocket( INT );
  80. bool InitTCPIP( void );
  81. bool CreateNewIoCompletionPort( DWORD );
  82. bool AssociateDeviceWithCompletionPort ( HANDLE, HANDLE, DWORD_PTR );
  83. bool IssueReadFromPipe( CClientInfo* );
  84. bool OnCompletionPacket( CClientInfo*, LPOVERLAPPED );
  85. bool IssueReadAgain( CClientInfo* );
  86. DWORD m_dwTelnetPort;
  87. DWORD m_dwMaxConnections;
  88. bool m_fLogToFile;
  89. LPWSTR m_pszIpAddrToListenOn;
  90. static CTelnetService* s_instance;
  91. DWORD m_dwNumOfActiveConnections;
  92. LONG m_lServerState;
  93. WCHAR m_szDomainName[ MAX_DOMAIN_NAME_LEN + 4 ]; //This may be of form \\solar-dc-01
  94. bool m_bIsWorkStation;
  95. SOCKADDR_STORAGE *m_pssWorkstationList;
  96. DWORD m_dwNoOfWorkstations;
  97. HANDLE m_hRegChangeEvent;
  98. HKEY m_hReadConfigKey;
  99. HANDLE m_hSyncAllClientObjAccess;
  100. FAMILY m_sFamily[ NUM_FAMILIES ];
  101. HANDLE m_hCompletionPort;
  102. HWINSTA m_hOldWinSta;
  103. HANDLE m_hIPCThread;
  104. WSAEVENT m_SocketAcceptEvent;
  105. HANDLE m_hSocketCloseEvent;
  106. OVERLAPPED m_oReadFromPipe;
  107. OVERLAPPED m_oWriteToPipe;
  108. OVERLAPPED m_oPostedMessage;
  109. };
  110. void LogEvent ( WORD wType, DWORD dwEventID, LPCTSTR pFormat, ... );
  111. void WriteAuditedMsgsToFile( LPSTR );
  112. void CloseLogFile( LPWSTR *, HANDLE * );
  113. bool InitializeLogFile( LPWSTR, HANDLE * );
  114. #endif