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.

441 lines
26 KiB

  1. /****************************************************************************/
  2. /* Header: cchannel.h */
  3. /* */
  4. /* Purpose: Virtual Channel Client API */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1999 */
  7. /* */
  8. /****************************************************************************/
  9. #ifndef H_CCHANNEL
  10. #define H_CCHANNEL
  11. /****************************************************************************/
  12. /* Include Virtual Channel Protocol header */
  13. /****************************************************************************/
  14. #include <pchannel.h>
  15. #ifdef _WIN32
  16. #define VCAPITYPE _stdcall
  17. #define VCEXPORT
  18. #else // _WIN32
  19. #define VCAPITYPE CALLBACK
  20. #define VCEXPORT __export
  21. #endif // _WIN32
  22. /****************************************************************************/
  23. /* Name: CHANNEL_INIT_EVENT_FN */
  24. /* */
  25. /* Purpose: */
  26. /* */
  27. /* This function is passed to MSTSC on VirtualChannelInit. It is called by */
  28. /* MSTSC to tell the application about interesting events. */
  29. /* */
  30. /* Returns: */
  31. /* */
  32. /* none */
  33. /* */
  34. /* Params: */
  35. /* */
  36. /* - pInitHandle - a handle uniquely identifying this connection */
  37. /* - event - the event that has occurred - see CHANNEL_EVENT_XXX below */
  38. /* - pData - data associated with the event - see CHANNEL_EVENT_XXX below */
  39. /* - dataLength - length of the data. */
  40. /* */
  41. /****************************************************************************/
  42. typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_FN(LPVOID pInitHandle,
  43. UINT event,
  44. LPVOID pData,
  45. UINT dataLength);
  46. typedef CHANNEL_INIT_EVENT_FN FAR * PCHANNEL_INIT_EVENT_FN;
  47. typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_EX_FN(LPVOID lpUserParam,
  48. LPVOID pInitHandle,
  49. UINT event,
  50. LPVOID pData,
  51. UINT dataLength);
  52. typedef CHANNEL_INIT_EVENT_EX_FN FAR * PCHANNEL_INIT_EVENT_EX_FN;
  53. /****************************************************************************/
  54. /* Events passed to VirtualChannelInitEvent */
  55. /****************************************************************************/
  56. /* Client initialized (no data) */
  57. #define CHANNEL_EVENT_INITIALIZED 0
  58. /* Connection established (data = name of Server) */
  59. #define CHANNEL_EVENT_CONNECTED 1
  60. /* Connection established with old Server, so no channel support */
  61. #define CHANNEL_EVENT_V1_CONNECTED 2
  62. /* Connection ended (no data) */
  63. #define CHANNEL_EVENT_DISCONNECTED 3
  64. /* Client terminated (no data) */
  65. #define CHANNEL_EVENT_TERMINATED 4
  66. /* Remote control is starting on this client */
  67. #define CHANNEL_EVENT_REMOTE_CONTROL_START 5
  68. /* Remote control is ending on this client */
  69. #define CHANNEL_EVENT_REMOTE_CONTROL_STOP 6
  70. /****************************************************************************/
  71. /* Name: CHANNEL_OPEN_EVENT_FN */
  72. /* */
  73. /* Purpose: */
  74. /* */
  75. /* This function is passed to MSTSC on VirtualChannelOpen. It is called by */
  76. /* MSTSC when data is available on the channel. */
  77. /* */
  78. /* Returns: */
  79. /* */
  80. /* none */
  81. /* */
  82. /* Params: */
  83. /* */
  84. /* - openHandle - a handle uniquely identifying this channel */
  85. /* - event - event that has occurred - see CHANNEL_EVENT_XXX below */
  86. /* - pData - data received */
  87. /* - dataLength - length of the data */
  88. /* - totalLength - total length of data written by the Server */
  89. /* - dataFlags - flags, zero, one or more of: */
  90. /* - 0x01 - beginning of data from a single write operation at the Server */
  91. /* - 0x02 - end of data from a single write operation at the Server. */
  92. /* */
  93. /****************************************************************************/
  94. typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_FN(DWORD openHandle,
  95. UINT event,
  96. LPVOID pData,
  97. UINT32 dataLength,
  98. UINT32 totalLength,
  99. UINT32 dataFlags);
  100. typedef CHANNEL_OPEN_EVENT_FN FAR * PCHANNEL_OPEN_EVENT_FN;
  101. typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_EX_FN(LPVOID lpUserParam,
  102. DWORD openHandle,
  103. UINT event,
  104. LPVOID pData,
  105. UINT32 dataLength,
  106. UINT32 totalLength,
  107. UINT32 dataFlags);
  108. typedef CHANNEL_OPEN_EVENT_EX_FN FAR * PCHANNEL_OPEN_EVENT_EX_FN;
  109. /****************************************************************************/
  110. /* Events passed to VirtualChannelOpenEvent */
  111. /****************************************************************************/
  112. /* Data received from Server (data = incoming data) */
  113. #define CHANNEL_EVENT_DATA_RECEIVED 10
  114. /* VirtualChannelWrite completed (pData - pUserData passed on
  115. VirtualChannelWrite) */
  116. #define CHANNEL_EVENT_WRITE_COMPLETE 11
  117. /* VirtualChannelWrite cancelled (pData - pUserData passed on
  118. VirtualChannelWrite) */
  119. #define CHANNEL_EVENT_WRITE_CANCELLED 12
  120. /****************************************************************************/
  121. /* Return codes from VirtualChannelXxx functions */
  122. /****************************************************************************/
  123. #define CHANNEL_RC_OK 0
  124. #define CHANNEL_RC_ALREADY_INITIALIZED 1
  125. #define CHANNEL_RC_NOT_INITIALIZED 2
  126. #define CHANNEL_RC_ALREADY_CONNECTED 3
  127. #define CHANNEL_RC_NOT_CONNECTED 4
  128. #define CHANNEL_RC_TOO_MANY_CHANNELS 5
  129. #define CHANNEL_RC_BAD_CHANNEL 6
  130. #define CHANNEL_RC_BAD_CHANNEL_HANDLE 7
  131. #define CHANNEL_RC_NO_BUFFER 8
  132. #define CHANNEL_RC_BAD_INIT_HANDLE 9
  133. #define CHANNEL_RC_NOT_OPEN 10
  134. #define CHANNEL_RC_BAD_PROC 11
  135. #define CHANNEL_RC_NO_MEMORY 12
  136. #define CHANNEL_RC_UNKNOWN_CHANNEL_NAME 13
  137. #define CHANNEL_RC_ALREADY_OPEN 14
  138. #define CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY 15
  139. #define CHANNEL_RC_NULL_DATA 16
  140. #define CHANNEL_RC_ZERO_LENGTH 17
  141. #define CHANNEL_RC_INVALID_INSTANCE 18
  142. #define CHANNEL_RC_UNSUPPORTED_VERSION 19
  143. /****************************************************************************/
  144. /* Levels of Virtual Channel Support */
  145. /****************************************************************************/
  146. #define VIRTUAL_CHANNEL_VERSION_WIN2000 1
  147. #ifdef __cplusplus
  148. extern "C" {
  149. #endif /* __cplusplus */
  150. /****************************************************************************/
  151. /* Name: VirtualChannelInit */
  152. /* */
  153. /* Purpose: */
  154. /* */
  155. /* This function is called by the application to register the virtual */
  156. /* channels it wants to have access to. Note that this does not open the */
  157. /* channels, merely reserves the names for use by this application. This */
  158. /* function must be called before the Client connects to the Server, hence */
  159. /* it is recommended that it is called from the DLL's initialization */
  160. /* procedure. */
  161. /* */
  162. /* */
  163. /* On_return, the channels requested have been registered. However, other */
  164. /* MSTSC initialization may not yet have completed. The application */
  165. /* receives a VirtualChannelInitEvent callback with the "Client */
  166. /* initialized" event when all MSTSC initialization is complete. */
  167. /* */
  168. /* Returns: */
  169. /* */
  170. /* CHANNEL_RC_OK */
  171. /* CHANNEL_RC_ALREADY_INITIALIZED */
  172. /* CHANNEL_RC_ALREADY_CONNECTED */
  173. /* CHANNEL_RC_TOO_MANY_CHANNELS */
  174. /* CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY */
  175. /* */
  176. /* Parameters */
  177. /* */
  178. /* - ppInitHandle (returned) - handle to pass to subsequent */
  179. /* VirtualChannelXxx calls */
  180. /* - pChannel - list of names registered by this application */
  181. /* - channelCount - number of channels registered. */
  182. /* - versionRequested - level of virtual channel support requested (one of */
  183. /* the VIRTUAL_CHANNEL_LEVEL_XXX parameters) */
  184. /* - pChannelInitEventProc - address of VirtualChannelInitEvent procedure */
  185. /* */
  186. /****************************************************************************/
  187. typedef UINT VCAPITYPE VIRTUALCHANNELINIT(
  188. LPVOID FAR * ppInitHandle,
  189. PCHANNEL_DEF pChannel,
  190. INT channelCount,
  191. ULONG versionRequested,
  192. PCHANNEL_INIT_EVENT_FN pChannelInitEventProc);
  193. typedef VIRTUALCHANNELINIT FAR * PVIRTUALCHANNELINIT;
  194. /****************************************************************************/
  195. /* Parameters for EX version */
  196. /* */
  197. /* pUserParam - user definded value that will be passed back */
  198. /* to addin in callbacks */
  199. /* */
  200. /* - pInitHandle - handle passed in in entry function */
  201. /* - pChannel - list of names registered by this application */
  202. /* - channelCount - number of channels registered. */
  203. /* - versionRequested - level of virtual channel support requested (one of */
  204. /* the VIRTUAL_CHANNEL_LEVEL_XXX parameters) */
  205. /* - pChannelInitEventProc - address of VirtualChannelInitEvent procedure */
  206. /* */
  207. /****************************************************************************/
  208. typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(
  209. LPVOID lpUserParam,
  210. LPVOID pInitHandle,
  211. PCHANNEL_DEF pChannel,
  212. INT channelCount,
  213. ULONG versionRequested,
  214. PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx);
  215. typedef VIRTUALCHANNELINITEX FAR * PVIRTUALCHANNELINITEX;
  216. /****************************************************************************/
  217. /* Name: VirtualChannelOpen */
  218. /* */
  219. /* Purpose: */
  220. /* */
  221. /* This function is called by the application to open a channel. It cannot */
  222. /* be called until a connection is established with a Server. */
  223. /* */
  224. /* Returns: */
  225. /* */
  226. /* CHANNEL_RC_OK */
  227. /* CHANNEL_RC_NOT_INITIALIZED */
  228. /* CHANNEL_RC_NOT_CONNECTED */
  229. /* CHANNEL_RC_BAD_CHANNEL_NAME */
  230. /* CHANNEL_RC_BAD_INIT_HANDLE */
  231. /* */
  232. /* Params: */
  233. /* */
  234. /* - pInitHandle - handle from VirtualChannelInit */
  235. /* */
  236. /* - pOpenHandle (returned) - handle to pass to subsequent */
  237. /* VirtualChannelXxx calls */
  238. /* - pChannelName - name of channel to open */
  239. /* - pChannelOpenEventProc - address of VirtualChannelOpenEvent procedure */
  240. /* */
  241. /****************************************************************************/
  242. typedef UINT VCAPITYPE VIRTUALCHANNELOPEN(
  243. LPVOID pInitHandle,
  244. LPDWORD pOpenHandle,
  245. PCHAR pChannelName,
  246. PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc);
  247. typedef VIRTUALCHANNELOPEN FAR * PVIRTUALCHANNELOPEN;
  248. typedef UINT VCAPITYPE VIRTUALCHANNELOPENEX(
  249. LPVOID pInitHandle,
  250. LPDWORD pOpenHandle,
  251. PCHAR pChannelName,
  252. PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx);
  253. typedef VIRTUALCHANNELOPENEX FAR * PVIRTUALCHANNELOPENEX;
  254. /****************************************************************************/
  255. /* Name: VirtualChannelClose */
  256. /* */
  257. /* Purpose: */
  258. /* */
  259. /* This function is called to close a previously opened channel. */
  260. /* */
  261. /* Returns: */
  262. /* */
  263. /* CHANNEL_RC_OK */
  264. /* CHANNEL_RC_BAD_CHANNEL_HANDLE */
  265. /* */
  266. /* Params: */
  267. /* */
  268. /* - (EX version) pInitHandle - handle identifying the client instance */
  269. /* - openHandle - handle returned on VirtualChannelOpen */
  270. /* */
  271. /****************************************************************************/
  272. typedef UINT VCAPITYPE VIRTUALCHANNELCLOSE(DWORD openHandle);
  273. typedef VIRTUALCHANNELCLOSE FAR * PVIRTUALCHANNELCLOSE;
  274. typedef UINT VCAPITYPE VIRTUALCHANNELCLOSEEX(LPVOID pInitHandle,
  275. DWORD openHandle);
  276. typedef VIRTUALCHANNELCLOSEEX FAR * PVIRTUALCHANNELCLOSEEX;
  277. /****************************************************************************/
  278. /* Name: VirtualChannelWrite */
  279. /* */
  280. /* Purpose: */
  281. /* */
  282. /* This function is used to send data to the partner app on the Server. */
  283. /* */
  284. /* VirtualChannelWrite copies the data to one or more network buffers as */
  285. /* necessary. VirtualChannelWrite ensures that data is sent to the Server */
  286. /* on the right context. It sends all data on MS TC's Sender thread. */
  287. /* */
  288. /* VirtualChannelWrite is asynchronous - the VirtualChannelOpenEvent */
  289. /* procedure is called when the write completes. Until that callback is */
  290. /* made, the caller must not free or reuse the buffer passed on */
  291. /* VirtualChannelWrite. The caller passes a piece of data (pUserData) to */
  292. /* VirtualChannelWrite, which is returned on the VirtualChannelOpenEvent */
  293. /* callback. The caller can use this data to identify the write which has */
  294. /* completed. */
  295. /* */
  296. /* */
  297. /* Returns: */
  298. /* */
  299. /* CHANNEL_RC_OK */
  300. /* CHANNEL_RC_NOT_INITIALIZED */
  301. /* CHANNEL_RC_NOT_CONNECTED */
  302. /* CHANNEL_RC_BAD_CHANNEL_HANDLE */
  303. /* */
  304. /* Params: */
  305. /* - (EX version) pInitHandle - handle identifying the client instance */
  306. /* - openHandle - handle from VirtualChannelOpen */
  307. /* - pData - data to write */
  308. /* - datalength - length of data to write */
  309. /* - pUserData - user supplied data, returned on VirtualChannelOpenEvent */
  310. /* when the write completes */
  311. /* */
  312. /****************************************************************************/
  313. typedef UINT VCAPITYPE VIRTUALCHANNELWRITE(DWORD openHandle,
  314. LPVOID pData,
  315. ULONG dataLength,
  316. LPVOID pUserData);
  317. typedef VIRTUALCHANNELWRITE FAR * PVIRTUALCHANNELWRITE;
  318. typedef UINT VCAPITYPE VIRTUALCHANNELWRITEEX(LPVOID pInitHandle,
  319. DWORD openHandle,
  320. LPVOID pData,
  321. ULONG dataLength,
  322. LPVOID pUserData);
  323. typedef VIRTUALCHANNELWRITEEX FAR * PVIRTUALCHANNELWRITEEX;
  324. /****************************************************************************/
  325. /* Structure: CHANNEL_ENTRY_POINTS */
  326. /* */
  327. /* Description: Virtual Channel entry points passed to VirtualChannelEntry */
  328. /****************************************************************************/
  329. typedef struct tagCHANNEL_ENTRY_POINTS
  330. {
  331. DWORD cbSize;
  332. DWORD protocolVersion;
  333. PVIRTUALCHANNELINIT pVirtualChannelInit;
  334. PVIRTUALCHANNELOPEN pVirtualChannelOpen;
  335. PVIRTUALCHANNELCLOSE pVirtualChannelClose;
  336. PVIRTUALCHANNELWRITE pVirtualChannelWrite;
  337. } CHANNEL_ENTRY_POINTS, FAR * PCHANNEL_ENTRY_POINTS;
  338. typedef struct tagCHANNEL_ENTRY_POINTS_EX
  339. {
  340. DWORD cbSize;
  341. DWORD protocolVersion;
  342. PVIRTUALCHANNELINITEX pVirtualChannelInitEx;
  343. PVIRTUALCHANNELOPENEX pVirtualChannelOpenEx;
  344. PVIRTUALCHANNELCLOSEEX pVirtualChannelCloseEx;
  345. PVIRTUALCHANNELWRITEEX pVirtualChannelWriteEx;
  346. } CHANNEL_ENTRY_POINTS_EX, FAR * PCHANNEL_ENTRY_POINTS_EX;
  347. /****************************************************************************/
  348. /* Name: VirtualChannelEntry */
  349. /* */
  350. /* Purpose: */
  351. /* */
  352. /* This function is provided by addin DLLS. It is called by MSTSC at */
  353. /* initialization to tell the addin DLL the addresses of the */
  354. /* VirtualChannelXxx functions. */
  355. /* */
  356. /* Returns: */
  357. /* */
  358. /* TRUE - everything OK */
  359. /* FALSE - error, unload the DLL */
  360. /* */
  361. /* Parameters: */
  362. /* */
  363. /* - pVirtualChannelInit - pointers to VirtualChannelXxx functions */
  364. /* - pVirtualChannelOpen */
  365. /* - pVirtualChannelClose */
  366. /* - pVirtualChannelWrite */
  367. /* */
  368. /* - (EX version) pInitHandle - value that identifies client instance */
  369. /* this must be passed back when calling into */
  370. /* the client. */
  371. /****************************************************************************/
  372. typedef BOOL VCAPITYPE VIRTUALCHANNELENTRY(
  373. PCHANNEL_ENTRY_POINTS pEntryPoints);
  374. typedef VIRTUALCHANNELENTRY FAR * PVIRTUALCHANNELENTRY;
  375. typedef BOOL VCAPITYPE VIRTUALCHANNELENTRYEX(
  376. PCHANNEL_ENTRY_POINTS_EX pEntryPointsEx,
  377. PVOID pInitHandle);
  378. typedef VIRTUALCHANNELENTRYEX FAR * PVIRTUALCHANNELENTRYEX;
  379. #ifdef __cplusplus
  380. }
  381. #endif /* __cplusplus */
  382. #endif /* H_CCHANNEL */