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.

510 lines
17 KiB

  1. /*++
  2. * File name:
  3. * tclient.h
  4. * Contents:
  5. * Common definitions for tclient.dll
  6. *
  7. * Copyright (C) 1998-1999 Microsoft Corp.
  8. --*/
  9. #ifndef _TCLIENT_H
  10. #define _TCLIENT_H
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #ifndef OS_WIN32
  15. #define OS_WIN32
  16. #endif
  17. #include "feedback.h"
  18. #include "clntdata.h"
  19. extern OSVERSIONINFOEXW g_OsInfo;
  20. //
  21. // OSVERSION macros...
  22. //
  23. #define ISNT() (g_OsInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
  24. #define ISWIN9X() (g_OsInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  25. #define ISWIN95_GOLDEN() (ISWIN95() && LOWORD(g_OsInfo.dwBuildNumber) <= 1000)
  26. #define ISWIN95_OSR2() (ISWIN95() && LOWORD(g_OsInfo.dwBuildNumber) > 1000)
  27. #define ISMEMPHIS() (ISWIN9X() && g_OsInfo.dwMajorVersion==4 && g_OsInfo.dwMinorVersion==10)
  28. #define ISATLEASTWIN98() (ISWIN9X() && g_OsInfo.dwMajorVersion==4 && g_OsInfo.dwMinorVersion>=10)
  29. #define ISWIN95() (ISWIN9X() && !ISATLEASTWIN98())
  30. #define ISMILLENNIUM() (ISWIN9X() && g_OsInfo.dwMajorVersion==4 && g_OsInfo.dwMinorVersion==90)
  31. #define BUILDNUMBER() (g_OsInfo.dwBuildNumber)
  32. //
  33. // The smartcard subsystem requires Windows NT 4.0 SP3 or higher on the NT
  34. // side, and Windows 95 OSR2 or higher on the 9x side.
  35. //
  36. #define ISSMARTCARDAWARE() (ISNT() && (g_OsInfo.dwMajorVersion >= 5 || \
  37. g_OsInfo.dwMajorVersion == 4 && \
  38. g_OsInfo.wServicePackMajor >= 3) || \
  39. ISATLEASTWIN98() || \
  40. ISWIN95_OSR2())
  41. // Error messages
  42. #define ERR_START_MENU_NOT_APPEARED "Start menu not appeared"
  43. #define ERR_COULDNT_OPEN_PROGRAM "Couldn't open a program"
  44. #define ERR_INVALID_SCANCODE_IN_XLAT "Invalid scancode in Xlat table"
  45. #define ERR_WAIT_FAIL_TIMEOUT "Wait failed: TIMEOUT"
  46. #define ERR_INVALID_PARAM "Invalid parameter"
  47. #define ERR_NULL_CONNECTINFO "ConnectInfo structure is NULL"
  48. #define ERR_CLIENT_IS_DEAD "Client is dead, sorry"
  49. #define ERR_ALLOCATING_MEMORY "Couldn't allocate memory"
  50. #define ERR_CREATING_PROCESS "Couldn't start process"
  51. #define ERR_CREATING_THREAD "Can't create thread"
  52. #define ERR_INVALID_COMMAND "Check: Invalid command"
  53. #define ERR_ALREADY_DISCONNECTED "No Info. Disconnect command" \
  54. " was executed"
  55. #define ERR_CONNECTING "Can't connect"
  56. #define ERR_CANTLOGON "Can't logon"
  57. #define ERR_NORMAL_EXIT "Client exit normaly"
  58. #define ERR_UNKNOWN_CLIPBOARD_OP "Unknown clipboard operation"
  59. #define ERR_COPY_CLIPBOARD "Error copying to the clipboard"
  60. #define ERR_PASTE_CLIPBOARD "Error pasting from the clipboard"
  61. #define ERR_PASTE_CLIPBOARD_EMPTY "The clipboard is empty"
  62. #define ERR_PASTE_CLIPBOARD_DIFFERENT_SIZE "Check clipboard: DIFFERENT SIZE"
  63. #define ERR_PASTE_CLIPBOARD_NOT_EQUAL "Check clipboard: NOT EQUAL"
  64. #define ERR_SAVE_CLIPBOARD "Save clipboard FAILED"
  65. #define ERR_CLIPBOARD_LOCKED "Clipboard is locked for writing " \
  66. "by another thread"
  67. #define ERR_CLIENTTERMINATE_FAIL "Client termination FAILED"
  68. #define ERR_NOTSUPPORTED "Call is not supported in this mode"
  69. #define ERR_CLIENT_DISCONNECTED "Client is disconnected"
  70. #define ERR_NODATA "The call failed, data is missing"
  71. #define ERR_LANGUAGE_NOT_FOUND "The language of the remote machine could not be found"
  72. #define ERR_UNKNOWNEXCEPTION "Unknown exception generated"
  73. #define ERR_CANTLOADLIB "Can't load dll"
  74. #define ERR_CANTGETPROCADDRESS "Can't get enrty address"
  75. #define ERR_CONSOLE_GENERIC "Generic error in console dll"
  76. // scancode modifier(s)
  77. #define SHIFT_DOWN 0x10000
  78. #define SHIFT_DOWN9X 0x20000
  79. // Look for WM_KEYUP or WM_KEYDOWN
  80. #define WM_KEY_LPARAM(repeat, scan, exten, context, prev, trans) \
  81. (repeat + ((scan & 0xff) << 16) + ((exten & 1) << 24) +\
  82. ((context & 1) << 29) + ((prev & 1) << 30) + ((trans & 1) << 31))
  83. extern VOID _TClientAssert(BOOL bCond,
  84. LPCSTR filename,
  85. INT line,
  86. LPCSTR expression,
  87. BOOL bBreak);
  88. //
  89. // Define assertion macros. Note that these are defined on both free and
  90. // checked builds. Checked-only versions might be preferable, if nothing is
  91. // broken by such a change.
  92. //
  93. #ifndef ASSERT
  94. #define ASSERT( exp ) \
  95. ((!(exp)) ? \
  96. (_TClientAssert(FALSE, __FILE__, __LINE__, #exp, TRUE),FALSE) : \
  97. TRUE)
  98. #endif // !ASSERT
  99. #ifndef RTL_SOFT_ASSERT
  100. #define RTL_SOFT_ASSERT( _exp ) \
  101. ((!(_exp)) ? \
  102. (_TClientAssert(FALSE, __FILE__, __LINE__, #_exp, FALSE),FALSE) : \
  103. TRUE)
  104. #endif // !RTL_SOFT_ASSERT
  105. //
  106. // Define verification macros. These are checked-only macros.
  107. //
  108. #ifndef RTL_VERIFY
  109. #if DBG
  110. #define RTL_VERIFY ASSERT
  111. #else
  112. #define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE)
  113. #endif // DBG
  114. #endif // !RTL_VERIFY
  115. #ifndef RTL_SOFT_VERIFY
  116. #if DBG
  117. #define RTL_SOFT_VERIFY RTL_SOFT_ASSERT
  118. #else
  119. #define RTL_SOFT_VERIFY RTL_VERIFY
  120. #endif // DBG
  121. #endif // !RTL_SOFT_VERIFY
  122. //
  123. // Define tracing macros.
  124. //
  125. #ifndef TRACE
  126. #define TRACE(_x_) if (g_pfnPrintMessage) {\
  127. g_pfnPrintMessage(ALIVE_MESSAGE, "Worker:%d ", GetCurrentThreadId());\
  128. g_pfnPrintMessage _x_; }
  129. #endif // !TRACE
  130. //
  131. // Define NT list manipulation routines (included manually for 9x
  132. // compatibility).
  133. //
  134. //
  135. // VOID
  136. // InitializeListHead32(
  137. // PLIST_ENTRY32 ListHead
  138. // );
  139. //
  140. #define InitializeListHead32(ListHead) (\
  141. (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
  142. #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
  143. VOID
  144. FORCEINLINE
  145. InitializeListHead(
  146. IN PLIST_ENTRY ListHead
  147. )
  148. {
  149. ListHead->Flink = ListHead->Blink = ListHead;
  150. }
  151. //
  152. // BOOLEAN
  153. // IsListEmpty(
  154. // PLIST_ENTRY ListHead
  155. // );
  156. //
  157. #define IsListEmpty(ListHead) \
  158. ((ListHead)->Flink == (ListHead))
  159. BOOLEAN
  160. FORCEINLINE
  161. RemoveEntryList(
  162. IN PLIST_ENTRY Entry
  163. )
  164. {
  165. PLIST_ENTRY Blink;
  166. PLIST_ENTRY Flink;
  167. Flink = Entry->Flink;
  168. Blink = Entry->Blink;
  169. Blink->Flink = Flink;
  170. Flink->Blink = Blink;
  171. return (BOOLEAN)(Flink == Blink);
  172. }
  173. PLIST_ENTRY
  174. FORCEINLINE
  175. RemoveHeadList(
  176. IN PLIST_ENTRY ListHead
  177. )
  178. {
  179. PLIST_ENTRY Flink;
  180. PLIST_ENTRY Entry;
  181. Entry = ListHead->Flink;
  182. Flink = Entry->Flink;
  183. ListHead->Flink = Flink;
  184. Flink->Blink = ListHead;
  185. return Entry;
  186. }
  187. PLIST_ENTRY
  188. FORCEINLINE
  189. RemoveTailList(
  190. IN PLIST_ENTRY ListHead
  191. )
  192. {
  193. PLIST_ENTRY Blink;
  194. PLIST_ENTRY Entry;
  195. Entry = ListHead->Blink;
  196. Blink = Entry->Blink;
  197. ListHead->Blink = Blink;
  198. Blink->Flink = ListHead;
  199. return Entry;
  200. }
  201. VOID
  202. FORCEINLINE
  203. InsertTailList(
  204. IN PLIST_ENTRY ListHead,
  205. IN PLIST_ENTRY Entry
  206. )
  207. {
  208. PLIST_ENTRY Blink;
  209. Blink = ListHead->Blink;
  210. Entry->Flink = ListHead;
  211. Entry->Blink = Blink;
  212. Blink->Flink = Entry;
  213. ListHead->Blink = Entry;
  214. }
  215. VOID
  216. FORCEINLINE
  217. InsertHeadList(
  218. IN PLIST_ENTRY ListHead,
  219. IN PLIST_ENTRY Entry
  220. )
  221. {
  222. PLIST_ENTRY Flink;
  223. Flink = ListHead->Flink;
  224. Entry->Flink = Flink;
  225. Entry->Blink = ListHead;
  226. Flink->Blink = Entry;
  227. ListHead->Flink = Entry;
  228. }
  229. //
  230. //
  231. // PSINGLE_LIST_ENTRY
  232. // PopEntryList(
  233. // PSINGLE_LIST_ENTRY ListHead
  234. // );
  235. //
  236. #define PopEntryList(ListHead) \
  237. (ListHead)->Next;\
  238. {\
  239. PSINGLE_LIST_ENTRY FirstEntry;\
  240. FirstEntry = (ListHead)->Next;\
  241. if (FirstEntry != NULL) { \
  242. (ListHead)->Next = FirstEntry->Next;\
  243. } \
  244. }
  245. //
  246. // VOID
  247. // PushEntryList(
  248. // PSINGLE_LIST_ENTRY ListHead,
  249. // PSINGLE_LIST_ENTRY Entry
  250. // );
  251. //
  252. #define PushEntryList(ListHead,Entry) \
  253. (Entry)->Next = (ListHead)->Next; \
  254. (ListHead)->Next = (Entry)
  255. #endif // !MIDL_PASS
  256. //
  257. // End of list manipulation routines.
  258. //
  259. #define REG_FORMAT L"smclient_%X_%X"
  260. // Registry key used to start the client
  261. // Sort of: smclient_0xProcId_0xThreadId
  262. #ifdef OS_WIN16
  263. #define SMCLIENT_INI "\\smclient.ini" // Our ini file
  264. #define TCLIENT_INI_SECTION "tclient" // Our section in ini file
  265. #else
  266. #define SMCLIENT_INI L"smclient.ini"
  267. #define TCLIENT_INI_SECTION L"tclient"
  268. #endif
  269. #define CHAT_SEPARATOR L"<->" // Separates wait<->repsonse
  270. // in chat sequence
  271. #define WAIT_STR_DELIMITER '|' // Deleimiter in Wait for
  272. // multiple strings
  273. #define MAX_WAITING_EVENTS 16
  274. #define MAX_STRING_LENGTH 128
  275. #define FEEDBACK_SIZE 32
  276. #define WAITINPUTIDLE 180000 // 3 min
  277. //
  278. // Keyboard-hook setting (see newclient\inc\autreg.h).
  279. //
  280. #define TCLIENT_KEYBOARD_HOOK_NEVER 0
  281. #define TCLIENT_KEYBOARD_HOOK_ALWAYS 1
  282. #define TCLIENT_KEYBOARD_HOOK_FULLSCREEN 2
  283. #ifdef _RCLX
  284. typedef struct _RCLXDATACHAIN {
  285. UINT uiOffset;
  286. struct _RCLXDATACHAIN *pNext;
  287. RCLXDATA RClxData;
  288. } RCLXDATACHAIN, *PRCLXDATACHAIN;
  289. #endif // _RCLX
  290. typedef struct _CONNECTINFO { // Connection context
  291. HWND hClient; // Main HWND of the client
  292. // or in RCLX mode
  293. // context structure
  294. HWND hContainer; // Client's child windows
  295. HWND hInput;
  296. HWND hOutput;
  297. HANDLE hProcess; // Client's process handle
  298. LONG_PTR lProcessId; // Client's process Id
  299. // or in RCLX mode, socket
  300. HANDLE hThread; // Clients first thread
  301. DWORD dwThreadId; // --"--
  302. // In RCLX mode this contains
  303. // our ThreadID
  304. DWORD OwnerThreadId; // thread id of the owner of
  305. // this structure
  306. BOOL dead; // TRUE if the client is dead
  307. BOOL bConnectionFailed;
  308. UINT xRes; // client's resolution
  309. UINT yRes;
  310. #ifdef _RCLX
  311. BOOL RClxMode; // TRUE if this thread is
  312. // in RCLX mode
  313. // the client is on remote
  314. // machine
  315. #endif // _RCLX
  316. HANDLE evWait4Str; // "Wait for something"
  317. // event handle
  318. HANDLE aevChatSeq[MAX_WAITING_EVENTS]; // Event on chat sequences
  319. INT nChatNum; // Number of chat sequences
  320. WCHAR Feedback[FEEDBACK_SIZE][MAX_STRING_LENGTH];
  321. // Feedback buffer
  322. INT nFBsize, nFBend; // Pointer within feedback
  323. // buffer
  324. CHAR szDiscReason[MAX_STRING_LENGTH*2]; // Explains disconnect reason
  325. CHAR szWait4MultipleStrResult[MAX_STRING_LENGTH];
  326. // Result of
  327. // Wait4MultipleStr:string
  328. INT nWait4MultipleStrResult; // Result of
  329. // Wait4MultipleStr:ID[0-n]
  330. #ifdef _RCLX
  331. HGLOBAL ghClipboard; // handle to received clipboard
  332. UINT uiClipboardFormat; // received clipboard format
  333. UINT nClipboardSize; // recevied clipboard size
  334. BOOL bRClxClipboardReceived; // Flag the clipbrd is received
  335. CHAR szClientType[MAX_STRING_LENGTH]; // in RCLX mode identifys the
  336. #endif // _RCLX
  337. // client machine and platform
  338. UINT uiSessionId;
  339. #ifdef _RCLX
  340. BOOL bWillCallAgain; // TRUE if FEED_WILLCALLAGAIN
  341. // is received in RCLX mode
  342. PRCLXDATACHAIN pRClxDataChain; // data receved from RCLX
  343. PRCLXDATACHAIN pRClxLastDataChain; // BITMAPs, Virtual Channels
  344. #endif // _RCLX
  345. BOOL bConsole; // TRUE if resolution is -1,-1
  346. // or TSFLAG_CONSOLE is spec
  347. PVOID pCIConsole; // extensions context
  348. HANDLE hConsoleExtension; // extens. lib handle
  349. struct _CONFIGINFO *pConfigInfo;
  350. struct _CONNECTINFO *pNext; // Next structure in the queue
  351. } CONNECTINFO, *PCONNECTINFO;
  352. typedef enum {
  353. WAIT_STRING, // Wait for unicode string from the client
  354. WAIT_DISC, // Wait for disconnected event
  355. WAIT_CONN, // Wait for conneted event
  356. WAIT_MSTRINGS, // Wait for multiple strings
  357. WAIT_CLIPBOARD, // Wait for clipboard data
  358. WAIT_DATA // Wait for data block (RCLX mode responces)
  359. } WAITTYPE;
  360. // Different event types
  361. // on which we wait
  362. typedef struct _WAIT4STRING {
  363. HANDLE evWait; // Wait for event
  364. PCONNECTINFO pOwner; // Context of the owner
  365. LONG_PTR lProcessId; // Clients ID
  366. WAITTYPE WaitType; // Event type
  367. DWORD_PTR strsize; // String length (WAIT_STRING,
  368. // WAIT_MSTRING)
  369. WCHAR waitstr[MAX_STRING_LENGTH]; // String we are waiting for
  370. DWORD_PTR respsize; // Length of responf
  371. WCHAR respstr[MAX_STRING_LENGTH]; // Respond string
  372. // (in chat sequences)
  373. struct _WAIT4STRING *pNext; // Next in the queue
  374. } WAIT4STRING, *PWAIT4STRING;
  375. typedef struct _CONFIGINFO {
  376. UINT WAIT4STR_TIMEOUT; // default is 10 min,
  377. // some events are waited
  378. // 1/4 of that time
  379. // This value can be changed from
  380. // smclient.ini [tclient]
  381. // timeout=XXX seconds
  382. UINT CONNECT_TIMEOUT; // Default is 35 seconds
  383. // This value can be changed from
  384. // smclient.ini [tclient]
  385. // contimeout=XXX seconds
  386. WCHAR strStartRun[MAX_STRING_LENGTH];
  387. WCHAR strStartRun_Act[MAX_STRING_LENGTH];
  388. WCHAR strRunBox[MAX_STRING_LENGTH];
  389. WCHAR strWinlogon[MAX_STRING_LENGTH];
  390. WCHAR strWinlogon_Act[MAX_STRING_LENGTH];
  391. WCHAR strPriorWinlogon[MAX_STRING_LENGTH];
  392. WCHAR strPriorWinlogon_Act[MAX_STRING_LENGTH];
  393. WCHAR strNoSmartcard[MAX_STRING_LENGTH];
  394. WCHAR strSmartcard[MAX_STRING_LENGTH];
  395. WCHAR strSmartcard_Act[MAX_STRING_LENGTH];
  396. WCHAR strNTSecurity[MAX_STRING_LENGTH];
  397. WCHAR strNTSecurity_Act[MAX_STRING_LENGTH];
  398. WCHAR strSureLogoff[MAX_STRING_LENGTH];
  399. WCHAR strStartLogoff[MAX_STRING_LENGTH];
  400. WCHAR strSureLogoffAct[MAX_STRING_LENGTH];
  401. WCHAR strLogonErrorMessage[MAX_STRING_LENGTH];
  402. WCHAR strLogonDisabled[MAX_STRING_LENGTH];
  403. WCHAR strLogonFmt[MAX_STRING_LENGTH]; // logon string
  404. WCHAR strSessionListDlg[MAX_STRING_LENGTH];
  405. WCHAR strClientCaption[MAX_STRING_LENGTH];
  406. WCHAR strDisconnectDialogBox[MAX_STRING_LENGTH];
  407. WCHAR strYesNoShutdown[MAX_STRING_LENGTH];
  408. WCHAR strClientImg[MAX_STRING_LENGTH];
  409. WCHAR strDebugger[MAX_STRING_LENGTH];
  410. WCHAR strMainWindowClass[MAX_STRING_LENGTH];
  411. WCHAR strCmdLineFmt[4 * MAX_STRING_LENGTH];
  412. WCHAR strConsoleExtension[MAX_STRING_LENGTH];
  413. INT ConnectionFlags;
  414. INT Autologon;
  415. INT UseRegistry;
  416. INT LoginWait;
  417. INT bTranslateStrings;
  418. BOOL bUnicode;
  419. INT KeyboardHook;
  420. } CONFIGINFO, *PCONFIGINFO;
  421. //
  422. // Allocation-list structure.
  423. //
  424. typedef struct _ALLOCATION {
  425. LIST_ENTRY AllocationListEntry;
  426. PVOID Address;
  427. } ALLOCATION, *PALLOCATION;
  428. VOID _FillConfigInfo(PCONFIGINFO pConfigInfo); // LPSTR szData);
  429. VOID LoadSmClientFile(WCHAR *szIniFileName, DWORD dwIniFileNameLen, LPSTR szLang);
  430. #ifdef __cplusplus
  431. }
  432. #endif
  433. #endif /* _TCLIENT_H */