Pull changes from downstream

- Drop Visual Studio 2010 support
- Update SAL
- New and updated classes and templates
- Copyright year update

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
2019-01-18 14:47:33 +01:00
parent 7440a3f421
commit f47faea71b
35 changed files with 1452 additions and 576 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -27,7 +27,7 @@
winstd::bstr::~bstr()
{
if (m_h)
if (m_h != invalid)
SysFreeString(m_h);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -29,7 +29,7 @@
winstd::cert_context::~cert_context()
{
if (m_h)
if (m_h != invalid)
CertFreeCertificateContext(m_h);
}
@@ -52,7 +52,7 @@ winstd::cert_context::handle_type winstd::cert_context::duplicate_internal(_In_
winstd::cert_chain_context::~cert_chain_context()
{
if (m_h)
if (m_h != invalid)
CertFreeCertificateChain(m_h);
}
@@ -75,7 +75,7 @@ winstd::cert_chain_context::handle_type winstd::cert_chain_context::duplicate_in
winstd::cert_store::~cert_store()
{
if (m_h)
if (m_h != invalid)
CertCloseStore(m_h, 0);
}
@@ -92,7 +92,7 @@ void winstd::cert_store::free_internal()
winstd::crypt_prov::~crypt_prov()
{
if (m_h)
if (m_h != invalid)
CryptReleaseContext(m_h, 0);
}
@@ -109,7 +109,7 @@ void winstd::crypt_prov::free_internal()
winstd::crypt_hash::~crypt_hash()
{
if (m_h)
if (m_h != invalid)
CryptDestroyHash(m_h);
}
@@ -122,8 +122,8 @@ void winstd::crypt_hash::free_internal()
winstd::crypt_hash::handle_type winstd::crypt_hash::duplicate_internal(_In_ handle_type h) const
{
handle_type hNew = NULL;
return CryptDuplicateHash(h, NULL, 0, &hNew) ? hNew : NULL;
handle_type hNew = invalid;
return CryptDuplicateHash(h, NULL, 0, &hNew) ? hNew : invalid;
}
@@ -133,7 +133,7 @@ winstd::crypt_hash::handle_type winstd::crypt_hash::duplicate_internal(_In_ hand
winstd::crypt_key::~crypt_key()
{
if (m_h)
if (m_h != invalid)
CryptDestroyKey(m_h);
}
@@ -209,8 +209,8 @@ void winstd::crypt_key::free_internal()
winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle_type h) const
{
handle_type hNew = NULL;
return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : NULL;
handle_type hNew = invalid;
return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : invalid;
}
@@ -220,6 +220,6 @@ winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle
winstd::data_blob::~data_blob()
{
if (pbData)
if (pbData != NULL)
LocalFree(pbData);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -80,7 +80,7 @@ const EAP_ATTRIBUTE winstd::eap_attr::blank = {};
winstd::eap_packet::~eap_packet()
{
if (m_h)
if (m_h != invalid)
HeapFree(GetProcessHeap(), 0, m_h);
}
@@ -95,9 +95,9 @@ winstd::eap_packet::handle_type winstd::eap_packet::duplicate_internal(_In_ hand
{
WORD n = ntohs(*(WORD*)h->Length);
handle_type h2 = (handle_type)HeapAlloc(GetProcessHeap(), 0, n);
if (!h2) {
if (h2 == invalid) {
SetLastError(ERROR_OUTOFMEMORY);
return NULL;
return invalid;
}
memcpy(h2, h, n);

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -118,7 +118,7 @@ void winstd::event_rec::set_user_data_internal(_In_ USHORT size, _In_bytecount_(
winstd::event_provider::~event_provider()
{
if (m_h)
if (m_h != invalid)
EventUnregister(m_h);
}
@@ -155,7 +155,7 @@ VOID NTAPI winstd::event_provider::enable_callback(_In_ LPCGUID SourceId, _In_ U
winstd::event_session::~event_session()
{
if (m_h)
if (m_h != invalid)
ControlTrace(m_h, name(), m_prop.get(), EVENT_TRACE_CONTROL_STOP);
}
@@ -192,7 +192,7 @@ winstd::event_trace_enabler::~event_trace_enabler()
winstd::event_trace::~event_trace()
{
if (m_h)
if (m_h != invalid)
CloseTrace(m_h);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.

51
src/SetupAPI.cpp Normal file
View File

@@ -0,0 +1,51 @@
/*
Copyright 1991-2019 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, "Setupapi.lib")
//////////////////////////////////////////////////////////////////////
// winstd::setup_device_info_list
//////////////////////////////////////////////////////////////////////
winstd::setup_device_info_list::~setup_device_info_list()
{
if (m_h != invalid)
SetupDiDestroyDeviceInfoList(m_h);
}
void winstd::setup_device_info_list::free_internal()
{
SetupDiDestroyDeviceInfoList(m_h);
}
//////////////////////////////////////////////////////////////////////
// winstd::setup_device_info_list
//////////////////////////////////////////////////////////////////////
winstd::setup_driver_info_list_builder::~setup_driver_info_list_builder()
{
if (m_result)
SetupDiDestroyDriverInfoList(m_DeviceInfoSet, m_DeviceInfoData, m_DriverType);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -20,6 +20,8 @@
#pragma once
#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h.
#include "../include/WinStd/Base64.h"
#include "../include/WinStd/COM.h"
#include "../include/WinStd/Cred.h"
@@ -33,8 +35,10 @@
#if defined(SECURITY_WIN32) || defined(SECURITY_KERNEL) || defined(SECURITY_MAC)
#include "../include/WinStd/Sec.h"
#endif
#include "../include/WinStd/SetupAPI.h"
#include "../include/WinStd/Shell.h"
#include "../include/WinStd/Win.h"
#include "../include/WinStd/WinSock2.h"
#include "../include/WinStd/WinTrust.h"
#include "../include/WinStd/WLAN.h"
#include "../include/WinStd/Common.h"

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -27,7 +27,7 @@
winstd::wlan_handle::~wlan_handle()
{
if (m_h)
if (m_h != invalid)
WlanCloseHandle(m_h, NULL);
}
@@ -36,5 +36,3 @@ void winstd::wlan_handle::free_internal()
{
WlanCloseHandle(m_h, NULL);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 GÉANT
This file is part of WinStd.
@@ -151,30 +151,13 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
}
//////////////////////////////////////////////////////////////////////
// winstd::win_handle
//////////////////////////////////////////////////////////////////////
winstd::win_handle::~win_handle()
{
if (m_h)
CloseHandle(m_h);
}
void winstd::win_handle::free_internal()
{
CloseHandle(m_h);
}
//////////////////////////////////////////////////////////////////////
// winstd::library
//////////////////////////////////////////////////////////////////////
winstd::library::~library()
{
if (m_h)
if (m_h != invalid)
FreeLibrary(m_h);
}
@@ -185,13 +168,47 @@ void winstd::library::free_internal()
}
//////////////////////////////////////////////////////////////////////
// winstd::critical_section
//////////////////////////////////////////////////////////////////////
winstd::critical_section::critical_section()
{
InitializeCriticalSection(&m_data);
}
winstd::critical_section::~critical_section()
{
DeleteCriticalSection(&m_data);
}
//////////////////////////////////////////////////////////////////////
// winstd::find_file
//////////////////////////////////////////////////////////////////////
winstd::find_file::~find_file()
{
if (m_h != invalid) {
FindClose(m_h);
}
}
void winstd::find_file::free_internal()
{
FindClose(m_h);
}
//////////////////////////////////////////////////////////////////////
// winstd::heap
//////////////////////////////////////////////////////////////////////
winstd::heap::~heap()
{
if (m_h) {
if (m_h != invalid) {
enumerate();
HeapDestroy(m_h);
}
@@ -200,6 +217,8 @@ winstd::heap::~heap()
bool winstd::heap::enumerate()
{
assert(m_h != invalid);
bool found = false;
// Lock the heap for exclusive access.
@@ -277,13 +296,31 @@ winstd::user_impersonator::~user_impersonator()
}
//////////////////////////////////////////////////////////////////////
// winstd::console_ctrl_handler
//////////////////////////////////////////////////////////////////////
winstd::console_ctrl_handler::console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) :
m_handler(HandlerRoutine)
{
m_cookie = SetConsoleCtrlHandler(m_handler, TRUE);
}
winstd::console_ctrl_handler::~console_ctrl_handler()
{
if (m_cookie)
SetConsoleCtrlHandler(m_handler, FALSE);
}
//////////////////////////////////////////////////////////////////////
// winstd::vmemory
//////////////////////////////////////////////////////////////////////
winstd::vmemory::~vmemory()
{
if (m_h)
if (m_h != invalid)
VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
}
@@ -300,7 +337,7 @@ void winstd::vmemory::free_internal()
winstd::reg_key::~reg_key()
{
if (m_h)
if (m_h != invalid)
RegCloseKey(m_h);
}
@@ -317,7 +354,7 @@ void winstd::reg_key::free_internal()
winstd::security_id::~security_id()
{
if (m_h)
if (m_h != invalid)
FreeSid(m_h);
}

42
src/WinSock2.cpp Normal file
View File

@@ -0,0 +1,42 @@
/*
Copyright 1991-2019 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"
#if (NTDDI_VERSION >= NTDDI_WINXPSP2) || (_WIN32_WINNT >= 0x0502)
//////////////////////////////////////////////////////////////////////
// winstd::addrinfo
//////////////////////////////////////////////////////////////////////
winstd::addrinfo::~addrinfo()
{
if (m_h != invalid)
FreeAddrInfo(m_h);
}
void winstd::addrinfo::free_internal()
{
FreeAddrInfo(m_h);
}
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 1991-2018 Amebis
Copyright 1991-2019 Amebis
Copyright 2016 G<>ANT
This file is part of WinStd.