Source code of Windows XP (NT5)
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.

409 lines
9.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. vrnmpipe.h
  5. Abstract:
  6. Prototypes, definitions and structures for VdmRedir named pipe handlers
  7. Author:
  8. Richard L Firth (rfirth) 10-Sep-1991
  9. Revision History:
  10. 10-Sep-1991 RFirth
  11. Created
  12. --*/
  13. //
  14. // manifests
  15. //
  16. #define MAXIMUM_ASYNC_PIPES 32
  17. //
  18. // async named pipe request types
  19. //
  20. #define ANP_READ 0x86
  21. #define ANP_READ2 0x90
  22. #define ANP_WRITE 0x8f
  23. #define ANP_WRITE2 0x91
  24. //
  25. // VDM Named Pipe support routines. Prototypes
  26. //
  27. VOID
  28. VrGetNamedPipeInfo(
  29. VOID
  30. );
  31. VOID
  32. VrGetNamedPipeHandleState(
  33. VOID
  34. );
  35. VOID
  36. VrSetNamedPipeHandleState(
  37. VOID
  38. );
  39. VOID
  40. VrPeekNamedPipe(
  41. VOID
  42. );
  43. VOID
  44. VrTransactNamedPipe(
  45. VOID
  46. );
  47. VOID
  48. VrCallNamedPipe(
  49. VOID
  50. );
  51. VOID
  52. VrWaitNamedPipe(
  53. VOID
  54. );
  55. VOID
  56. VrNetHandleGetInfo(
  57. VOID
  58. );
  59. VOID
  60. VrNetHandleSetInfo(
  61. VOID
  62. );
  63. VOID
  64. VrReadWriteAsyncNmPipe(
  65. VOID
  66. );
  67. BOOLEAN
  68. VrNmPipeInterrupt(
  69. VOID
  70. );
  71. VOID
  72. VrTerminateNamedPipes(
  73. IN WORD DosPdb
  74. );
  75. //
  76. // VDM open/close and read/write intercept routines
  77. //
  78. #ifdef VDMREDIR_DLL
  79. BOOL
  80. VrAddOpenNamedPipeInfo(
  81. IN HANDLE Handle,
  82. IN LPSTR lpFileName
  83. );
  84. BOOL
  85. VrRemoveOpenNamedPipeInfo(
  86. IN HANDLE Handle
  87. );
  88. BOOL
  89. VrReadNamedPipe(
  90. IN HANDLE Handle,
  91. IN LPBYTE Buffer,
  92. IN DWORD Buflen,
  93. OUT LPDWORD BytesRead,
  94. OUT LPDWORD Error
  95. );
  96. BOOL
  97. VrWriteNamedPipe(
  98. IN HANDLE Handle,
  99. IN LPBYTE Buffer,
  100. IN DWORD Buflen,
  101. OUT LPDWORD BytesWritten
  102. );
  103. VOID
  104. VrCancelPipeIo(
  105. IN DWORD Thread
  106. );
  107. #else
  108. BOOL
  109. (*VrAddOpenNamedPipeInfo)(
  110. IN HANDLE Handle,
  111. IN LPSTR lpFileName
  112. );
  113. BOOL
  114. (*VrRemoveOpenNamedPipeInfo)(
  115. IN HANDLE Handle
  116. );
  117. BOOL
  118. (*VrReadNamedPipe)(
  119. IN HANDLE Handle,
  120. IN LPBYTE Buffer,
  121. IN DWORD Buflen,
  122. OUT LPDWORD BytesRead,
  123. OUT LPDWORD Error
  124. );
  125. BOOL
  126. (*VrWriteNamedPipe)(
  127. IN HANDLE Handle,
  128. IN LPBYTE Buffer,
  129. IN DWORD Buflen,
  130. OUT LPDWORD BytesWritten
  131. );
  132. VOID
  133. (*VrCancelPipeIo)(
  134. IN DWORD Thread
  135. );
  136. #endif
  137. //
  138. // VDM pipe name to NT pipe name helper routines
  139. //
  140. #ifdef VDMREDIR_DLL
  141. BOOL
  142. VrIsNamedPipeName(
  143. IN LPSTR Name
  144. );
  145. BOOL
  146. VrIsNamedPipeHandle(
  147. IN HANDLE Handle
  148. );
  149. LPSTR
  150. VrConvertLocalNtPipeName(
  151. OUT LPSTR Buffer OPTIONAL,
  152. IN LPSTR Name
  153. );
  154. #else
  155. BOOL
  156. (*VrIsNamedPipeName)(
  157. IN LPSTR Name
  158. );
  159. BOOL
  160. (*VrIsNamedPipeHandle)(
  161. IN HANDLE Handle
  162. );
  163. LPSTR
  164. (*VrConvertLocalNtPipeName)(
  165. OUT LPSTR Buffer OPTIONAL,
  166. IN LPSTR Name
  167. );
  168. #endif
  169. //
  170. // structures
  171. //
  172. //typedef struct {
  173. // PDOSNMPINFO Next; // pointer to next info structure in list
  174. // WORD DosPdb;
  175. // WORD Handle16;
  176. // HANDLE Handle32; // handle returned from CreateFile call
  177. // DWORD NameLength; // length of ASCIZ pipe name
  178. // LPSTR Name; // ASCIZ pipe name
  179. // DWORD Instances; // current instances
  180. //} DOSNMPINFO, *PDOSNMPINFO;
  181. //
  182. // OPEN_NAMED_PIPE_INFO - this structure contains information recorded when a
  183. // named pipe is opened on behalf of the VDM. DosQNmPipeInfo wants the name
  184. // of the pipe
  185. //
  186. typedef struct _OPEN_NAMED_PIPE_INFO* POPEN_NAMED_PIPE_INFO;
  187. typedef struct _OPEN_NAMED_PIPE_INFO {
  188. POPEN_NAMED_PIPE_INFO Next; // linked list
  189. HANDLE Handle; // open named pipe handle
  190. DWORD NameLength; // including terminating 0
  191. WORD DosPdb; // the process which owns this named pipe
  192. CHAR Name[2]; // full pipe name
  193. } OPEN_NAMED_PIPE_INFO;
  194. //
  195. // DOS_ASYNC_NAMED_PIPE_INFO - in this structure we keep all the information
  196. // required to complete an asynchronous named pipe operation
  197. //
  198. typedef struct _DOS_ASYNC_NAMED_PIPE_INFO {
  199. struct _DOS_ASYNC_NAMED_PIPE_INFO* Next; // linked list
  200. OVERLAPPED Overlapped; // contains 32-bit event handle
  201. BOOL Type2; // TRUE if request is Read2 or Write2
  202. BOOL Completed; // TRUE if this request has completed
  203. HANDLE Handle; // 32-bit named pipe handle
  204. DWORD Buffer; // 16:16 address of buffer
  205. DWORD BytesTransferred; // actual number of bytes read/written
  206. LPWORD pBytesTransferred; // flat-32 pointer to returned read/write count in VDM
  207. LPWORD pErrorCode; // flat-32 pointer to returned error code in VDM
  208. DWORD ANR; // 16:16 address of ANR
  209. DWORD Semaphore; // 16:16 address of 'semaphore' in VDM
  210. #if DBG
  211. DWORD RequestType;
  212. #endif
  213. } DOS_ASYNC_NAMED_PIPE_INFO, *PDOS_ASYNC_NAMED_PIPE_INFO;
  214. //
  215. // DOS_CALL_NAMED_PIPE_STRUCT - this structure is created and handed to the DOS
  216. // CallNmPipe routine because there is too much information to get into a 286's
  217. // registers. This structure should be in apistruc.h, but it aint
  218. //
  219. //#include <packon.h>
  220. #pragma pack(1)
  221. typedef struct {
  222. DWORD Timeout; // Time to wait for pipe to become available
  223. LPWORD lpBytesRead; // pointer to returned bytes read
  224. WORD nOutBufferLen; // size of send data
  225. LPBYTE lpOutBuffer; // pointer to send data
  226. WORD nInBufferLen; // size of receive buffer
  227. LPBYTE lpInBuffer; // pointer to receive buffer
  228. LPSTR lpPipeName; // pointer to pipe name
  229. } DOS_CALL_NAMED_PIPE_STRUCT, *PDOS_CALL_NAMED_PIPE_STRUCT;
  230. //#include <packoff.h>
  231. #pragma pack()
  232. //
  233. // DOS_ASYNC_NAMED_PIPE_STRUCT - as with the above, this structure is used
  234. // to pass all the info to DosReadAsyncNmPipe which won't fit into registers.
  235. // Used for read and write operations. Should be defined in apistruc.h
  236. //
  237. //#include <packon.h>
  238. #pragma pack(1)
  239. typedef struct {
  240. LPWORD lpBytesRead; // pointer to returned bytes read/written
  241. WORD BufferLength; // size of caller's buffer
  242. LPBYTE lpBuffer; // pointer to caller's buffer
  243. LPWORD lpErrorCode; // pointer to returned error code
  244. LPVOID lpANR; // pointer to Asynchronous Notification Routine
  245. WORD PipeHandle; // named pipe handle
  246. LPBYTE lpSemaphore; // pointer to caller's 'semaphore'
  247. } DOS_ASYNC_NAMED_PIPE_STRUCT, *PDOS_ASYNC_NAMED_PIPE_STRUCT;
  248. //#include <packoff.h>
  249. #pragma pack()
  250. //
  251. // The following selectively copied from BSEDOS.H and other Lanman include
  252. // files
  253. //
  254. /*** Data structures and equates used with named pipes ***/
  255. //#include <packon.h>
  256. #pragma pack(1)
  257. typedef struct _PIPEINFO { /* nmpinf */
  258. USHORT cbOut;
  259. USHORT cbIn;
  260. BYTE cbMaxInst;
  261. BYTE cbCurInst;
  262. BYTE cbName;
  263. CHAR szName[1];
  264. } PIPEINFO;
  265. //#include <packoff.h>
  266. #pragma pack()
  267. typedef PIPEINFO FAR *PPIPEINFO;
  268. /* defined bits in pipe mode */
  269. #define NP_NBLK 0x8000 /* non-blocking read/write */
  270. #define NP_SERVER 0x4000 /* set if server end */
  271. #define NP_WMESG 0x0400 /* write messages */
  272. #define NP_RMESG 0x0100 /* read as messages */
  273. #define NP_ICOUNT 0x00FF /* instance count field */
  274. /* Named pipes may be in one of several states depending on the actions
  275. * that have been taken on it by the server end and client end. The
  276. * following state/action table summarizes the valid state transitions:
  277. *
  278. * Current state Action Next state
  279. *
  280. * <none> server DosMakeNmPipe DISCONNECTED
  281. * DISCONNECTED server connect LISTENING
  282. * LISTENING client open CONNECTED
  283. * CONNECTED server disconn DISCONNECTED
  284. * CONNECTED client close CLOSING
  285. * CLOSING server disconn DISCONNECTED
  286. * CONNECTED server close CLOSING
  287. * <any other> server close <pipe deallocated>
  288. *
  289. * If a server disconnects his end of the pipe, the client end will enter a
  290. * special state in which any future operations (except close) on the file
  291. * descriptor associated with the pipe will return an error.
  292. */
  293. /*
  294. * Values for named pipe state
  295. */
  296. #define NP_DISCONNECTED 1 /* after pipe creation or Disconnect */
  297. #define NP_LISTENING 2 /* after DosNmPipeConnect */
  298. #define NP_CONNECTED 3 /* after Client open */
  299. #define NP_CLOSING 4 /* after Client or Server close */
  300. /* DosMakeNmPipe open modes */
  301. #define NP_ACCESS_INBOUND 0x0000
  302. #define NP_ACCESS_OUTBOUND 0x0001
  303. #define NP_ACCESS_DUPLEX 0x0002
  304. #define NP_INHERIT 0x0000
  305. #define NP_NOINHERIT 0x0080
  306. #define NP_WRITEBEHIND 0x0000
  307. #define NP_NOWRITEBEHIND 0x4000
  308. /* DosMakeNmPipe and DosQNmPHandState state */
  309. #define NP_READMODE_BYTE 0x0000
  310. #define NP_READMODE_MESSAGE 0x0100
  311. #define NP_TYPE_BYTE 0x0000
  312. #define NP_TYPE_MESSAGE 0x0400
  313. #define NP_END_CLIENT 0x0000
  314. #define NP_END_SERVER 0x4000
  315. #define NP_WAIT 0x0000
  316. #define NP_NOWAIT 0x8000
  317. #define NP_UNLIMITED_INSTANCES 0x00FF
  318. typedef struct _AVAILDATA { /* PeekNMPipe Bytes Available record */
  319. USHORT cbpipe; /* bytes left in the pipe */
  320. USHORT cbmessage; /* bytes left in current message */
  321. } AVAILDATA;
  322. typedef AVAILDATA FAR *PAVAILDATA;
  323. //
  324. // handle info level 1 - this is different to the structure in lmchdev.h
  325. //
  326. //#include <packon.h>
  327. #pragma pack(1)
  328. typedef struct _VDM_HANDLE_INFO_1 {
  329. ULONG CharTime;
  330. USHORT CharCount;
  331. } VDM_HANDLE_INFO_1, *LPVDM_HANDLE_INFO_1;
  332. #pragma pack()
  333. //#include <packoff.h>