@joebigelow / wix-1 / commits / f1f1a124

Remove Burn Authenticode

Fixes https://github.com/wixtoolset/issues/issues/6301

Bob Arnson committed Jan 31, 2021 at 19:28 UTC f1f1a124df59e8639c2bcbfa7d3a4b37fb348bb7
16 files changed +12 -562
src/engine/cache.cpp
+5 -247
@@ -94,15 +94,6 @@ static HRESULT VerifyHash(
94 __in_z LPCWSTR wzUnverifiedPayloadPath,
95 __in HANDLE hFile
96 );
97 -static HRESULT VerifyPayloadWithCatalog(
98 - __in BURN_PAYLOAD* pPayload,
99 - __in_z LPCWSTR wzUnverifiedPayloadPath,
100 - __in HANDLE hFile
101 - );
102 -static HRESULT VerifyPayloadAgainstChain(
103 - __in BURN_PAYLOAD* pPayload,
104 - __in PCCERT_CHAIN_CONTEXT pChainContext
105 - );
97
98
99 extern "C" HRESULT CacheInitialize(
@@ -189,7 +180,7 @@ LExit:
180 }
181
182 extern "C" HRESULT CacheEnsureWorkingFolder(
192 - __in_z LPCWSTR wzBundleId,
183 + __in_z_opt LPCWSTR wzBundleId,
184 __deref_out_z_opt LPWSTR* psczWorkingFolder
185 )
186 {
@@ -964,56 +955,6 @@ LExit:
955 return hr;
956 }
957
967 -extern "C" HRESULT CacheVerifyPayloadSignature(
968 - __in BURN_PAYLOAD* pPayload,
969 - __in_z LPCWSTR wzUnverifiedPayloadPath,
970 - __in HANDLE hFile
971 - )
972 -{
973 - HRESULT hr = S_OK;
974 - LONG er = ERROR_SUCCESS;
975 -
976 - GUID guidAuthenticode = WINTRUST_ACTION_GENERIC_VERIFY_V2;
977 - WINTRUST_FILE_INFO wfi = { };
978 - WINTRUST_DATA wtd = { };
979 - CRYPT_PROVIDER_DATA* pProviderData = NULL;
980 - CRYPT_PROVIDER_SGNR* pSigner = NULL;
981 -
982 - // Verify the payload assuming online.
983 - wfi.cbStruct = sizeof(wfi);
984 - wfi.pcwszFilePath = wzUnverifiedPayloadPath;
985 - wfi.hFile = hFile;
986 -
987 - wtd.cbStruct = sizeof(wtd);
988 - wtd.dwUnionChoice = WTD_CHOICE_FILE;
989 - wtd.pFile = &wfi;
990 - wtd.dwStateAction = WTD_STATEACTION_VERIFY;
991 - wtd.dwProvFlags = WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT;
992 - wtd.dwUIChoice = WTD_UI_NONE;
993 -
994 - er = ::WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), &guidAuthenticode, &wtd);
995 - if (er)
996 - {
997 - // Verify the payload assuming offline.
998 - wtd.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL;
999 -
1000 - er = ::WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), &guidAuthenticode, &wtd);
1001 - ExitOnWin32Error(er, hr, "Failed authenticode verification of payload: %ls", wzUnverifiedPayloadPath);
1002 - }
1003 -
1004 - pProviderData = WTHelperProvDataFromStateData(wtd.hWVTStateData);
1005 - ExitOnNullWithLastError(pProviderData, hr, "Failed to get provider state from authenticode certificate.");
1006 -
1007 - pSigner = WTHelperGetProvSignerFromChain(pProviderData, 0, FALSE, 0);
1008 - ExitOnNullWithLastError(pSigner, hr, "Failed to get signer chain from authenticode certificate.");
1009 -
1010 - hr = VerifyPayloadAgainstChain(pPayload, pSigner->pChainContext);
1011 - ExitOnFailure(hr, "Failed to verify expected payload against actual certificate chain.");
1012 -
1013 -LExit:
1014 - return hr;
1015 -}
1016 -
958 extern "C" void CacheCleanup(
959 __in BOOL fPerMachine,
960 __in_z LPCWSTR wzBundleId
@@ -1098,7 +1039,7 @@ extern "C" void CacheUninitialize()
1039 // Internal functions.
1040
1041 static HRESULT CalculateWorkingFolder(
1101 - __in_z LPCWSTR /*wzBundleId*/,
1042 + __in_z_opt LPCWSTR /*wzBundleId*/,
1043 __deref_out_z LPWSTR* psczWorkingFolder
1044 )
1045 {
@@ -1387,18 +1328,7 @@ static HRESULT VerifyThenTransferPayload(
1328 ExitWithLastError(hr, "Failed to open payload in working path: %ls", wzUnverifiedPayloadPath);
1329 }
1330
1390 - // If the payload has a certificate root public key identifier provided, verify the certificate.
1391 - if (pPayload->pbCertificateRootPublicKeyIdentifier)
1392 - {
1393 - hr = CacheVerifyPayloadSignature(pPayload, wzUnverifiedPayloadPath, hFile);
1394 - ExitOnFailure(hr, "Failed to verify payload signature: %ls", wzCachedPath);
1395 - }
1396 - else if (pPayload->pCatalog) // If catalog files are specified, attempt to verify the file with a catalog file
1397 - {
1398 - hr = VerifyPayloadWithCatalog(pPayload, wzUnverifiedPayloadPath, hFile);
1399 - ExitOnFailure(hr, "Failed to verify payload signature: %ls", wzCachedPath);
1400 - }
1401 - else if (pPayload->pbHash) // the payload should have a hash we can use to verify it.
1331 + if (pPayload->pbHash) // the payload should have a hash we can use to verify it.
1332 {
1333 hr = VerifyHash(pPayload->pbHash, pPayload->cbHash, wzUnverifiedPayloadPath, hFile);
1334 ExitOnFailure(hr, "Failed to verify payload hash: %ls", wzCachedPath);
@@ -1466,18 +1396,7 @@ static HRESULT VerifyFileAgainstPayload(
1396 ExitOnRootFailure(hr, "Failed to open payload at path: %ls", wzVerifyPath);
1397 }
1398
1469 - // If the payload has a certificate root public key identifier provided, verify the certificate.
1470 - if (pPayload->pbCertificateRootPublicKeyIdentifier)
1471 - {
1472 - hr = CacheVerifyPayloadSignature(pPayload, wzVerifyPath, hFile);
1473 - ExitOnFailure(hr, "Failed to verify signature of payload: %ls", pPayload->sczKey);
1474 - }
1475 - else if (pPayload->pCatalog) // If catalog files are specified, attempt to verify the file with a catalog file
1476 - {
1477 - hr = VerifyPayloadWithCatalog(pPayload, wzVerifyPath, hFile);
1478 - ExitOnFailure(hr, "Failed to verify catalog signature of payload: %ls", pPayload->sczKey);
1479 - }
1480 - else if (pPayload->pbHash) // the payload should have a hash we can use to verify it.
1399 + if (pPayload->pbHash) // the payload should have a hash we can use to verify it.
1400 {
1401 hr = VerifyHash(pPayload->pbHash, pPayload->cbHash, wzVerifyPath, hFile);
1402 ExitOnFailure(hr, "Failed to verify hash of payload: %ls", pPayload->sczKey);
@@ -1517,7 +1436,7 @@ LExit:
1436
1437 static HRESULT ResetPathPermissions(
1438 __in BOOL fPerMachine,
1520 - __in LPCWSTR wzPath
1439 + __in_z LPCWSTR wzPath
1440 )
1441 {
1442 HRESULT hr = S_OK;
@@ -1863,164 +1782,3 @@ LExit:
1782
1783 return hr;
1784 }
1866 -
1867 -static HRESULT VerifyPayloadWithCatalog(
1868 - __in BURN_PAYLOAD* pPayload,
1869 - __in_z LPCWSTR wzUnverifiedPayloadPath,
1870 - __in HANDLE hFile
1871 - )
1872 -{
1873 - HRESULT hr = S_FALSE;
1874 - DWORD er = ERROR_SUCCESS;
1875 - WINTRUST_DATA WinTrustData = { };
1876 - WINTRUST_CATALOG_INFO WinTrustCatalogInfo = { };
1877 - GUID gSubSystemDriver = WINTRUST_ACTION_GENERIC_VERIFY_V2;
1878 - LPWSTR sczLowerCaseFile = NULL;
1879 - LPWSTR pCurrent = NULL;
1880 - LPWSTR sczName = NULL;
1881 - DWORD dwHashSize = 0;
1882 - DWORD dwTagSize;
1883 - LPBYTE pbHash = NULL;
1884 -
1885 - // Get lower case file name. Older operating systems need a lower case file
1886 - // to match in the catalog
1887 - hr = StrAllocString(&sczLowerCaseFile, wzUnverifiedPayloadPath, 0);
1888 - ExitOnFailure(hr, "Failed to allocate memory");
1889 -
1890 - // Go through each character doing the lower case of each letter
1891 - pCurrent = sczLowerCaseFile;
1892 - while ('\0' != *pCurrent)
1893 - {
1894 - *pCurrent = (WCHAR)_tolower(*pCurrent);
1895 - pCurrent++;
1896 - }
1897 -
1898 - // Get file hash
1899 - CryptCATAdminCalcHashFromFileHandle(hFile, &dwHashSize, pbHash, 0);
1900 - er = ::GetLastError();
1901 - if (ERROR_INSUFFICIENT_BUFFER == er)
1902 - {
1903 - pbHash = (LPBYTE)MemAlloc(dwHashSize, TRUE);
1904 - if (!CryptCATAdminCalcHashFromFileHandle(hFile, &dwHashSize, pbHash, 0))
1905 - {
1906 - ExitWithLastError(hr, "Failed to get file hash.");
1907 - }
1908 - }
1909 - else
1910 - {
1911 - ExitOnWin32Error(er, hr, "Failed to get file hash.");
1912 - }
1913 -
1914 - // Make the hash into a string. This is the member tag for the catalog
1915 - dwTagSize = (dwHashSize * 2) + 1;
1916 - hr = StrAlloc(&sczName, dwTagSize);
1917 - ExitOnFailure(hr, "Failed to allocate string.");
1918 - hr = StrHexEncode(pbHash, dwHashSize, sczName, dwTagSize);
1919 - ExitOnFailure(hr, "Failed to encode file hash.");
1920 -
1921 - // Set up the WinVerifyTrust structures assuming online.
1922 - WinTrustData.cbStruct = sizeof(WINTRUST_DATA);
1923 - WinTrustData.dwUIChoice = WTD_UI_NONE;
1924 - WinTrustData.dwUnionChoice = WTD_CHOICE_CATALOG;
1925 - WinTrustData.dwStateAction = WTD_STATEACTION_VERIFY;
1926 - WinTrustData.dwProvFlags = WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT;
1927 - WinTrustData.pCatalog = &WinTrustCatalogInfo;
1928 -
1929 - WinTrustCatalogInfo.cbStruct = sizeof(WINTRUST_CATALOG_INFO);
1930 - WinTrustCatalogInfo.pbCalculatedFileHash = pbHash;
1931 - WinTrustCatalogInfo.cbCalculatedFileHash = dwHashSize;
1932 - WinTrustCatalogInfo.hMemberFile = hFile;
1933 - WinTrustCatalogInfo.pcwszMemberTag = sczName;
1934 - WinTrustCatalogInfo.pcwszMemberFilePath = sczLowerCaseFile;
1935 - WinTrustCatalogInfo.pcwszCatalogFilePath = pPayload->pCatalog->sczLocalFilePath;
1936 -
1937 - hr = ::WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), &gSubSystemDriver, &WinTrustData);
1938 - if (hr)
1939 - {
1940 - // Set up the WinVerifyTrust structures assuming online.
1941 - WinTrustData.dwProvFlags |= WTD_CACHE_ONLY_URL_RETRIEVAL;
1942 -
1943 - er = ::WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), &gSubSystemDriver, &WinTrustData);
1944 -
1945 - // WinVerifyTrust returns 0 for success, a few different Win32 error codes if it can't
1946 - // find the provider, and any other error code is provider specific, so may not
1947 - // be an actual Win32 error code
1948 - ExitOnWin32Error(er, hr, "Could not verify file %ls.", wzUnverifiedPayloadPath);
1949 - }
1950 -
1951 - // Need to close the WinVerifyTrust action
1952 - WinTrustData.dwStateAction = WTD_STATEACTION_CLOSE;
1953 - er = ::WinVerifyTrust(static_cast<HWND>(INVALID_HANDLE_VALUE), &gSubSystemDriver, &WinTrustData);
1954 - ExitOnWin32Error(er, hr, "Could not close verify handle.");
1955 -
1956 -LExit:
1957 - ReleaseStr(sczLowerCaseFile);
1958 - ReleaseStr(sczName);
1959 - ReleaseMem(pbHash);
1960 -
1961 - return hr;
1962 -}
1963 -
1964 -static HRESULT VerifyPayloadAgainstChain(
1965 - __in BURN_PAYLOAD* pPayload,
1966 - __in PCCERT_CHAIN_CONTEXT pChainContext
1967 - )
1968 -{
1969 - HRESULT hr = S_OK;
1970 - PCCERT_CONTEXT pChainElementCertContext = NULL;
1971 -
1972 - BYTE rgbPublicKeyIdentifier[SHA1_HASH_LEN] = { };
1973 - DWORD cbPublicKeyIdentifier = sizeof(rgbPublicKeyIdentifier);
1974 - BYTE* pbThumbprint = NULL;
1975 - DWORD cbThumbprint = 0;
1976 -
1977 - // Walk up the chain looking for a certificate in the chain that matches our expected public key identifier
1978 - // and thumbprint (if a thumbprint was provided).
1979 - HRESULT hrChainVerification = E_NOTFOUND; // assume we won't find a match.
1980 - for (DWORD i = 0; i < pChainContext->rgpChain[0]->cElement; ++i)
1981 - {
1982 - pChainElementCertContext = pChainContext->rgpChain[0]->rgpElement[i]->pCertContext;
1983 -
1984 - // Get the certificate's public key identifier.
1985 - if (!::CryptHashPublicKeyInfo(NULL, CALG_SHA1, 0, X509_ASN_ENCODING, &pChainElementCertContext->pCertInfo->SubjectPublicKeyInfo, rgbPublicKeyIdentifier, &cbPublicKeyIdentifier))
1986 - {
1987 - ExitWithLastError(hr, "Failed to get certificate public key identifier.");
1988 - }
1989 -
1990 - // Compare the certificate's public key identifier with the payload's public key identifier. If they
1991 - // match, we're one step closer to the a positive result.
1992 - if (pPayload->cbCertificateRootPublicKeyIdentifier == cbPublicKeyIdentifier &&
1993 - 0 == memcmp(pPayload->pbCertificateRootPublicKeyIdentifier, rgbPublicKeyIdentifier, cbPublicKeyIdentifier))
1994 - {
1995 - // If the payload specified a thumbprint for the certificate, verify it.
1996 - if (pPayload->pbCertificateRootThumbprint)
1997 - {
1998 - hr = CertReadProperty(pChainElementCertContext, CERT_SHA1_HASH_PROP_ID, &pbThumbprint, &cbThumbprint);
1999 - ExitOnFailure(hr, "Failed to read certificate thumbprint.");
2000 -
2001 - if (pPayload->cbCertificateRootThumbprint == cbThumbprint &&
2002 - 0 == memcmp(pPayload->pbCertificateRootThumbprint, pbThumbprint, cbThumbprint))
2003 - {
2004 - // If we got here, we found that our payload public key identifier and thumbprint
2005 - // matched an element in the certficate chain.
2006 - hrChainVerification = S_OK;
2007 - break;
2008 - }
2009 -
2010 - ReleaseNullMem(pbThumbprint);
2011 - }
2012 - else // no thumbprint match necessary so we're good to go.
2013 - {
2014 - hrChainVerification = S_OK;
2015 - break;
2016 - }
2017 - }
2018 - }
2019 - hr = hrChainVerification;
2020 - ExitOnFailure(hr, "Failed to find expected public key in certificate chain.");
2021 -
2022 -LExit:
2023 - ReleaseMem(pbThumbprint);
2024 -
2025 - return hr;
2026 -}
src/engine/cache.h
+1 -6
@@ -16,7 +16,7 @@ HRESULT CacheInitialize(
16 __in_z_opt LPCWSTR wzSourceProcessPath
17 );
18 HRESULT CacheEnsureWorkingFolder(
19 - __in LPCWSTR wzBundleId,
19 + __in_z LPCWSTR wzBundleId,
20 __deref_out_z_opt LPWSTR* psczWorkingFolder
21 );
22 HRESULT CacheCalculateBundleWorkingPath(
@@ -134,11 +134,6 @@ HRESULT CacheRemovePackage(
134 __in_z LPCWSTR wzPackageId,
135 __in_z LPCWSTR wzCacheId
136 );
137 -HRESULT CacheVerifyPayloadSignature(
138 - __in BURN_PAYLOAD* pPayload,
139 - __in_z LPCWSTR wzUnverifiedPayloadPath,
140 - __in HANDLE hFile
141 - );
137 void CacheCleanup(
138 __in BOOL fPerMachine,
139 __in_z LPCWSTR wzBundleId
src/engine/catalog.cpp deleted
-180
@@ -1,180 +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 -// function definitions
7 -
8 -extern "C" HRESULT CatalogsParseFromXml(
9 - __in BURN_CATALOGS* pCatalogs,
10 - __in IXMLDOMNode* pixnBundle
11 - )
12 -{
13 - HRESULT hr = S_OK;
14 - IXMLDOMNodeList* pixnNodes = NULL;
15 - IXMLDOMNode* pixnNode = NULL;
16 - DWORD cNodes = 0;
17 - LPWSTR scz = NULL;
18 -
19 - // select catalog nodes
20 - hr = XmlSelectNodes(pixnBundle, L"Catalog", &pixnNodes);
21 - ExitOnFailure(hr, "Failed to select catalog nodes.");
22 -
23 - // get catalog node count
24 - hr = pixnNodes->get_length((long*)&cNodes);
25 - ExitOnFailure(hr, "Failed to get payload node count.");
26 - if (!cNodes)
27 - {
28 - ExitFunction();
29 - }
30 -
31 - // allocate memory for catalogs
32 - pCatalogs->rgCatalogs = (BURN_CATALOG*)MemAlloc(sizeof(BURN_CATALOG) * cNodes, TRUE);
33 - ExitOnNull(pCatalogs->rgCatalogs, hr, E_OUTOFMEMORY, "Failed to allocate memory for payload structs.");
34 -
35 - pCatalogs->cCatalogs = cNodes;
36 -
37 - // parse catalog elements
38 - for (DWORD i = 0; i < cNodes; ++i)
39 - {
40 - BURN_CATALOG* pCatalog = &pCatalogs->rgCatalogs[i];
41 - pCatalog->hFile = INVALID_HANDLE_VALUE;
42 -
43 - hr = XmlNextElement(pixnNodes, &pixnNode, NULL);
44 - ExitOnFailure(hr, "Failed to get next node.");
45 -
46 - // @Id
47 - hr = XmlGetAttributeEx(pixnNode, L"Id", &pCatalog->sczKey);
48 - ExitOnFailure(hr, "Failed to get @Id.");
49 -
50 - // @Payload
51 - hr = XmlGetAttributeEx(pixnNode, L"Payload", &pCatalog->sczPayload);
52 - ExitOnFailure(hr, "Failed to get @Payload.");
53 -
54 - // prepare next iteration
55 - ReleaseNullObject(pixnNode);
56 - }
57 -
58 -LExit:
59 - ReleaseObject(pixnNodes);
60 - ReleaseObject(pixnNode);
61 - ReleaseStr(scz);
62 -
63 - return hr;
64 -}
65 -
66 -extern "C" HRESULT CatalogFindById(
67 - __in BURN_CATALOGS* pCatalogs,
68 - __in_z LPCWSTR wzId,
69 - __out BURN_CATALOG** ppCatalog
70 - )
71 -{
72 - HRESULT hr = S_OK;
73 - BURN_CATALOG* pCatalog = NULL;
74 -
75 - for (DWORD i = 0; i < pCatalogs->cCatalogs; ++i)
76 - {
77 - pCatalog = &pCatalogs->rgCatalogs[i];
78 -
79 - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pCatalog->sczKey, -1, wzId, -1))
80 - {
81 - *ppCatalog = pCatalog;
82 - ExitFunction1(hr = S_OK);
83 - }
84 - }
85 -
86 - hr = E_NOTFOUND;
87 -
88 -LExit:
89 - return hr;
90 -}
91 -
92 -extern "C" HRESULT CatalogLoadFromPayload(
93 - __in BURN_CATALOGS* pCatalogs,
94 - __in BURN_PAYLOADS* pPayloads
95 - )
96 -{
97 - HRESULT hr = S_OK;
98 - BURN_CATALOG* pCatalog = NULL;
99 - BURN_PAYLOAD* pPayload = NULL;
100 -
101 - // go through each catalog file
102 - for (DWORD i = 0; i < pCatalogs->cCatalogs; i++)
103 - {
104 - pCatalog = &pCatalogs->rgCatalogs[i];
105 -
106 - // get the payload for this catalog file
107 - hr = PayloadFindById(pPayloads, pCatalog->sczPayload, &pPayload);
108 - ExitOnFailure(hr, "Failed to find payload for catalog file.");
109 -
110 - // Get the local file name
111 - hr = StrAllocString(&pCatalog->sczLocalFilePath, pPayload->sczLocalFilePath, 0);
112 - ExitOnFailure(hr, "Failed to get catalog local file path");
113 -
114 - // Get a handle to the file
115 - pCatalog->hFile = ::CreateFileW(pCatalog->sczLocalFilePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
116 - if (INVALID_HANDLE_VALUE == pCatalog->hFile)
117 - {
118 - ExitWithLastError(hr, "Failed to open catalog in working path: %ls", pCatalog->sczLocalFilePath);
119 - }
120 -
121 - // Verify the catalog file
122 - hr = CacheVerifyPayloadSignature(pPayload, pCatalog->sczLocalFilePath, pCatalog->hFile);
123 - ExitOnFailure(hr, "Failed to verify catalog signature: %ls", pCatalog->sczLocalFilePath);
124 - }
125 -
126 -LExit:
127 - return hr;
128 -}
129 -
130 -extern "C" HRESULT CatalogElevatedUpdateCatalogFile(
131 - __in BURN_CATALOGS* pCatalogs,
132 - __in_z LPCWSTR wzId,
133 - __in_z LPCWSTR wzPath
134 - )
135 -{
136 - HRESULT hr = S_OK;
137 - BURN_CATALOG* pCatalog = NULL;
138 -
139 - // Find the catalog
140 - hr = CatalogFindById(pCatalogs, wzId, &pCatalog);
141 - ExitOnFailure(hr, "Failed to locate catalog information.");
142 -
143 - if (NULL == pCatalog->sczLocalFilePath)
144 - {
145 - hr = StrAllocString(&pCatalog->sczLocalFilePath, wzPath, 0);
146 - ExitOnFailure(hr, "Failed to allocated catalog path.");
147 -
148 - // Get a handle to the file
149 - pCatalog->hFile = ::CreateFileW(pCatalog->sczLocalFilePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
150 - if (INVALID_HANDLE_VALUE == pCatalog->hFile)
151 - {
152 - ExitWithLastError(hr, "Failed to open catalog in working path: %ls", pCatalog->sczLocalFilePath);
153 - }
154 - }
155 -
156 -LExit:
157 - return hr;
158 -}
159 -
160 -extern "C" void CatalogUninitialize(
161 - __in BURN_CATALOGS* pCatalogs
162 - )
163 -{
164 - if (pCatalogs->rgCatalogs)
165 - {
166 - for (DWORD i = 0; i < pCatalogs->cCatalogs; ++i)
167 - {
168 - BURN_CATALOG* pCatalog = &pCatalogs->rgCatalogs[i];
169 -
170 - ReleaseHandle(pCatalog->hFile);
171 - ReleaseStr(pCatalog->sczKey);
172 - ReleaseStr(pCatalog->sczLocalFilePath);
173 - ReleaseStr(pCatalog->sczPayload);
174 - }
175 - MemFree(pCatalogs->rgCatalogs);
176 - }
177 -
178 - // clear struct
179 - memset(pCatalogs, 0, sizeof(BURN_CATALOGS));
180 -}
src/engine/catalog.h deleted
-56
@@ -1,56 +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 -
5 -#if defined(__cplusplus)
6 -extern "C" {
7 -#endif
8 -
9 -// structs
10 -
11 -typedef struct _BURN_CATALOG
12 -{
13 - LPWSTR sczKey;
14 - LPWSTR sczPayload;
15 -
16 - // mutable members
17 - LPWSTR sczLocalFilePath; // location of extracted or downloaded copy
18 - HANDLE hFile;
19 -} BURN_CATALOG;
20 -
21 -typedef struct _BURN_CATALOGS
22 -{
23 - BURN_CATALOG* rgCatalogs;
24 - DWORD cCatalogs;
25 -} BURN_CATALOGS;
26 -
27 -typedef struct _BURN_PAYLOADS BURN_PAYLOADS;
28 -
29 -
30 -// functions
31 -
32 -HRESULT CatalogsParseFromXml(
33 - __in BURN_CATALOGS* pCatalogs,
34 - __in IXMLDOMNode* pixnBundle
35 - );
36 -HRESULT CatalogFindById(
37 - __in BURN_CATALOGS* pCatalogs,
38 - __in_z LPCWSTR wzId,
39 - __out BURN_CATALOG** ppCatalog
40 - );
41 -HRESULT CatalogLoadFromPayload(
42 - __in BURN_CATALOGS* pCatalogs,
43 - __in BURN_PAYLOADS* pPayloads
44 - );
45 -HRESULT CatalogElevatedUpdateCatalogFile(
46 - __in BURN_CATALOGS* pCatalogs,
47 - __in_z LPCWSTR wzId,
48 - __in_z LPCWSTR wzPath
49 - );
50 -void CatalogUninitialize(
51 - __in BURN_CATALOGS* pCatalogs
52 - );
53 -
54 -#if defined(__cplusplus)
55 -}
56 -#endif
src/engine/core.cpp
-4
@@ -151,10 +151,6 @@ extern "C" HRESULT CoreInitialize(
151 hr = PayloadExtractFromContainer(&pEngineState->userExperience.payloads, NULL, &containerContext, pEngineState->userExperience.sczTempDirectory);
152 ExitOnFailure(hr, "Failed to extract bootstrapper application payloads.");
153
154 - // Load the catalog files as soon as they are extracted.
155 - hr = CatalogLoadFromPayload(&pEngineState->catalogs, &pEngineState->userExperience.payloads);
156 - ExitOnFailure(hr, "Failed to load catalog files.");
157 -
154 hr = PathConcat(pEngineState->userExperience.sczTempDirectory, L"BootstrapperApplicationData.xml", &pEngineState->command.wzBootstrapperApplicationDataPath);
155 ExitOnFailure(hr, "Failed to get BootstrapperApplicationDataPath.");
156
src/engine/core.h
-1
@@ -98,7 +98,6 @@ typedef struct _BURN_ENGINE_STATE
98 BURN_USER_EXPERIENCE userExperience;
99 BURN_REGISTRATION registration;
100 BURN_CONTAINERS containers;
101 - BURN_CATALOGS catalogs;
101 BURN_PAYLOADS payloads;
102 BURN_PACKAGES packages;
103 BURN_UPDATE update;
src/engine/engine.cpp
-1
@@ -400,7 +400,6 @@ static void UninitializeEngineState(
400 RegistrationUninitialize(&pEngineState->registration);
401 PayloadsUninitialize(&pEngineState->payloads);
402 PackagesUninitialize(&pEngineState->packages);
403 - CatalogUninitialize(&pEngineState->catalogs);
403 SectionUninitialize(&pEngineState->section);
404 ContainersUninitialize(&pEngineState->containers);
405
src/engine/engine.vcxproj
+1 -17
@@ -1,9 +1,7 @@
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 -
3 <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <Import Project="..\..\packages\WixToolset.DUtil.4.0.59\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.59\build\WixToolset.DUtil.props')" />
6 -
5 <ItemGroup Label="ProjectConfigurations">
6 <ProjectConfiguration Include="Debug|Win32">
7 <Configuration>Debug</Configuration>
@@ -30,7 +28,6 @@
28 <Platform>ARM64</Platform>
29 </ProjectConfiguration>
30 </ItemGroup>
33 -
31 <PropertyGroup Label="Globals">
32 <ProjectGuid>{8119537D-E1D9-6591-D51A-49768A2F9C37}</ProjectGuid>
33 <ConfigurationType>StaticLibrary</ConfigurationType>
@@ -39,22 +36,17 @@
36 <CharacterSet>Unicode</CharacterSet>
37 <Description>Native component of WixToolset.Burn</Description>
38 </PropertyGroup>
42 -
39 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
40 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
45 -
41 <ImportGroup Label="ExtensionSettings">
42 </ImportGroup>
48 -
43 <ImportGroup Label="Shared">
44 </ImportGroup>
51 -
45 <ItemGroup>
46 <ClCompile Include="apply.cpp" />
47 <ClCompile Include="approvedexe.cpp" />
48 <ClCompile Include="bitsengine.cpp" />
49 <ClCompile Include="burnextension.cpp" />
57 - <ClCompile Include="catalog.cpp" />
50 <ClCompile Include="detect.cpp" />
51 <ClCompile Include="embedded.cpp" />
52 <ClCompile Include="EngineForApplication.cpp" />
@@ -95,7 +87,6 @@
87 <ClCompile Include="variable.cpp" />
88 <ClCompile Include="variant.cpp" />
89 </ItemGroup>
98 -
90 <ItemGroup>
91 <ClInclude Include="apply.h" />
92 <ClInclude Include="approvedexe.h" />
@@ -107,7 +98,6 @@
98 <ClInclude Include="burnextension.h" />
99 <ClInclude Include="cabextract.h" />
100 <ClInclude Include="cache.h" />
110 - <ClInclude Include="catalog.h" />
101 <ClInclude Include="condition.h" />
102 <ClInclude Include="container.h" />
103 <ClInclude Include="core.h" />
@@ -145,11 +135,9 @@
135 <ClInclude Include="variable.h" />
136 <ClInclude Include="variant.h" />
137 </ItemGroup>
148 -
138 <ItemGroup>
139 <None Include="packages.config" />
140 </ItemGroup>
152 -
141 <ItemGroup>
142 <CustomBuild Include="engine.mc">
143 <Message>Compiling message file...</Message>
@@ -158,10 +146,7 @@ rc.exe -fo "$(OutDir)engine.res" "$(IntDir)engine.messages.rc"</Command>
146 <Outputs>$(IntDir)engine.messages.h;$(IntDir)engine.messages.rc;$(OutDir)engine.res</Outputs>
147 </CustomBuild>
148 </ItemGroup>
161 -
162 - <Target Name="SetWixVersion"
163 - DependsOnTargets="GetBuildVersion"
164 - BeforeTargets="ClCompile">
149 + <Target Name="SetWixVersion" DependsOnTargets="GetBuildVersion" BeforeTargets="ClCompile">
150 <PropertyGroup>
151 <rmj>$(MajorMinorVersion.Split(`.`)[0])</rmj>
152 <rmm>$(MajorMinorVersion.Split(`.`)[1])</rmm>
@@ -176,7 +161,6 @@ rc.exe -fo "$(OutDir)engine.res" "$(IntDir)engine.messages.rc"</Command>
161 </ClCompile>
162 </ItemGroup>
163 </Target>
179 -
164 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
165 <Import Project="..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\packages\Nerdbank.GitVersioning.3.3.37\build\Nerdbank.GitVersioning.targets')" />
166 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
src/engine/manifest.cpp
+1 -5
@@ -132,10 +132,6 @@ static HRESULT ParseFromXml(
132 hr = SearchesParseFromXml(&pEngineState->searches, &pEngineState->extensions, pixeBundle);
133 ExitOnFailure(hr, "Failed to parse searches.");
134
135 - // parse catalog files
136 - hr = CatalogsParseFromXml(&pEngineState->catalogs, pixeBundle);
137 - ExitOnFailure(hr, "Failed to parse catalog files.");
138 -
135 // parse registration
136 hr = RegistrationParseFromXml(&pEngineState->registration, pixeBundle);
137 ExitOnFailure(hr, "Failed to parse registration.");
@@ -149,7 +145,7 @@ static HRESULT ParseFromXml(
145 ExitOnFailure(hr, "Failed to parse containers.");
146
147 // parse payloads
152 - hr = PayloadsParseFromXml(&pEngineState->payloads, &pEngineState->containers, &pEngineState->catalogs, pixeBundle);
148 + hr = PayloadsParseFromXml(&pEngineState->payloads, &pEngineState->containers, pixeBundle);
149 ExitOnFailure(hr, "Failed to parse payloads.");
150
151 // parse packages
src/engine/payload.cpp
-33
@@ -18,7 +18,6 @@ static HRESULT FindEmbeddedBySourcePath(
18 extern "C" HRESULT PayloadsParseFromXml(
19 __in BURN_PAYLOADS* pPayloads,
20 __in_opt BURN_CONTAINERS* pContainers,
21 - __in_opt BURN_CATALOGS* pCatalogs,
21 __in IXMLDOMNode* pixnBundle
22 )
23 {
@@ -130,26 +129,6 @@ extern "C" HRESULT PayloadsParseFromXml(
129 ExitOnFailure(hr, "Failed to parse @FileSize.");
130 }
131
133 - // @CertificateAuthorityKeyIdentifier
134 - hr = XmlGetAttributeEx(pixnNode, L"CertificateRootPublicKeyIdentifier", &scz);
135 - if (E_NOTFOUND != hr)
136 - {
137 - ExitOnFailure(hr, "Failed to get @CertificateRootPublicKeyIdentifier.");
138 -
139 - hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootPublicKeyIdentifier, &pPayload->cbCertificateRootPublicKeyIdentifier);
140 - ExitOnFailure(hr, "Failed to hex decode @CertificateRootPublicKeyIdentifier.");
141 - }
142 -
143 - // @CertificateThumbprint
144 - hr = XmlGetAttributeEx(pixnNode, L"CertificateRootThumbprint", &scz);
145 - if (E_NOTFOUND != hr)
146 - {
147 - ExitOnFailure(hr, "Failed to get @CertificateRootThumbprint.");
148 -
149 - hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootThumbprint, &pPayload->cbCertificateRootThumbprint);
150 - ExitOnFailure(hr, "Failed to hex decode @CertificateRootThumbprint.");
151 - }
152 -
132 // @Hash
133 hr = XmlGetAttributeEx(pixnNode, L"Hash", &scz);
134 ExitOnFailure(hr, "Failed to get @Hash.");
@@ -157,16 +136,6 @@ extern "C" HRESULT PayloadsParseFromXml(
136 hr = StrAllocHexDecode(scz, &pPayload->pbHash, &pPayload->cbHash);
137 ExitOnFailure(hr, "Failed to hex decode the Payload/@Hash.");
138
160 - // @Catalog
161 - hr = XmlGetAttributeEx(pixnNode, L"Catalog", &scz);
162 - if (E_NOTFOUND != hr)
163 - {
164 - ExitOnFailure(hr, "Failed to get @Catalog.");
165 -
166 - hr = CatalogFindById(pCatalogs, scz, &pPayload->pCatalog);
167 - ExitOnFailure(hr, "Failed to find catalog.");
168 - }
169 -
139 // prepare next iteration
140 ReleaseNullObject(pixnNode);
141 }
@@ -194,8 +163,6 @@ extern "C" void PayloadsUninitialize(
163 ReleaseStr(pPayload->sczKey);
164 ReleaseStr(pPayload->sczFilePath);
165 ReleaseMem(pPayload->pbHash);
197 - ReleaseMem(pPayload->pbCertificateRootThumbprint);
198 - ReleaseMem(pPayload->pbCertificateRootPublicKeyIdentifier);
166 ReleaseStr(pPayload->sczSourcePath);
167 ReleaseStr(pPayload->sczLocalFilePath);
168 ReleaseStr(pPayload->downloadSource.sczUrl);
src/engine/payload.h
-6
@@ -35,11 +35,6 @@ typedef struct _BURN_PAYLOAD
35 DWORD64 qwFileSize;
36 LPWSTR sczFilePath; // file path relative to the execute location
37
38 - BURN_CATALOG *pCatalog; // used to verify this payload
39 - BYTE* pbCertificateRootPublicKeyIdentifier;
40 - DWORD cbCertificateRootPublicKeyIdentifier;
41 - BYTE* pbCertificateRootThumbprint;
42 - DWORD cbCertificateRootThumbprint;
38 BYTE* pbHash;
39 DWORD cbHash;
40
@@ -64,7 +59,6 @@ typedef struct _BURN_PAYLOADS
59 HRESULT PayloadsParseFromXml(
60 __in BURN_PAYLOADS* pPayloads,
61 __in_opt BURN_CONTAINERS* pContainers,
67 - __in_opt BURN_CATALOGS* pCatalogs,
62 __in IXMLDOMNode* pixnBundle
63 );
64 void PayloadsUninitialize(
src/engine/precomp.h
-1
@@ -68,7 +68,6 @@
68 #include "section.h"
69 #include "approvedexe.h"
70 #include "container.h"
71 -#include "catalog.h"
71 #include "payload.h"
72 #include "cabextract.h"
73 #include "burnextension.h"
src/engine/userexperience.cpp
+1 -1
@@ -55,7 +55,7 @@ extern "C" HRESULT UserExperienceParseFromXml(
55 }
56
57 // parse payloads
58 - hr = PayloadsParseFromXml(&pUserExperience->payloads, NULL, NULL, pixnUserExperienceNode);
58 + hr = PayloadsParseFromXml(&pUserExperience->payloads, NULL, pixnUserExperienceNode);
59 ExitOnFailure(hr, "Failed to parse user experience payloads.");
60
61 // make sure we have at least one payload
src/stub/stub.vcxproj
+2 -2
@@ -63,14 +63,14 @@
63
64 <PropertyGroup>
65 <ProjectAdditionalIncludeDirectories>$(ProjectDir)..\engine\inc</ProjectAdditionalIncludeDirectories>
66 - <ProjectAdditionalLinkLibraries>cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;wininet.lib;wintrust.lib;wuguid.lib;engine.lib;engine.res</ProjectAdditionalLinkLibraries>
66 + <ProjectAdditionalLinkLibraries>cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;wininet.lib;wuguid.lib;engine.lib;engine.res</ProjectAdditionalLinkLibraries>
67 </PropertyGroup>
68
69 <ItemDefinitionGroup>
70 <Link>
71 <SwapRunFromCD>true</SwapRunFromCD>
72 <SwapRunFromNET>true</SwapRunFromNET>
73 - <DelayLoadDLLs>cabinet.dll;crypt32.dll;msi.dll;shlwapi.dll;version.dll;wininet.dll;wintrust.dll</DelayLoadDLLs>
73 + <DelayLoadDLLs>cabinet.dll;crypt32.dll;msi.dll;shlwapi.dll;version.dll;wininet.dll</DelayLoadDLLs>
74 </Link>
75 </ItemDefinitionGroup>
76
src/test/BurnUnitTest/BurnUnitTest.vcxproj
+1 -1
@@ -36,7 +36,7 @@
36 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
37 <PropertyGroup>
38 <ProjectAdditionalIncludeDirectories>..\..\engine;..\..\WixToolset.BootstrapperCore.Native\inc</ProjectAdditionalIncludeDirectories>
39 - <ProjectAdditionalLinkLibraries>cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;wininet.lib;wintrust.lib</ProjectAdditionalLinkLibraries>
39 + <ProjectAdditionalLinkLibraries>cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;wininet.lib</ProjectAdditionalLinkLibraries>
40 </PropertyGroup>
41 <ItemGroup>
42 <ClCompile Include="AssemblyInfo.cpp" />
src/test/BurnUnitTest/precomp.h
-1
@@ -43,7 +43,6 @@
43 #include "section.h"
44 #include "approvedexe.h"
45 #include "container.h"
46 -#include "catalog.h"
46 #include "payload.h"
47 #include "cabextract.h"
48 #include "burnextension.h"