blob: c7175a4759eb0874bc884a6660e93f4739861cc8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// 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.
#include "precomp.h"
// https://gist.github.com/navossoc/7572c7d82243e9f818989e2765e7793a
HRESULT DetectSHA2CodeSigning(
__out BOOL* pfSupported
)
{
HRESULT hr = S_OK;
HMODULE hModule = NULL;
FARPROC pfn = NULL;
DWORD er = ERROR_SUCCESS;
hr = LoadSystemLibrary(L"wintrust.dll", &hModule);
BextExitOnFailure(hr, "Failed to load wintrust.dll");
pfn = ::GetProcAddress(hModule, "CryptCATAdminAcquireContext2");
if (pfn)
{
*pfSupported = TRUE;
ExitFunction1(hr = S_OK);
}
er = ::GetLastError();
if (er == ERROR_PROC_NOT_FOUND)
{
*pfSupported = FALSE;
ExitFunction1(hr = S_OK);
}
hr = HRESULT_FROM_WIN32(er);
BextExitOnFailure(hr, "Failed to probe for CryptCATAdminAcquireContext2 in wintrust.dll");
LExit:
::FreeLibrary(hModule);
return hr;
}
HRESULT UtilPerformDetectSHA2CodeSigning(
__in LPCWSTR wzVariable,
__in UTIL_SEARCH* /*pSearch*/,
__in IBootstrapperExtensionEngine* pEngine
)
{
HRESULT hr = S_OK;
BOOL fSupported = FALSE;
hr = DetectSHA2CodeSigning(&fSupported);
BextExitOnFailure(hr, "DetectSHA2CodeSigning failed.");
hr = pEngine->SetVariableNumeric(wzVariable, fSupported ? 1 : 0);
BextExitOnFailure(hr, "Failed to set variable '%ls'", wzVariable);
LExit:
return hr;
}
|