aboutsummaryrefslogtreecommitdiff
path: root/src/wcautil/inc
diff options
context:
space:
mode:
authorSean Hall <rseanhall@gmail.com>2017-09-03 17:25:02 -0500
committerSean Hall <rseanhall@gmail.com>2017-09-03 18:10:41 -0500
commit7df142a4586bcede1442feb38029ff15556ccb46 (patch)
tree4a52b55f2f0ff7bd511bd01cf08b67479d64cd76 /src/wcautil/inc
parenta3073f2da5160b71dc4b89fd6c4cef1008521aa4 (diff)
downloadwix-7df142a4586bcede1442feb38029ff15556ccb46.tar.gz
wix-7df142a4586bcede1442feb38029ff15556ccb46.tar.bz2
wix-7df142a4586bcede1442feb38029ff15556ccb46.zip
Initialize repo
Diffstat (limited to 'src/wcautil/inc')
-rw-r--r--src/wcautil/inc/wcalog.h14
-rw-r--r--src/wcautil/inc/wcautil.h384
-rw-r--r--src/wcautil/inc/wcawow64.h20
-rw-r--r--src/wcautil/inc/wcawrapquery.h130
4 files changed, 548 insertions, 0 deletions
diff --git a/src/wcautil/inc/wcalog.h b/src/wcautil/inc/wcalog.h
new file mode 100644
index 00000000..ffa3fa03
--- /dev/null
+++ b/src/wcautil/inc/wcalog.h
@@ -0,0 +1,14 @@
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
9BOOL WIXAPI IsVerboseLogging();
10HRESULT WIXAPI SetVerboseLoggingAtom(BOOL bValue);
11
12#ifdef __cplusplus
13}
14#endif
diff --git a/src/wcautil/inc/wcautil.h b/src/wcautil/inc/wcautil.h
new file mode 100644
index 00000000..8139a7ca
--- /dev/null
+++ b/src/wcautil/inc/wcautil.h
@@ -0,0 +1,384 @@
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 WIXAPI __stdcall
10#define ExitTrace WcaLogError
11
12#include "dutil.h"
13
14#define MessageExitOnLastError(x, e, s, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; } }
15#define MessageExitOnFailure(x, e, s, ...) if (FAILED(x)) { ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, -1, __VA_ARGS__); goto LExit; }
16#define MessageExitOnNullWithLastError(p, x, e, s, ...) if (NULL == p) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTrace(x, "%s", s, __VA_ARGS__); WcaErrorMessage(e, x, MB_OK, -1, __VA_ARGS__); goto LExit; }
17
18// Generic action enum.
19typedef enum WCA_ACTION
20{
21 WCA_ACTION_NONE,
22 WCA_ACTION_INSTALL,
23 WCA_ACTION_UNINSTALL,
24} WCA_ACTION;
25
26typedef enum WCA_CASCRIPT
27{
28 WCA_CASCRIPT_SCHEDULED,
29 WCA_CASCRIPT_ROLLBACK,
30} WCA_CASCRIPT;
31
32typedef enum WCA_CASCRIPT_CLOSE
33{
34 WCA_CASCRIPT_CLOSE_PRESERVE,
35 WCA_CASCRIPT_CLOSE_DELETE,
36} WCA_CASCRIPT_CLOSE;
37
38typedef enum WCA_TODO
39{
40 WCA_TODO_UNKNOWN,
41 WCA_TODO_INSTALL,
42 WCA_TODO_UNINSTALL,
43 WCA_TODO_REINSTALL,
44} WCA_TODO;
45
46typedef struct WCA_CASCRIPT_STRUCT
47{
48 LPWSTR pwzScriptPath;
49 HANDLE hScriptFile;
50} *WCA_CASCRIPT_HANDLE;
51
52typedef enum WCA_ENCODING
53{
54 WCA_ENCODING_UNKNOWN,
55 WCA_ENCODING_UTF_16,
56 WCA_ENCODING_UTF_8,
57 WCA_ENCODING_ANSI,
58} WCA_ENCODING;
59
60void WIXAPI WcaGlobalInitialize(
61 __in HINSTANCE hInst
62 );
63void WIXAPI WcaGlobalFinalize();
64
65HRESULT WIXAPI WcaInitialize(
66 __in MSIHANDLE hInstall,
67 __in_z PCSTR szCustomActionLogName
68 );
69UINT WIXAPI WcaFinalize(
70 __in UINT iReturnValue
71 );
72BOOL WIXAPI WcaIsInitialized();
73
74MSIHANDLE WIXAPI WcaGetInstallHandle();
75MSIHANDLE WIXAPI WcaGetDatabaseHandle();
76
77const char* WIXAPI WcaGetLogName();
78
79void WIXAPI WcaSetReturnValue(
80 __in UINT iReturnValue
81 );
82BOOL WIXAPI WcaCancelDetected();
83
84#define LOG_BUFFER 2048
85typedef enum LOGLEVEL
86{
87 LOGMSG_TRACEONLY, // Never written to the log file (except in DEBUG builds)
88 LOGMSG_VERBOSE, // Written to log when LOGVERBOSE
89 LOGMSG_STANDARD // Written to log whenever informational logging is enabled
90} LOGLEVEL;
91
92void __cdecl WcaLog(
93 __in LOGLEVEL llv,
94 __in_z __format_string PCSTR fmt, ...
95 );
96BOOL WIXAPI WcaDisplayAssert(
97 __in LPCSTR sz
98 );
99void __cdecl WcaLogError(
100 __in HRESULT hr,
101 __in LPCSTR szMessage,
102 ...
103 );
104
105UINT WIXAPI WcaProcessMessage(
106 __in INSTALLMESSAGE eMessageType,
107 __in MSIHANDLE hRecord
108 );
109UINT __cdecl WcaErrorMessage(
110 __in int iError,
111 __in HRESULT hrError,
112 __in UINT uiType,
113 __in INT cArgs,
114 ...
115 );
116HRESULT WIXAPI WcaProgressMessage(
117 __in UINT uiCost,
118 __in BOOL fExtendProgressBar
119 );
120
121BOOL WIXAPI WcaIsInstalling(
122 __in INSTALLSTATE isInstalled,
123 __in INSTALLSTATE isAction
124 );
125BOOL WIXAPI WcaIsReInstalling(
126 __in INSTALLSTATE isInstalled,
127 __in INSTALLSTATE isAction
128 );
129BOOL WIXAPI WcaIsUninstalling(
130 __in INSTALLSTATE isInstalled,
131 __in INSTALLSTATE isAction
132 );
133
134HRESULT WIXAPI WcaSetComponentState(
135 __in_z LPCWSTR wzComponent,
136 __in INSTALLSTATE isState
137 );
138
139HRESULT WIXAPI WcaTableExists(
140 __in_z LPCWSTR wzTable
141 );
142
143HRESULT WIXAPI WcaOpenView(
144 __in_z LPCWSTR wzSql,
145 __out MSIHANDLE* phView
146 );
147HRESULT WIXAPI WcaExecuteView(
148 __in MSIHANDLE hView,
149 __in MSIHANDLE hRec
150 );
151HRESULT WIXAPI WcaOpenExecuteView(
152 __in_z LPCWSTR wzSql,
153 __out MSIHANDLE* phView
154 );
155HRESULT WIXAPI WcaFetchRecord(
156 __in MSIHANDLE hView,
157 __out MSIHANDLE* phRec
158 );
159HRESULT WIXAPI WcaFetchSingleRecord(
160 __in MSIHANDLE hView,
161 __out MSIHANDLE* phRec
162 );
163
164HRESULT WIXAPI WcaGetProperty(
165 __in_z LPCWSTR wzProperty,
166 __inout LPWSTR* ppwzData
167 );
168HRESULT WIXAPI WcaGetFormattedProperty(
169 __in_z LPCWSTR wzProperty,
170 __out LPWSTR* ppwzData
171 );
172HRESULT WIXAPI WcaGetFormattedString(
173 __in_z LPCWSTR wzString,
174 __out LPWSTR* ppwzData
175 );
176HRESULT WIXAPI WcaGetIntProperty(
177 __in_z LPCWSTR wzProperty,
178 __inout int* piData
179 );
180HRESULT WIXAPI WcaGetTargetPath(
181 __in_z LPCWSTR wzFolder,
182 __out LPWSTR* ppwzData
183 );
184HRESULT WIXAPI WcaSetProperty(
185 __in_z LPCWSTR wzPropertyName,
186 __in_z LPCWSTR wzPropertyValue
187 );
188HRESULT WIXAPI WcaSetIntProperty(
189 __in_z LPCWSTR wzPropertyName,
190 __in int nPropertyValue
191 );
192BOOL WIXAPI WcaIsPropertySet(
193 __in LPCSTR szProperty
194 );
195BOOL WIXAPI WcaIsUnicodePropertySet(
196 __in LPCWSTR wzProperty
197 );
198
199HRESULT WIXAPI WcaGetRecordInteger(
200 __in MSIHANDLE hRec,
201 __in UINT uiField,
202 __inout int* piData
203 );
204HRESULT WIXAPI WcaGetRecordString(
205 __in MSIHANDLE hRec,
206 __in UINT uiField,
207 __inout LPWSTR* ppwzData
208 );
209HRESULT WIXAPI WcaGetRecordFormattedInteger(
210 __in MSIHANDLE hRec,
211 __in UINT uiField,
212 __out int* piData
213 );
214HRESULT WIXAPI WcaGetRecordFormattedString(
215 __in MSIHANDLE hRec,
216 __in UINT uiField,
217 __inout LPWSTR* ppwzData
218 );
219
220HRESULT WIXAPI WcaAllocStream(
221 __deref_out_bcount_part(cbData, 0) BYTE** ppbData,
222 __in DWORD cbData
223 );
224HRESULT WIXAPI WcaFreeStream(
225 __in BYTE* pbData
226 );
227
228HRESULT WIXAPI WcaGetRecordStream(
229 __in MSIHANDLE hRecBinary,
230 __in UINT uiField,
231 __deref_out_bcount_full(*pcbData) BYTE** ppbData,
232 __out DWORD* pcbData
233 );
234HRESULT WIXAPI WcaSetRecordString(
235 __in MSIHANDLE hRec,
236 __in UINT uiField,
237 __in_z LPCWSTR wzData
238 );
239HRESULT WIXAPI WcaSetRecordInteger(
240 __in MSIHANDLE hRec,
241 __in UINT uiField,
242 __in int iValue
243 );
244
245HRESULT WIXAPI WcaDoDeferredAction(
246 __in_z LPCWSTR wzAction,
247 __in_z LPCWSTR wzCustomActionData,
248 __in UINT uiCost
249 );
250DWORD WIXAPI WcaCountOfCustomActionDataRecords(
251 __in_z LPCWSTR wzData
252 );
253
254HRESULT WIXAPI WcaReadStringFromCaData(
255 __deref_in LPWSTR* ppwzCustomActionData,
256 __deref_out_z LPWSTR* ppwzString
257 );
258HRESULT WIXAPI WcaReadIntegerFromCaData(
259 __deref_in LPWSTR* ppwzCustomActionData,
260 __out int* piResult
261 );
262HRESULT WIXAPI WcaReadStreamFromCaData(
263 __deref_in LPWSTR* ppwzCustomActionData,
264 __deref_out_bcount(*pcbData) BYTE** ppbData,
265 __out DWORD_PTR* pcbData
266 );
267HRESULT WIXAPI WcaWriteStringToCaData(
268 __in_z LPCWSTR wzString,
269 __deref_inout_z LPWSTR* ppwzCustomActionData
270 );
271HRESULT WIXAPI WcaWriteIntegerToCaData(
272 __in int i,
273 __deref_out_z_opt LPWSTR* ppwzCustomActionData
274 );
275HRESULT WIXAPI WcaWriteStreamToCaData(
276 __in_bcount(cbData) const BYTE* pbData,
277 __in DWORD cbData,
278 __deref_inout_z_opt LPWSTR* ppwzCustomActionData
279 );
280
281HRESULT __cdecl WcaAddTempRecord(
282 __inout MSIHANDLE* phTableView,
283 __inout MSIHANDLE* phColumns,
284 __in_z LPCWSTR wzTable,
285 __out_opt MSIDBERROR* pdbError,
286 __in UINT uiUniquifyColumn,
287 __in UINT cColumns,
288 ...
289 );
290
291HRESULT WIXAPI WcaDumpTable(
292 __in_z LPCWSTR wzTable
293 );
294
295HRESULT WIXAPI WcaDeferredActionRequiresReboot();
296BOOL WIXAPI WcaDidDeferredActionRequireReboot();
297
298HRESULT WIXAPI WcaCaScriptCreateKey(
299 __out LPWSTR* ppwzScriptKey
300 );
301
302HRESULT WIXAPI WcaCaScriptCreate(
303 __in WCA_ACTION action,
304 __in WCA_CASCRIPT script,
305 __in BOOL fImpersonated,
306 __in_z LPCWSTR wzScriptKey,
307 __in BOOL fAppend,
308 __out WCA_CASCRIPT_HANDLE* phScript
309 );
310
311HRESULT WIXAPI WcaCaScriptOpen(
312 __in WCA_ACTION action,
313 __in WCA_CASCRIPT script,
314 __in BOOL fImpersonated,
315 __in_z LPCWSTR wzScriptKey,
316 __out WCA_CASCRIPT_HANDLE* phScript
317 );
318
319void WIXAPI WcaCaScriptClose(
320 __in_opt WCA_CASCRIPT_HANDLE hScript,
321 __in WCA_CASCRIPT_CLOSE closeOperation
322 );
323
324HRESULT WIXAPI WcaCaScriptReadAsCustomActionData(
325 __in WCA_CASCRIPT_HANDLE hScript,
326 __out LPWSTR* ppwzCustomActionData
327 );
328
329HRESULT WIXAPI WcaCaScriptWriteString(
330 __in WCA_CASCRIPT_HANDLE hScript,
331 __in_z LPCWSTR wzValue
332 );
333
334HRESULT WIXAPI WcaCaScriptWriteNumber(
335 __in WCA_CASCRIPT_HANDLE hScript,
336 __in DWORD dwValue
337 );
338
339void WIXAPI WcaCaScriptFlush(
340 __in WCA_CASCRIPT_HANDLE hScript
341 );
342
343void WIXAPI WcaCaScriptCleanup(
344 __in_z LPCWSTR wzProductCode,
345 __in BOOL fImpersonated
346 );
347
348HRESULT WIXAPI QuietExec(
349 __inout_z LPWSTR wzCommand,
350 __in DWORD dwTimeout,
351 __in BOOL fLogCommand,
352 __in BOOL fLogOutput
353 );
354
355HRESULT WIXAPI QuietExecCapture(
356 __inout_z LPWSTR wzCommand,
357 __in DWORD dwTimeout,
358 __in BOOL fLogCommand,
359 __in BOOL fLogOutput,
360 __out_z_opt LPWSTR* psczOutput
361 );
362
363WCA_TODO WIXAPI WcaGetComponentToDo(
364 __in_z LPCWSTR wzComponentId
365 );
366
367HRESULT WIXAPI WcaExtractBinaryToBuffer(
368 __in LPCWSTR wzBinaryId,
369 __out BYTE** pbData,
370 __out DWORD* pcbData
371 );
372HRESULT WIXAPI WcaExtractBinaryToFile(
373 __in LPCWSTR wzBinaryId,
374 __in LPCWSTR wzPath
375 );
376HRESULT WIXAPI WcaExtractBinaryToString(
377 __in LPCWSTR wzBinaryId,
378 __deref_out_z LPWSTR* psczOutput,
379 __out WCA_ENCODING* encoding
380 );
381
382#ifdef __cplusplus
383}
384#endif
diff --git a/src/wcautil/inc/wcawow64.h b/src/wcautil/inc/wcawow64.h
new file mode 100644
index 00000000..dd55f3fd
--- /dev/null
+++ b/src/wcautil/inc/wcawow64.h
@@ -0,0 +1,20 @@
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#include "wcautil.h"
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11HRESULT WIXAPI WcaInitializeWow64();
12BOOL WIXAPI WcaIsWow64Process();
13BOOL WIXAPI WcaIsWow64Initialized();
14HRESULT WIXAPI WcaDisableWow64FSRedirection();
15HRESULT WIXAPI WcaRevertWow64FSRedirection();
16HRESULT WIXAPI WcaFinalizeWow64();
17
18#ifdef __cplusplus
19}
20#endif
diff --git a/src/wcautil/inc/wcawrapquery.h b/src/wcautil/inc/wcawrapquery.h
new file mode 100644
index 00000000..e08f1c3f
--- /dev/null
+++ b/src/wcautil/inc/wcawrapquery.h
@@ -0,0 +1,130 @@
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#include "wcautil.h"
6
7// Enumerations
8typedef enum eWrapQueryAction
9{
10 wqaTableBegin = 1,
11 wqaTableFinish,
12 wqaRowBegin,
13 wqaRowFinish
14} eWrapQueryAction;
15
16typedef enum eColumnDataType
17{
18 cdtString = 1,
19 cdtInt,
20 cdtStream,
21 cdtUnknown
22} eColumnDataType;
23
24typedef enum eFormatMaskColumn
25{
26 efmcColumn1 = 1,
27 efmcColumn2 = 1 << 1,
28 efmcColumn3 = 1 << 2,
29 efmcColumn4 = 1 << 3,
30 efmcColumn5 = 1 << 4,
31 efmcColumn6 = 1 << 5,
32 efmcColumn7 = 1 << 6,
33 efmcColumn8 = 1 << 7,
34 efmcColumn9 = 1 << 8,
35 efmcColumn10 = 1 << 9,
36 efmcColumn11 = 1 << 10,
37 efmcColumn12 = 1 << 11,
38 efmcColumn13 = 1 << 12,
39 efmcColumn14 = 1 << 13,
40 efmcColumn15 = 1 << 14,
41 efmcColumn16 = 1 << 15,
42 efmcColumn17 = 1 << 16,
43 efmcColumn18 = 1 << 17,
44 efmcColumn19 = 1 << 18,
45 efmcColumn20 = 1 << 19,
46 efmcColumn21 = 1 << 20,
47 efmcColumn22 = 1 << 21,
48 efmcColumn23 = 1 << 22,
49 efmcColumn24 = 1 << 23,
50 efmcColumn25 = 1 << 24,
51 efmcColumn26 = 1 << 25,
52 efmcColumn27 = 1 << 26,
53 efmcColumn28 = 1 << 27,
54 efmcColumn29 = 1 << 28,
55 efmcColumn30 = 1 << 29,
56 efmcColumn31 = 1 << 30,
57 efmcColumn32 = 1 << 31,
58} eFormatMaskColumn;
59
60// Keeps track of the query instance for the reading CA (deferred CA)
61typedef struct WCA_WRAPQUERY_STRUCT
62{
63 // These are used to size our dynamic arrays below
64 DWORD dwColumns, dwRows, dwNextIndex;
65
66 // Dynamic arrays of column schema information
67 eColumnDataType *pcdtColumnType;
68 LPWSTR *ppwzColumnNames;
69
70 // Dynamic array of raw record data
71 MSIHANDLE *phRecords;
72} *WCA_WRAPQUERY_HANDLE;
73
74// Wrap a query
75// Setting the pfFormatMask enables control over which fields will be formatted, and which will be left unchanged
76// Setting dwComponentColumn to something other than 0xFFFFFFFF tells WcaWrapQuery to add two additional columns to the right side of the table
77// - ISInstalled and ISAction - which map to the ComponentState of the component (the component is found in the column specified)
78// Note that if a component is NULL, the component state columns will also be left null, and it will be up to the deferred CA to fail or ignore the case appropriately
79// Setting dwDirectoryColumn to something other than 0xFFFFFFFF tells WcaWrapQuery to add two more additional columns to the right side of the table
80// - SourcePath and TargetPath - which map to the Directory's Source and Target Path (the directory is found in the column specified)
81// Note that if a directory is NULL, the directory source/target path columns will also be left null, and it will be up to the deferred CA to fail or ignore the case appropriately
82HRESULT WIXAPI WcaWrapQuery(
83 __in_z LPCWSTR pwzQuery,
84 __inout LPWSTR * ppwzCustomActionData,
85 __in_opt DWORD dwFormatMask,
86 __in_opt DWORD dwComponentColumn,
87 __in_opt DWORD dwDirectoryColumn
88 );
89// This wraps an empty table query into the custom action data - this is a way to indicate to the deferred custom action that a necessary table doesn't exist, or its query returned no results
90HRESULT WIXAPI WcaWrapEmptyQuery(
91 __inout LPWSTR * ppwzCustomActionData
92 );
93
94// Open a new unwrap query operation, with data from the ppwzCustomActionData string
95HRESULT WIXAPI WcaBeginUnwrapQuery(
96 __out WCA_WRAPQUERY_HANDLE * phWrapQuery,
97 __inout LPWSTR * ppwzCustomActionData
98 );
99
100// Get the number of records in a query being unwrapped
101DWORD WIXAPI WcaGetQueryRecords(
102 __in const WCA_WRAPQUERY_HANDLE hWrapQuery
103 );
104
105// This function resets a query back to its first row, so that the next fetch returns the first record
106void WIXAPI WcaFetchWrappedReset(
107 __in WCA_WRAPQUERY_HANDLE hWrapQuery
108 );
109// Fetch the next record in this query
110// NOTE: the MSIHANDLE returned by this function should not be released, as it is the same handle used by the query object to maintain the item.
111// so, don't use this function with PMSIHANDLE objects!
112HRESULT WIXAPI WcaFetchWrappedRecord(
113 __in WCA_WRAPQUERY_HANDLE hWrapQuery,
114 __out MSIHANDLE* phRec
115 );
116
117// Fetch the next record in the query where the string value in column dwComparisonColumn equals the value pwzExpectedValue
118// NOTE: the MSIHANDLE returned by this function should not be released, as it is the same handle used by the query object to maintain the item.
119// so, don't use this function with PMSIHANDLE objects!
120HRESULT WIXAPI WcaFetchWrappedRecordWhereString(
121 __in WCA_WRAPQUERY_HANDLE hWrapQuery,
122 __in DWORD dwComparisonColumn,
123 __in_z LPCWSTR pwzExpectedValue,
124 __out MSIHANDLE* phRec
125 );
126
127// Release a query ID (frees memory, and frees the ID for a new query)
128void WIXAPI WcaFinishUnwrapQuery(
129 __in_opt WCA_WRAPQUERY_HANDLE hWrapQuery
130 );