aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/buffutil.h115
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/dlutil.h1
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/dutil.h7
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h115
4 files changed, 232 insertions, 6 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h b/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h
index 322209e6..116b67bd 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/buffutil.h
@@ -9,9 +9,35 @@ extern "C" {
9 9
10// macro definitions 10// macro definitions
11 11
12#define ReleaseBuffer ReleaseMem 12#define ReleaseBuffer(b) BuffFree(b)
13#define ReleaseNullBuffer ReleaseNullMem 13#define ReleaseNullBuffer(b) BuffFree(b)
14#define BuffFree MemFree 14#define BuffFree(b) if (b.pbData) { MemFree(b.pbData); b.pbData = NULL; } b.cbData = 0
15
16
17// structs
18
19// A buffer that owns its data and must be freed with BuffFree().
20typedef struct _BUFF_BUFFER
21{
22 LPBYTE pbData;
23 SIZE_T cbData;
24} BUFF_BUFFER;
25
26// A read-only buffer with internal pointer that can be advanced for multiple reads.
27typedef struct _BUFF_READER
28{
29 LPCBYTE pbData;
30 SIZE_T cbData;
31
32 SIZE_T iBuffer;
33} BUFF_READER;
34
35// A write buffer that does not own its data.
36typedef struct _BUFF_WRITER
37{
38 LPBYTE *ppbData;
39 SIZE_T *pcbData;
40} BUFF_WRITER;
15 41
16 42
17// function declarations 43// function declarations
@@ -53,6 +79,37 @@ HRESULT BuffReadStream(
53 __deref_inout_bcount(*pcbStream) BYTE** ppbStream, 79 __deref_inout_bcount(*pcbStream) BYTE** ppbStream,
54 __out SIZE_T* pcbStream 80 __out SIZE_T* pcbStream
55 ); 81 );
82HRESULT BuffSkipExtraData(
83 __in SIZE_T cbExpectedSize,
84 __in SIZE_T cbActualSize,
85 __inout SIZE_T* piBuffer
86 );
87
88HRESULT BuffReaderReadNumber(
89 __in BUFF_READER* pReader,
90 __out DWORD* pdw
91 );
92HRESULT BuffReaderReadNumber64(
93 __in BUFF_READER* pReader,
94 __out DWORD64* pdw64
95 );
96HRESULT BuffReaderReadPointer(
97 __in BUFF_READER* pReader,
98 __out DWORD_PTR* pdw
99);
100HRESULT BuffReaderReadString(
101 __in BUFF_READER* pReader,
102 __deref_out_z LPWSTR* pscz
103 );
104HRESULT BuffReaderReadStringAnsi(
105 __in BUFF_READER* pReader,
106 __deref_out_z LPSTR* pscz
107 );
108HRESULT BuffReaderReadStream(
109 __in BUFF_READER* pReader,
110 __deref_inout_bcount(*pcbStream) BYTE** ppbStream,
111 __out SIZE_T* pcbStream
112 );
56 113
57HRESULT BuffWriteNumber( 114HRESULT BuffWriteNumber(
58 __deref_inout_bcount(*piBuffer) BYTE** ppbBuffer, 115 __deref_inout_bcount(*piBuffer) BYTE** ppbBuffer,
@@ -86,6 +143,58 @@ HRESULT BuffWriteStream(
86 __in SIZE_T cbStream 143 __in SIZE_T cbStream
87 ); 144 );
88 145
146HRESULT BuffWriteNumberToBuffer(
147 __in BUFF_BUFFER* pBuffer,
148 __in DWORD dw
149 );
150HRESULT BuffWriteNumber64ToBuffer(
151 __in BUFF_BUFFER* pBuffer,
152 __in DWORD64 dw64
153 );
154HRESULT BuffWritePointerToBuffer(
155 __in BUFF_BUFFER* pBuffer,
156 __in DWORD_PTR dw
157 );
158HRESULT BuffWriteStringToBuffer(
159 __in BUFF_BUFFER* pBuffer,
160 __in_z_opt LPCWSTR scz
161 );
162HRESULT BuffWriteStringAnsiToBuffer(
163 __in BUFF_BUFFER* pBuffer,
164 __in_z_opt LPCSTR scz
165 );
166HRESULT BuffWriteStreamToBuffer(
167 __in BUFF_BUFFER* pBuffer,
168 __in_bcount(cbStream) const BYTE* pbStream,
169 __in SIZE_T cbStream
170 );
171
172HRESULT BuffWriterWriteNumber(
173 __in BUFF_WRITER* pWriter,
174 __in DWORD dw
175 );
176HRESULT BuffWriterWriteNumber64(
177 __in BUFF_WRITER* pWriter,
178 __in DWORD64 dw64
179 );
180HRESULT BuffWriterWritePointer(
181 __in BUFF_WRITER* pWriter,
182 __in DWORD_PTR dw
183 );
184HRESULT BuffWriterWriteString(
185 __in BUFF_WRITER* pWriter,
186 __in_z_opt LPCWSTR scz
187 );
188HRESULT BuffWriterWriteStringAnsi(
189 __in BUFF_WRITER* pWriter,
190 __in_z_opt LPCSTR scz
191 );
192HRESULT BuffWriterWriteStream(
193 __in BUFF_WRITER* pWriter,
194 __in_bcount(cbStream) const BYTE* pbStream,
195 __in SIZE_T cbStream
196 );
197
89#ifdef __cplusplus 198#ifdef __cplusplus
90} 199}
91#endif 200#endif
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/dlutil.h b/src/libs/dutil/WixToolset.DUtil/inc/dlutil.h
index 3e95103a..912c2732 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/dlutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/dlutil.h
@@ -27,6 +27,7 @@ typedef struct _DOWNLOAD_SOURCE
27 LPWSTR sczUrl; 27 LPWSTR sczUrl;
28 LPWSTR sczUser; 28 LPWSTR sczUser;
29 LPWSTR sczPassword; 29 LPWSTR sczPassword;
30 LPWSTR sczAuthorizationHeader;
30} DOWNLOAD_SOURCE; 31} DOWNLOAD_SOURCE;
31 32
32typedef struct _DOWNLOAD_CACHE_CALLBACK 33typedef struct _DOWNLOAD_CACHE_CALLBACK
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/dutil.h b/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
index 4a172f46..7d8c7d81 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/dutil.h
@@ -41,6 +41,13 @@ HRESULT DAPI DutilInitialize(
41*******************************************************************/ 41*******************************************************************/
42void DAPI DutilUninitialize(); 42void DAPI DutilUninitialize();
43 43
44/*******************************************************************
45 DutilSizetToDword - safely convert SIZE_T to DWORD.
46
47 Returns
48 E_INVALIDARG - If SIZE_T value is greater than DWORD_MAX.
49********************************************************************/
50HRESULT DAPI DutilSizetToDword(SIZE_T sizet, DWORD* pdw);
44 51
45/******************************************************************** 52/********************************************************************
46 DutilSuppressTraceErrorSource - tells dutil to skip calling 53 DutilSuppressTraceErrorSource - tells dutil to skip calling
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h b/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h
index d16d768c..e92462d2 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/pipeutil.h
@@ -6,7 +6,9 @@
6extern "C" { 6extern "C" {
7#endif 7#endif
8 8
9#define ReleasePipeHandle(h) if (h != INVALID_HANDLE_VALUE) { ::CloseHandle(h); } 9// macro definitions
10
11#define ReleasePipeHandle(h) if (h != INVALID_HANDLE_VALUE) { ::CloseHandle(h); h = INVALID_HANDLE_VALUE; }
10#define ReleasePipeMessage(pMsg) if (pMsg) { PipeFreeMessage(pMsg); } 12#define ReleasePipeMessage(pMsg) if (pMsg) { PipeFreeMessage(pMsg); }
11 13
12 14
@@ -27,6 +29,23 @@ typedef struct _PIPE_MESSAGE
27 LPVOID pvData; 29 LPVOID pvData;
28} PIPE_MESSAGE; 30} PIPE_MESSAGE;
29 31
32typedef struct _PIPE_RPC_HANDLE
33{
34 HANDLE hPipe;
35 CRITICAL_SECTION cs;
36
37 BOOL fInitialized;
38 BOOL fOwnHandle;
39} PIPE_RPC_HANDLE;
40
41typedef struct _PIPE_RPC_RESULT
42{
43 HRESULT hr;
44
45 DWORD cbData;
46 LPBYTE pbData;
47} PIPE_RPC_RESULT;
48
30 49
31// functions 50// functions
32 51
@@ -72,17 +91,87 @@ DAPI_(HRESULT) PipeReadMessage(
72); 91);
73 92
74/******************************************************************* 93/*******************************************************************
75 PipeWriteMessage - writes a message to the pipe. 94 PipeRpcInitiailize - initializes a RPC pipe handle from a pipe handle.
76 95
77*******************************************************************/ 96*******************************************************************/
78DAPI_(HRESULT) PipeWriteMessage( 97DAPI_(void) PipeRpcInitialize(
98 __in PIPE_RPC_HANDLE* phRpcPipe,
79 __in HANDLE hPipe, 99 __in HANDLE hPipe,
100 __in BOOL fTakeHandleOwnership
101);
102
103/*******************************************************************
104 PipeRpcInitialized - checks if a RPC pipe handle is initialized.
105
106*******************************************************************/
107DAPI_(BOOL) PipeRpcInitialized(
108 __in PIPE_RPC_HANDLE* phRpcPipe
109);
110
111/*******************************************************************
112 PipeRpcUninitiailize - uninitializes a RPC pipe handle.
113
114*******************************************************************/
115DAPI_(void) PipeRpcUninitiailize(
116 __in PIPE_RPC_HANDLE* phRpcPipe
117);
118
119/*******************************************************************
120 PipeRpcReadMessage - reads a message from the pipe. Free with
121 PipeFreeMessage().
122
123*******************************************************************/
124DAPI_(HRESULT) PipeRpcReadMessage(
125 __in PIPE_RPC_HANDLE* phRpcPipe,
126 __in PIPE_MESSAGE* pMsg
127);
128
129/*******************************************************************
130 PipeRpcRequest - sends message and reads a response over the pipe.
131 Free with PipeFreeRpcResult().
132
133*******************************************************************/
134DAPI_(HRESULT) PipeRpcRequest(
135 __in PIPE_RPC_HANDLE* phRpcPipe,
136 __in DWORD dwMessageType,
137 __in_bcount(cbArgs) LPVOID pbArgs,
138 __in SIZE_T cbArgs,
139 __in PIPE_RPC_RESULT* pResult
140);
141
142/*******************************************************************
143 PipeRpcResponse - sends response over the pipe.
144
145*******************************************************************/
146DAPI_(HRESULT) PipeRpcResponse(
147 __in PIPE_RPC_HANDLE* phPipe,
148 __in DWORD dwMessageType,
149 __in HRESULT hrResult,
150 __in_bcount(cbResult) LPVOID pvResult,
151 __in SIZE_T cbResult
152 );
153
154/*******************************************************************
155 PipeRpcWriteMessage - writes a message to the pipe.
156
157*******************************************************************/
158DAPI_(HRESULT) PipeRpcWriteMessage(
159 __in PIPE_RPC_HANDLE* phPipe,
80 __in DWORD dwMessageType, 160 __in DWORD dwMessageType,
81 __in_bcount_opt(cbData) LPVOID pvData, 161 __in_bcount_opt(cbData) LPVOID pvData,
82 __in SIZE_T cbData 162 __in SIZE_T cbData
83); 163);
84 164
85/******************************************************************* 165/*******************************************************************
166 PipeWriteDisconnect - writes a message to the pipe indicating the
167 client should disconnect.
168
169*******************************************************************/
170DAPI_(HRESULT) PipeWriteDisconnect(
171 __in HANDLE hPipe
172 );
173
174/*******************************************************************
86 PipeFreeMessage - frees any memory allocated in PipeReadMessage. 175 PipeFreeMessage - frees any memory allocated in PipeReadMessage.
87 176
88*******************************************************************/ 177*******************************************************************/
@@ -91,14 +180,34 @@ DAPI_(void) PipeFreeMessage(
91); 180);
92 181
93/******************************************************************* 182/*******************************************************************
183 PipeFreeRpcResult - frees any memory allocated in PipeRpcRequest.
184
185*******************************************************************/
186DAPI_(void) PipeFreeRpcResult(
187 __in PIPE_RPC_RESULT* pResult
188);
189
190/*******************************************************************
94 PipeServerWaitForClientConnect - Called from the server process to 191 PipeServerWaitForClientConnect - Called from the server process to
95 wait for a client to connect back to the provided pipe. 192 wait for a client to connect back to the provided pipe.
96 193
97*******************************************************************/ 194*******************************************************************/
98DAPI_(HRESULT) PipeServerWaitForClientConnect( 195DAPI_(HRESULT) PipeServerWaitForClientConnect(
196 __in HANDLE hClientProcess,
99 __in HANDLE hPipe 197 __in HANDLE hPipe
100); 198);
101 199
200/*******************************************************************
201 PipeWriteMessage - writes a message to the pipe.
202
203*******************************************************************/
204DAPI_(HRESULT) PipeWriteMessage(
205 __in HANDLE hPipe,
206 __in DWORD dwMessageType,
207 __in_bcount_opt(cbData) LPVOID pvData,
208 __in SIZE_T cbData
209);
210
102#ifdef __cplusplus 211#ifdef __cplusplus
103} 212}
104#endif 213#endif