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.

180 lines
5.4 KiB

  1. // scraper.cpp : This file contains the
  2. // Created: Dec '97
  3. // History:
  4. // Copyright (C) 1997 Microsoft Corporation
  5. // All rights reserved.
  6. // Microsoft Confidential
  7. #ifndef __SCRAPER__H__
  8. #define __SCRAPER__H__
  9. //#define IS_CONTROL_CHAR( ucChar ) ( ( ucChar ) < 32 )
  10. #define MAX_SOCKET_BUFFER_SIZE ( 8 * 1024 )
  11. #define DEFAULT_SEND_BUFFER_SIZE ( 4 * 1024 )
  12. #define SMALL_ARRAY 64
  13. #define LNM 20
  14. #define VT_ESC 0x1B
  15. #define DEFAULT_TERMCAP L"termcap"
  16. #define POLL_INTERVAL 1000 //Milli Secs
  17. #define MIN_POLL_INTERVAL 100 //Milli Secs
  18. #define CONVERT_TO_MILLI_SECS( dwNum ) ( dwNum ) = ( dwNum ) * 1000
  19. #define CTRLC 0x03
  20. #define ESC '\033'
  21. #define VTNT "vtnt"
  22. #define VT100 "vt100"
  23. #define VT52 "vt52"
  24. #define VT80 "vt80"
  25. #define ANSI "ansi"
  26. #define DELTA 100
  27. #define TERMVT52 0x0001
  28. #define TERMVT100 0x0002
  29. #define TERMVT80 0x0004
  30. #define TERMVTNT 0x0008
  31. #define TERMANSI 0x0010
  32. #define VS_O 24
  33. #define VKEY_CTRL_BREAK 0x03
  34. #define VS_MENU 56
  35. #define VS_DELETE 83
  36. #define VS_ESCAPE 1
  37. #define VS_UP 72
  38. #define VS_DOWN 80
  39. #define VS_LEFT 75
  40. #define VS_RIGHT 77
  41. #define VS_OEM_4 26
  42. #define VS_NEXT 81
  43. #define VS_PRIOR 33
  44. #define VS_END 79
  45. #define VS_INSERT 82
  46. #define VS_HOME 76
  47. #define VS_PAUSE 69
  48. #define VS_F1 59
  49. #define VS_F2 60
  50. #define VS_F3 61
  51. #define VS_F4 62
  52. #define VS_F5 63
  53. #define VS_F6 64
  54. #define VS_F7 65
  55. #define VS_F8 66
  56. #define VS_F9 67
  57. #define VS_F10 68
  58. #define VS_F11 87
  59. #define VS_F12 88
  60. #define VT302_NEXT 6
  61. #define VT302_PRIOR 5
  62. #define VT302_END 4
  63. #define VT302_INSERT 2
  64. #define VT302_HOME 1
  65. #define VT302_PAUSE 'P'
  66. #define VT302_F5 15
  67. #define VT302_F6 17
  68. #define VT302_F7 18
  69. #define VT302_F8 19
  70. #define VT302_F9 20
  71. #define VT302_F10 21
  72. #define VT302_F11 23
  73. #define VT302_F12 24
  74. typedef struct {
  75. UINT dwInputTimerId;
  76. HANDLE hTimerExpired;
  77. } TimerContext;
  78. #define COMPARE_AND_UPDATE( wRows, wCols, pCurrent,pLastSeen,CSBI,LastCSBI,fDiff) \
  79. (m_dwCurrentCodePage == 932 ||m_dwCurrentCodePage == 949 || m_dwCurrentCodePage == 950 || m_dwCurrentCodePage == 936) ? \
  80. CompareAndUpdateVT80(wRows,wCols,pCurrent,pLastSeen,CSBI,LastCSBI,fDiff) : \
  81. CompareAndUpdateVT100(wRows,wCols,pCurrent,pLastSeen,CSBI,LastCSBI,fDiff)
  82. enum { IP_INIT, IP_ESC_RCVD, IP_ESC_BRACKET_RCVD, IP_ESC_O_RCVD, IP_ESC_BRACKET_DIGIT_RCVD };
  83. #define ISSESSION_TIMEOUT_DISABLED( dwIdleSessionTimeOut ) ( dwIdleSessionTimeOut == ~0 )
  84. class CSession;
  85. class CScraper
  86. {
  87. CSession *m_pSession;
  88. PCHAR_INFO pLastSeen;
  89. PCHAR_INFO pCurrent;
  90. CONSOLE_SCREEN_BUFFER_INFO CSBI;
  91. CONSOLE_SCREEN_BUFFER_INFO LastCSBI;
  92. DWORD m_dwCurrentCodePage;
  93. DWORD m_bCheckForScrolling;
  94. DWORD m_dwInputSequneceState;
  95. DWORD m_dwDigitInTheSeq;
  96. bool CompareAndUpdateVT80( WORD, WORD, PCHAR_INFO, PCHAR_INFO,
  97. PCONSOLE_SCREEN_BUFFER_INFO,
  98. PCONSOLE_SCREEN_BUFFER_INFO,
  99. bool * );
  100. bool CompareAndUpdateVT100( WORD, WORD, PCHAR_INFO, PCHAR_INFO,
  101. PCONSOLE_SCREEN_BUFFER_INFO,
  102. PCONSOLE_SCREEN_BUFFER_INFO,
  103. bool * );
  104. bool CompareAndUpdateVTNT( WORD, WORD, PCHAR_INFO, PCHAR_INFO,
  105. PCONSOLE_SCREEN_BUFFER_INFO,
  106. PCONSOLE_SCREEN_BUFFER_INFO,
  107. bool * );
  108. bool SendVTNTData( WORD, COORD, COORD, SMALL_RECT* , CHAR_INFO* );
  109. void SendChar( char );
  110. void SendString( LPSTR );
  111. void SendFmt( LPSTR , ... );
  112. bool ProcessEnhancedKeys( unsigned char, char*, bool );
  113. bool GetRegistryValues( void );
  114. void SendColorInfo( WORD );
  115. inline void EchoCharBackToClient( UCHAR );
  116. void EchoVtntCharToClient( INPUT_RECORD * );
  117. void LoadStrings( void );
  118. bool InitializeNonVtntTerms( void );
  119. bool SetWindowInfo();
  120. protected:
  121. DWORD m_dwPollInterval;
  122. DWORD m_dwHowLongIdle;
  123. DWORD m_dwTerm;
  124. HANDLE m_hConBufIn;
  125. HANDLE m_hConBufOut;
  126. void Init( CSession * );
  127. bool InitSession( void );
  128. bool OnWaitTimeOut();
  129. bool EmulateAndWriteToCmdConsoleInput();
  130. DWORD WriteAKeyToCMD( WORD, WORD, CHAR, DWORD );
  131. void Shutdown();
  132. void DeleteCMStrings( void );
  133. bool InitTerm( void );
  134. void SendBytes( PUCHAR, DWORD );
  135. bool TransmitBytes( PUCHAR, DWORD );
  136. bool Transmit( );
  137. bool IsSessionTimedOut( void );
  138. bool SetCmdInfo( void );
  139. public:
  140. void WriteMessageToCmd( WCHAR [] );
  141. CScraper();
  142. virtual ~CScraper();
  143. };
  144. void DeleteCMStrings();
  145. void LoadStrings();
  146. #endif __SCRAPER__H__