-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: incorporate new win7 code signing technique
https://git.zx2c4.com/downlevel-driver-enabler/about/ Signed-off-by: Jason A. Donenfeld <[email protected]>
- Loading branch information
Showing
7 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{6E8213E6-5046-4DE8-A760-0932C7D6E33E}</ProjectGuid> | ||
<RootNamespace>downlevelshim</RootNamespace> | ||
<ProjectName>downlevelshim</ProjectName> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<PlatformToolset>WindowsApplicationForDrivers10.0</PlatformToolset> | ||
</PropertyGroup> | ||
<Import Project="..\wintun.props" /> | ||
<PropertyGroup> | ||
<TargetName>downlevelshim</TargetName> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<PreprocessorDefinitions>_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<AdditionalOptions>/volatile:iso %(AdditionalOptions)</AdditionalOptions> | ||
</ClCompile> | ||
<Link> | ||
<ModuleDefinitionFile>exports.def</ModuleDefinitionFile> | ||
<SubSystem>Windows</SubSystem> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<None Include="exports.def" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="shim.c" /> | ||
</ItemGroup> | ||
<Import Project="..\wintun.props.user" Condition="exists('..\wintun.props.user')" /> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LIBRARY downlevelshim.dll | ||
EXPORTS | ||
DriverFinalPolicy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 | ||
* | ||
* Copyright (C) 2018-2021 WireGuard LLC. All Rights Reserved. | ||
*/ | ||
|
||
#include <windows.h> | ||
#include <wintrust.h> | ||
|
||
typedef DWORD(DRIVER_FINAL_POLICY_FN)(CRYPT_PROVIDER_DATA *); | ||
typedef DRIVER_FINAL_POLICY_FN *PDRIVER_FINAL_POLICY_FN; | ||
|
||
DRIVER_FINAL_POLICY_FN DriverFinalPolicy; | ||
|
||
DWORD | ||
DriverFinalPolicy(CRYPT_PROVIDER_DATA *ProvData) | ||
{ | ||
DWORD OriginalLastError = GetLastError(); | ||
HMODULE WintrustModule = GetModuleHandleA("WINTRUST.DLL"); | ||
if (!WintrustModule) | ||
return ERROR_INVALID_LIBRARY; | ||
PDRIVER_FINAL_POLICY_FN RealDriverFinalPolicy = | ||
(PDRIVER_FINAL_POLICY_FN)GetProcAddress(WintrustModule, "DriverFinalPolicy"); | ||
if (!RealDriverFinalPolicy) | ||
return ERROR_INVALID_FUNCTION; | ||
DWORD Ret = RealDriverFinalPolicy(ProvData); | ||
if (Ret == ERROR_APP_WRONG_OS) | ||
{ | ||
Ret = ERROR_SUCCESS; | ||
SetLastError(OriginalLastError); | ||
} | ||
return Ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters