Add support for WinTrust API
This commit is contained in:
parent
aa7cd261f2
commit
cd78963fd2
@ -32,6 +32,9 @@
|
||||
<ClCompile Include="..\src\Win.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\WinTrust.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Sec.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -46,6 +49,9 @@
|
||||
<ClInclude Include="..\include\WinStd\Win.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\WinStd\WinTrust.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\WinStd\MSI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -32,6 +32,9 @@
|
||||
<ClCompile Include="..\src\Win.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\WinTrust.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Sec.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -46,6 +49,9 @@
|
||||
<ClInclude Include="..\include\WinStd\Win.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\WinStd\WinTrust.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\WinStd\MSI.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -31,6 +31,7 @@
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Win.cpp" />
|
||||
<ClCompile Include="..\src\WinTrust.cpp" />
|
||||
<ClCompile Include="..\src\WLAN.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -46,6 +47,7 @@
|
||||
<ClInclude Include="..\include\WinStd\Sec.h" />
|
||||
<ClInclude Include="..\include\WinStd\Shell.h" />
|
||||
<ClInclude Include="..\include\WinStd\Win.h" />
|
||||
<ClInclude Include="..\include\WinStd\WinTrust.h" />
|
||||
<ClInclude Include="..\include\WinStd\WLAN.h" />
|
||||
<ClInclude Include="..\src\StdAfx.h" />
|
||||
</ItemGroup>
|
||||
|
76
include/WinStd/WinTrust.h
Normal file
76
include/WinStd/WinTrust.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright 1991-2018 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of WinStd.
|
||||
|
||||
Setup is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Setup is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Setup. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// \defgroup WinTrustAPI WinTrust API
|
||||
/// Integrates WinStd classes with Microsoft WinTrust API
|
||||
///
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace winstd
|
||||
{
|
||||
class WINSTD_API wintrust;
|
||||
}
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <WinTrust.h>
|
||||
|
||||
|
||||
namespace winstd
|
||||
{
|
||||
/// \addtogroup WinTrustAPI
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// WinTrust engine wrapper class
|
||||
///
|
||||
class WINSTD_API wintrust
|
||||
{
|
||||
public:
|
||||
///
|
||||
/// Initializes a new class instance.
|
||||
///
|
||||
inline wintrust(_In_opt_ HWND hwnd, _In_ const GUID &action, _Inout_ WINTRUST_DATA &wtd) :
|
||||
m_hwnd(hwnd),
|
||||
m_action(action),
|
||||
m_wtd(wtd)
|
||||
{
|
||||
LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
throw win_runtime_error(lResult, "WinVerifyTrust failed.");
|
||||
}
|
||||
|
||||
///
|
||||
/// Destroys the WinTrust context.
|
||||
///
|
||||
virtual ~wintrust();
|
||||
|
||||
protected:
|
||||
HWND m_hwnd;
|
||||
GUID m_action;
|
||||
WINTRUST_DATA &m_wtd;
|
||||
};
|
||||
|
||||
/// @}
|
||||
}
|
34
src/WinTrust.cpp
Normal file
34
src/WinTrust.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 1991-2018 Amebis
|
||||
Copyright 2016 GÉANT
|
||||
|
||||
This file is part of WinStd.
|
||||
|
||||
Setup is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Setup is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Setup. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#pragma comment(lib, "Wintrust.lib")
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// winstd::wintrust
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
winstd::wintrust::~wintrust()
|
||||
{
|
||||
m_wtd.dwStateAction = WTD_STATEACTION_CLOSE;
|
||||
WinVerifyTrust(m_hwnd, (GUID*)&m_action, &m_wtd);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user