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.

341 lines
11 KiB

  1. /****************************************************************************/
  2. // aco.h
  3. //
  4. // Core API header.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef _H_ACO
  9. #define _H_ACO
  10. extern "C" {
  11. #include <adcgdata.h>
  12. }
  13. #include "autil.h"
  14. class CUI;
  15. class CSL;
  16. class CUH;
  17. class CRCV;
  18. class CCD;
  19. class CSND;
  20. class CCC;
  21. class CIH;
  22. class COR;
  23. class CSP;
  24. class COP;
  25. class CCM;
  26. #include "objs.h"
  27. /****************************************************************************/
  28. /* Structure: CONNECTSTRUCT */
  29. /* */
  30. /* Description: Structure of the data passed from the UI on connection */
  31. /****************************************************************************/
  32. typedef struct tagCONNECTSTRUCT
  33. {
  34. TCHAR RNSAddress[UT_MAX_ADDRESS_LENGTH];
  35. #define CO_BITSPERPEL4 0
  36. #define CO_BITSPERPEL8 1
  37. #ifdef DC_HICOLOR
  38. #define CO_BITSPERPEL15 2
  39. #define CO_BITSPERPEL16 3
  40. #define CO_BITSPERPEL24 4
  41. #endif
  42. unsigned colorDepthID;
  43. UINT16 desktopWidth;
  44. UINT16 desktopHeight;
  45. #define CO_TRANSPORT_TCP SL_TRANSPORT_TCP
  46. UINT16 transportType;
  47. UINT16 sasSequence;
  48. UINT32 keyboardLayout;
  49. UINT32 keyboardType;
  50. UINT32 keyboardSubType;
  51. UINT32 keyboardFunctionKey;
  52. TCHAR imeFileName[TS_MAX_IMEFILENAME];
  53. /****************************************************************************/
  54. /* These flags are used to determine whether */
  55. /* - the Shadow Bitmap is to be enabled */
  56. /* - we are running on a dedicated terminal. */
  57. /* This will be used by UH to determine whether to enable SSB orders. */
  58. /****************************************************************************/
  59. #define CO_CONN_FLAG_SHADOW_BITMAP_ENABLED 1
  60. #define CO_CONN_FLAG_DEDICATED_TERMINAL 2
  61. UINT32 connectFlags;
  62. //-------------------------------------------------------------------------
  63. // These timer handles are used for managing connection timeout.
  64. //
  65. // hSingleConnectTimer: the single connection timer
  66. // hConnectionTimer: the overall connection timer
  67. // hLicensingTimer: the licensing phase timer
  68. //-------------------------------------------------------------------------
  69. HANDLE hSingleConnectTimer;
  70. HANDLE hConnectionTimer;
  71. HANDLE hLicensingTimer;
  72. BOOL bInitiateConnect;
  73. } CONNECTSTRUCT, FAR *PCONNECTSTRUCT;
  74. /****************************************************************************/
  75. /* Window message used to notify the UI that the desktop size has changed. */
  76. /* The new size is passed as */
  77. /* */
  78. /* width = LOWORD(lParam) */
  79. /* height = HIWORD(lParam) */
  80. /****************************************************************************/
  81. #define WM_DESKTOPSIZECHANGE (DUC_CO_MESSAGE_BASE + 1)
  82. /****************************************************************************/
  83. /* Configuration items/values */
  84. /* */
  85. /* CO_CFG_ACCELERATOR_PASSTHROUGH: */
  86. /* 0: Disabled */
  87. /* 1: Enabled */
  88. /* */
  89. /* CO_CFG_SHADOW_BITMAP: */
  90. /* 0: Disabled */
  91. /* 1: Enabled */
  92. /* */
  93. /* CO_CFG_ENCRYPTION: */
  94. /* 0: Disabled */
  95. /* 1: Enabled */
  96. /* */
  97. /* CO_CFG_SCREEN_MODE_HOTKEY */
  98. /* VKCode */
  99. /* */
  100. /* CO_CFG_DEBUG_SETTINGS: */
  101. /* A combination of zero or more of the following flags */
  102. /* CO_CFG_FLAG_HATCH_BITMAP_PDU_DATA: BitmapPDU data */
  103. /* CO_CFG_FLAG_HATCH_MEMBLT_ORDER_DATA: MemBlt order data */
  104. /* CO_CFG_FLAG_LABEL_MEMBLT_ORDERS: Label MemBlt orders */
  105. /* CO_CFG_FLAG_BITMAP_CACHE_MONITOR: Show Bitmap Cache Monitor */
  106. /****************************************************************************/
  107. #define CO_CFG_ACCELERATOR_PASSTHROUGH 0
  108. #define CO_CFG_SHADOW_BITMAP 1
  109. #define CO_CFG_ENCRYPTION 2
  110. #define CO_CFG_SCREEN_MODE_HOTKEY 3
  111. #ifdef DC_DEBUG
  112. #define CO_CFG_DEBUG_SETTINGS 100
  113. #define CO_CFG_FLAG_HATCH_BITMAP_PDU_DATA 1
  114. #define CO_CFG_FLAG_HATCH_MEMBLT_ORDER_DATA 2
  115. #define CO_CFG_FLAG_LABEL_MEMBLT_ORDERS 4
  116. #define CO_CFG_FLAG_BITMAP_CACHE_MONITOR 8
  117. #define CO_CFG_FLAG_HATCH_SSB_ORDER_DATA 16
  118. #define CO_CFG_FLAG_HATCH_INDEX_PDU_DATA 32
  119. #endif /* DC_DEBUG */
  120. #ifdef DC_DEBUG
  121. #define CO_CFG_MALLOC_FAILURE 200
  122. #define CO_CFG_MALLOC_HUGE_FAILURE 201
  123. #endif /* DC_DEBUG */
  124. #define CO_SHUTDOWN 0x70
  125. #define CO_DISCONNECT_AND_EXIT 0x71
  126. /****************************************************************************/
  127. /* Structure: CO_GLOBAL_DATA */
  128. /* */
  129. /* Description: Variables that need to be shared across the whole of the */
  130. /* Core */
  131. /****************************************************************************/
  132. typedef struct tagCO_GLOBAL_DATA
  133. {
  134. UT_THREAD_DATA sendThreadID;
  135. WNDPROC pUIContainerWndProc;
  136. WNDPROC pUIMainWndProc;
  137. BOOL inSizeMove;
  138. } CO_GLOBAL_DATA;
  139. extern "C" {
  140. VOID WINAPI CO_StaticInit(HINSTANCE hInstance);
  141. VOID WINAPI CO_StaticTerm();
  142. };
  143. #define MAX_DISSCONNECT_HRS 10
  144. class CCO
  145. {
  146. public:
  147. CCO(CObjs* objs);
  148. virtual ~CCO();
  149. /****************************************************************************/
  150. /* API functions */
  151. /****************************************************************************/
  152. void DCAPI CO_Init(HINSTANCE, HWND, HWND);
  153. void DCAPI CO_Term();
  154. void DCAPI CO_Connect(PCONNECTSTRUCT);
  155. void DCAPI CO_Disconnect();
  156. void DCAPI CO_Shutdown(unsigned);
  157. HRESULT DCAPI CO_OnSaveSessionInfoPDU(
  158. PTS_SAVE_SESSION_INFO_PDU_DATA, DCUINT);
  159. HRESULT DCAPI CO_OnSetKeyboardIndicatorsPDU(
  160. PTS_SET_KEYBOARD_INDICATORS_PDU, DCUINT);
  161. void DCAPI CO_SetConfigurationValue(unsigned, unsigned);
  162. void DCAPI CO_SetHotkey(PDCHOTKEY);
  163. HRESULT DCAPI CO_OnServerRedirectionPacket(
  164. RDP_SERVER_REDIRECTION_PACKET UNALIGNED *, DCUINT);
  165. #ifdef DC_DEBUG
  166. int DCAPI CO_GetRandomFailureItem(unsigned);
  167. void DCAPI CO_SetRandomFailureItem(unsigned, int);
  168. #endif
  169. //
  170. // callbacks
  171. //
  172. void DCCALLBACK CO_OnInitialized();
  173. void DCCALLBACK CO_OnTerminating();
  174. void DCCALLBACK CO_OnConnected(unsigned, PVOID, unsigned, UINT32);
  175. void DCCALLBACK CO_OnDisconnected(unsigned);
  176. HRESULT DCCALLBACK CO_OnPacketReceived(PBYTE, unsigned, unsigned, unsigned, unsigned);
  177. void DCCALLBACK CO_OnBufferAvailable();
  178. HRESULT DCAPI CO_OnFastPathOutputReceived(BYTE FAR *, unsigned);
  179. //
  180. // Static inline versions
  181. //
  182. static void DCCALLBACK CO_StaticOnInitialized(PVOID inst)
  183. {
  184. ((CCO*)inst)->CO_OnInitialized();
  185. }
  186. static void DCCALLBACK CO_StaticOnTerminating(PVOID inst)
  187. {
  188. ((CCO*)inst)->CO_OnTerminating();
  189. }
  190. static void DCCALLBACK CO_StaticOnConnected(
  191. PVOID inst,
  192. unsigned channelID,
  193. PVOID pUserData,
  194. unsigned userDataLength,
  195. UINT32 serverVersion)
  196. {
  197. ((CCO*)inst)->CO_OnConnected(channelID, pUserData, userDataLength, serverVersion);
  198. }
  199. static void DCCALLBACK CO_StaticOnDisconnected(PVOID inst, unsigned result)
  200. {
  201. ((CCO*)inst)->CO_OnDisconnected(result);
  202. }
  203. static HRESULT DCCALLBACK CO_StaticOnPacketReceived(
  204. PVOID inst,
  205. PBYTE pData,
  206. unsigned dataLen,
  207. unsigned flags,
  208. unsigned channelID,
  209. unsigned priority)
  210. {
  211. return ((CCO*)inst)->CO_OnPacketReceived(pData, dataLen, flags, channelID, priority);
  212. }
  213. static void DCCALLBACK CO_StaticOnBufferAvailable(PVOID inst)
  214. {
  215. ((CCO*)inst)->CO_OnBufferAvailable();
  216. }
  217. HRESULT DCINTERNAL CO_DropLinkImmediate(UINT reason, HRESULT hrDisconnect );
  218. public:
  219. //
  220. // Public data members
  221. //
  222. CO_GLOBAL_DATA _CO;
  223. private:
  224. LRESULT CALLBACK COContainerWindowSubclassProc( HWND hwnd,
  225. UINT message,
  226. WPARAM wParam,
  227. LPARAM lParam );
  228. LRESULT CALLBACK COMainWindowSubclassProc( HWND hwnd,
  229. UINT message,
  230. WPARAM wParam,
  231. LPARAM lParam );
  232. //
  233. // Static versions that delegate to appropriate instance
  234. //
  235. static LRESULT CALLBACK COStaticContainerWindowSubclassProc( HWND hwnd,
  236. UINT message,
  237. WPARAM wParam,
  238. LPARAM lParam );
  239. static LRESULT CALLBACK COStaticMainWindowSubclassProc( HWND hwnd,
  240. UINT message,
  241. WPARAM wParam,
  242. LPARAM lParam );
  243. void DCINTERNAL COSubclassUIWindows();
  244. private:
  245. CUT* _pUt;
  246. CUI* _pUi;
  247. CSL* _pSl;
  248. CUH* _pUh;
  249. CRCV* _pRcv;
  250. CCD* _pCd;
  251. CSND* _pSnd;
  252. CCC* _pCc;
  253. CIH* _pIh;
  254. COR* _pOr;
  255. CSP* _pSp;
  256. COP* _pOp;
  257. CCM* _pCm;
  258. CCLX* _pClx;
  259. private:
  260. CObjs* _pClientObjects;
  261. BOOL _fCOInitComplete;
  262. HRESULT m_disconnectHRs[ MAX_DISSCONNECT_HRS ];
  263. short m_disconnectHRIndex;
  264. public:
  265. inline void DCINTERNAL COSetDisconnectHR( HRESULT hr ) {
  266. m_disconnectHRs[m_disconnectHRIndex] = hr;
  267. m_disconnectHRIndex = (m_disconnectHRIndex + 1) % MAX_DISSCONNECT_HRS;
  268. }
  269. };
  270. #endif // _H_ACO