| 1 | /* $Id: npipe.cpp,v 1.10 2002-02-09 17:27:32 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Named pipes API
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 6 | * Copyright 2000 Przemyslaw Dobrowolski
|
|---|
| 7 | *
|
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 9 | */
|
|---|
| 10 | #include <odin.h>
|
|---|
| 11 | #include <odinwrap.h>
|
|---|
| 12 | #include <os2win.h>
|
|---|
| 13 | #include <stdlib.h>
|
|---|
| 14 | #include <unicode.h>
|
|---|
| 15 | #include <heapstring.h>
|
|---|
| 16 | #include <options.h>
|
|---|
| 17 | #include <HandleManager.h>
|
|---|
| 18 | #include "debugtools.h"
|
|---|
| 19 | #include "oslibdos.h"
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | #define DBG_LOCALLOG DBG_npipe
|
|---|
| 23 | #include "dbglocal.h"
|
|---|
| 24 |
|
|---|
| 25 | ODINDEBUGCHANNEL(KERNEL32-NPIPE)
|
|---|
| 26 |
|
|---|
| 27 | //******************************************************************************
|
|---|
| 28 | //******************************************************************************
|
|---|
| 29 | BOOL WIN32API PeekNamedPipe(HANDLE hPipe, LPVOID lpvBuffer,
|
|---|
| 30 | DWORD cbBuffer, LPDWORD lpcbRead,
|
|---|
| 31 | LPDWORD lpcbAvail, LPDWORD lpcbMessage)
|
|---|
| 32 | {
|
|---|
| 33 | return (HMPeekNamedPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,lpcbAvail,lpcbMessage));
|
|---|
| 34 | }
|
|---|
| 35 | //******************************************************************************
|
|---|
| 36 | //******************************************************************************
|
|---|
| 37 | BOOL WIN32API CreatePipe(PHANDLE phRead, PHANDLE phWrite,
|
|---|
| 38 | LPSECURITY_ATTRIBUTES lpsa, DWORD cbPipe)
|
|---|
| 39 | {
|
|---|
| 40 | return (HMCreatePipe(phRead,phWrite,lpsa,cbPipe));
|
|---|
| 41 | }
|
|---|
| 42 | //******************************************************************************
|
|---|
| 43 | //******************************************************************************
|
|---|
| 44 | HANDLE WIN32API CreateNamedPipeA(LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode,
|
|---|
| 45 | DWORD nMaxInstances, DWORD nOutBufferSize,
|
|---|
| 46 | DWORD nInBufferSize, DWORD nDefaultTimeOut,
|
|---|
| 47 | LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
|---|
| 48 |
|
|---|
| 49 | {
|
|---|
| 50 | return (HMCreateNamedPipe(lpName,
|
|---|
| 51 | dwOpenMode,
|
|---|
| 52 | dwPipeMode,
|
|---|
| 53 | nMaxInstances,
|
|---|
| 54 | nOutBufferSize,
|
|---|
| 55 | nInBufferSize,
|
|---|
| 56 | nDefaultTimeOut,
|
|---|
| 57 | lpSecurityAttributes));
|
|---|
| 58 |
|
|---|
| 59 | }
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | HANDLE WIN32API CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode,
|
|---|
| 63 | DWORD nMaxInstances, DWORD nOutBufferSize,
|
|---|
| 64 | DWORD nInBufferSize, DWORD nDefaultTimeOut,
|
|---|
| 65 | LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
|---|
| 66 | {
|
|---|
| 67 | char *asciiname;
|
|---|
| 68 | HANDLE hPipe;
|
|---|
| 69 |
|
|---|
| 70 | asciiname = UnicodeToAsciiString((LPWSTR)lpName);
|
|---|
| 71 |
|
|---|
| 72 | hPipe=HMCreateNamedPipe(asciiname,
|
|---|
| 73 | dwOpenMode,
|
|---|
| 74 | dwPipeMode,
|
|---|
| 75 | nMaxInstances,
|
|---|
| 76 | nOutBufferSize,
|
|---|
| 77 | nInBufferSize,
|
|---|
| 78 | nDefaultTimeOut,
|
|---|
| 79 | lpSecurityAttributes);
|
|---|
| 80 |
|
|---|
| 81 | FreeAsciiString(asciiname);
|
|---|
| 82 |
|
|---|
| 83 | return(hPipe);
|
|---|
| 84 | }
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | //******************************************************************************
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | /*****************************************************************************
|
|---|
| 90 | * Name : BOOL WIN32API ConnectNamedPipe
|
|---|
| 91 | * Purpose : The ConnectNamedPipe function enables a named pipe server process
|
|---|
| 92 | * to wait for a client process to connect to an instance of a
|
|---|
| 93 | * named pipe. A client process connects by calling either the
|
|---|
| 94 | * CreateFile or CallNamedPipe function.
|
|---|
| 95 | * Parameters: HANDLE hNamedPipe handle to named pipe to connect
|
|---|
| 96 | * LPOVERLAPPED lpOverlapped pointer to overlapped structure
|
|---|
| 97 | * Variables :
|
|---|
| 98 | * Result : If the function succeeds, the return value is nonzero.
|
|---|
| 99 | * If the function fails, the return value is zero.
|
|---|
| 100 | * To get extended error information, call GetLastError.
|
|---|
| 101 | * Remark :
|
|---|
| 102 | * Status : NOT FULLY TESTED
|
|---|
| 103 | *
|
|---|
| 104 | * Author : Przemyslaw Dobrowolski [Sun, 2000/01/02 12:48]
|
|---|
| 105 | *****************************************************************************/
|
|---|
| 106 | BOOL WIN32API ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
|
|---|
| 107 | {
|
|---|
| 108 | return (HMConnectNamedPipe(hNamedPipe,lpOverlapped));
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | /*****************************************************************************
|
|---|
| 112 | * Name : BOOL WIN32AOI CallNamedPipeA
|
|---|
| 113 | * Purpose : The CallNamedPipe function connects to a message-type pipe
|
|---|
| 114 | * (and waits if an instance of the pipe is not available),
|
|---|
| 115 | * writes to and reads from the pipe, and then closes the pipe.
|
|---|
| 116 | * Parameters: LPCSTR lpNamedPipeName pointer to pipe name
|
|---|
| 117 | * LPVOID lpInBuffer pointer to write buffer
|
|---|
| 118 | * DWORD nInBufferSize size, in bytes, of write buffer
|
|---|
| 119 | * LPVOID lpOutBuffer pointer to read buffer
|
|---|
| 120 | * DWORD nOutBufferSize size, in bytes, of read buffer
|
|---|
| 121 | * LPDWORD lpBytesRead pointer to number of bytes read
|
|---|
| 122 | * DWORD nTimeOut time-out time, in milliseconds
|
|---|
| 123 | * Variables :
|
|---|
| 124 | * Result : If the function succeeds, the return value is nonzero.
|
|---|
| 125 | * If the function fails, the return value is zero.
|
|---|
| 126 | * To get extended error information, call GetLastError.
|
|---|
| 127 | * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile
|
|---|
| 128 | * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately),
|
|---|
| 129 | * TransactNamedPipe, and CloseHandle functions. CreateFile is called
|
|---|
| 130 | * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit
|
|---|
| 131 | * handle flag of FALSE, and a share mode of zero (indicating no
|
|---|
| 132 | * sharing of this pipe instance).
|
|---|
| 133 | * If the message written to the pipe by the server process is
|
|---|
| 134 | * longer than nOutBufferSize, CallNamedPipe returns FALSE, and
|
|---|
| 135 | * GetLastError returns ERROR_MORE_DATA. The remainder of the
|
|---|
| 136 | * message is discarded, because CallNamedPipe closes the handle
|
|---|
| 137 | * to the pipe before returning.
|
|---|
| 138 | *
|
|---|
| 139 | * CallNamedPipe fails if the pipe is a byte-type pipe.
|
|---|
| 140 | * Status : NOT FULLY TESTED
|
|---|
| 141 | *
|
|---|
| 142 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:32]
|
|---|
| 143 | *****************************************************************************/
|
|---|
| 144 |
|
|---|
| 145 | BOOL WIN32API CallNamedPipeA(LPCSTR lpNamedPipeName,
|
|---|
| 146 | LPVOID lpInBuffer,
|
|---|
| 147 | DWORD nInBufferSize,
|
|---|
| 148 | LPVOID lpOutBuffer,
|
|---|
| 149 | DWORD nOutBufferSize,
|
|---|
| 150 | LPDWORD lpBytesRead,
|
|---|
| 151 | DWORD nTimeOut)
|
|---|
| 152 | {
|
|---|
| 153 | return(OSLibDosCallNamedPipe(lpNamedPipeName,
|
|---|
| 154 | lpInBuffer,
|
|---|
| 155 | nInBufferSize,
|
|---|
| 156 | lpOutBuffer,
|
|---|
| 157 | nOutBufferSize,
|
|---|
| 158 | lpBytesRead,
|
|---|
| 159 | nTimeOut ));
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | /*****************************************************************************
|
|---|
| 163 | * Name : BOOL WIN32AOI CallNamedPipeW
|
|---|
| 164 | * Purpose : The CallNamedPipe function connects to a message-type pipe
|
|---|
| 165 | * (and waits if an instance of the pipe is not available),
|
|---|
| 166 | * writes to and reads from the pipe, and then closes the pipe.
|
|---|
| 167 | * Parameters: LPCWSTR lpNamedPipeName pointer to pipe name
|
|---|
| 168 | * LPVOID lpInBuffer pointer to write buffer
|
|---|
| 169 | * DWORD nInBufferSize size, in bytes, of write buffer
|
|---|
| 170 | * LPVOID lpOutBuffer pointer to read buffer
|
|---|
| 171 | * DWORD nOutBufferSize size, in bytes, of read buffer
|
|---|
| 172 | * LPDWORD lpBytesRead pointer to number of bytes read
|
|---|
| 173 | * DWORD nTimeOut time-out time, in milliseconds
|
|---|
| 174 | * Variables :
|
|---|
| 175 | * Result : If the function succeeds, the return value is nonzero.
|
|---|
| 176 | * If the function fails, the return value is zero.
|
|---|
| 177 | * To get extended error information, call GetLastError.
|
|---|
| 178 | * Remark : Calling CallNamedPipe is equivalent to calling the CreateFile
|
|---|
| 179 | * (or WaitNamedPipe, if CreateFile cannot open the pipe immediately),
|
|---|
| 180 | * TransactNamedPipe, and CloseHandle functions. CreateFile is called
|
|---|
| 181 | * with an access flag of GENERIC_READ | GENERIC_WRITE, an inherit
|
|---|
| 182 | * handle flag of FALSE, and a share mode of zero (indicating no
|
|---|
| 183 | * sharing of this pipe instance).
|
|---|
| 184 | * If the message written to the pipe by the server process is
|
|---|
| 185 | * longer than nOutBufferSize, CallNamedPipe returns FALSE, and
|
|---|
| 186 | * GetLastError returns ERROR_MORE_DATA. The remainder of the
|
|---|
| 187 | * message is discarded, because CallNamedPipe closes the handle
|
|---|
| 188 | * to the pipe before returning.
|
|---|
| 189 | *
|
|---|
| 190 | * CallNamedPipe fails if the pipe is a byte-type pipe.
|
|---|
| 191 | * Status : NOT FULLY TESTED
|
|---|
| 192 | *
|
|---|
| 193 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:33]
|
|---|
| 194 | *****************************************************************************/
|
|---|
| 195 | BOOL WIN32API CallNamedPipeW(LPCWSTR lpNamedPipeName,
|
|---|
| 196 | LPVOID lpInBuffer,
|
|---|
| 197 | DWORD nInBufferSize,
|
|---|
| 198 | LPVOID lpOutBuffer,
|
|---|
| 199 | DWORD nOutBufferSize,
|
|---|
| 200 | LPDWORD lpBytesRead,
|
|---|
| 201 | DWORD nTimeOut)
|
|---|
| 202 | {
|
|---|
| 203 | char *asciiname;
|
|---|
| 204 | BOOL rc;
|
|---|
| 205 |
|
|---|
| 206 | asciiname = UnicodeToAsciiString((LPWSTR)lpNamedPipeName);
|
|---|
| 207 |
|
|---|
| 208 | rc=OSLibDosCallNamedPipe(asciiname,
|
|---|
| 209 | lpInBuffer,
|
|---|
| 210 | nInBufferSize,
|
|---|
| 211 | lpOutBuffer,
|
|---|
| 212 | nOutBufferSize,
|
|---|
| 213 | lpBytesRead,
|
|---|
| 214 | nTimeOut );
|
|---|
| 215 |
|
|---|
| 216 | FreeAsciiString(asciiname);
|
|---|
| 217 |
|
|---|
| 218 | return(rc);
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | /*****************************************************************************
|
|---|
| 222 | * Name : BOOL WIN32API DisconnectNamedPipe
|
|---|
| 223 | * Purpose : The DisconnectNamedPipe function disconnects the server end
|
|---|
| 224 | * of a named pipe instance from a client process.
|
|---|
| 225 | * Parameters: HANDLE hNamedPipe handle to named pipe
|
|---|
| 226 | * Variables :
|
|---|
| 227 | * Result : If the function succeeds, the return value is nonzero.
|
|---|
| 228 | * If the function fails, the return value is zero
|
|---|
| 229 | * Remark :
|
|---|
| 230 | * Status : NOT FULLY TESTED
|
|---|
| 231 | *
|
|---|
| 232 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:34]
|
|---|
| 233 | *****************************************************************************/
|
|---|
| 234 |
|
|---|
| 235 | BOOL WIN32API DisconnectNamedPipe(HANDLE hNamedPipe)
|
|---|
| 236 | {
|
|---|
| 237 | return (HMDisconnectNamedPipe(hNamedPipe));
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | /*****************************************************************************
|
|---|
| 241 | * Name : BOOL GetNamedPipeHandleStateA
|
|---|
| 242 | * Purpose : The GetNamedPipeHandleStateA function retrieves information about
|
|---|
| 243 | * a specified named pipe. The information returned can vary during
|
|---|
| 244 | * the lifetime of an instance of the named pipe.
|
|---|
| 245 | * Parameters: HANDLE hNamedPipe handle of named pipe
|
|---|
| 246 | * LPDWORD lpState address of flags indicating pipe state
|
|---|
| 247 | * LPDWORD lpCurInstances address of number of current pipe instances
|
|---|
| 248 | * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission
|
|---|
| 249 | * LPDWORD lpCollectDataTimeout address of max. time before remote transmission
|
|---|
| 250 | * LPTSTR lpUserName address of user name of client process
|
|---|
| 251 | * DWORD nMaxUserNameSize size, in characters, of user name buffer
|
|---|
| 252 | * Variables :
|
|---|
| 253 | * Result : TRUE / FALSE
|
|---|
| 254 | * Remark :
|
|---|
| 255 | * Status : UNTESTED STUB
|
|---|
| 256 | *
|
|---|
| 257 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 258 | *****************************************************************************/
|
|---|
| 259 |
|
|---|
| 260 | BOOL WIN32API GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
|---|
| 261 | LPDWORD lpState,
|
|---|
| 262 | LPDWORD lpCurInstances,
|
|---|
| 263 | LPDWORD lpMaxCollectionCount,
|
|---|
| 264 | LPDWORD lpCollectDataTimeout,
|
|---|
| 265 | LPTSTR lpUserName,
|
|---|
| 266 | DWORD nMaxUserNameSize)
|
|---|
| 267 | {
|
|---|
| 268 | // Not implemented but waiting to implementation in hmnpipe.cpp
|
|---|
| 269 | return ( HMGetNamedPipeHandleState( hNamedPipe,
|
|---|
| 270 | lpState,
|
|---|
| 271 | lpCurInstances,
|
|---|
| 272 | lpMaxCollectionCount,
|
|---|
| 273 | lpCollectDataTimeout,
|
|---|
| 274 | lpUserName,
|
|---|
| 275 | nMaxUserNameSize));
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | /*****************************************************************************
|
|---|
| 280 | * Name : BOOL GetNamedPipeHandleStateW
|
|---|
| 281 | * Purpose : The GetNamedPipeHandleStateW function retrieves information about
|
|---|
| 282 | * a specified named pipe. The information returned can vary during
|
|---|
| 283 | * the lifetime of an instance of the named pipe.
|
|---|
| 284 | * Parameters: HANDLE hNamedPipe handle of named pipe
|
|---|
| 285 | * LPDWORD lpState address of flags indicating pipe state
|
|---|
| 286 | * LPDWORD lpCurInstances address of number of current pipe instances
|
|---|
| 287 | * LPDWORD lpMaxCollectionCount address of max. bytes before remote transmission
|
|---|
| 288 | * LPDWORD lpCollectDataTimeout address of max. time before remote transmission
|
|---|
| 289 | * LPWSTR lpUserName address of user name of client process
|
|---|
| 290 | * DWORD nMaxUserNameSize size, in characters, of user name buffer
|
|---|
| 291 | * Variables :
|
|---|
| 292 | * Result : TRUE / FALSE
|
|---|
| 293 | * Remark :
|
|---|
| 294 | * Status : UNTESTED STUB
|
|---|
| 295 | *
|
|---|
| 296 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 297 | *****************************************************************************/
|
|---|
| 298 |
|
|---|
| 299 | BOOL WIN32API GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
|---|
| 300 | LPDWORD lpState,
|
|---|
| 301 | LPDWORD lpCurInstances,
|
|---|
| 302 | LPDWORD lpMaxCollectionCount,
|
|---|
| 303 | LPDWORD lpCollectDataTimeout,
|
|---|
| 304 | LPWSTR lpUserName,
|
|---|
| 305 | DWORD nMaxUserNameSize)
|
|---|
| 306 | {
|
|---|
| 307 | char *asciiname;
|
|---|
| 308 | BOOL rc;
|
|---|
| 309 |
|
|---|
| 310 | asciiname = UnicodeToAsciiString((LPWSTR)lpUserName);
|
|---|
| 311 |
|
|---|
| 312 | // Not implemented but waiting to implementation in hmnpipe.cpp
|
|---|
| 313 | rc= HMGetNamedPipeHandleState( hNamedPipe,
|
|---|
| 314 | lpState,
|
|---|
| 315 | lpCurInstances,
|
|---|
| 316 | lpMaxCollectionCount,
|
|---|
| 317 | lpCollectDataTimeout,
|
|---|
| 318 | asciiname,
|
|---|
| 319 | nMaxUserNameSize);
|
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 | FreeAsciiString(asciiname);
|
|---|
| 323 |
|
|---|
| 324 | return (rc);
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 | /*****************************************************************************
|
|---|
| 329 | * Name : BOOL GetNamedPipeInfo
|
|---|
| 330 | * Purpose : The GetNamedPipeInfo function retrieves information about the specified named pipe.
|
|---|
| 331 | * Parameters: HANDLE hNamedPipe handle of named pipe
|
|---|
| 332 | * LPDWORD lpFlags address of flags indicating type of pipe
|
|---|
| 333 | * LPDWORD lpOutBufferSize address of size, in bytes, of pipe's output buffer
|
|---|
| 334 | * LPDWORD lpInBufferSize address of size, in bytes, of pipe's input buffer
|
|---|
| 335 | * LPDWORD lpMaxInstances address of max. number of pipe instances
|
|---|
| 336 | * Variables :
|
|---|
| 337 | * Result : TRUE / FALSE
|
|---|
| 338 | * Remark :
|
|---|
| 339 | * Status : UNTESTED STUB
|
|---|
| 340 | *
|
|---|
| 341 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 342 | *****************************************************************************/
|
|---|
| 343 |
|
|---|
| 344 | BOOL WIN32API GetNamedPipeInfo(HANDLE hNamedPipe,
|
|---|
| 345 | LPDWORD lpFlags,
|
|---|
| 346 | LPDWORD lpOutBufferSize,
|
|---|
| 347 | LPDWORD lpInBufferSize,
|
|---|
| 348 | LPDWORD lpMaxInstances)
|
|---|
| 349 | {
|
|---|
| 350 | // Not implemented but waiting to implementation in hmnpipe.cpp
|
|---|
| 351 | return ( HMGetNamedPipeInfo( hNamedPipe,
|
|---|
| 352 | lpFlags,
|
|---|
| 353 | lpOutBufferSize,
|
|---|
| 354 | lpInBufferSize,
|
|---|
| 355 | lpMaxInstances));
|
|---|
| 356 |
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | /*****************************************************************************
|
|---|
| 360 | * Name : BOOL SetNamedPipeHandleState
|
|---|
| 361 | * Purpose : The SetNamedPipeHandleState function sets the read mode and the
|
|---|
| 362 | * blocking mode of the specified named pipe. If the specified handle
|
|---|
| 363 | * is to the client end of a named pipe and if the named pipe server
|
|---|
| 364 | * process is on a remote computer, the function can also be used to
|
|---|
| 365 | * control local buffering.
|
|---|
| 366 | * Parameters: HANDLE hNamedPipe handle of named pipe
|
|---|
| 367 | * LPDWORD lpdwMode address of new pipe mode
|
|---|
| 368 | * LPDWORD lpcbMaxCollect address of max. bytes before remote transmission
|
|---|
| 369 | * LPDWORD lpdwCollectDataTimeout address of max. time before remote transmission
|
|---|
| 370 | * Variables :
|
|---|
| 371 | * Result : TRUE / FALSE
|
|---|
| 372 | * Remark :
|
|---|
| 373 | * Status : UNTESTED STUB
|
|---|
| 374 | *
|
|---|
| 375 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 376 | *****************************************************************************/
|
|---|
| 377 |
|
|---|
| 378 | BOOL WIN32API SetNamedPipeHandleState(HANDLE hNamedPipe,
|
|---|
| 379 | LPDWORD lpdwMode,
|
|---|
| 380 | LPDWORD lpcbMaxCollect,
|
|---|
| 381 | LPDWORD lpdwCollectDataTimeout)
|
|---|
| 382 | {
|
|---|
| 383 | // Not implemented but waiting to implementation in hmnpipe.cpp
|
|---|
| 384 | return ( HMSetNamedPipeHandleState( hNamedPipe,
|
|---|
| 385 | lpdwMode,
|
|---|
| 386 | lpcbMaxCollect,
|
|---|
| 387 | lpdwCollectDataTimeout));
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | /*****************************************************************************
|
|---|
| 391 | * Name : DWORD TransactNamedPipe
|
|---|
| 392 | * Purpose : The TransactNamedPipe function combines into a single network
|
|---|
| 393 | * operation the functions that write a message to and read a
|
|---|
| 394 | * message from the specified named pipe.
|
|---|
| 395 | * Parameters: HANDLE hNamedPipe handle of named pipe
|
|---|
| 396 | * LPVOID lpvWriteBuf address of write buffer
|
|---|
| 397 | * DWORD cbWriteBuf size of the write buffer, in bytes
|
|---|
| 398 | * LPVOID lpvReadBuf address of read buffer
|
|---|
| 399 | * DWORD cbReadBuf size of read buffer, in bytes
|
|---|
| 400 | * LPDWORD lpcbRead address of variable for bytes actually read
|
|---|
| 401 | * LPOVERLAPPED lpo address of overlapped structure
|
|---|
| 402 | * Variables :
|
|---|
| 403 | * Result : TRUE / FALSE
|
|---|
| 404 | * Remark :
|
|---|
| 405 | * Status : NOT FULLY TESTED (YET!)
|
|---|
| 406 | *
|
|---|
| 407 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 08:48]
|
|---|
| 408 | *****************************************************************************/
|
|---|
| 409 |
|
|---|
| 410 | DWORD WIN32API TransactNamedPipe(HANDLE hNamedPipe,
|
|---|
| 411 | LPVOID lpvWriteBuf,
|
|---|
| 412 | DWORD cbWriteBuf,
|
|---|
| 413 | LPVOID lpvReadBuf,
|
|---|
| 414 | DWORD cbReadBuf,
|
|---|
| 415 | LPDWORD lpcbRead,
|
|---|
| 416 | LPOVERLAPPED lpo)
|
|---|
| 417 | {
|
|---|
| 418 | return(HMTransactNamedPipe( hNamedPipe,
|
|---|
| 419 | lpvWriteBuf,
|
|---|
| 420 | cbWriteBuf,
|
|---|
| 421 | lpvReadBuf,
|
|---|
| 422 | cbReadBuf,
|
|---|
| 423 | lpcbRead,
|
|---|
| 424 | lpo));
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| 427 | /*****************************************************************************
|
|---|
| 428 | * Name : BOOL WaitNamedPipeA
|
|---|
| 429 | * Purpose : The WaitNamedPipe function waits until either a time-out interval
|
|---|
| 430 | * elapses or an instance of the specified named pipe is available
|
|---|
| 431 | * to be connected to (that is, the pipe's server process has a
|
|---|
| 432 | * pending ConnectNamedPipe operation on the pipe).
|
|---|
| 433 | * Parameters: LPCTSTR lpszNamedPipeName
|
|---|
| 434 | * DWORD dwTimeout
|
|---|
| 435 | * Variables :
|
|---|
| 436 | * Result : TRUE / FALSE
|
|---|
| 437 | * Remark :
|
|---|
| 438 | * Status : UNTESTED (YET)
|
|---|
| 439 | *
|
|---|
| 440 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:52]
|
|---|
| 441 | *****************************************************************************/
|
|---|
| 442 |
|
|---|
| 443 | BOOL WIN32API WaitNamedPipeA(LPCSTR lpszNamedPipeName, DWORD dwTimeout)
|
|---|
| 444 | {
|
|---|
| 445 | return(OSLibDosWaitNamedPipe(lpszNamedPipeName, dwTimeout));
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 | /*****************************************************************************
|
|---|
| 450 | * Name : BOOL WaitNamedPipeW
|
|---|
| 451 | * Purpose : The WaitNamedPipe function waits until either a time-out interval
|
|---|
| 452 | * elapses or an instance of the specified named pipe is available
|
|---|
| 453 | * to be connected to (that is, the pipe's server process has a
|
|---|
| 454 | * pending ConnectNamedPipe operation on the pipe).
|
|---|
| 455 | * Parameters: LPCWSTR lpszNamedPipeName
|
|---|
| 456 | * DWORD dwTimeout
|
|---|
| 457 | * Variables :
|
|---|
| 458 | * Result : TRUE / FALSE
|
|---|
| 459 | * Remark :
|
|---|
| 460 | * Status : UNTESTED (YET)
|
|---|
| 461 | *
|
|---|
| 462 | * Author : Przemyslaw Dobrowolski [Mon, 2000/01/03 13:44]
|
|---|
| 463 | *****************************************************************************/
|
|---|
| 464 |
|
|---|
| 465 | BOOL WIN32API WaitNamedPipeW(LPCWSTR lpszNamedPipeName, DWORD dwTimeout)
|
|---|
| 466 | {
|
|---|
| 467 | char *asciiname;
|
|---|
| 468 | DWORD rc;
|
|---|
| 469 |
|
|---|
| 470 | asciiname = UnicodeToAsciiString((LPWSTR)lpszNamedPipeName);
|
|---|
| 471 |
|
|---|
| 472 | rc=OSLibDosWaitNamedPipe(asciiname, dwTimeout);
|
|---|
| 473 |
|
|---|
| 474 | FreeAsciiString(asciiname);
|
|---|
| 475 |
|
|---|
| 476 | return(rc);
|
|---|
| 477 | }
|
|---|