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.

460 lines
13 KiB

  1. /**INC+**********************************************************************/
  2. /* */
  3. /* ClxApi.h */
  4. /* */
  5. /* Client extension header file */
  6. /* */
  7. /* Copyright(c) Microsoft 1997-1999 */
  8. /* */
  9. /* Notes: */
  10. /* */
  11. /* CLINFO_VERSION */
  12. /* 1 Initial version */
  13. /* 2 hwndMain added to CLINFO struct */
  14. /* */
  15. /****************************************************************************/
  16. #ifndef _H_CLX_
  17. #define _H_CLX_
  18. extern "C" {
  19. #include <extypes.h>
  20. }
  21. #include "objs.h"
  22. #define CLINFO_VERSION 2
  23. #define CLX_DISCONNECT_LOCAL 1
  24. #define CLX_DISCONNECT_BY_USER 2
  25. #define CLX_DISCONNECT_BY_SERVER 3
  26. #define CLX_DISCONNECT_NL_ERROR 4
  27. #define CLX_DISCONNECT_SL_ERROR 5
  28. #define CLX_DISCONNECT_UNKNOWN 6
  29. typedef struct _tag_CLINFO
  30. {
  31. DWORD cbSize; // Size of CLINFO structure (bytes)
  32. DWORD dwVersion; // CLINFO_VERSION
  33. //CLX expects ANSI strings here
  34. LPSTR pszServer; // Test server name / address
  35. LPSTR pszCmdLine; // /clxcmdline= switch data
  36. HWND hwndMain; // Main window handle
  37. } CLINFO, *PCLINFO;
  38. #define VLADIMIS_NEW_CHANGE
  39. typedef enum
  40. {
  41. CLX_EVENT_CONNECT, // Connect event
  42. CLX_EVENT_DISCONNECT, // Disconnect event
  43. CLX_EVENT_LOGON, // Logon event
  44. CLX_EVENT_SHADOWBITMAP, // Shadow bitmap created
  45. CLX_EVENT_SHADOWBITMAPDC, // -- " --
  46. CLX_EVENT_PALETTE, // new color palette
  47. } CLXEVENT;
  48. #ifndef PVOID
  49. typedef void * PVOID;
  50. typedef unsigned long ULONG;
  51. typedef char *PCHAR, *PCH, *LPSTR;
  52. #endif
  53. #ifndef DWORD
  54. typedef unsigned long DWORD;
  55. typedef char *LPSTR;
  56. #endif
  57. #ifndef IN
  58. #define IN
  59. #endif
  60. #define CLX_INITIALIZE CE_WIDETEXT("ClxInitialize")
  61. #define CLX_CONNECT CE_WIDETEXT("ClxConnect")
  62. #define CLX_EVENT CE_WIDETEXT("ClxEvent")
  63. #define CLX_DISCONNECT CE_WIDETEXT("ClxDisconnect")
  64. #define CLX_TERMINATE CE_WIDETEXT("ClxTerminate")
  65. #define CLX_TEXTOUT CE_WIDETEXT("ClxTextOut")
  66. #define CLX_TEXTPOSOUT CE_WIDETEXT("ClxTextAndPosOut")
  67. #define CLX_OFFSCROUT CE_WIDETEXT("ClxOffscrOut")
  68. #define CLX_GLYPHOUT CE_WIDETEXT("ClxGlyphOut")
  69. #define CLX_BITMAP CE_WIDETEXT("ClxBitmap")
  70. #define CLX_DIALOG CE_WIDETEXT("ClxDialog")
  71. #define CLX_PKTDRAWN CE_WIDETEXT("ClxPktDrawn")
  72. #define CLX_REDIRECTNOTIFY CE_WIDETEXT("ClxRedirectNotify")
  73. #define CLX_CONNECT_EX CE_WIDETEXT("ClxConnectEx")
  74. #define CLXSERVER _T("CLXSERVER")
  75. #define CLXDLL _T("CLXDLL")
  76. #define CLXCMDLINE _T("CLXCMDLINE")
  77. #ifdef ASSERT
  78. #undef ASSERT
  79. #endif // ASSERT
  80. #ifdef ASSERTMSG
  81. #undef ASSERTMSG
  82. #endif // ASSERTMSG
  83. #if DBG && WIN32
  84. /////////////////////////////////////////////////////////////
  85. extern "C" {
  86. NTSYSAPI
  87. VOID
  88. NTAPI
  89. RtlAssert(
  90. PVOID FailedAssertion,
  91. PVOID FileName,
  92. ULONG LineNumber,
  93. PCHAR Message
  94. );
  95. ULONG
  96. _cdecl
  97. DbgPrint(
  98. PCH Format,
  99. ...
  100. );
  101. } //extern c
  102. #ifdef OS_WINCE
  103. #define KdPrint(_x_) \
  104. NKDbgPrintfW _x_
  105. #else // !OS_WINCE
  106. #define KdPrint(_x_) \
  107. DbgPrint _x_
  108. #endif // OS_WINCE
  109. #define ASSERT(exp) \
  110. if (!(exp)) \
  111. RtlAssert(#exp, __FILE__, __LINE__, NULL)
  112. #define ASSERTMSG(msg, exp) \
  113. if (!(exp)) \
  114. RtlAssert(#exp, __FILE__, __LINE__, msg)
  115. #else
  116. #define KdPrint(_x_)
  117. #define ASSERT(exp)
  118. #define ASSERTMSG(msg, exp)
  119. #endif // DBG
  120. typedef BOOL (WINAPI * PCLX_INITIALIZE)(PCLINFO, PVOID);
  121. typedef BOOL (WINAPI * PCLX_CONNECT)(PVOID, LPTSTR);
  122. typedef VOID (WINAPI * PCLX_EVENT)(PVOID, CLXEVENT, LPARAM);
  123. typedef VOID (WINAPI * PCLX_DISCONNECT)(PVOID);
  124. typedef VOID (WINAPI * PCLX_TERMINATE)(PVOID);
  125. typedef VOID (WINAPI * PCLX_TEXTOUT)(PVOID, PVOID, int);
  126. typedef VOID (WINAPI * PCLX_TEXTPOSOUT)(PVOID, PVOID, int, PRECT, HANDLE);
  127. typedef VOID (WINAPI * PCLX_OFFSCROUT)(PVOID, HANDLE, int, int);
  128. typedef VOID (WINAPI * PCLX_GLYPHOUT)(PVOID, UINT, UINT, PVOID);
  129. typedef VOID (WINAPI * PCLX_BITMAP)(PVOID, UINT, UINT, PVOID, UINT, PVOID);
  130. typedef VOID (WINAPI * PCLX_DIALOG)(PVOID, HWND);
  131. typedef VOID (WINAPI * PCLX_PKTDRAWN)(PVOID);
  132. typedef VOID (WINAPI * PCLX_REDIRECTNOTIFY)(
  133. RDP_SERVER_REDIRECTION_PACKET UNALIGNED *pRedirPacket,
  134. UINT dataLen
  135. );
  136. typedef BOOL (WINAPI * PCLX_CONNECT_EX)(
  137. LPTSTR szConnectAddress,
  138. BOOL fAutoReconnecting,
  139. BOOL fIsConnectedToCluster,
  140. BSTR RedirectedLBInfo
  141. );
  142. typedef struct _tag_CLEXTENSION
  143. {
  144. LPTSTR pszClxServer;
  145. LPTSTR pszClxDll;
  146. LPTSTR pszClxCmdLine;
  147. HINSTANCE hInstance;
  148. PCLX_INITIALIZE pClxInitialize;
  149. PCLX_CONNECT pClxConnect;
  150. PCLX_EVENT pClxEvent;
  151. PCLX_DISCONNECT pClxDisconnect;
  152. PCLX_TERMINATE pClxTerminate;
  153. PCLX_TEXTOUT pClxTextOut;
  154. PCLX_TEXTPOSOUT pClxTextPosOut;
  155. PCLX_OFFSCROUT pClxOffscrOut;
  156. PCLX_GLYPHOUT pClxGlyphOut;
  157. PCLX_BITMAP pClxBitmap;
  158. PCLX_DIALOG pClxDialog;
  159. PCLX_PKTDRAWN pClxPktDrawn;
  160. PCLX_REDIRECTNOTIFY pClxRedirectNotify;
  161. PCLX_CONNECT_EX pClxConnectEx;
  162. PVOID pvClxContext;
  163. } CLEXTENSION, *PCLEXTENSION;
  164. class CCLX
  165. {
  166. public:
  167. CCLX(CObjs* objs);
  168. ~CCLX();
  169. public:
  170. //
  171. // API
  172. //
  173. PVOID CLX_Alloc(IN DWORD dwSize);
  174. VOID CLX_Free(IN PVOID lpMemory);
  175. VOID CLX_OnConnected(VOID);
  176. VOID CLX_OnDisconnected(UINT uResult);
  177. //
  178. // Internal functions
  179. //
  180. LPTSTR CLX_SkipWhite(LPTSTR lpszCmdParam);
  181. LPTSTR CLX_SkipNonWhite(LPTSTR lpszCmdParam);
  182. PCLEXTENSION CLX_GetClx(VOID);
  183. BOOL CLX_LoadProcs(VOID);
  184. UINT CLX_GetSwitch_CLXSERVER(LPTSTR lpszCmdParam);
  185. UINT CLX_GetSwitch_CLXCMDLINE(LPTSTR lpszCmdParam);
  186. BOOL CLX_Init(HWND hwndMain, LPTSTR szCmdLine);
  187. VOID CLX_Term(VOID);
  188. BOOL CLX_ClxConnect(VOID);
  189. VOID CLX_ClxEvent(CLXEVENT ClxEvent, LPARAM lParam);
  190. VOID CLX_ClxDisconnect(VOID);
  191. VOID CLX_ClxTerminate(VOID);
  192. VOID CLX_ClxDialog(HWND hwnd);
  193. BOOL CLX_Loaded(void);
  194. PCLEXTENSION _pClx;
  195. //*************************************************************
  196. //
  197. // CLX_ClxOffscrOut()
  198. //
  199. // Purpose: Notifies clx dll that an offscreen bitmap
  200. // was drawn and specifies the position
  201. //
  202. // Parameters: IN [hBitmap] - handle of the bitmap that was drawn
  203. // IN [left] - left drawing position
  204. // IN [top] - top drawing position
  205. //
  206. // Return: void
  207. //
  208. // History: 04-15-01 CostinH Created
  209. //
  210. //*************************************************************
  211. __inline VOID
  212. CLX_ClxOffscrOut(HANDLE hBitmap,
  213. int left,
  214. int top)
  215. {
  216. if (_pClx && _pClx->pClxOffscrOut) {
  217. _pClx->pClxOffscrOut(_pClx->pvClxContext, hBitmap, left, top);
  218. }
  219. }
  220. //*************************************************************
  221. //
  222. // CLX_ClxTextOut()
  223. //
  224. // Purpose: Let the clx dll have a look-see at all
  225. // test out orders
  226. //
  227. // Parameters: IN [pText] - ptr to text
  228. // IN [textLength] - text length
  229. // IN [hBitmap] - handle of the offscreen bitmap
  230. // IN [left] - text position
  231. // IN [right] - on the client screen
  232. // IN [top] -
  233. // IN [bottom] -
  234. //
  235. //
  236. // Return: void
  237. //
  238. // History: 09-30-97 BrianTa Created
  239. //
  240. //*************************************************************
  241. __inline VOID
  242. CLX_ClxTextOut(PVOID pText,
  243. int textLength,
  244. HANDLE hBitmap,
  245. LONG left,
  246. LONG right,
  247. LONG top,
  248. LONG bottom)
  249. {
  250. if (_pClx) {
  251. if (_pClx->pClxTextPosOut) {
  252. RECT r;
  253. r.left = left;
  254. r.right = right;
  255. r.top = top;
  256. r.bottom = bottom;
  257. _pClx->pClxTextPosOut(_pClx->pvClxContext, pText, textLength, &r, hBitmap);
  258. }
  259. else if (_pClx->pClxTextOut) {
  260. _pClx->pClxTextOut(_pClx->pvClxContext, pText, textLength);
  261. }
  262. }
  263. }
  264. //*************************************************************
  265. //
  266. // CLX_ClxGlyphOut()
  267. //
  268. // Purpose: Let the clx dll have a look-see at all
  269. // glyph out orders
  270. //
  271. // Parameters: IN [cxBits, cyBits] - Size of mono bitmap
  272. // IN [pBitmap] - ptr to the bitmap data
  273. //
  274. // Return: void
  275. //
  276. // History: 5-01-98 VLADIMIS Created
  277. //
  278. //*************************************************************
  279. __inline VOID
  280. CLX_ClxGlyphOut(UINT cxBits, UINT cyBits, PVOID pBitmap)
  281. {
  282. if (_pClx && _pClx->pClxGlyphOut)
  283. _pClx->pClxGlyphOut(_pClx->pvClxContext, cxBits, cyBits, pBitmap);
  284. }
  285. //*************************************************************
  286. //
  287. // CLX_ClxBitmap()
  288. //
  289. // Purpose: Let the clx dll have a look-see at all
  290. // MemBlt orders
  291. //
  292. // Parameters: IN [cxSize, cySize] - Size of the bitmap
  293. // IN [pBitmap] - ptr to the bitmap data
  294. // IN [bmiSize] - size of pBmi
  295. // IN [pBmi] - ptr to the bitmap info
  296. //
  297. // Return: void
  298. //
  299. // History: 5-01-98 VLADIMIS Created
  300. //
  301. //*************************************************************
  302. __inline VOID
  303. CLX_ClxBitmap(UINT cxSize, UINT cySize, PVOID pBitmap, UINT bmiSize, PVOID pBmi)
  304. {
  305. if (_pClx && _pClx->pClxBitmap)
  306. _pClx->pClxBitmap(_pClx->pvClxContext,
  307. cxSize, cySize,
  308. pBitmap,
  309. bmiSize,
  310. pBmi);
  311. }
  312. //*************************************************************
  313. //
  314. // CLX_ClxPktDrawn()
  315. //
  316. // Purpose: Notifies the clx dll that a new received packet
  317. // was drawn
  318. //
  319. // Return: void
  320. //
  321. // History: 5-14-01 COSTINH Created
  322. //
  323. //*************************************************************
  324. __inline VOID
  325. CLX_ClxPktDrawn()
  326. {
  327. if (_pClx && _pClx->pClxPktDrawn)
  328. _pClx->pClxPktDrawn(_pClx->pvClxContext);
  329. }
  330. //
  331. // Redirect notify - notify the CLX of the receipt of an SD
  332. // redirection packet
  333. //
  334. __inline VOID
  335. CLX_RedirectNotify(
  336. RDP_SERVER_REDIRECTION_PACKET UNALIGNED *pRedirPacket,
  337. UINT dataLen
  338. )
  339. {
  340. if (_pClx && _pClx->pClxRedirectNotify) {
  341. _pClx->pClxRedirectNotify(pRedirPacket, dataLen);
  342. }
  343. }
  344. //
  345. // ConnectEx - notify clx at connection time
  346. //
  347. // szConnectAddress - exact address we're connecting to,
  348. // in redirect case this is redirection IP
  349. // fAutoReconnecting - TRUE if this is an AutoReconnection
  350. // fIsConnectedToCluster - TRUE if the connection is in response
  351. // to a redirection request
  352. // RedirectedLBInfo - Redirected LB info (cookie)
  353. //
  354. __inline VOID
  355. CLX_ConnectEx(
  356. LPTSTR szConnectAddress,
  357. BOOL fAutoReconnecting,
  358. BOOL fIsConnectedToCluster,
  359. BSTR RedirectedLBInfo
  360. )
  361. {
  362. if (_pClx && _pClx->pClxConnectEx) {
  363. _pClx->pClxConnectEx(
  364. szConnectAddress,
  365. fAutoReconnecting,
  366. fIsConnectedToCluster,
  367. RedirectedLBInfo
  368. );
  369. }
  370. }
  371. private:
  372. #ifdef UNICODE
  373. CHAR _szAnsiClxServer[100];
  374. CHAR _szAnsiClxCmdLine[MAX_PATH];
  375. #endif
  376. CObjs* _pClientObjects;
  377. };
  378. #endif // _H_CLX_