aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-09-03 16:51:39 -0700
committerRob Mensching <rob@firegiant.com>2017-09-07 23:21:11 -0700
commit088dc648a3478e2cacdbdab1cb1782556642ee69 (patch)
tree70535a2e14113ebe639040fa908599322511dfc6 /src
parent2a72f06449431b326c671cf59811b9cefb73a2c8 (diff)
downloadwix-088dc648a3478e2cacdbdab1cb1782556642ee69.tar.gz
wix-088dc648a3478e2cacdbdab1cb1782556642ee69.tar.bz2
wix-088dc648a3478e2cacdbdab1cb1782556642ee69.zip
Initial commit
Diffstat (limited to 'src')
-rw-r--r--src/Cpp.Build.props1
-rw-r--r--src/Directory.Build.props1
-rw-r--r--src/WixToolset.Core.Native/CabInterop.cs312
-rw-r--r--src/WixToolset.Core.Native/WixToolset.Core.Native.csproj23
-rw-r--r--src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec24
-rw-r--r--src/winterop/packages.config5
-rw-r--r--src/winterop/precomp.h12
-rw-r--r--src/winterop/runtime.win-xxx.WixToolset.Core.Native.nuspec19
-rw-r--r--src/winterop/winterop.cpp216
-rw-r--r--src/winterop/winterop.def18
-rw-r--r--src/winterop/winterop.vcxproj79
11 files changed, 710 insertions, 0 deletions
diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props
index 1e4d4cbc..453aa442 100644
--- a/src/Cpp.Build.props
+++ b/src/Cpp.Build.props
@@ -3,6 +3,7 @@
3 3
4<Project> 4<Project>
5 <PropertyGroup> 5 <PropertyGroup>
6 <Platform Condition=" '$(Platform)' == 'AnyCPU' ">Win32</Platform>
6 <BaseOutputPath>$(OutputPath)</BaseOutputPath> 7 <BaseOutputPath>$(OutputPath)</BaseOutputPath>
7 <IntDir>$(BaseIntermediateOutputPath)$(Platform)\</IntDir> 8 <IntDir>$(BaseIntermediateOutputPath)$(Platform)\</IntDir>
8 <OutDir>$(OutputPath)$(Platform)\</OutDir> 9 <OutDir>$(OutputPath)$(Platform)\</OutDir>
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 48ba462d..63ad5d6e 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -4,6 +4,7 @@
4<Project> 4<Project>
5 <PropertyGroup> 5 <PropertyGroup>
6 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 6 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath> 8 <BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
8 <OutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</OutputPath> 9 <OutputPath>$(MSBuildThisFileDirectory)..\build\$(Configuration)\</OutputPath>
9 10
diff --git a/src/WixToolset.Core.Native/CabInterop.cs b/src/WixToolset.Core.Native/CabInterop.cs
new file mode 100644
index 00000000..6ad11c67
--- /dev/null
+++ b/src/WixToolset.Core.Native/CabInterop.cs
@@ -0,0 +1,312 @@
1// 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.
2
3namespace WixToolset.Core.Native
4{
5 using System;
6 using System.Diagnostics.CodeAnalysis;
7 using System.Text;
8 using System.Runtime.InteropServices;
9 // using WixToolset.Msi;
10 // using WixToolset.Msi.Interop;
11
12 /// <summary>
13 /// The native methods.
14 /// </summary>
15 public sealed class NativeMethods
16 {
17 /// <summary>
18 /// Starts creating a cabinet.
19 /// </summary>
20 /// <param name="cabinetName">Name of cabinet to create.</param>
21 /// <param name="cabinetDirectory">Directory to create cabinet in.</param>
22 /// <param name="maxFiles">Maximum number of files that will be added to cabinet.</param>
23 /// <param name="maxSize">Maximum size of the cabinet.</param>
24 /// <param name="maxThreshold">Maximum threshold in the cabinet.</param>
25 /// <param name="compressionType">Type of compression to use in the cabinet.</param>
26 /// <param name="contextHandle">Handle to opened cabinet.</param>
27 [DllImport("winterop.dll", EntryPoint = "CreateCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
28 public static extern void CreateCabBegin(string cabinetName, string cabinetDirectory, uint maxFiles, uint maxSize, uint maxThreshold, uint compressionType, out IntPtr contextHandle);
29
30 /// <summary>
31 /// Adds a file to an open cabinet.
32 /// </summary>
33 /// <param name="file">Full path to file to add to cabinet.</param>
34 /// <param name="token">Name of file in cabinet.</param>
35 /// <param name="contextHandle">Handle to open cabinet.</param>
36 // [DllImport("winterop.dll", EntryPoint = "CreateCabAddFile", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
37 // public static extern void CreateCabAddFile(string file, string token, MsiInterop.MSIFILEHASHINFO fileHash, IntPtr contextHandle);
38
39 /// <summary>
40 /// Closes a cabinet.
41 /// </summary>
42 /// <param name="contextHandle">Handle to open cabinet to close.</param>
43 /// <param name="newCabNamesCallBackAddress">Address of Binder's cabinet split callback</param>
44 [DllImport("winterop.dll", EntryPoint = "CreateCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
45 public static extern void CreateCabFinish(IntPtr contextHandle, IntPtr newCabNamesCallBackAddress);
46
47 /// <summary>
48 /// Cancels cabinet creation.
49 /// </summary>
50 /// <param name="contextHandle">Handle to open cabinet to cancel.</param>
51 [DllImport("winterop.dll", EntryPoint = "CreateCabCancel", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
52 public static extern void CreateCabCancel(IntPtr contextHandle);
53
54 /// <summary>
55 /// Initializes cabinet extraction.
56 /// </summary>
57 [DllImport("winterop.dll", EntryPoint = "ExtractCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
58 public static extern void ExtractCabBegin();
59
60 /// <summary>
61 /// Extracts files from cabinet.
62 /// </summary>
63 /// <param name="cabinet">Path to cabinet to extract files from.</param>
64 /// <param name="extractDirectory">Directory to extract files to.</param>
65 [DllImport("winterop.dll", EntryPoint = "ExtractCab", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, PreserveSig = false)]
66 public static extern void ExtractCab(string cabinet, string extractDirectory);
67
68 /// <summary>
69 /// Cleans up after cabinet extraction.
70 /// </summary>
71 [DllImport("winterop.dll", EntryPoint = "ExtractCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
72 public static extern void ExtractCabFinish();
73
74 /// <summary>
75 /// Initializes cabinet enumeration.
76 /// </summary>
77 [DllImport("winterop.dll", EntryPoint = "EnumerateCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
78 public static extern void EnumerateCabBegin();
79
80 /// <summary>
81 /// Enumerates files from cabinet.
82 /// </summary>
83 /// <param name="cabinet">Path to cabinet to enumerate files from.</param>
84 /// <param name="notify">callback that gets each file.</param>
85 [DllImport("winterop.dll", EntryPoint = "EnumerateCab", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, PreserveSig = false)]
86 public static extern void EnumerateCab(string cabinet, CabInterop.PFNNOTIFY notify);
87
88 /// <summary>
89 /// Cleans up after cabinet enumeration.
90 /// </summary>
91 [DllImport("winterop.dll", EntryPoint = "EnumerateCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
92 public static extern void EnumerateCabFinish();
93
94 /// <summary>
95 /// Resets the DACL on an array of files to "empty".
96 /// </summary>
97 /// <param name="files">Array of file reset ACL to "empty".</param>
98 /// <param name="fileCount">Number of file paths in array.</param>
99 [DllImport("winterop.dll", EntryPoint = "ResetAcls", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
100 public static extern void ResetAcls(string[] files, uint fileCount);
101
102 /// <summary>
103 /// Gets the hash of the pCertContext->pCertInfo->SubjectPublicKeyInfo using ::CryptHashPublicKeyInfo() which does not seem
104 /// to be exposed by .NET Frameowkr.
105 /// </summary>
106 /// <param name="certContext">Pointer to a CERT_CONTEXT struct with public key information to hash.</param>
107 /// <param name="fileCount">Number of file paths in array.</param>
108 [DllImport("winterop.dll", EntryPoint = "HashPublicKeyInfo", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
109 public static extern void HashPublicKeyInfo(IntPtr certContext, byte[] publicKeyInfoHashed, ref uint sizePublicKeyInfoHashed);
110
111 /// <summary>
112 /// Converts file time to a local file time.
113 /// </summary>
114 /// <param name="fileTime">file time</param>
115 /// <param name="localTime">local file time</param>
116 /// <returns>true if successful, false otherwise</returns>
117 [DllImport("kernel32.dll", SetLastError = true)]
118 [return: MarshalAs(UnmanagedType.Bool)]
119 public static extern bool FileTimeToLocalFileTime(ref long fileTime, ref long localTime);
120
121 /// <summary>
122 /// Converts file time to a MS-DOS time.
123 /// </summary>
124 /// <param name="fileTime">file time</param>
125 /// <param name="wFatDate">MS-DOS date</param>
126 /// <param name="wFatTime">MS-DOS time</param>
127 /// <returns>true if successful, false otherwise</returns>
128 [DllImport("kernel32.dll", SetLastError = true)]
129 [return: MarshalAs(UnmanagedType.Bool)]
130 public static extern bool FileTimeToDosDateTime(ref long fileTime, out ushort wFatDate, out ushort wFatTime);
131 }
132
133 /// <summary>
134 /// Interop class for the winterop.dll.
135 /// </summary>
136 public static class CabInterop
137 {
138 /// <summary>
139 /// Delegate type that's called by cabinet api for every file in cabinet.
140 /// </summary>
141 /// <param name="fdint">NOTIFICATIONTYPE</param>
142 /// <param name="pfdin">NOTIFICATION</param>
143 /// <returns>0 for success, -1 otherwise</returns>
144 public delegate Int32 PFNNOTIFY(NOTIFICATIONTYPE fdint, NOTIFICATION pfdin);
145
146 /// <summary>
147 /// Wraps FDINOTIFICATIONTYPE.
148 /// </summary>
149 public enum NOTIFICATIONTYPE : int
150 {
151 /// <summary>Info about the cabinet.</summary>
152 CABINET_INFO,
153 /// <summary>One or more files are continued.</summary>
154 PARTIAL_FILE,
155 /// <summary>Called for each file in cabinet.</summary>
156 COPY_FILE,
157 /// <summary>Called after all of the data has been written to a target file.</summary>
158 CLOSE_FILE_INFO,
159 /// <summary>A file is continued to the next cabinet.</summary>
160 NEXT_CABINET,
161 /// <summary>Called once after a call to FDICopy() starts scanning a CAB's CFFILE entries, and again when there are no more CFFILE entries.</summary>
162 ENUMERATE,
163 }
164
165 /// <summary>
166 /// Converts DateTime to MS-DOS date and time which cabinet uses.
167 /// </summary>
168 /// <param name="dateTime">DateTime</param>
169 /// <param name="cabDate">MS-DOS date</param>
170 /// <param name="cabTime">MS-DOS time</param>
171 public static void DateTimeToCabDateAndTime(DateTime dateTime, out ushort cabDate, out ushort cabTime)
172 {
173 // dateTime.ToLocalTime() does not match FileTimeToLocalFileTime() for some reason.
174 // so we need to call FileTimeToLocalFileTime() from kernel32.dll.
175 long filetime = dateTime.ToFileTime();
176 long localTime = 0;
177 NativeMethods.FileTimeToLocalFileTime(ref filetime, ref localTime);
178 NativeMethods.FileTimeToDosDateTime(ref localTime, out cabDate, out cabTime);
179 }
180
181 /// <summary>
182 /// Wraps FDINOTIFICATION.
183 /// </summary>
184 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
185 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
186 public class NOTIFICATION
187 {
188 private int cb;
189 [MarshalAs(UnmanagedType.LPStr)]
190 private string psz1;
191 [MarshalAs(UnmanagedType.LPStr)]
192 private string psz2;
193 [MarshalAs(UnmanagedType.LPStr)]
194 private string psz3;
195 private IntPtr pv;
196
197 private IntPtr hf;
198
199 private ushort date;
200 private ushort time;
201 private ushort attribs;
202 private ushort setID;
203 private ushort cabinet;
204 private ushort folder;
205 private int fdie;
206
207 /// <summary>
208 /// Uncompressed size of file.
209 /// </summary>
210 public int Cb
211 {
212 get { return this.cb; }
213 }
214
215 /// <summary>
216 /// File name in cabinet.
217 /// </summary>
218 public String Psz1
219 {
220 get { return this.psz1; }
221 }
222
223 /// <summary>
224 /// Name of next disk.
225 /// </summary>
226 public string Psz2
227 {
228 get { return this.psz2; }
229 }
230
231 /// <summary>
232 /// Points to a 256 character buffer.
233 /// </summary>
234 public string Psz3
235 {
236 get { return this.psz3; }
237 }
238
239 /// <summary>
240 /// Value for client.
241 /// </summary>
242 public IntPtr Pv
243 {
244 get { return this.pv; }
245 }
246
247 /// <summary>
248 /// Not used.
249 /// </summary>
250 public Int32 Hf
251 {
252 get { return (Int32)this.hf; }
253 }
254
255 /// <summary>
256 /// Last modified MS-DOS date.
257 /// </summary>
258 public ushort Date
259 {
260 get { return this.date; }
261 }
262
263 /// <summary>
264 /// Last modified MS-DOS time.
265 /// </summary>
266 public ushort Time
267 {
268 get { return this.time; }
269 }
270
271 /// <summary>
272 /// File attributes.
273 /// </summary>
274 public ushort Attribs
275 {
276 get { return this.attribs; }
277 }
278
279 /// <summary>
280 /// Cabinet set ID (a random 16-bit number).
281 /// </summary>
282 public ushort SetID
283 {
284 get { return this.setID; }
285 }
286
287 /// <summary>
288 /// Cabinet number within cabinet set (0-based).
289 /// </summary>
290 public ushort Cabinet
291 {
292 get { return this.cabinet; }
293 }
294
295 /// <summary>
296 /// File's folder index.
297 /// </summary>
298 public ushort Folder
299 {
300 get { return this.folder; }
301 }
302
303 /// <summary>
304 /// Error code.
305 /// </summary>
306 public int Fdie
307 {
308 get { return this.fdie; }
309 }
310 }
311 }
312}
diff --git a/src/WixToolset.Core.Native/WixToolset.Core.Native.csproj b/src/WixToolset.Core.Native/WixToolset.Core.Native.csproj
new file mode 100644
index 00000000..858b9be2
--- /dev/null
+++ b/src/WixToolset.Core.Native/WixToolset.Core.Native.csproj
@@ -0,0 +1,23 @@
1<Project Sdk="Microsoft.NET.Sdk">
2
3 <PropertyGroup>
4 <TargetFramework>netstandard2.0</TargetFramework>
5 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
6 <!-- <BeforePack>SetNuspecProperties</BeforePack> -->
7 </PropertyGroup>
8
9 <ItemGroup>
10 <PackageReference Include="Nerdbank.GitVersioning" Version="2.0.37-beta" PrivateAssets="all" />
11 </ItemGroup>
12
13 <!-- <ItemGroup>
14 <ProjectReference Include="..\winterop\winterop.vcxproj" ExcludeAssets="All" />
15 </ItemGroup> -->
16 <Target Name="SetNuspecProperties"
17 AfterTargets="Build">
18 <PropertyGroup>
19 <NuspecBasePath>$(OutputPath)</NuspecBasePath>
20 <NuspecProperties>Configuration=$(Configuration);Id=$(MSBuildThisFileName);Version=$(BuildVersionSimple);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description)</NuspecProperties>
21 </PropertyGroup>
22 </Target>
23</Project>
diff --git a/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec b/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec
new file mode 100644
index 00000000..68d154c8
--- /dev/null
+++ b/src/WixToolset.Core.Native/WixToolset.Core.Native.nuspec
@@ -0,0 +1,24 @@
1<?xml version="1.0"?>
2<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 <metadata minClientVersion="4.0">
4 <id>$id$</id>
5 <version>$version$</version>
6 <authors>$authors$</authors>
7 <owners>$authors$</owners>
8 <licenseUrl>https://github.com/wixtoolset/Core.Native/blob/master/LICENSE.TXT</licenseUrl>
9 <projectUrl>https://github.com/wixtoolset/Core.Native</projectUrl>
10 <requireLicenseAcceptance>false</requireLicenseAcceptance>
11 <description>$description$</description>
12 <copyright>$copyright$</copyright>
13
14 <dependencies>
15 <dependency id="runtime.win-x86.WixToolset.Core.Native" version="$version$" />
16 <dependency id="runtime.win-x64.WixToolset.Core.Native" version="$version$" />
17 </dependencies>
18 </metadata>
19
20 <files>
21 <file src="$id$.dll" target="lib\netstandard2.0" />
22 <file src="$id$.pdb" target="lib\netstandard2.0" />
23 </files>
24</package>
diff --git a/src/winterop/packages.config b/src/winterop/packages.config
new file mode 100644
index 00000000..b11fe210
--- /dev/null
+++ b/src/winterop/packages.config
@@ -0,0 +1,5 @@
1<?xml version="1.0" encoding="utf-8"?>
2<packages>
3 <package id="Nerdbank.GitVersioning" version="2.0.37-beta" targetFramework="native" developmentDependency="true" />
4 <package id="WixToolset.DUtil" version="4.0.3" targetFramework="native" />
5</packages> \ No newline at end of file
diff --git a/src/winterop/precomp.h b/src/winterop/precomp.h
new file mode 100644
index 00000000..eba996c7
--- /dev/null
+++ b/src/winterop/precomp.h
@@ -0,0 +1,12 @@
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#include <windows.h>
5#include <aclapi.h>
6
7#include "dutil.h"
8#include "fileutil.h"
9#include "memutil.h"
10#include "strutil.h"
11#include "cabcutil.h"
12#include "cabutil.h"
diff --git a/src/winterop/runtime.win-xxx.WixToolset.Core.Native.nuspec b/src/winterop/runtime.win-xxx.WixToolset.Core.Native.nuspec
new file mode 100644
index 00000000..87cf0919
--- /dev/null
+++ b/src/winterop/runtime.win-xxx.WixToolset.Core.Native.nuspec
@@ -0,0 +1,19 @@
1<?xml version="1.0"?>
2<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3 <metadata minClientVersion="4.0">
4 <id>$id$</id>
5 <version>$version$</version>
6 <authors>$authors$</authors>
7 <owners>$authors$</owners>
8 <licenseUrl>https://github.com/wixtoolset/Core.Native/blob/master/LICENSE.TXT</licenseUrl>
9 <projectUrl>https://github.com/wixtoolset/Core.Native</projectUrl>
10 <requireLicenseAcceptance>false</requireLicenseAcceptance>
11 <description>$description$</description>
12 <copyright>$copyright$</copyright>
13 </metadata>
14
15 <files>
16 <file src="winterop.dll" target="runtimes\win-$platform$\native" />
17 <file src="winterop.pdb" target="runtimes\win-$platform$\native" />
18 </files>
19</package>
diff --git a/src/winterop/winterop.cpp b/src/winterop/winterop.cpp
new file mode 100644
index 00000000..12d8ca3f
--- /dev/null
+++ b/src/winterop/winterop.cpp
@@ -0,0 +1,216 @@
1// 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.
2
3#include "precomp.h"
4
5
6HRESULT HashPublicKeyInfo(
7 __in PCERT_CONTEXT pCertContext,
8 __in_ecount(*pcbSubjectKeyIndentifier) BYTE* rgbSubjectKeyIdentifier,
9 __inout DWORD* pcbSubjectKeyIndentifier
10 )
11{
12 HRESULT hr = S_OK;
13
14 if (!::CryptHashPublicKeyInfo(NULL, CALG_SHA1, 0, X509_ASN_ENCODING, &pCertContext->pCertInfo->SubjectPublicKeyInfo, rgbSubjectKeyIdentifier, pcbSubjectKeyIndentifier))
15 {
16 ExitWithLastError(hr, "Failed to hash public key information.");
17 }
18
19LExit:
20 return hr;
21}
22
23HRESULT ResetAcls(
24 __in LPCWSTR pwzFiles[],
25 __in DWORD cFiles
26 )
27{
28 HRESULT hr = S_OK;
29 ACL* pacl = NULL;
30 DWORD cbAcl = sizeof(ACL);
31
32 OSVERSIONINFO osvi;
33
34 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
35 if (!::GetVersionExA(&osvi))
36 {
37 ExitOnLastError(hr, "failed to get OS version");
38 }
39
40 // If we're running on NT 4 or earlier, or ME or earlier, don't reset ACLs.
41 if (4 >= osvi.dwMajorVersion)
42 {
43 ExitFunction1(hr = S_FALSE);
44 }
45
46 // create an empty (not NULL!) ACL to use on all the files
47 pacl = static_cast<ACL*>(MemAlloc(cbAcl, FALSE));
48 ExitOnNull(pacl, hr, E_OUTOFMEMORY, "failed to allocate ACL");
49
50#pragma prefast(push)
51#pragma prefast(disable:25029)
52 if (!::InitializeAcl(pacl, cbAcl, ACL_REVISION))
53#pragma prefast(op)
54 {
55 ExitOnLastError(hr, "failed to initialize ACL");
56 }
57
58 // reset the existing security permissions on each file
59 for (DWORD i = 0; i < cFiles; ++i)
60 {
61 hr = ::SetNamedSecurityInfoW(const_cast<LPWSTR>(pwzFiles[i]), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, pacl, NULL);
62 if (ERROR_FILE_NOT_FOUND != hr && ERROR_PATH_NOT_FOUND != hr)
63 {
64 ExitOnFailure(hr = HRESULT_FROM_WIN32(hr), "failed to set security descriptor for file: %S", pwzFiles[i]);
65 }
66 }
67
68 // Setting to S_OK because we could end with ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND as valid return values.
69 hr = S_OK;
70
71 AssertSz(::IsValidAcl(pacl), "ResetAcls() - created invalid ACL");
72
73LExit:
74 if (pacl)
75 {
76 MemFree(pacl);
77 }
78
79 return hr;
80}
81
82
83HRESULT CreateCabBegin(
84 __in LPCWSTR wzCab,
85 __in LPCWSTR wzCabDir,
86 __in DWORD dwMaxFiles,
87 __in DWORD dwMaxSize,
88 __in DWORD dwMaxThresh,
89 __in COMPRESSION_TYPE ct,
90 __out HANDLE *phContext
91 )
92{
93 return CabCBegin(wzCab, wzCabDir, dwMaxFiles, dwMaxSize, dwMaxThresh, ct, phContext);
94}
95
96
97HRESULT CreateCabAddFile(
98 __in LPCWSTR wzFile,
99 __in_opt LPCWSTR wzToken,
100 __in_opt PMSIFILEHASHINFO pmfHash,
101 __in HANDLE hContext
102 )
103{
104 return CabCAddFile(wzFile, wzToken, pmfHash, hContext);
105}
106
107
108HRESULT CreateCabAddFiles(
109 __in LPCWSTR pwzFiles[],
110 __in LPCWSTR pwzTokens[],
111 __in PMSIFILEHASHINFO pmfHash[],
112 __in DWORD cFiles,
113 __in HANDLE hContext
114 )
115{
116 HRESULT hr = S_OK;
117 DWORD i;
118
119 Assert(pwzFiles);
120 Assert(hContext);
121
122 for (i = 0; i < cFiles; i++)
123 {
124 hr = CreateCabAddFile(
125 pwzFiles[i],
126 pwzTokens ? pwzTokens[i] : NULL,
127 pmfHash[i],
128 hContext
129 );
130 ExitOnFailure(hr, "Failed to add file %S to cab", pwzFiles[i]);
131 }
132
133LExit:
134 return hr;
135}
136
137
138HRESULT CreateCabFinish(
139 __in HANDLE hContext,
140 __in_opt FileSplitCabNamesCallback newCabNamesCallBackAddress
141 )
142{
143 // Convert address into Binder callback function
144 return CabCFinish(hContext, newCabNamesCallBackAddress);
145}
146
147
148void CreateCabCancel(
149 __in HANDLE hContext
150 )
151{
152 CabCCancel(hContext);
153}
154
155
156HRESULT ExtractCabBegin()
157{
158 return CabInitialize(FALSE);
159}
160
161
162HRESULT ExtractCab(
163 __in LPCWSTR wzCabinet,
164 __in LPCWSTR wzExtractDir
165 )
166{
167 return CabExtract(wzCabinet, L"*", wzExtractDir, NULL, NULL, 0);
168}
169
170
171void ExtractCabFinish()
172{
173 CabUninitialize();
174 return;
175}
176
177
178HRESULT EnumerateCabBegin()
179{
180 return CabInitialize(FALSE);
181}
182
183
184HRESULT EnumerateCab(
185 __in LPCWSTR wzCabinet,
186 __in STDCALL_PFNFDINOTIFY pfnNotify
187 )
188{
189 return CabEnumerate(wzCabinet, L"*", pfnNotify, 0);
190}
191
192
193void EnumerateCabFinish()
194{
195 CabUninitialize();
196 return;
197}
198
199
200BOOL WINAPI DllMain(
201 __in HINSTANCE /*hInstance*/,
202 __in DWORD dwReason,
203 __in LPVOID /*lpvReserved*/
204 )
205{
206 switch(dwReason)
207 {
208 case DLL_PROCESS_ATTACH:
209 case DLL_PROCESS_DETACH:
210 case DLL_THREAD_ATTACH:
211 case DLL_THREAD_DETACH:
212 break;
213 }
214
215 return TRUE;
216}
diff --git a/src/winterop/winterop.def b/src/winterop/winterop.def
new file mode 100644
index 00000000..dffa6268
--- /dev/null
+++ b/src/winterop/winterop.def
@@ -0,0 +1,18 @@
1; 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.
2
3LIBRARY "winterop.dll"
4
5EXPORTS
6 CreateCabBegin
7 CreateCabCancel
8 CreateCabAddFile
9 CreateCabAddFiles
10 CreateCabFinish
11 EnumerateCabBegin
12 EnumerateCab
13 EnumerateCabFinish
14 ExtractCabBegin
15 ExtractCab
16 ExtractCabFinish
17 ResetAcls
18 HashPublicKeyInfo
diff --git a/src/winterop/winterop.vcxproj b/src/winterop/winterop.vcxproj
new file mode 100644
index 00000000..6274a063
--- /dev/null
+++ b/src/winterop/winterop.vcxproj
@@ -0,0 +1,79 @@
1<?xml version="1.0" encoding="utf-8"?>
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<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <Import Project="..\..\packages\WixToolset.DUtil.4.0.3\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.3\build\WixToolset.DUtil.props')" />
6
7 <ItemGroup Label="ProjectConfigurations">
8 <ProjectConfiguration Include="Debug|Win32">
9 <Configuration>Debug</Configuration>
10 <Platform>Win32</Platform>
11 </ProjectConfiguration>
12 <ProjectConfiguration Include="Release|Win32">
13 <Configuration>Release</Configuration>
14 <Platform>Win32</Platform>
15 </ProjectConfiguration>
16 <ProjectConfiguration Include="Debug|x64">
17 <Configuration>Debug</Configuration>
18 <Platform>x64</Platform>
19 </ProjectConfiguration>
20 <ProjectConfiguration Include="Release|x64">
21 <Configuration>Release</Configuration>
22 <Platform>x64</Platform>
23 </ProjectConfiguration>
24 </ItemGroup>
25
26 <PropertyGroup Label="Globals">
27 <ProjectGuid>{26D45E58-E703-431D-B67E-493C72C9DA0B}</ProjectGuid>
28 <ConfigurationType>DynamicLibrary</ConfigurationType>
29 <TargetName>winterop</TargetName>
30 <PlatformToolset>v141</PlatformToolset>
31 <CharacterSet>MultiByte</CharacterSet>
32 <ProjectModuleDefinitionFile>winterop.def</ProjectModuleDefinitionFile>
33 <Description>Native component of WixToolset.Core</Description>
34 </PropertyGroup>
35
36 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
37 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
38
39 <ImportGroup Label="ExtensionSettings">
40 </ImportGroup>
41
42 <ImportGroup Label="Shared">
43 </ImportGroup>
44
45 <PropertyGroup>
46 <ProjectAdditionalLinkLibraries>crypt32.lib;cabinet.lib;msi.lib</ProjectAdditionalLinkLibraries>
47 </PropertyGroup>
48
49 <ItemGroup>
50 <ClCompile Include="winterop.cpp">
51 <!-- turn off deprecation warning -->
52 <DisableSpecificWarnings>4996</DisableSpecificWarnings>
53 <PrecompiledHeader>Create</PrecompiledHeader>
54 </ClCompile>
55 </ItemGroup>
56
57 <ItemGroup>
58 <ClInclude Include="precomp.h" />
59 </ItemGroup>
60
61 <ItemGroup>
62 <None Include="packages.config" />
63 <None Include="winterop.def" />
64 </ItemGroup>
65
66 <Target Name="PackNativeNuget" DependsOnTargets="Build">
67 <Exec Command="nuget pack runtime.win-xxx.WixToolset.Core.Native.nuspec -BasePath &quot;$(OutputPath)\&quot; -OutputDirectory &quot;$(BaseOutputPath)\&quot; -NoPackageAnalysis -Properties Configuration=$(Configuration);Id=runtime.win-$(PlatformTarget).WixToolset.Core.Native;Version=&quot;$(BuildVersionSimple)&quot;;Platform=$(PlatformTarget);Authors=&quot;$(Authors)&quot;;Copyright=&quot;$(Copyright)&quot;;Description=&quot;$(Description)&quot;;Title=&quot;$(Title)&quot;" />
68 </Target>
69
70 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
71 <Import Project="..\..\packages\Nerdbank.GitVersioning.2.0.37-beta\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.2.0.37-beta\build\Nerdbank.GitVersioning.targets')" />
72 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
73 <PropertyGroup>
74 <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
75 </PropertyGroup>
76 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.3\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.3\build\WixToolset.DUtil.props'))" />
77 <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.0.37-beta\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.0.37-beta\build\Nerdbank.GitVersioning.targets'))" />
78 </Target>
79</Project>