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.

277 lines
7.9 KiB

  1. /*++
  2. * File name:
  3. * clxtshar.h
  4. * Contents:
  5. * Header file for clxtshar.dll
  6. *
  7. * Copyright (C) 1998-1999 Microsoft Corp.
  8. --*/
  9. #ifndef _CLXTSHAR_H
  10. #define _CLXTSHAR_H
  11. #ifdef OS_WIN16
  12. #include <ctype.h>
  13. #include <tchar.h>
  14. #define UINT_PTR UINT
  15. #define LONG_PTR LONG
  16. #define TEXT(_s_) _s_
  17. #define LPCTSTR LPCSTR
  18. #define TCHAR char
  19. #define CHAR char
  20. #define INT int
  21. #define LOADDS __loadds
  22. #define HUGEMOD __huge
  23. #define HUGEMEMCPY hmemcpy
  24. #define MAKEWORD(_hi, _lo) ((((WORD)((_hi) & 0xFF)) << 8)|((_lo) & 0xFF))
  25. #define BST_UNCHECKED 0x0000
  26. #define BST_CHECKED 0x0001
  27. #define BST_INDETERMINATE 0x0002
  28. #define BST_PUSHED 0x0004
  29. #define BST_FOCUS 0x0008
  30. #endif // OS_WIN16
  31. #ifdef OS_WIN32
  32. //#define EXPORT
  33. #define LOADDS
  34. #define HUGEMOD
  35. #define HUGEMEMCPY memcpy
  36. #endif // OS_WIN32
  37. #ifdef UNICODE
  38. #define _CLX_strstr(s1, s2) wcsstr(s1, s2)
  39. #define _CLX_strchr(s, c) wcschr(s, c)
  40. #define _CLX_strlen(s) wcslen(s)
  41. #define _CLX_strcpy(s1, s2) wcscpy(s1, s2)
  42. #define _CLX_strncpy(s1, s2, n) wcsncpy(s1, s2, n)
  43. #define _CLX_atol(s) _wtol(s)
  44. #define _CLX_vsnprintf(s, n, f, a) _vsnwprintf(s, n, f, a)
  45. #define _CLX_strcmp(s1, s2) wcscmp(s1, s2)
  46. BOOL _CLX_SetDlgItemTextA(HWND hDlg, INT nDlgItem, LPCSTR lpString);
  47. #else // !UNICODE
  48. #define _CLX_strstr(s1, s2) strstr(s1, s2)
  49. #define _CLX_strchr(s, c) strchr(s, c)
  50. #define _CLX_strlen(s) strlen(s)
  51. #define _CLX_strcpy(s1, s2) strcpy(s1, s2)
  52. #define _CLX_strncpy(s1, s2, n) strncpy(s1, s2, n)
  53. #define _CLX_atol(s) atol(s)
  54. #define _CLX_vsnprintf(s, n, f, a) _vsnprintf(s, n, f, a)
  55. #define _CLX_strcmp(s1, s2) strcmp(s1, s2)
  56. #endif
  57. #ifndef OS_WINCE
  58. #define _CLXALLOC(_size_) GlobalAllocPtr(GMEM_FIXED, _size_)
  59. #define _CLXFREE(_ptr_) GlobalFreePtr(_ptr_)
  60. #define _CLXREALLOC(_ptr_, _size_) GlobalReAllocPtr(_ptr_, _size_, 0)
  61. typedef HINSTANCE _CLXWINDOWOWNER;
  62. // Windows are identified by
  63. // hInstance
  64. #else // OS_WINCE
  65. #define _CLXALLOC(_size_) LocalAlloc(LMEM_FIXED, _size_)
  66. #define _CLXFREE(_ptr_) LocalFree(_ptr_)
  67. #define _CLXREALLOC(_ptr_, _size_) LocalReAlloc(_ptr_, _size_, 0)
  68. typedef DWORD _CLXWINDOWOWNER;
  69. // Identified by process Id
  70. #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
  71. #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
  72. BOOL _StartAsyncThread(VOID);
  73. VOID _CloseAsyncThread(VOID);
  74. INT WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uiMsg, LONG lEvent);
  75. INT AsyncRecv(SOCKET s, PVOID pBuffer, INT nBytesToRead, INT *pnErrorCode);
  76. BOOL
  77. CheckDlgButton(
  78. HWND hDlg,
  79. INT nIDButton,
  80. UINT uCheck);
  81. #define isalpha(c) ((c >= 'A' && c <= 'Z') ||\
  82. (c >= 'a' && c <= 'z'))
  83. #endif // OS_WINCE
  84. #include <adcgbase.h>
  85. #include "oleauto.h."
  86. #include <clx.h>
  87. #include <wuiids.h>
  88. #include "feedback.h"
  89. #include "clntdata.h"
  90. #include "clxexport.h"
  91. // Context structure
  92. typedef struct _CLXINFO {
  93. HWND hwndMain; // Clients main window
  94. HDC hdcShadowBitmap; // Client's shadow bitmap
  95. HBITMAP hShadowBitmap; // -- " --
  96. HPALETTE hShadowPalette; // -- " --
  97. // members used in local mode
  98. HWND hwndSMC; // SmClient window handle
  99. #ifdef OS_WIN32
  100. #ifndef OS_WINCE
  101. HANDLE hMapF; // Map file for passing data to smclient
  102. UINT nMapSize; // Currently allocated map file
  103. HANDLE hBMPMapF;
  104. UINT nBMPMapSize;
  105. DWORD_PTR dwProcessId; // Our process ID
  106. #endif // !OS_WINCE
  107. #endif // OS_WIN32
  108. HWND hwndDialog; // RDP client's dialog
  109. #ifndef OS_WINCE
  110. #ifdef OS_WIN32
  111. BOOL bSendMsgThreadExit; // Used by _ClxSendMessage
  112. HANDLE semSendReady;
  113. HANDLE semSendDone;
  114. HANDLE hSendMsgThread;
  115. MSG msg;
  116. #endif // OS_WIN32
  117. #endif // !OS_WINCE
  118. } CLXINFO, *PCLXINFO;
  119. /*
  120. * Clipboard help functions (clputil.c)
  121. */
  122. VOID
  123. Clp_GetClipboardData(
  124. UINT format,
  125. HGLOBAL hClipData,
  126. UINT32 *pnClipDataSize,
  127. HGLOBAL *phNewData);
  128. BOOL
  129. Clp_SetClipboardData(
  130. UINT formatID,
  131. HGLOBAL hClipData,
  132. UINT32 nClipDataSize,
  133. BOOL *pbFreeHandle);
  134. /*
  135. * Internal functions definitions
  136. */
  137. VOID _StripGlyph(LPBYTE pData, UINT *pxSize, UINT ySize);
  138. HWND _ParseCmdLine(LPCTSTR szCmdLine, PCLXINFO pClx);
  139. VOID
  140. CLXAPI
  141. ClxEvent(PCLXINFO pClx, CLXEVENT Event, WPARAM wResult);
  142. HWND _FindTopWindow(LPCTSTR, LPCTSTR, _CLXWINDOWOWNER);
  143. #ifndef OS_WINCE
  144. HWND _FindSMCWindow(PCLXINFO, LPARAM);
  145. HWND _CheckWindow(PCLXINFO);
  146. #endif // !OS_WINCE
  147. #ifdef OS_WIN32
  148. #ifndef OS_WINCE
  149. #define CLX_ONE_PAGE 4096 // Map-file alignment
  150. BOOL _OpenMapFile(
  151. UINT nSize,
  152. HANDLE *phMapF,
  153. UINT *pnMapSize
  154. );
  155. BOOL _ReOpenMapFile(
  156. UINT newSize,
  157. HANDLE *phMapF,
  158. UINT *pnMapSize
  159. );
  160. BOOL _SaveInMapFile(HANDLE hMapF,
  161. LPVOID str,
  162. INT strsize,
  163. DWORD_PTR dwProcessId);
  164. BOOL _CheckRegistrySettings(VOID);
  165. #endif // !OS_WINCE
  166. #endif // OS_WIN32
  167. #ifdef OS_WIN16
  168. BOOL _CheckIniSettings(VOID);
  169. __inline INT GetLastError(VOID) { return -1; }
  170. #endif // OS_WIN16
  171. VOID _GetIniSettings(VOID);
  172. VOID __cdecl LocalPrintMessage(INT errlevel, LPCTSTR format, ...);
  173. VOID _ClxAssert(BOOL bCond, LPCTSTR filename, INT line);
  174. HWND _FindWindow(HWND hwndParent, LPCTSTR srchclass);
  175. VOID _SetClipboard(UINT uiFormat, PVOID pClipboard, UINT32 nSize);
  176. VOID _OnBackground(PCLXINFO);
  177. BOOL _GarbageCollecting(PCLXINFO, BOOL bNotifiyForErrorBox);
  178. BOOL
  179. WS_Init(VOID);
  180. VOID
  181. _AttemptToCloseTheClient(
  182. PCLXINFO pClx
  183. );
  184. VOID
  185. _GetDIBFromBitmap(
  186. HDC hdcMemSrc,
  187. HBITMAP hBitmap,
  188. HANDLE *phDIB,
  189. INT left,
  190. INT top,
  191. INT right,
  192. INT bottom);
  193. BOOL
  194. _ClxAcquireSendMessageThread( PCLXINFO pClx );
  195. DWORD
  196. _ClxSendMsgThread(VOID *param);
  197. VOID
  198. _ClxReleaseSendMessageThread( PCLXINFO pClx );
  199. LRESULT
  200. _ClxSendMessage(
  201. PCLXINFO pClx,
  202. HWND hWnd,
  203. UINT Msg,
  204. WPARAM wParam,
  205. LPARAM lParam
  206. );
  207. BOOL
  208. _ClxInitSendMessageThread( PCLXINFO pClx );
  209. VOID
  210. _ClxDestroySendMsgThread(PCLXINFO pClx);
  211. // This structure is used by _FindTopWindow
  212. typedef struct _SEARCHWND {
  213. LPCTSTR szClassName; // The class name of searched window,
  214. // NULL - ignore
  215. LPCTSTR szCaption; // Window caption, NULL - ignore
  216. _CLXWINDOWOWNER hInstance;
  217. // instance of the owner, NULL - ignore
  218. HWND hWnd; // Found window handle
  219. } SEARCHWND, *PSEARCHWND;
  220. enum {ERROR_MESSAGE = 0, WARNING_MESSAGE, INFO_MESSAGE, ALIVE_MESSAGE};
  221. #define _CLXWINDOW_CLASS "CLXTSHARClass"
  222. PCLXINFO g_pClx = NULL;
  223. HINSTANCE g_hInstance = NULL; // Dll instance
  224. _CLXWINDOWOWNER g_hRDPInst; // instance of RDP client
  225. INT g_VerboseLevel = 1; // default verbose level: only errors
  226. INT g_GlyphEnable = 0;
  227. // UI texts, captions and so
  228. TCHAR g_strClientCaption[_MAX_PATH];
  229. TCHAR g_strDisconnectDialogBox[_MAX_PATH];
  230. TCHAR g_strYesNoShutdown[_MAX_PATH];
  231. TCHAR g_strMainWindowClass[_MAX_PATH];
  232. // BitMask is used by _StripGlyph
  233. const BYTE BitMask[] = {0x0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF};
  234. #define TRACE(_x_) LocalPrintMessage _x_
  235. #ifndef OS_WINCE
  236. #undef ASSERT
  237. #define ASSERT(_x_) if (!(_x_)) _ClxAssert( FALSE, __FILE__, __LINE__)
  238. #endif
  239. #endif // !_CLXTSHAR_H