@joebigelow / wix / commits / e62434ac

Remove a bunch of dead code related to winterop.dll

Rob Mensching committed Mar 19, 2021 at 07:34 UTC e62434acc6c6e41bbafd3f1d46b2ed2011a9ad98
12 files changed +52 -795
src/WixToolset.Core.Native/CabInterop.cs deleted
-309
@@ -1,309 +0,0 @@
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 -namespace WixToolset.Core.Native
4 -{
5 - using System;
6 - using System.Runtime.InteropServices;
7 -
8 - /// <summary>
9 - /// Interop class for the winterop.dll.
10 - /// </summary>
11 - public static class CabInterop
12 - {
13 - /// <summary>
14 - /// Delegate type that's called by cabinet api for every file in cabinet.
15 - /// </summary>
16 - /// <param name="fdint">NOTIFICATIONTYPE</param>
17 - /// <param name="pfdin">NOTIFICATION</param>
18 - /// <returns>0 for success, -1 otherwise</returns>
19 - public delegate Int32 PFNNOTIFY(NOTIFICATIONTYPE fdint, NOTIFICATION pfdin);
20 -
21 - /// <summary>
22 - /// Wraps FDINOTIFICATIONTYPE.
23 - /// </summary>
24 - public enum NOTIFICATIONTYPE : int
25 - {
26 - /// <summary>Info about the cabinet.</summary>
27 - CABINET_INFO,
28 - /// <summary>One or more files are continued.</summary>
29 - PARTIAL_FILE,
30 - /// <summary>Called for each file in cabinet.</summary>
31 - COPY_FILE,
32 - /// <summary>Called after all of the data has been written to a target file.</summary>
33 - CLOSE_FILE_INFO,
34 - /// <summary>A file is continued to the next cabinet.</summary>
35 - NEXT_CABINET,
36 - /// <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>
37 - ENUMERATE,
38 - }
39 -
40 - /// <summary>
41 - /// Converts DateTime to MS-DOS date and time which cabinet uses.
42 - /// </summary>
43 - /// <param name="dateTime">DateTime</param>
44 - /// <param name="cabDate">MS-DOS date</param>
45 - /// <param name="cabTime">MS-DOS time</param>
46 - public static void DateTimeToCabDateAndTime(DateTime dateTime, out ushort cabDate, out ushort cabTime)
47 - {
48 - // dateTime.ToLocalTime() does not match FileTimeToLocalFileTime() for some reason.
49 - // so we need to call FileTimeToLocalFileTime() from kernel32.dll.
50 - long filetime = dateTime.ToFileTime();
51 - long localTime = 0;
52 - NativeMethods.FileTimeToLocalFileTime(ref filetime, ref localTime);
53 - NativeMethods.FileTimeToDosDateTime(ref localTime, out cabDate, out cabTime);
54 - }
55 -
56 - /// <summary>
57 - /// Wraps FDINOTIFICATION.
58 - /// </summary>
59 - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
60 - public class NOTIFICATION
61 - {
62 - private int cb;
63 - [MarshalAs(UnmanagedType.LPStr)]
64 - private string psz1;
65 - [MarshalAs(UnmanagedType.LPStr)]
66 - private string psz2;
67 - [MarshalAs(UnmanagedType.LPStr)]
68 - private string psz3;
69 - private IntPtr pv;
70 -
71 - private IntPtr hf;
72 -
73 - private ushort date;
74 - private ushort time;
75 - private ushort attribs;
76 - private ushort setID;
77 - private ushort cabinet;
78 - private ushort folder;
79 - private int fdie;
80 -
81 - /// <summary>
82 - /// Uncompressed size of file.
83 - /// </summary>
84 - public int Cb
85 - {
86 - get { return this.cb; }
87 - }
88 -
89 - /// <summary>
90 - /// File name in cabinet.
91 - /// </summary>
92 - public String Psz1
93 - {
94 - get { return this.psz1; }
95 - }
96 -
97 - /// <summary>
98 - /// Name of next disk.
99 - /// </summary>
100 - public string Psz2
101 - {
102 - get { return this.psz2; }
103 - }
104 -
105 - /// <summary>
106 - /// Points to a 256 character buffer.
107 - /// </summary>
108 - public string Psz3
109 - {
110 - get { return this.psz3; }
111 - }
112 -
113 - /// <summary>
114 - /// Value for client.
115 - /// </summary>
116 - public IntPtr Pv
117 - {
118 - get { return this.pv; }
119 - }
120 -
121 - /// <summary>
122 - /// Not used.
123 - /// </summary>
124 - public Int32 Hf
125 - {
126 - get { return (Int32)this.hf; }
127 - }
128 -
129 - /// <summary>
130 - /// Last modified MS-DOS date.
131 - /// </summary>
132 - public ushort Date
133 - {
134 - get { return this.date; }
135 - }
136 -
137 - /// <summary>
138 - /// Last modified MS-DOS time.
139 - /// </summary>
140 - public ushort Time
141 - {
142 - get { return this.time; }
143 - }
144 -
145 - /// <summary>
146 - /// File attributes.
147 - /// </summary>
148 - public ushort Attribs
149 - {
150 - get { return this.attribs; }
151 - }
152 -
153 - /// <summary>
154 - /// Cabinet set ID (a random 16-bit number).
155 - /// </summary>
156 - public ushort SetID
157 - {
158 - get { return this.setID; }
159 - }
160 -
161 - /// <summary>
162 - /// Cabinet number within cabinet set (0-based).
163 - /// </summary>
164 - public ushort Cabinet
165 - {
166 - get { return this.cabinet; }
167 - }
168 -
169 - /// <summary>
170 - /// File's folder index.
171 - /// </summary>
172 - public ushort Folder
173 - {
174 - get { return this.folder; }
175 - }
176 -
177 - /// <summary>
178 - /// Error code.
179 - /// </summary>
180 - public int Fdie
181 - {
182 - get { return this.fdie; }
183 - }
184 - }
185 -
186 - /// <summary>
187 - /// The native methods.
188 - /// </summary>
189 - private class NativeMethods
190 - {
191 - /// <summary>
192 - /// Starts creating a cabinet.
193 - /// </summary>
194 - /// <param name="cabinetName">Name of cabinet to create.</param>
195 - /// <param name="cabinetDirectory">Directory to create cabinet in.</param>
196 - /// <param name="maxFiles">Maximum number of files that will be added to cabinet.</param>
197 - /// <param name="maxSize">Maximum size of the cabinet.</param>
198 - /// <param name="maxThreshold">Maximum threshold in the cabinet.</param>
199 - /// <param name="compressionType">Type of compression to use in the cabinet.</param>
200 - /// <param name="contextHandle">Handle to opened cabinet.</param>
201 - [DllImport("winterop.dll", EntryPoint = "CreateCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
202 - public static extern void CreateCabBegin(string cabinetName, string cabinetDirectory, uint maxFiles, uint maxSize, uint maxThreshold, uint compressionType, out IntPtr contextHandle);
203 -
204 - /// <summary>
205 - /// Adds a file to an open cabinet.
206 - /// </summary>
207 - /// <param name="file">Full path to file to add to cabinet.</param>
208 - /// <param name="token">Name of file in cabinet.</param>
209 - /// <param name="fileHash"></param>
210 - /// <param name="contextHandle">Handle to open cabinet.</param>
211 - [DllImport("winterop.dll", EntryPoint = "CreateCabAddFile", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
212 - public static extern void CreateCabAddFile(string file, string token, MSIFILEHASHINFO fileHash, IntPtr contextHandle);
213 -
214 - /// <summary>
215 - /// Closes a cabinet.
216 - /// </summary>
217 - /// <param name="contextHandle">Handle to open cabinet to close.</param>
218 - /// <param name="newCabNamesCallBackAddress">Address of Binder's cabinet split callback</param>
219 - [DllImport("winterop.dll", EntryPoint = "CreateCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
220 - public static extern void CreateCabFinish(IntPtr contextHandle, IntPtr newCabNamesCallBackAddress);
221 -
222 - /// <summary>
223 - /// Cancels cabinet creation.
224 - /// </summary>
225 - /// <param name="contextHandle">Handle to open cabinet to cancel.</param>
226 - [DllImport("winterop.dll", EntryPoint = "CreateCabCancel", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
227 - public static extern void CreateCabCancel(IntPtr contextHandle);
228 -
229 - /// <summary>
230 - /// Initializes cabinet extraction.
231 - /// </summary>
232 - [DllImport("winterop.dll", EntryPoint = "ExtractCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
233 - public static extern void ExtractCabBegin();
234 -
235 - /// <summary>
236 - /// Extracts files from cabinet.
237 - /// </summary>
238 - /// <param name="cabinet">Path to cabinet to extract files from.</param>
239 - /// <param name="extractDirectory">Directory to extract files to.</param>
240 - [DllImport("winterop.dll", EntryPoint = "ExtractCab", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, PreserveSig = false)]
241 - public static extern void ExtractCab(string cabinet, string extractDirectory);
242 -
243 - /// <summary>
244 - /// Cleans up after cabinet extraction.
245 - /// </summary>
246 - [DllImport("winterop.dll", EntryPoint = "ExtractCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
247 - public static extern void ExtractCabFinish();
248 -
249 - /// <summary>
250 - /// Initializes cabinet enumeration.
251 - /// </summary>
252 - [DllImport("winterop.dll", EntryPoint = "EnumerateCabBegin", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
253 - public static extern void EnumerateCabBegin();
254 -
255 - /// <summary>
256 - /// Enumerates files from cabinet.
257 - /// </summary>
258 - /// <param name="cabinet">Path to cabinet to enumerate files from.</param>
259 - /// <param name="notify">callback that gets each file.</param>
260 - [DllImport("winterop.dll", EntryPoint = "EnumerateCab", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true, PreserveSig = false)]
261 - public static extern void EnumerateCab(string cabinet, CabInterop.PFNNOTIFY notify);
262 -
263 - /// <summary>
264 - /// Cleans up after cabinet enumeration.
265 - /// </summary>
266 - [DllImport("winterop.dll", EntryPoint = "EnumerateCabFinish", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
267 - public static extern void EnumerateCabFinish();
268 -
269 - /// <summary>
270 - /// Resets the DACL on an array of files to "empty".
271 - /// </summary>
272 - /// <param name="files">Array of file reset ACL to "empty".</param>
273 - /// <param name="fileCount">Number of file paths in array.</param>
274 - [DllImport("winterop.dll", EntryPoint = "ResetAcls", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
275 - public static extern void ResetAcls(string[] files, uint fileCount);
276 -
277 - /// <summary>
278 - /// Gets the hash of the pCertContext->pCertInfo->SubjectPublicKeyInfo using ::CryptHashPublicKeyInfo() which does not seem
279 - /// to be exposed by .NET Frameowkr.
280 - /// </summary>
281 - /// <param name="certContext">Pointer to a CERT_CONTEXT struct with public key information to hash.</param>
282 - /// <param name="publicKeyInfoHashed"></param>
283 - /// <param name="sizePublicKeyInfoHashed"></param>
284 - [DllImport("winterop.dll", EntryPoint = "HashPublicKeyInfo", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)]
285 - public static extern void HashPublicKeyInfo(IntPtr certContext, byte[] publicKeyInfoHashed, ref uint sizePublicKeyInfoHashed);
286 -
287 - /// <summary>
288 - /// Converts file time to a local file time.
289 - /// </summary>
290 - /// <param name="fileTime">file time</param>
291 - /// <param name="localTime">local file time</param>
292 - /// <returns>true if successful, false otherwise</returns>
293 - [DllImport("kernel32.dll", SetLastError = true)]
294 - [return: MarshalAs(UnmanagedType.Bool)]
295 - public static extern bool FileTimeToLocalFileTime(ref long fileTime, ref long localTime);
296 -
297 - /// <summary>
298 - /// Converts file time to a MS-DOS time.
299 - /// </summary>
300 - /// <param name="fileTime">file time</param>
301 - /// <param name="wFatDate">MS-DOS date</param>
302 - /// <param name="wFatTime">MS-DOS time</param>
303 - /// <returns>true if successful, false otherwise</returns>
304 - [DllImport("kernel32.dll", SetLastError = true)]
305 - [return: MarshalAs(UnmanagedType.Bool)]
306 - public static extern bool FileTimeToDosDateTime(ref long fileTime, out ushort wFatDate, out ushort wFatTime);
307 - }
308 - }
309 -}
src/WixToolset.Core.Native/Cabinet.cs
+2 -87
@@ -8,7 +8,7 @@ namespace WixToolset.Core.Native
8 using WixToolset.Data;
9
10 /// <summary>
11 - /// Wrapper class around interop with wixcab.dll to compress files into a cabinet.
11 + /// Cabinet create, enumerate and extract mechanism.
12 /// </summary>
13 public sealed class Cabinet
14 {
@@ -16,7 +16,7 @@ namespace WixToolset.Core.Native
16 private static readonly char[] TextLineSplitter = new[] { '\t' };
17
18 /// <summary>
19 - ///
19 + /// Creates a cabinet creation, enumeration, extraction mechanism.
20 /// </summary>
21 /// <param name="path">Path of cabinet</param>
22 public Cabinet(string path)
@@ -116,90 +116,5 @@ namespace WixToolset.Core.Native
116 var wixnative = new WixNativeExe("extractcab", this.Path, outputFolder);
117 return wixnative.Run().Where(output => !String.IsNullOrWhiteSpace(output));
118 }
119 -
120 -#if TOOD_ERROR_HANDLING
121 - /// <summary>
122 - /// Adds a file to the cabinet with an optional MSI file hash.
123 - /// </summary>
124 - /// <param name="file">The file to add.</param>
125 - /// <param name="token">The token for the file.</param>
126 - /// <param name="fileHash">The MSI file hash of the file.</param>
127 - //private void AddFile(string file, string token, MsiInterop.MSIFILEHASHINFO fileHash)
128 - //{
129 - // try
130 - // {
131 - // NativeMethods.CreateCabAddFile(file, token, fileHash, this.handle);
132 - // }
133 - // catch (COMException ce)
134 - // {
135 - // if (0x80004005 == unchecked((uint)ce.ErrorCode)) // E_FAIL
136 - // {
137 - // throw new WixException(WixErrors.CreateCabAddFileFailed());
138 - // }
139 - // else if (0x80070070 == unchecked((uint)ce.ErrorCode)) // ERROR_DISK_FULL
140 - // {
141 - // throw new WixException(WixErrors.CreateCabInsufficientDiskSpace());
142 - // }
143 - // else
144 - // {
145 - // throw;
146 - // }
147 - // }
148 - // catch (DirectoryNotFoundException)
149 - // {
150 - // throw new WixFileNotFoundException(file);
151 - // }
152 - // catch (FileNotFoundException)
153 - // {
154 - // throw new WixFileNotFoundException(file);
155 - // }
156 - //}
157 -
158 - /// <summary>
159 - /// Complete/commit the cabinet - this must be called before Dispose so that errors will be
160 - /// reported on the same thread.
161 - /// </summary>
162 - /// <param name="newCabNamesCallBackAddress">Address of Binder's callback function for Cabinet Splitting</param>
163 - public void Complete(IntPtr newCabNamesCallBackAddress)
164 - {
165 - if (IntPtr.Zero != this.handle)
166 - {
167 - try
168 - {
169 - if (newCabNamesCallBackAddress != IntPtr.Zero && this.maxSize != 0)
170 - {
171 - NativeMethods.CreateCabFinish(this.handle, newCabNamesCallBackAddress);
172 - }
173 - else
174 - {
175 - NativeMethods.CreateCabFinish(this.handle, IntPtr.Zero);
176 - }
177 -
178 - GC.SuppressFinalize(this);
179 - this.disposed = true;
180 - }
181 - catch (COMException ce)
182 - {
183 - //if (0x80004005 == unchecked((uint)ce.ErrorCode)) // E_FAIL
184 - //{
185 - // // This error seems to happen, among other situations, when cabbing more than 0xFFFF files
186 - // throw new WixException(WixErrors.FinishCabFailed());
187 - //}
188 - //else if (0x80070070 == unchecked((uint)ce.ErrorCode)) // ERROR_DISK_FULL
189 - //{
190 - // throw new WixException(WixErrors.CreateCabInsufficientDiskSpace());
191 - //}
192 - //else
193 - //{
194 - // throw;
195 - //}
196 - }
197 - finally
198 - {
199 - this.handle = IntPtr.Zero;
200 - }
201 - }
202 - }
203 -#endif
119 }
120 }
src/WixToolset.Core.Native/CabinetFileInfo.cs
+1 -1
@@ -56,7 +56,7 @@ namespace WixToolset.Core.Native
56 /// </returns>
57 public bool SameAsDateTime(DateTime dateTime)
58 {
59 - CabInterop.DateTimeToCabDateAndTime(dateTime, out var cabDate, out var cabTime);
59 + DateTimeInterop.DateTimeToCabDateAndTime(dateTime, out var cabDate, out var cabTime);
60 return this.Date == cabDate && this.Time == cabTime;
61 }
62 }
src/WixToolset.Core.Native/DateTimeInterop.cs new
+48
@@ -0,0 +1,48 @@
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 +namespace WixToolset.Core.Native
4 +{
5 + using System;
6 + using System.Runtime.InteropServices;
7 +
8 + /// <summary>
9 + /// Interop class for the date/time handling.
10 + /// </summary>
11 + internal static class DateTimeInterop
12 + {
13 + /// <summary>
14 + /// Converts DateTime to MS-DOS date and time which cabinet uses.
15 + /// </summary>
16 + /// <param name="dateTime">DateTime</param>
17 + /// <param name="cabDate">MS-DOS date</param>
18 + /// <param name="cabTime">MS-DOS time</param>
19 + public static void DateTimeToCabDateAndTime(DateTime dateTime, out ushort cabDate, out ushort cabTime)
20 + {
21 + // dateTime.ToLocalTime() does not match FileTimeToLocalFileTime() for some reason.
22 + // so we need to call FileTimeToLocalFileTime() from kernel32.dll.
23 + long filetime = dateTime.ToFileTime();
24 + long localTime = 0;
25 + FileTimeToLocalFileTime(ref filetime, ref localTime);
26 + FileTimeToDosDateTime(ref localTime, out cabDate, out cabTime);
27 + }
28 +
29 + /// <summary>
30 + /// Converts file time to a local file time.
31 + /// </summary>
32 + /// <param name="fileTime">file time</param>
33 + /// <param name="localTime">local file time</param>
34 + /// <returns>true if successful, false otherwise</returns>
35 + [DllImport("kernel32.dll", SetLastError = true)]
36 + private static extern bool FileTimeToLocalFileTime(ref long fileTime, ref long localTime);
37 +
38 + /// <summary>
39 + /// Converts file time to a MS-DOS time.
40 + /// </summary>
41 + /// <param name="fileTime">file time</param>
42 + /// <param name="wFatDate">MS-DOS date</param>
43 + /// <param name="wFatTime">MS-DOS time</param>
44 + /// <returns>true if successful, false otherwise</returns>
45 + [DllImport("kernel32.dll", SetLastError = true)]
46 + private static extern bool FileTimeToDosDateTime(ref long fileTime, out ushort wFatDate, out ushort wFatTime);
47 + }
48 +}
src/WixToolset.Core.Native/Msi/MSIFILEHASHINFO.cs renamed
+1 -1
@@ -1,6 +1,6 @@
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 -namespace WixToolset.Core.Native
3 +namespace WixToolset.Core.Native.Msi
4 {
5 using System.Runtime.InteropServices;
6
src/test/WixToolsetTest.Core.Native/CabinetFixture.cs
-24
@@ -46,30 +46,6 @@ namespace WixToolsetTest.CoreNative
46 // Assert.True(file.SameAsDateTime(new DateTime(2017, 9, 28, 0, 19, 38)));
47 }
48
49 - [Fact]
50 - public void CanExtractSingleFileCabinet()
51 - {
52 - var cabinetPath = TestData.Get(@"TestData\test.cab");
53 -
54 - using (var fs = new DisposableFileSystem())
55 - {
56 - var extractFolder = fs.GetFolder(true);
57 -
58 - var cabinet = new Cabinet(cabinetPath);
59 - var reportedFiles = cabinet.Extract(extractFolder);
60 - var files = Directory.EnumerateFiles(extractFolder);
61 - Assert.Equal(reportedFiles, files.Select(f => Path.GetFileName(f)));
62 -
63 - var file = new FileInfo(files.Single());
64 - CabInterop.DateTimeToCabDateAndTime(file.CreationTime, out var date, out var time);
65 -
66 - Assert.Equal("test.txt", file.Name);
67 - Assert.Equal(17, file.Length);
68 - Assert.Equal(19259, date);
69 - Assert.Equal(47731, time);
70 - }
71 - }
72 -
49 [Fact]
50 public void IntegrationTest()
51 {
src/winterop/packages.config deleted
-8
@@ -1,8 +0,0 @@
1 -<?xml version="1.0" encoding="utf-8"?>
2 -<packages>
3 - <package id="Microsoft.Build.Tasks.Git" version="1.0.0" targetFramework="native" developmentDependency="true" />
4 - <package id="Microsoft.SourceLink.Common" version="1.0.0" targetFramework="native" developmentDependency="true" />
5 - <package id="Microsoft.SourceLink.GitHub" version="1.0.0" targetFramework="native" developmentDependency="true" />
6 - <package id="Nerdbank.GitVersioning" version="3.3.37" targetFramework="native" developmentDependency="true" />
7 - <package id="WixToolset.DUtil" version="4.0.56" targetFramework="native" />
8 -</packages>
\ No newline at end of file
src/winterop/precomp.h deleted
-12
@@ -1,12 +0,0 @@
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"
src/winterop/runtime.win-xxx.WixToolset.Core.Native.nuspec deleted
-20
@@ -1,20 +0,0 @@
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 - <!-- <license type="expression">MS-RL</license> -->
9 - <licenseUrl>https://licenses.nuget.org/MS-RL</licenseUrl>
10 - <projectUrl>https://github.com/wixtoolset/Core.Native</projectUrl>
11 - <requireLicenseAcceptance>false</requireLicenseAcceptance>
12 - <description>$description$</description>
13 - <copyright>$copyright$</copyright>
14 - </metadata>
15 -
16 - <files>
17 - <file src="winterop.dll" target="runtimes\win-$platform$\native" />
18 - <file src="winterop.pdb" target="runtimes\win-$platform$\native" />
19 - </files>
20 -</package>
src/winterop/winterop.cpp deleted
-216
@@ -1,216 +0,0 @@
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 -
6 -HRESULT 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 -
19 -LExit:
20 - return hr;
21 -}
22 -
23 -HRESULT 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 -
73 -LExit:
74 - if (pacl)
75 - {
76 - MemFree(pacl);
77 - }
78 -
79 - return hr;
80 -}
81 -
82 -
83 -HRESULT 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 -
97 -HRESULT 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 -
108 -HRESULT 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 -
133 -LExit:
134 - return hr;
135 -}
136 -
137 -
138 -HRESULT 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 -
148 -void CreateCabCancel(
149 - __in HANDLE hContext
150 - )
151 -{
152 - CabCCancel(hContext);
153 -}
154 -
155 -
156 -HRESULT ExtractCabBegin()
157 -{
158 - return CabInitialize(FALSE);
159 -}
160 -
161 -
162 -HRESULT ExtractCab(
163 - __in LPCWSTR wzCabinet,
164 - __in LPCWSTR wzExtractDir
165 - )
166 -{
167 - return CabExtract(wzCabinet, L"*", wzExtractDir, NULL, NULL, 0);
168 -}
169 -
170 -
171 -void ExtractCabFinish()
172 -{
173 - CabUninitialize();
174 - return;
175 -}
176 -
177 -
178 -HRESULT EnumerateCabBegin()
179 -{
180 - return CabInitialize(FALSE);
181 -}
182 -
183 -
184 -HRESULT EnumerateCab(
185 - __in LPCWSTR wzCabinet,
186 - __in STDCALL_PFNFDINOTIFY pfnNotify
187 - )
188 -{
189 - return CabEnumerate(wzCabinet, L"*", pfnNotify, 0);
190 -}
191 -
192 -
193 -void EnumerateCabFinish()
194 -{
195 - CabUninitialize();
196 - return;
197 -}
198 -
199 -
200 -BOOL 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 -}
src/winterop/winterop.def deleted
-18
@@ -1,18 +0,0 @@
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 -LIBRARY "winterop.dll"
4 -
5 -EXPORTS
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
src/winterop/winterop.vcxproj deleted
-99
@@ -1,99 +0,0 @@
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\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
6 - <Import Project="..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props" Condition="Exists('..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" />
7 - <Import Project="..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" />
8 - <Import Project="..\..\packages\WixToolset.DUtil.4.0.56\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.56\build\WixToolset.DUtil.props')" />
9 -
10 - <ItemGroup Label="ProjectConfigurations">
11 - <ProjectConfiguration Include="Debug|ARM64">
12 - <Configuration>Debug</Configuration>
13 - <Platform>ARM64</Platform>
14 - </ProjectConfiguration>
15 - <ProjectConfiguration Include="Debug|Win32">
16 - <Configuration>Debug</Configuration>
17 - <Platform>Win32</Platform>
18 - </ProjectConfiguration>
19 - <ProjectConfiguration Include="Debug|x64">
20 - <Configuration>Debug</Configuration>
21 - <Platform>x64</Platform>
22 - </ProjectConfiguration>
23 - <ProjectConfiguration Include="Release|ARM64">
24 - <Configuration>Release</Configuration>
25 - <Platform>ARM64</Platform>
26 - </ProjectConfiguration>
27 - <ProjectConfiguration Include="Release|Win32">
28 - <Configuration>Release</Configuration>
29 - <Platform>Win32</Platform>
30 - </ProjectConfiguration>
31 - <ProjectConfiguration Include="Release|x64">
32 - <Configuration>Release</Configuration>
33 - <Platform>x64</Platform>
34 - </ProjectConfiguration>
35 - </ItemGroup>
36 -
37 - <PropertyGroup Label="Globals">
38 - <ProjectGuid>{26D45E58-E703-431D-B67E-493C72C9DA0B}</ProjectGuid>
39 - <ConfigurationType>DynamicLibrary</ConfigurationType>
40 - <TargetName>winterop</TargetName>
41 - <PlatformToolset>v142</PlatformToolset>
42 - <CharacterSet>MultiByte</CharacterSet>
43 - <ProjectModuleDefinitionFile>winterop.def</ProjectModuleDefinitionFile>
44 - <Description>Native component of WixToolset.Core</Description>
45 - </PropertyGroup>
46 -
47 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
48 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
49 -
50 - <ImportGroup Label="ExtensionSettings">
51 - </ImportGroup>
52 -
53 - <ImportGroup Label="Shared">
54 - <Import Project="..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" />
55 - <Import Project="..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets" Condition="Exists('..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" />
56 - <Import Project="..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
57 - <Import Project="..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
58 - </ImportGroup>
59 -
60 - <PropertyGroup>
61 - <ProjectAdditionalLinkLibraries>crypt32.lib;cabinet.lib;msi.lib</ProjectAdditionalLinkLibraries>
62 - </PropertyGroup>
63 -
64 - <ItemGroup>
65 - <ClCompile Include="winterop.cpp">
66 - <!-- turn off deprecation warning -->
67 - <DisableSpecificWarnings>4996</DisableSpecificWarnings>
68 - <PrecompiledHeader>Create</PrecompiledHeader>
69 - </ClCompile>
70 - </ItemGroup>
71 -
72 - <ItemGroup>
73 - <ClInclude Include="precomp.h" />
74 - </ItemGroup>
75 -
76 - <ItemGroup>
77 - <None Include="packages.config" />
78 - <None Include="winterop.def" />
79 - </ItemGroup>
80 -
81 - <Target Name="PackNativeNuget" DependsOnTargets="Build">
82 - <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;" />
83 - </Target>
84 -
85 - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
86 - <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
87 - <PropertyGroup>
88 - <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
89 - </PropertyGroup>
90 - <Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets'))" />
91 - <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.56\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.56\build\WixToolset.DUtil.props'))" />
92 - <Error Condition="!Exists('..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.props'))" />
93 - <Error Condition="!Exists('..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets'))" />
94 - <Error Condition="!Exists('..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.props'))" />
95 - <Error Condition="!Exists('..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets'))" />
96 - <Error Condition="!Exists('..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props'))" />
97 - <Error Condition="!Exists('..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets'))" />
98 - </Target>
99 -</Project>