diff options
Diffstat (limited to '')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h b/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h new file mode 100644 index 00000000..d16d768c --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | #pragma once | ||
| 2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 3 | |||
| 4 | |||
| 5 | #ifdef __cplusplus | ||
| 6 | extern "C" { | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #define ReleasePipeHandle(h) if (h != INVALID_HANDLE_VALUE) { ::CloseHandle(h); } | ||
| 10 | #define ReleasePipeMessage(pMsg) if (pMsg) { PipeFreeMessage(pMsg); } | ||
| 11 | |||
| 12 | |||
| 13 | // constants | ||
| 14 | |||
| 15 | static const DWORD PIPE_WAIT_FOR_CONNECTION = 100; // wait a 10th of a second, | ||
| 16 | static const DWORD PIPE_RETRY_FOR_CONNECTION = 1800; // for up to 3 minutes. | ||
| 17 | |||
| 18 | |||
| 19 | // structs | ||
| 20 | |||
| 21 | typedef struct _PIPE_MESSAGE | ||
| 22 | { | ||
| 23 | DWORD dwMessageType; | ||
| 24 | DWORD cbData; | ||
| 25 | |||
| 26 | BOOL fAllocatedData; | ||
| 27 | LPVOID pvData; | ||
| 28 | } PIPE_MESSAGE; | ||
| 29 | |||
| 30 | |||
| 31 | // functions | ||
| 32 | |||
| 33 | /******************************************************************* | ||
| 34 | PipeClientConnect - Called from the client process to connect back | ||
| 35 | to the pipe provided by the server process. | ||
| 36 | |||
| 37 | *******************************************************************/ | ||
| 38 | DAPI_(HRESULT) PipeClientConnect( | ||
| 39 | __in_z LPCWSTR wzPipeName, | ||
| 40 | __out HANDLE* phPipe | ||
| 41 | ); | ||
| 42 | |||
| 43 | /******************************************************************* | ||
| 44 | PipeCreate - create a duplex byte-mode named pipe compatible for use | ||
| 45 | with the other pipeutil functions. | ||
| 46 | |||
| 47 | *******************************************************************/ | ||
| 48 | DAPI_(HRESULT) PipeCreate( | ||
| 49 | __in LPCWSTR wzName, | ||
| 50 | __in_opt LPSECURITY_ATTRIBUTES psa, | ||
| 51 | __out HANDLE* phPipe | ||
| 52 | ); | ||
| 53 | |||
| 54 | /******************************************************************* | ||
| 55 | PipeOpen - opens an exist named pipe compatible for use with the other | ||
| 56 | pipeutil functions. | ||
| 57 | |||
| 58 | *******************************************************************/ | ||
| 59 | DAPI_(HRESULT) PipeOpen( | ||
| 60 | __in_z LPCWSTR wzName, | ||
| 61 | __out HANDLE* phPipe | ||
| 62 | ); | ||
| 63 | |||
| 64 | /******************************************************************* | ||
| 65 | PipeReadMessage - reads a message from the pipe. Free with | ||
| 66 | PipeFreeMessage(). | ||
| 67 | |||
| 68 | *******************************************************************/ | ||
| 69 | DAPI_(HRESULT) PipeReadMessage( | ||
| 70 | __in HANDLE hPipe, | ||
| 71 | __in PIPE_MESSAGE* pMsg | ||
| 72 | ); | ||
| 73 | |||
| 74 | /******************************************************************* | ||
| 75 | PipeWriteMessage - writes a message to the pipe. | ||
| 76 | |||
| 77 | *******************************************************************/ | ||
| 78 | DAPI_(HRESULT) PipeWriteMessage( | ||
| 79 | __in HANDLE hPipe, | ||
| 80 | __in DWORD dwMessageType, | ||
| 81 | __in_bcount_opt(cbData) LPVOID pvData, | ||
| 82 | __in SIZE_T cbData | ||
| 83 | ); | ||
| 84 | |||
| 85 | /******************************************************************* | ||
| 86 | PipeFreeMessage - frees any memory allocated in PipeReadMessage. | ||
| 87 | |||
| 88 | *******************************************************************/ | ||
| 89 | DAPI_(void) PipeFreeMessage( | ||
| 90 | __in PIPE_MESSAGE* pMsg | ||
| 91 | ); | ||
| 92 | |||
| 93 | /******************************************************************* | ||
| 94 | PipeServerWaitForClientConnect - Called from the server process to | ||
| 95 | wait for a client to connect back to the provided pipe. | ||
| 96 | |||
| 97 | *******************************************************************/ | ||
| 98 | DAPI_(HRESULT) PipeServerWaitForClientConnect( | ||
| 99 | __in HANDLE hPipe | ||
| 100 | ); | ||
| 101 | |||
| 102 | #ifdef __cplusplus | ||
| 103 | } | ||
| 104 | #endif | ||
