aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-01-10 23:53:18 -0800
committerRob Mensching <rob@firegiant.com>2024-01-11 18:24:06 -0800
commit4e7b7c0059d76498d1c24f348dbf6d5799203fe0 (patch)
tree1b00606cee7fd54ca4e07aa7b550fe63982220b3 /src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h
parent57b7689b2dc5e971911d1c6d48eebb5424ebca89 (diff)
downloadwix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.tar.gz
wix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.tar.bz2
wix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.zip
Add pipeutil to dutil
Plus a couple small clean-ups in a couple of dutil files.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h104
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
6extern "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
15static const DWORD PIPE_WAIT_FOR_CONNECTION = 100; // wait a 10th of a second,
16static const DWORD PIPE_RETRY_FOR_CONNECTION = 1800; // for up to 3 minutes.
17
18
19// structs
20
21typedef 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*******************************************************************/
38DAPI_(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*******************************************************************/
48DAPI_(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*******************************************************************/
59DAPI_(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*******************************************************************/
69DAPI_(HRESULT) PipeReadMessage(
70 __in HANDLE hPipe,
71 __in PIPE_MESSAGE* pMsg
72);
73
74/*******************************************************************
75 PipeWriteMessage - writes a message to the pipe.
76
77*******************************************************************/
78DAPI_(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*******************************************************************/
89DAPI_(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*******************************************************************/
98DAPI_(HRESULT) PipeServerWaitForClientConnect(
99 __in HANDLE hPipe
100);
101
102#ifdef __cplusplus
103}
104#endif