Address code analysis warnings

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-02-12 19:27:07 +01:00
parent 7d2062d3bf
commit 73619821ee
24 changed files with 473 additions and 454 deletions

View File

@ -51,7 +51,7 @@ namespace winstd
/// ///
/// Constructs blank encoding session /// Constructs blank encoding session
/// ///
inline base64_enc() : num(0) inline base64_enc() noexcept : num(0)
{ {
buf[0] = 0; buf[0] = 0;
buf[1] = 0; buf[1] = 0;
@ -99,7 +99,7 @@ namespace winstd
/// ///
/// Resets encoding session /// Resets encoding session
/// ///
inline void clear() inline void clear() noexcept
{ {
num = 0; num = 0;
} }
@ -112,7 +112,7 @@ namespace winstd
/// ///
/// \returns Maximum number of bytes for the encoded data of `size` length /// \returns Maximum number of bytes for the encoded data of `size` length
/// ///
inline size_t enc_size(size_t size) const inline size_t enc_size(size_t size) const noexcept
{ {
return ((num + size + 2)/3)*4; return ((num + size + 2)/3)*4;
} }
@ -182,7 +182,7 @@ namespace winstd
/// ///
/// Constructs blank decoding session /// Constructs blank decoding session
/// ///
inline base64_dec() : num(0) inline base64_dec() noexcept : num(0)
{ {
buf[0] = 0; buf[0] = 0;
buf[1] = 0; buf[1] = 0;
@ -235,7 +235,7 @@ namespace winstd
/// ///
/// Resets decoding session /// Resets decoding session
/// ///
inline void clear() inline void clear() noexcept
{ {
num = 0; num = 0;
} }
@ -248,7 +248,7 @@ namespace winstd
/// ///
/// \returns Maximum number of bytes for the decoded data of `size` length /// \returns Maximum number of bytes for the decoded data of `size` length
/// ///
inline size_t dec_size(size_t size) const inline size_t dec_size(size_t size) const noexcept
{ {
return ((num + size + 3)/4)*3; return ((num + size + 3)/4)*3;
} }

View File

@ -78,16 +78,6 @@ namespace winstd
inline com_runtime_error(_In_ error_type num, _In_opt_z_ const char *msg = nullptr) : num_runtime_error<HRESULT>(num, msg) inline com_runtime_error(_In_ error_type num, _In_opt_z_ const char *msg = nullptr) : num_runtime_error<HRESULT>(num, msg)
{ {
} }
///
/// Copies an exception
///
/// \param[in] other Exception to copy from
///
inline com_runtime_error(const com_runtime_error &other) : num_runtime_error<HRESULT>(other)
{
}
}; };
/// @} /// @}
@ -102,7 +92,7 @@ namespace winstd
/// ///
/// Default constructor /// Default constructor
/// ///
CoTaskMemFree_delete() {} CoTaskMemFree_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
@ -223,7 +213,7 @@ namespace winstd
/// ///
/// \sa [IUnknown::Release method](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682317.aspx) /// \sa [IUnknown::Release method](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682317.aspx)
/// ///
virtual void free_internal() void free_internal() noexcept override
{ {
m_h->Release(); m_h->Release();
} }
@ -238,7 +228,7 @@ namespace winstd
/// ///
/// \return Duplicated object handle /// \return Duplicated object handle
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const handle_type duplicate_internal(_In_ handle_type h) const noexcept override
{ {
h->AddRef(); h->AddRef();
return h; return h;
@ -257,7 +247,7 @@ namespace winstd
/// ///
/// Constructs BSTR from OLE string /// Constructs BSTR from OLE string
/// ///
inline bstr(_In_ LPCOLESTR src) inline bstr(_In_ LPCOLESTR src) noexcept
{ {
m_h = SysAllocString(src); m_h = SysAllocString(src);
} }
@ -265,7 +255,7 @@ namespace winstd
/// ///
/// Constructs BSTR from OLE string with length /// Constructs BSTR from OLE string with length
/// ///
inline bstr(_In_ LPCOLESTR src, _In_ UINT len) inline bstr(_In_ LPCOLESTR src, _In_ UINT len) noexcept
{ {
m_h = SysAllocStringLen(src, len); m_h = SysAllocStringLen(src, len);
} }
@ -274,7 +264,7 @@ namespace winstd
/// Constructs BSTR from std::basic_string /// Constructs BSTR from std::basic_string
/// ///
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline bstr(_In_ const std::basic_string<wchar_t, _Traits, _Ax> &src) inline bstr(_In_ const std::basic_string<wchar_t, _Traits, _Ax> &src) noexcept
{ {
m_h = SysAllocStringLen(src.c_str(), (UINT)src.length()); m_h = SysAllocStringLen(src.c_str(), (UINT)src.length());
} }
@ -291,7 +281,7 @@ namespace winstd
/// ///
/// \sa [SysStringLen function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221240.aspx) /// \sa [SysStringLen function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221240.aspx)
/// ///
inline UINT length() const inline UINT length() const noexcept
{ {
return SysStringLen(m_h); return SysStringLen(m_h);
} }
@ -302,7 +292,7 @@ namespace winstd
/// ///
/// \sa [SysFreeString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221481.aspx) /// \sa [SysFreeString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221481.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the string /// Duplicates the string
@ -313,20 +303,22 @@ namespace winstd
/// ///
/// \sa [SysAllocString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221458.aspx) /// \sa [SysAllocString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221458.aspx)
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
/// ///
/// VARIANT struct wrapper /// VARIANT struct wrapper
/// ///
#pragma warning(push)
#pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
class WINSTD_API variant : public VARIANT class WINSTD_API variant : public VARIANT
{ {
public: public:
/// ///
/// Constructs blank VARIANT /// Constructs blank VARIANT
/// ///
inline variant() inline variant() noexcept
{ {
VariantInit(this); VariantInit(this);
} }
@ -337,7 +329,7 @@ namespace winstd
inline variant(_In_ const VARIANT& varSrc) inline variant(_In_ const VARIANT& varSrc)
{ {
vt = VT_EMPTY; vt = VT_EMPTY;
HRESULT hr = VariantCopy(this, &varSrc); const HRESULT hr = VariantCopy(this, &varSrc);
if (FAILED(hr)) if (FAILED(hr))
throw winstd::com_runtime_error(hr, "VariantCopy failed."); throw winstd::com_runtime_error(hr, "VariantCopy failed.");
} }
@ -346,7 +338,7 @@ namespace winstd
/// Moves VARIANT from another /// Moves VARIANT from another
/// ///
#pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy() #pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy()
inline variant(_Inout_ VARIANT&& varSrc) inline variant(_Inout_ VARIANT&& varSrc) noexcept
{ {
memcpy(this, &varSrc, sizeof(VARIANT)); memcpy(this, &varSrc, sizeof(VARIANT));
varSrc.vt = VT_EMPTY; varSrc.vt = VT_EMPTY;
@ -355,7 +347,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from bool /// Constructs VARIANT from bool
/// ///
inline variant(_In_ bool bSrc) inline variant(_In_ bool bSrc) noexcept
{ {
vt = VT_BOOL; vt = VT_BOOL;
boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE; boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
@ -364,7 +356,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from character /// Constructs VARIANT from character
/// ///
inline variant(_In_ char cSrc) inline variant(_In_ char cSrc) noexcept
{ {
vt = VT_I1; vt = VT_I1;
cVal = cSrc; cVal = cSrc;
@ -373,7 +365,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from byte /// Constructs VARIANT from byte
/// ///
inline variant(_In_ unsigned char nSrc) inline variant(_In_ unsigned char nSrc) noexcept
{ {
vt = VT_UI1; vt = VT_UI1;
bVal = nSrc; bVal = nSrc;
@ -382,7 +374,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from short /// Constructs VARIANT from short
/// ///
inline variant(_In_ short nSrc) inline variant(_In_ short nSrc) noexcept
{ {
vt = VT_I2; vt = VT_I2;
iVal = nSrc; iVal = nSrc;
@ -391,7 +383,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from unsigned short /// Constructs VARIANT from unsigned short
/// ///
inline variant(_In_ unsigned short nSrc) inline variant(_In_ unsigned short nSrc) noexcept
{ {
vt = VT_UI2; vt = VT_UI2;
uiVal = nSrc; uiVal = nSrc;
@ -400,7 +392,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from integer /// Constructs VARIANT from integer
/// ///
inline variant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) inline variant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
{ {
assert(vtSrc == VT_I4 || vtSrc == VT_INT); assert(vtSrc == VT_I4 || vtSrc == VT_INT);
vt = vtSrc; vt = vtSrc;
@ -410,7 +402,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from unsigned integer /// Constructs VARIANT from unsigned integer
/// ///
inline variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) inline variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) noexcept
{ {
assert(vtSrc == VT_UI4 || vtSrc == VT_UINT); assert(vtSrc == VT_UI4 || vtSrc == VT_UINT);
vt = vtSrc; vt = vtSrc;
@ -420,7 +412,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from long /// Constructs VARIANT from long
/// ///
inline variant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) inline variant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
{ {
assert(vtSrc == VT_I4 || vtSrc == VT_ERROR); assert(vtSrc == VT_I4 || vtSrc == VT_ERROR);
vt = vtSrc; vt = vtSrc;
@ -430,7 +422,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from unsigned long /// Constructs VARIANT from unsigned long
/// ///
inline variant(_In_ unsigned long nSrc) inline variant(_In_ unsigned long nSrc) noexcept
{ {
vt = VT_UI4; vt = VT_UI4;
ulVal = nSrc; ulVal = nSrc;
@ -439,7 +431,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from float /// Constructs VARIANT from float
/// ///
inline variant(_In_ float fltSrc) inline variant(_In_ float fltSrc) noexcept
{ {
vt = VT_R4; vt = VT_R4;
fltVal = fltSrc; fltVal = fltSrc;
@ -448,7 +440,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from double or variant date /// Constructs VARIANT from double or variant date
/// ///
inline variant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) inline variant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) noexcept
{ {
assert(vtSrc == VT_R8 || vtSrc == VT_DATE); assert(vtSrc == VT_R8 || vtSrc == VT_DATE);
vt = vtSrc; vt = vtSrc;
@ -458,7 +450,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from 64-bit integer /// Constructs VARIANT from 64-bit integer
/// ///
inline variant(_In_ long long nSrc) inline variant(_In_ long long nSrc) noexcept
{ {
vt = VT_I8; vt = VT_I8;
llVal = nSrc; llVal = nSrc;
@ -467,7 +459,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from unsigned integer /// Constructs VARIANT from unsigned integer
/// ///
inline variant(_In_ unsigned long long nSrc) inline variant(_In_ unsigned long long nSrc) noexcept
{ {
vt = VT_UI8; vt = VT_UI8;
ullVal = nSrc; ullVal = nSrc;
@ -476,7 +468,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from CY (64-bit integer) /// Constructs VARIANT from CY (64-bit integer)
/// ///
inline variant(_In_ CY cySrc) inline variant(_In_ CY cySrc) noexcept
{ {
vt = VT_CY; vt = VT_CY;
cyVal.Hi = cySrc.Hi; cyVal.Hi = cySrc.Hi;
@ -486,7 +478,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from OLE string /// Constructs VARIANT from OLE string
/// ///
inline variant(_In_z_ LPCOLESTR lpszSrc) inline variant(_In_z_ LPCOLESTR lpszSrc) noexcept
{ {
vt = VT_EMPTY; vt = VT_EMPTY;
*this = lpszSrc; *this = lpszSrc;
@ -495,7 +487,7 @@ namespace winstd
/// ///
/// Constructs VARIANT from BSTR /// Constructs VARIANT from BSTR
/// ///
inline variant(_In_z_ BSTR bstr) inline variant(_In_z_ BSTR bstr) noexcept
{ {
vt = VT_EMPTY; vt = VT_EMPTY;
*this = bstr; *this = bstr;
@ -533,11 +525,11 @@ namespace winstd
assert(pSrc != NULL); assert(pSrc != NULL);
LPSAFEARRAY pCopy; LPSAFEARRAY pCopy;
HRESULT hr = SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
if (FAILED(hr)) if (FAILED(hr))
throw winstd::com_runtime_error(hr, "SafeArrayCopy failed."); throw winstd::com_runtime_error(hr, "SafeArrayCopy failed.");
SafeArrayGetVartype((LPSAFEARRAY)pSrc, &vt); SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
vt |= VT_ARRAY; vt |= VT_ARRAY;
parray = pCopy; parray = pCopy;
} }
@ -553,7 +545,7 @@ namespace winstd
inline variant& operator=(_In_ const VARIANT& varSrc) inline variant& operator=(_In_ const VARIANT& varSrc)
{ {
if (this != &varSrc) { if (this != &varSrc) {
HRESULT hr = VariantCopy(this, &varSrc); const HRESULT hr = VariantCopy(this, &varSrc);
if (FAILED(hr)) if (FAILED(hr))
throw winstd::com_runtime_error(hr, "VariantCopy failed."); throw winstd::com_runtime_error(hr, "VariantCopy failed.");
} }
@ -563,7 +555,7 @@ namespace winstd
/// ///
/// Moves from another VARIANT /// Moves from another VARIANT
/// ///
inline variant& operator=(_Inout_ VARIANT&& varSrc) inline variant& operator=(_Inout_ VARIANT&& varSrc) noexcept
{ {
if (this != &varSrc) { if (this != &varSrc) {
VariantClear(this); VariantClear(this);
@ -576,7 +568,7 @@ namespace winstd
/// ///
/// Copy from bool value /// Copy from bool value
/// ///
inline variant& operator=(_In_ bool bSrc) inline variant& operator=(_In_ bool bSrc) noexcept
{ {
if (vt != VT_BOOL) { if (vt != VT_BOOL) {
VariantClear(this); VariantClear(this);
@ -589,7 +581,7 @@ namespace winstd
/// ///
/// Copy from char value /// Copy from char value
/// ///
inline variant& operator=(_In_ char cSrc) inline variant& operator=(_In_ char cSrc) noexcept
{ {
if (vt != VT_I1) { if (vt != VT_I1) {
VariantClear(this); VariantClear(this);
@ -602,7 +594,7 @@ namespace winstd
/// ///
/// Copy from unsigned char value /// Copy from unsigned char value
/// ///
inline variant& operator=(_In_ unsigned char nSrc) inline variant& operator=(_In_ unsigned char nSrc) noexcept
{ {
if (vt != VT_UI1) { if (vt != VT_UI1) {
VariantClear(this); VariantClear(this);
@ -615,7 +607,7 @@ namespace winstd
/// ///
/// Copy from short value /// Copy from short value
/// ///
inline variant& operator=(_In_ short nSrc) inline variant& operator=(_In_ short nSrc) noexcept
{ {
if (vt != VT_I2) { if (vt != VT_I2) {
VariantClear(this); VariantClear(this);
@ -628,7 +620,7 @@ namespace winstd
/// ///
/// Copy from unsigned short value /// Copy from unsigned short value
/// ///
inline variant& operator=(_In_ unsigned short nSrc) inline variant& operator=(_In_ unsigned short nSrc) noexcept
{ {
if (vt != VT_UI2) { if (vt != VT_UI2) {
VariantClear(this); VariantClear(this);
@ -641,7 +633,7 @@ namespace winstd
/// ///
/// Copy from int value /// Copy from int value
/// ///
inline variant& operator=(_In_ int nSrc) inline variant& operator=(_In_ int nSrc) noexcept
{ {
if (vt != VT_I4) { if (vt != VT_I4) {
VariantClear(this); VariantClear(this);
@ -654,7 +646,7 @@ namespace winstd
/// ///
/// Copy from unsigned int value /// Copy from unsigned int value
/// ///
inline variant& operator=(_In_ unsigned int nSrc) inline variant& operator=(_In_ unsigned int nSrc) noexcept
{ {
if (vt != VT_UI4) { if (vt != VT_UI4) {
VariantClear(this); VariantClear(this);
@ -667,7 +659,7 @@ namespace winstd
/// ///
/// Copy from long value /// Copy from long value
/// ///
inline variant& operator=(_In_ long nSrc) inline variant& operator=(_In_ long nSrc) noexcept
{ {
if (vt != VT_I4) { if (vt != VT_I4) {
VariantClear(this); VariantClear(this);
@ -680,7 +672,7 @@ namespace winstd
/// ///
/// Copy from unsigned long value /// Copy from unsigned long value
/// ///
inline variant& operator=(_In_ unsigned long nSrc) inline variant& operator=(_In_ unsigned long nSrc) noexcept
{ {
if (vt != VT_UI4) { if (vt != VT_UI4) {
VariantClear(this); VariantClear(this);
@ -694,7 +686,7 @@ namespace winstd
/// ///
/// Copy from long long value /// Copy from long long value
/// ///
inline variant& operator=(_In_ long long nSrc) inline variant& operator=(_In_ long long nSrc) noexcept
{ {
if (vt != VT_I8) { if (vt != VT_I8) {
VariantClear(this); VariantClear(this);
@ -707,7 +699,7 @@ namespace winstd
/// ///
/// Copy from unsigned long long value /// Copy from unsigned long long value
/// ///
inline variant& operator=(_In_ unsigned long long nSrc) inline variant& operator=(_In_ unsigned long long nSrc) noexcept
{ {
if (vt != VT_UI8) { if (vt != VT_UI8) {
VariantClear(this); VariantClear(this);
@ -721,7 +713,7 @@ namespace winstd
/// ///
/// Copy from float value /// Copy from float value
/// ///
inline variant& operator=(_In_ float fltSrc) inline variant& operator=(_In_ float fltSrc) noexcept
{ {
if (vt != VT_R4) { if (vt != VT_R4) {
VariantClear(this); VariantClear(this);
@ -734,7 +726,7 @@ namespace winstd
/// ///
/// Copy from double value /// Copy from double value
/// ///
inline variant& operator=(_In_ double dblSrc) inline variant& operator=(_In_ double dblSrc) noexcept
{ {
if (vt != VT_R8) { if (vt != VT_R8) {
VariantClear(this); VariantClear(this);
@ -747,7 +739,7 @@ namespace winstd
/// ///
/// Copy from CY value /// Copy from CY value
/// ///
inline variant& operator=(_In_ CY cySrc) inline variant& operator=(_In_ CY cySrc) noexcept
{ {
if (vt != VT_CY) { if (vt != VT_CY) {
VariantClear(this); VariantClear(this);
@ -761,7 +753,7 @@ namespace winstd
/// ///
/// Copy from OLE string value /// Copy from OLE string value
/// ///
inline variant& operator=(_In_z_ LPCOLESTR lpszSrc) inline variant& operator=(_In_z_ LPCOLESTR lpszSrc) noexcept
{ {
VariantClear(this); VariantClear(this);
vt = VT_BSTR; vt = VT_BSTR;
@ -798,7 +790,7 @@ namespace winstd
/// ///
/// Copy from unsigned char reference /// Copy from unsigned char reference
/// ///
inline variant& operator=(_In_ unsigned char* pbSrc) inline variant& operator=(_In_ unsigned char* pbSrc) noexcept
{ {
if (vt != (VT_UI1|VT_BYREF)) { if (vt != (VT_UI1|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -811,7 +803,7 @@ namespace winstd
/// ///
/// Copy from short reference /// Copy from short reference
/// ///
inline variant& operator=(_In_ short* pnSrc) inline variant& operator=(_In_ short* pnSrc) noexcept
{ {
if (vt != (VT_I2|VT_BYREF)) { if (vt != (VT_I2|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -824,7 +816,7 @@ namespace winstd
/// ///
/// Copy from unsigned short reference /// Copy from unsigned short reference
/// ///
inline variant& operator=(_In_ unsigned short* pnSrc) inline variant& operator=(_In_ unsigned short* pnSrc) noexcept
{ {
if (vt != (VT_UI2|VT_BYREF)) { if (vt != (VT_UI2|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -837,7 +829,7 @@ namespace winstd
/// ///
/// Copy from int reference /// Copy from int reference
/// ///
inline variant& operator=(_In_ int* pnSrc) inline variant& operator=(_In_ int* pnSrc) noexcept
{ {
if (vt != (VT_I4|VT_BYREF)) { if (vt != (VT_I4|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -850,7 +842,7 @@ namespace winstd
/// ///
/// Copy from unsigned int reference /// Copy from unsigned int reference
/// ///
inline variant& operator=(_In_ unsigned int* pnSrc) inline variant& operator=(_In_ unsigned int* pnSrc) noexcept
{ {
if (vt != (VT_UI4|VT_BYREF)) { if (vt != (VT_UI4|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -863,7 +855,7 @@ namespace winstd
/// ///
/// Copy from long reference /// Copy from long reference
/// ///
inline variant& operator=(_In_ long* pnSrc) inline variant& operator=(_In_ long* pnSrc) noexcept
{ {
if (vt != (VT_I4|VT_BYREF)) { if (vt != (VT_I4|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -876,7 +868,7 @@ namespace winstd
/// ///
/// Copy from unsigned long reference /// Copy from unsigned long reference
/// ///
inline variant& operator=(_In_ unsigned long* pnSrc) inline variant& operator=(_In_ unsigned long* pnSrc) noexcept
{ {
if (vt != (VT_UI4|VT_BYREF)) { if (vt != (VT_UI4|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -889,7 +881,7 @@ namespace winstd
/// ///
/// Copy from long long reference /// Copy from long long reference
/// ///
inline variant& operator=(_In_ long long* pnSrc) inline variant& operator=(_In_ long long* pnSrc) noexcept
{ {
if (vt != (VT_I8|VT_BYREF)) { if (vt != (VT_I8|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -902,7 +894,7 @@ namespace winstd
/// ///
/// Copy from unsigned long long reference /// Copy from unsigned long long reference
/// ///
inline variant& operator=(_In_ unsigned long long* pnSrc) inline variant& operator=(_In_ unsigned long long* pnSrc) noexcept
{ {
if (vt != (VT_UI8|VT_BYREF)) { if (vt != (VT_UI8|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -915,7 +907,7 @@ namespace winstd
/// ///
/// Copy from float reference /// Copy from float reference
/// ///
inline variant& operator=(_In_ float* pfSrc) inline variant& operator=(_In_ float* pfSrc) noexcept
{ {
if (vt != (VT_R4|VT_BYREF)) { if (vt != (VT_R4|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -928,7 +920,7 @@ namespace winstd
/// ///
/// Copy from double reference /// Copy from double reference
/// ///
inline variant& operator=(_In_ double* pfSrc) inline variant& operator=(_In_ double* pfSrc) noexcept
{ {
if (vt != (VT_R8|VT_BYREF)) { if (vt != (VT_R8|VT_BYREF)) {
VariantClear(this); VariantClear(this);
@ -941,15 +933,15 @@ namespace winstd
/// ///
/// Copy from SAFEARRAY /// Copy from SAFEARRAY
/// ///
inline variant& operator=(_In_ const SAFEARRAY *pSrc) inline variant& operator=(_In_ const SAFEARRAY *pSrc) noexcept
{ {
assert(pSrc != NULL); assert(pSrc != NULL);
VariantClear(this); VariantClear(this);
LPSAFEARRAY pCopy; LPSAFEARRAY pCopy;
HRESULT hr = SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
SafeArrayGetVartype((LPSAFEARRAY)pSrc, &vt); SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
vt |= VT_ARRAY; vt |= VT_ARRAY;
parray = pCopy; parray = pCopy;
} else } else
@ -967,7 +959,7 @@ namespace winstd
/// - Non zero when variant is equal to \p varSrc; /// - Non zero when variant is equal to \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator==(_In_ const VARIANT& varSrc) const inline bool operator==(_In_ const VARIANT& varSrc) const noexcept
{ {
if (vt == VT_NULL && varSrc.vt == VT_NULL) return true; if (vt == VT_NULL && varSrc.vt == VT_NULL) return true;
if (vt != varSrc.vt) return false; if (vt != varSrc.vt) return false;
@ -982,7 +974,7 @@ namespace winstd
/// - Non zero when variant is not equal to \p varSrc; /// - Non zero when variant is not equal to \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator!=(_In_ const VARIANT& varSrc) const inline bool operator!=(_In_ const VARIANT& varSrc) const noexcept
{ {
return !operator==(varSrc); return !operator==(varSrc);
} }
@ -995,7 +987,7 @@ namespace winstd
/// - Non zero when variant is less than \p varSrc; /// - Non zero when variant is less than \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator<(_In_ const VARIANT& varSrc) const inline bool operator<(_In_ const VARIANT& varSrc) const noexcept
{ {
if (vt == VT_NULL && varSrc.vt == VT_NULL) return false; if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_LT); return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_LT);
@ -1009,7 +1001,7 @@ namespace winstd
/// - Non zero when variant is greater than \p varSrc; /// - Non zero when variant is greater than \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator>(_In_ const VARIANT& varSrc) const inline bool operator>(_In_ const VARIANT& varSrc) const noexcept
{ {
if (vt == VT_NULL && varSrc.vt == VT_NULL) return false; if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_GT); return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_GT);
@ -1023,7 +1015,7 @@ namespace winstd
/// - Non zero when variant is less than or equal to \p varSrc; /// - Non zero when variant is less than or equal to \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator<=(_In_ const VARIANT& varSrc) const inline bool operator<=(_In_ const VARIANT& varSrc) const noexcept
{ {
return !operator>(varSrc); return !operator>(varSrc);
} }
@ -1036,7 +1028,7 @@ namespace winstd
/// - Non zero when variant is greater than or equal to \p varSrc; /// - Non zero when variant is greater than or equal to \p varSrc;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator>=(_In_ const VARIANT& varSrc) const inline bool operator>=(_In_ const VARIANT& varSrc) const noexcept
{ {
return !operator<(varSrc); return !operator<(varSrc);
} }
@ -1046,14 +1038,14 @@ namespace winstd
/// ///
/// \sa [VariantChangeType function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221258.aspx) /// \sa [VariantChangeType function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms221258.aspx)
/// ///
inline HRESULT change_type(_In_ VARTYPE _vt, _In_opt_ USHORT wFlags = 0) inline HRESULT change_type(_In_ VARTYPE _vt, _In_opt_ USHORT wFlags = 0) noexcept
{ {
return VariantChangeType(this, this, wFlags, _vt); return VariantChangeType(this, this, wFlags, _vt);
} }
private: private:
/// \cond internal /// \cond internal
inline HRESULT compare(_In_ const VARIANT &varLeft, _In_ const VARIANT &varRight, _In_ LCID lcid, _In_ ULONG dwFlags) const inline HRESULT compare(_In_ const VARIANT &varLeft, _In_ const VARIANT &varRight, _In_ LCID lcid, _In_ ULONG dwFlags) const noexcept
{ {
switch(vt) { switch(vt) {
case VT_I1: return varLeft.cVal == varRight.cVal ? VARCMP_EQ : varLeft.cVal > varRight.cVal ? VARCMP_GT : VARCMP_LT; case VT_I1: return varLeft.cVal == varRight.cVal ? VARCMP_EQ : varLeft.cVal > varRight.cVal ? VARCMP_GT : VARCMP_LT;
@ -1065,6 +1057,7 @@ namespace winstd
} }
/// \endcond /// \endcond
}; };
#pragma warning(pop)
/// ///
@ -1072,13 +1065,16 @@ namespace winstd
/// ///
class WINSTD_API com_initializer class WINSTD_API com_initializer
{ {
WINSTD_NONCOPYABLE(com_initializer)
WINSTD_NONMOVABLE(com_initializer)
public: public:
/// ///
/// Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA). /// Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA).
/// ///
/// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx) /// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx)
/// ///
inline com_initializer(_In_opt_ LPVOID pvReserved) inline com_initializer(_In_opt_ LPVOID pvReserved) noexcept
{ {
m_result = CoInitialize(pvReserved); m_result = CoInitialize(pvReserved);
} }
@ -1089,7 +1085,7 @@ namespace winstd
/// ///
/// \sa [CoInitializeEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms695279.aspx) /// \sa [CoInitializeEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms695279.aspx)
/// ///
inline com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit) inline com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit) noexcept
{ {
m_result = CoInitializeEx(pvReserved, dwCoInit); m_result = CoInitializeEx(pvReserved, dwCoInit);
} }
@ -1108,7 +1104,7 @@ namespace winstd
/// ///
/// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx) /// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx)
/// ///
inline HRESULT status() const inline HRESULT status() const noexcept
{ {
return m_result; return m_result;
} }

View File

@ -105,16 +105,16 @@
/// ///
#define WINSTD_NONCOPYABLE(C) \ #define WINSTD_NONCOPYABLE(C) \
private: \ private: \
inline C (_In_ const C &h); \ inline C (_In_ const C &h) noexcept; \
inline C& operator=(_In_ const C &h); inline C& operator=(_In_ const C &h) noexcept;
/// ///
/// Declares a class as non-movable /// Declares a class as non-movable
/// ///
#define WINSTD_NONMOVABLE(C) \ #define WINSTD_NONMOVABLE(C) \
private: \ private: \
inline C (_Inout_ C &&h); \ inline C (_Inout_ C &&h) noexcept; \
inline C& operator=(_Inout_ C &&h); inline C& operator=(_Inout_ C &&h) noexcept;
/// @} /// @}
@ -163,10 +163,10 @@ private: \
/// ///
#define HANDLE_IMPL(C, INVAL) \ #define HANDLE_IMPL(C, INVAL) \
public: \ public: \
inline C ( ) { } \ inline C ( ) noexcept { } \
inline C (_In_opt_ handle_type h) : handle<handle_type, INVAL>( h ) { } \ inline C (_In_opt_ handle_type h) noexcept : handle<handle_type, INVAL>( h ) { } \
inline C (_Inout_ C &&h) noexcept : handle<handle_type, INVAL>(std::move(h)) { } \ inline C (_Inout_ C &&h) noexcept : handle<handle_type, INVAL>(std::move(h)) { } \
inline C& operator=(_In_opt_ handle_type h) { handle<handle_type, INVAL>::operator=( h ); return *this; } \ inline C& operator=(_In_opt_ handle_type h) noexcept { handle<handle_type, INVAL>::operator=( h ); return *this; } \
inline C& operator=(_Inout_ C &&h) noexcept { handle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \ inline C& operator=(_Inout_ C &&h) noexcept { handle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
WINSTD_NONCOPYABLE(C) WINSTD_NONCOPYABLE(C)
@ -175,12 +175,12 @@ WINSTD_NONCOPYABLE(C)
/// ///
#define DPLHANDLE_IMPL(C, INVAL) \ #define DPLHANDLE_IMPL(C, INVAL) \
public: \ public: \
inline C ( ) { } \ inline C ( ) noexcept { } \
inline C (_In_opt_ handle_type h) : dplhandle<handle_type, INVAL>( h ) { } \ inline C (_In_opt_ handle_type h) noexcept : dplhandle<handle_type, INVAL>( h ) { } \
inline C (_In_ const C &h) : dplhandle<handle_type, INVAL>(duplicate_internal(h.m_h)) { } \ inline C (_In_ const C &h) noexcept : dplhandle<handle_type, INVAL>(duplicate_internal(h.m_h)) { } \
inline C (_Inout_ C &&h) noexcept : dplhandle<handle_type, INVAL>(std::move (h )) { } \ inline C (_Inout_ C &&h) noexcept : dplhandle<handle_type, INVAL>(std::move (h )) { } \
inline C& operator=(_In_opt_ handle_type h) { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \ inline C& operator=(_In_opt_ handle_type h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
inline C& operator=(_In_ const C &h) { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \ inline C& operator=(_In_ const C &h) noexcept { dplhandle<handle_type, INVAL>::operator=( h ); return *this; } \
inline C& operator=(_Inout_ C &&h) noexcept { dplhandle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \ inline C& operator=(_Inout_ C &&h) noexcept { dplhandle<handle_type, INVAL>::operator=(std::move(h)); return *this; } \
private: private:
@ -234,7 +234,7 @@ namespace winstd
/// ///
/// \returns A helper wrapper class to handle returning a reference to the pointer /// \returns A helper wrapper class to handle returning a reference to the pointer
/// ///
template<class _Ty, class _Dx> inline ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner); template<class _Ty, class _Dx> inline ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) noexcept;
/// ///
/// Helper function template for returning pointers to std::unique_ptr /// Helper function template for returning pointers to std::unique_ptr
@ -244,7 +244,7 @@ namespace winstd
/// ///
/// \returns A helper wrapper class to handle returning a reference to the pointer /// \returns A helper wrapper class to handle returning a reference to the pointer
/// ///
template<class _Ty, class _Dx> inline ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner); template<class _Ty, class _Dx> inline ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept;
/// @} /// @}
@ -374,7 +374,7 @@ inline int vsnprintf(_Out_z_cap_(capacity) char *str, _In_ size_t capacity, _In_
/// ///
/// \returns Number of characters in result. /// \returns Number of characters in result.
/// ///
inline int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg); inline int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg) noexcept;
/// ///
/// Formats string using `printf()`. /// Formats string using `printf()`.
@ -491,12 +491,12 @@ namespace winstd
/// ///
/// Default construct /// Default construct
/// ///
LocalFree_delete() {} LocalFree_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
/// ///
void operator()(_Frees_ptr_opt_ _Ty *_Ptr) const void operator()(_Frees_ptr_opt_ _Ty *_Ptr) const noexcept
{ {
LocalFree(_Ptr); LocalFree(_Ptr);
} }
@ -582,6 +582,8 @@ namespace winstd
/// Helper class for returning pointers to std::unique_ptr /// Helper class for returning pointers to std::unique_ptr
/// (specialization for arrays) /// (specialization for arrays)
/// ///
#pragma warning(push)
#pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
template<class _Ty, class _Dx> template<class _Ty, class _Dx>
class ref_unique_ptr<_Ty[], _Dx> class ref_unique_ptr<_Ty[], _Dx>
{ {
@ -591,11 +593,28 @@ namespace winstd
/// ///
/// \param[inout] owner Object to attach helper to /// \param[inout] owner Object to attach helper to
/// ///
inline ref_unique_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) : inline ref_unique_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept :
m_own(owner), m_own(owner),
m_ptr(owner.release()) m_ptr(owner.release())
{} {}
///
/// Takes ownership of the pointer
///
/// \param[inout] owner Object to attach helper to
///
/// \returns Reference to this object
///
inline ref_unique_ptr& operator=(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept
{
if (this != &other) {
m_own = owner;
m_ptr = owner.release();
}
return *this;
}
/// ///
/// Moves object /// Moves object
/// ///
@ -608,10 +627,28 @@ namespace winstd
other.m_ptr = nullptr; other.m_ptr = nullptr;
} }
///
/// Moves object
///
/// \param[inout] other Source object
///
/// \returns Reference to this object
///
inline ref_unique_ptr& operator=(_Inout_ ref_unique_ptr<_Ty[], _Dx> &&other)
{
if (this != &other) {
m_own = other.m_own;
m_ptr = other.m_ptr;
other.m_ptr = nullptr;
}
return *this;
}
/// ///
/// Returns ownership of the pointer /// Returns ownership of the pointer
/// ///
inline ~ref_unique_ptr() virtual ~ref_unique_ptr()
{ {
if (m_ptr != nullptr) if (m_ptr != nullptr)
m_own.reset(m_ptr); m_own.reset(m_ptr);
@ -622,7 +659,7 @@ namespace winstd
/// ///
/// \return Pointer to the pointer /// \return Pointer to the pointer
/// ///
inline operator typename _Ty**() inline operator typename _Ty**() noexcept
{ {
return &m_ptr; return &m_ptr;
} }
@ -641,15 +678,16 @@ namespace winstd
std::unique_ptr<_Ty[], _Dx> &m_own; ///< Original owner of the pointer std::unique_ptr<_Ty[], _Dx> &m_own; ///< Original owner of the pointer
_Ty *m_ptr; ///< Pointer _Ty *m_ptr; ///< Pointer
}; };
#pragma warning(pop)
template<class _Ty, class _Dx> template<class _Ty, class _Dx>
inline ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) inline ref_unique_ptr<_Ty, _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty, _Dx> &owner) noexcept
{ {
return ref_unique_ptr<_Ty, _Dx>(owner); return ref_unique_ptr<_Ty, _Dx>(owner);
} }
template<class _Ty, class _Dx> template<class _Ty, class _Dx>
inline ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) inline ref_unique_ptr<_Ty[], _Dx> get_ptr(_Inout_ std::unique_ptr<_Ty[], _Dx> &owner) noexcept
{ {
return ref_unique_ptr<_Ty[], _Dx>(owner); return ref_unique_ptr<_Ty[], _Dx>(owner);
} }
@ -682,7 +720,7 @@ namespace winstd
/// ///
/// Initializes a new class instance with the object handle set to INVAL. /// Initializes a new class instance with the object handle set to INVAL.
/// ///
inline handle() : m_h(invalid) inline handle() noexcept : m_h(invalid)
{ {
} }
@ -691,7 +729,7 @@ namespace winstd
/// ///
/// \param[in] h Initial object handle value /// \param[in] h Initial object handle value
/// ///
inline handle(_In_opt_ handle_type h) : m_h(h) inline handle(_In_opt_ handle_type h) noexcept : m_h(h)
{ {
} }
@ -709,8 +747,8 @@ namespace winstd
private: private:
// This class is noncopyable. // This class is noncopyable.
handle(_In_ const handle<handle_type, INVAL> &h); inline handle(_In_ const handle<handle_type, INVAL> &h) noexcept {};
handle<handle_type, INVAL>& operator=(_In_ const handle<handle_type, INVAL> &h); inline handle<handle_type, INVAL>& operator=(_In_ const handle<handle_type, INVAL> &h) noexcept {};
public: public:
/// ///
@ -718,7 +756,7 @@ namespace winstd
/// ///
/// \param[in] h Object handle value /// \param[in] h Object handle value
/// ///
inline handle<handle_type, INVAL>& operator=(_In_opt_ handle_type h) inline handle<handle_type, INVAL>& operator=(_In_opt_ handle_type h) noexcept
{ {
attach(h); attach(h);
return *this; return *this;
@ -729,6 +767,7 @@ namespace winstd
/// ///
/// \param[inout] h A rvalue reference of another object /// \param[inout] h A rvalue reference of another object
/// ///
#pragma warning(suppress: 26432) // Move constructor is also present, but not detected by code analysis somehow.
inline handle<handle_type, INVAL>& operator=(_Inout_ handle<handle_type, INVAL> &&h) noexcept inline handle<handle_type, INVAL>& operator=(_Inout_ handle<handle_type, INVAL> &&h) noexcept
{ {
if (this != std::addressof(h)) { if (this != std::addressof(h)) {
@ -880,7 +919,7 @@ namespace winstd
/// ///
/// \param[in] h New object handle /// \param[in] h New object handle
/// ///
inline void attach(_In_opt_ handle_type h) inline void attach(_In_opt_ handle_type h) noexcept
{ {
if (m_h != invalid) if (m_h != invalid)
free_internal(); free_internal();
@ -916,7 +955,7 @@ namespace winstd
/// ///
/// Abstract member function that must be implemented by child classes to do the actual object destruction. /// Abstract member function that must be implemented by child classes to do the actual object destruction.
/// ///
virtual void free_internal() = 0; virtual void free_internal() noexcept = 0;
protected: protected:
handle_type m_h; ///< Object handle handle_type m_h; ///< Object handle
@ -937,7 +976,7 @@ namespace winstd
/// ///
/// Initializes a new class instance with the object handle set to INVAL. /// Initializes a new class instance with the object handle set to INVAL.
/// ///
inline dplhandle() inline dplhandle() noexcept
{ {
} }
@ -946,7 +985,7 @@ namespace winstd
/// ///
/// \param[in] h Initial object handle value /// \param[in] h Initial object handle value
/// ///
inline dplhandle(_In_opt_ handle_type h) : handle<handle_type, INVAL>(h) inline dplhandle(_In_opt_ handle_type h) noexcept : handle<handle_type, INVAL>(h)
{ {
} }
@ -955,7 +994,7 @@ namespace winstd
/// ///
/// \param[inout] h A reference of another object /// \param[inout] h A reference of another object
/// ///
inline dplhandle<handle_type, INVAL>(_In_ const dplhandle<handle_type, INVAL> &h) : handle<handle_type, INVAL>(internal_duplicate(h.m_h)) inline dplhandle<handle_type, INVAL>(_In_ const dplhandle<handle_type, INVAL> &h) noexcept : handle<handle_type, INVAL>(duplicate_internal(h.m_h))
{ {
} }
@ -973,7 +1012,7 @@ namespace winstd
/// ///
/// \param[in] h Object handle value /// \param[in] h Object handle value
/// ///
inline dplhandle<handle_type, INVAL>& operator=(_In_opt_ handle_type h) inline dplhandle<handle_type, INVAL>& operator=(_In_opt_ handle_type h) noexcept
{ {
handle<handle_type, INVAL>::operator=(h); handle<handle_type, INVAL>::operator=(h);
return *this; return *this;
@ -984,7 +1023,7 @@ namespace winstd
/// ///
/// \param[in] h Object /// \param[in] h Object
/// ///
inline dplhandle<handle_type, INVAL>& operator=(_In_ const dplhandle<handle_type, INVAL> &h) inline dplhandle<handle_type, INVAL>& operator=(_In_ const dplhandle<handle_type, INVAL> &h) noexcept
{ {
if (this != std::addressof(h)) { if (this != std::addressof(h)) {
if (h.m_h != invalid) { if (h.m_h != invalid) {
@ -1011,6 +1050,7 @@ namespace winstd
/// ///
/// \param[inout] h A rvalue reference of another object /// \param[inout] h A rvalue reference of another object
/// ///
#pragma warning(disable: 26432) // Move constructor is also present, but not detected by code analysis somehow.
inline dplhandle<handle_type, INVAL>& operator=(_Inout_ dplhandle<handle_type, INVAL> &&h) noexcept inline dplhandle<handle_type, INVAL>& operator=(_Inout_ dplhandle<handle_type, INVAL> &&h) noexcept
{ {
handle<handle_type, INVAL>::operator=(std::move(h)); handle<handle_type, INVAL>::operator=(std::move(h));
@ -1052,7 +1092,7 @@ namespace winstd
/// ///
/// \return Duplicated object handle /// \return Duplicated object handle
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const = 0; virtual handle_type duplicate_internal(_In_ handle_type h) const noexcept = 0;
}; };
/// @} /// @}
@ -1505,34 +1545,6 @@ namespace winstd
} }
///
/// Copies an exception
///
/// \param[in] other Exception to copy from
///
inline num_runtime_error(const num_runtime_error<_Tn> &other) :
m_num(other.m_num),
runtime_error(other)
{
}
///
/// Copies an exception
///
/// \param[in] other Exception to copy from
///
inline num_runtime_error& operator=(const num_runtime_error<_Tn> &other)
{
if (this != addressof(other)) {
*(runtime_error*)this = other;
m_num = other.m_num;
}
return *this;
}
/// ///
/// Returns the Windows error number /// Returns the Windows error number
/// ///
@ -1594,16 +1606,6 @@ namespace winstd
} }
///
/// Copies an exception
///
/// \param[in] other Exception to copy from
///
inline win_runtime_error(const win_runtime_error &other) : num_runtime_error<DWORD>(other)
{
}
/// ///
/// Returns a user-readable Windows error message /// Returns a user-readable Windows error message
/// ///
@ -1914,7 +1916,7 @@ namespace winstd
/// ///
/// Construct default allocator /// Construct default allocator
/// ///
inline sanitizing_allocator() : _Mybase() inline sanitizing_allocator() noexcept : _Mybase()
{ {
} }
@ -1931,7 +1933,7 @@ namespace winstd
/// Construct from a related allocator /// Construct from a related allocator
/// ///
template<class _Other> template<class _Other>
inline sanitizing_allocator(_In_ const sanitizing_allocator<_Other> &_Othr) : _Mybase(_Othr) inline sanitizing_allocator(_In_ const sanitizing_allocator<_Other> &_Othr) noexcept : _Mybase(_Othr)
{ {
} }
@ -1939,7 +1941,7 @@ namespace winstd
/// ///
/// Deallocate object at _Ptr sanitizing its content first /// Deallocate object at _Ptr sanitizing its content first
/// ///
inline void deallocate(_In_ pointer _Ptr, _In_ size_type _Size) void deallocate(_In_ pointer _Ptr, _In_ size_type _Size)
{ {
// Sanitize then free. // Sanitize then free.
SecureZeroMemory(_Ptr, _Size); SecureZeroMemory(_Ptr, _Size);
@ -1996,7 +1998,7 @@ inline int vsnprintf(_Out_z_cap_(capacity) char *str, _In_ size_t capacity, _In_
#endif #endif
inline int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg) inline int vsnprintf(_Out_z_cap_(capacity) wchar_t *str, _In_ size_t capacity, _In_z_ _Printf_format_string_ const wchar_t *format, _In_ va_list arg) noexcept
{ {
return _vsnwprintf(str, capacity, format, arg); return _vsnwprintf(str, capacity, format, arg);
} }
@ -2015,7 +2017,7 @@ inline int vsprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_
} else { } else {
for (size_t capacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; capacity *= 2) { for (size_t capacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; capacity *= 2) {
// Allocate on heap and retry. // Allocate on heap and retry.
std::unique_ptr<_Elem[]> buf_dyn(new _Elem[capacity]); auto buf_dyn = std::make_unique<_Elem[]>(capacity);
count = vsnprintf(buf_dyn.get(), capacity - 1, format, arg); count = vsnprintf(buf_dyn.get(), capacity - 1, format, arg);
if (count >= 0) { if (count >= 0) {
str.assign(buf_dyn.get(), count); str.assign(buf_dyn.get(), count);
@ -2035,7 +2037,7 @@ inline int sprintf(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &str, _In_z_ _
{ {
va_list arg; va_list arg;
va_start(arg, format); va_start(arg, format);
int res = vsprintf(str, format, arg); const int res = vsprintf(str, format, arg);
va_end(arg); va_end(arg);
return res; return res;
} }

View File

@ -44,7 +44,7 @@ namespace winstd
/// ///
/// \sa [CredEnumerate function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374794.aspx) /// \sa [CredEnumerate function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374794.aspx)
/// ///
inline BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIAL[], winstd::CredFree_delete<PCREDENTIAL[]> > &cCredentials); inline BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIAL[], winstd::CredFree_delete<PCREDENTIAL[]> > &cCredentials) noexcept;
/// @copydoc CredProtectW() /// @copydoc CredProtectW()
template<class _Elem, class _Traits, class _Ax> inline BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType); template<class _Elem, class _Traits, class _Ax> inline BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType);
@ -122,7 +122,7 @@ namespace winstd
/// ///
/// \sa [CredFree function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374796.aspx) /// \sa [CredFree function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374796.aspx)
/// ///
void operator()(_Ty *_Ptr) const void operator()(_Ty *_Ptr) const noexcept
{ {
CredFree(_Ptr); CredFree(_Ptr);
} }
@ -143,7 +143,7 @@ namespace winstd
} }
inline BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIAL[], winstd::CredFree_delete<PCREDENTIAL[]> > &cCredentials) inline BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIAL[], winstd::CredFree_delete<PCREDENTIAL[]> > &cCredentials) noexcept
{ {
PCREDENTIAL *pCredentials; PCREDENTIAL *pCredentials;
if (CredEnumerate(Filter, Flags, Count, &pCredentials)) { if (CredEnumerate(Filter, Flags, Count, &pCredentials)) {

View File

@ -141,7 +141,7 @@ namespace winstd
/// ///
/// \sa [CertCreateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376033.aspx) /// \sa [CertCreateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376033.aspx)
/// ///
inline bool create(_In_ DWORD dwCertEncodingType, _In_ LPCBYTE pbCertEncoded, _In_ DWORD cbCertEncoded) inline bool create(_In_ DWORD dwCertEncodingType, _In_ LPCBYTE pbCertEncoded, _In_ DWORD cbCertEncoded) noexcept
{ {
handle_type h = CertCreateCertificateContext(dwCertEncodingType, pbCertEncoded, cbCertEncoded); handle_type h = CertCreateCertificateContext(dwCertEncodingType, pbCertEncoded, cbCertEncoded);
if (h != invalid) { if (h != invalid) {
@ -159,7 +159,7 @@ namespace winstd
/// - Non zero when certificate is equal to \p other; /// - Non zero when certificate is equal to \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator==(_In_ const handle_type &other) const inline bool operator==(_In_ const handle_type &other) const noexcept
{ {
// TODO: [Crypto] Make constant time. // TODO: [Crypto] Make constant time.
return return
@ -175,7 +175,7 @@ namespace winstd
/// - Non zero when certificate is not equal to \p other; /// - Non zero when certificate is not equal to \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator!=(_In_ const handle_type &other) const inline bool operator!=(_In_ const handle_type &other) const noexcept
{ {
return !operator==(other); return !operator==(other);
} }
@ -188,10 +188,10 @@ namespace winstd
/// - Non zero when certificate is less than \p other; /// - Non zero when certificate is less than \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator<(_In_ const handle_type &other) const inline bool operator<(_In_ const handle_type &other) const noexcept
{ {
// TODO: [Crypto] Make constant time. // TODO: [Crypto] Make constant time.
int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded)); const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
return r < 0 || r == 0 && m_h->cbCertEncoded < other->cbCertEncoded; return r < 0 || r == 0 && m_h->cbCertEncoded < other->cbCertEncoded;
} }
@ -203,10 +203,10 @@ namespace winstd
/// - Non zero when certificate is greater than \p other; /// - Non zero when certificate is greater than \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator>(_In_ const handle_type &other) const inline bool operator>(_In_ const handle_type &other) const noexcept
{ {
// TODO: [Crypto] Make constant time. // TODO: [Crypto] Make constant time.
int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded)); const int r = memcmp(m_h->pbCertEncoded, other->pbCertEncoded, std::min<DWORD>(m_h->cbCertEncoded, other->cbCertEncoded));
return r > 0 || r == 0 && m_h->cbCertEncoded > other->cbCertEncoded; return r > 0 || r == 0 && m_h->cbCertEncoded > other->cbCertEncoded;
} }
@ -218,7 +218,7 @@ namespace winstd
/// - Non zero when certificate is less than \p other; /// - Non zero when certificate is less than \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator<=(_In_ const handle_type &other) const inline bool operator<=(_In_ const handle_type &other) const noexcept
{ {
return !operator>(other); return !operator>(other);
} }
@ -231,7 +231,7 @@ namespace winstd
/// - Non zero when certificate is greater than \p other; /// - Non zero when certificate is greater than \p other;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator>=(_In_ const handle_type &other) const inline bool operator>=(_In_ const handle_type &other) const noexcept
{ {
return !operator<(other); return !operator<(other);
} }
@ -242,7 +242,7 @@ namespace winstd
/// ///
/// \sa [CertFreeCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376075.aspx) /// \sa [CertFreeCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376075.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the certificate context. /// Duplicates the certificate context.
@ -253,7 +253,7 @@ namespace winstd
/// ///
/// \sa [CertDuplicateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376045.aspx) /// \sa [CertDuplicateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376045.aspx)
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
@ -281,7 +281,7 @@ namespace winstd
/// ///
/// \sa [CertGetCertificateChain function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376078.aspx) /// \sa [CertGetCertificateChain function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376078.aspx)
/// ///
inline bool create(_In_opt_ HCERTCHAINENGINE hChainEngine, _In_ PCCERT_CONTEXT pCertContext, _In_opt_ LPFILETIME pTime, _In_opt_ HCERTSTORE hAdditionalStore, _In_ PCERT_CHAIN_PARA pChainPara, _In_ DWORD dwFlags, __reserved LPVOID pvReserved = NULL) inline bool create(_In_opt_ HCERTCHAINENGINE hChainEngine, _In_ PCCERT_CONTEXT pCertContext, _In_opt_ LPFILETIME pTime, _In_opt_ HCERTSTORE hAdditionalStore, _In_ PCERT_CHAIN_PARA pChainPara, _In_ DWORD dwFlags, __reserved LPVOID pvReserved = NULL) noexcept
{ {
handle_type h; handle_type h;
if (CertGetCertificateChain(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, &h)) { if (CertGetCertificateChain(hChainEngine, pCertContext, pTime, hAdditionalStore, pChainPara, dwFlags, pvReserved, &h)) {
@ -297,7 +297,7 @@ namespace winstd
/// ///
/// \sa [CertFreeCertificateChain function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376073.aspx) /// \sa [CertFreeCertificateChain function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376073.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the certificate chain context. /// Duplicates the certificate chain context.
@ -308,7 +308,7 @@ namespace winstd
/// ///
/// \sa [CertDuplicateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376045.aspx) /// \sa [CertDuplicateCertificateContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376045.aspx)
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
@ -336,7 +336,7 @@ namespace winstd
/// ///
/// \sa [CertOpenStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376559.aspx) /// \sa [CertOpenStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376559.aspx)
/// ///
inline bool create(_In_ LPCSTR lpszStoreProvider, _In_ DWORD dwEncodingType, _In_opt_ HCRYPTPROV_LEGACY hCryptProv, _In_ DWORD dwFlags, _In_opt_ const void *pvPara) inline bool create(_In_ LPCSTR lpszStoreProvider, _In_ DWORD dwEncodingType, _In_opt_ HCRYPTPROV_LEGACY hCryptProv, _In_ DWORD dwFlags, _In_opt_ const void *pvPara) noexcept
{ {
handle_type h = CertOpenStore(lpszStoreProvider, dwEncodingType, hCryptProv, dwFlags, pvPara); handle_type h = CertOpenStore(lpszStoreProvider, dwEncodingType, hCryptProv, dwFlags, pvPara);
if (h != invalid) { if (h != invalid) {
@ -355,7 +355,7 @@ namespace winstd
/// ///
/// \sa [CertOpenSystemStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376560.aspx) /// \sa [CertOpenSystemStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376560.aspx)
/// ///
inline bool create(_In_opt_ HCRYPTPROV_LEGACY hCryptProv, _In_z_ LPCTSTR szSubsystemProtocol) inline bool create(_In_opt_ HCRYPTPROV_LEGACY hCryptProv, _In_z_ LPCTSTR szSubsystemProtocol) noexcept
{ {
handle_type h = CertOpenSystemStore(hCryptProv, szSubsystemProtocol); handle_type h = CertOpenSystemStore(hCryptProv, szSubsystemProtocol);
if (h != invalid) { if (h != invalid) {
@ -371,7 +371,7 @@ namespace winstd
/// ///
/// \sa [CertCloseStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376026.aspx) /// \sa [CertCloseStore function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376026.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -399,7 +399,7 @@ namespace winstd
/// ///
/// \sa [CryptAcquireContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886.aspx) /// \sa [CryptAcquireContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886.aspx)
/// ///
inline bool create(_In_opt_z_ LPCTSTR szContainer, _In_opt_z_ LPCTSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags = 0) inline bool create(_In_opt_z_ LPCTSTR szContainer, _In_opt_z_ LPCTSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags = 0) noexcept
{ {
handle_type h; handle_type h;
if (CryptAcquireContext(&h, szContainer, szProvider, dwProvType, dwFlags)) { if (CryptAcquireContext(&h, szContainer, szProvider, dwProvType, dwFlags)) {
@ -415,7 +415,7 @@ namespace winstd
/// ///
/// \sa [CryptReleaseContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380268.aspx) /// \sa [CryptReleaseContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380268.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -443,7 +443,7 @@ namespace winstd
/// ///
/// \sa [CryptCreateHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379908.aspx) /// \sa [CryptCreateHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379908.aspx)
/// ///
inline bool create(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_opt_ HCRYPTKEY hKey = NULL, _In_opt_ DWORD dwFlags = 0) inline bool create(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_opt_ HCRYPTKEY hKey = NULL, _In_opt_ DWORD dwFlags = 0) noexcept
{ {
handle_type h; handle_type h;
if (CryptCreateHash(hProv, Algid, hKey, dwFlags, &h)) { if (CryptCreateHash(hProv, Algid, hKey, dwFlags, &h)) {
@ -459,7 +459,7 @@ namespace winstd
/// ///
/// \sa [CryptDestroyHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379917.aspx) /// \sa [CryptDestroyHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379917.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the hash context. /// Duplicates the hash context.
@ -470,7 +470,7 @@ namespace winstd
/// ///
/// \sa [CryptDuplicateHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379919.aspx) /// \sa [CryptDuplicateHash function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379919.aspx)
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
@ -494,7 +494,7 @@ namespace winstd
/// ///
/// \sa [CryptGenKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379941.aspx) /// \sa [CryptGenKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379941.aspx)
/// ///
inline bool generate(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ DWORD dwFlags) inline bool generate(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ DWORD dwFlags) noexcept
{ {
handle_type h; handle_type h;
if (CryptGenKey(hProv, Algid, dwFlags, &h)) { if (CryptGenKey(hProv, Algid, dwFlags, &h)) {
@ -509,7 +509,7 @@ namespace winstd
/// ///
/// \sa [CryptImportKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380207.aspx) /// \sa [CryptImportKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380207.aspx)
/// ///
inline bool import(_In_ HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags) inline bool import(_In_ HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags) noexcept
{ {
handle_type h; handle_type h;
if (CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h)) { if (CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h)) {
@ -524,7 +524,7 @@ namespace winstd
/// ///
/// \sa [CryptImportPublicKeyInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380209.aspx) /// \sa [CryptImportPublicKeyInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380209.aspx)
/// ///
inline bool import_public(_In_ HCRYPTPROV hCryptProv, _In_ DWORD dwCertEncodingType, _In_ PCERT_PUBLIC_KEY_INFO pInfo) inline bool import_public(_In_ HCRYPTPROV hCryptProv, _In_ DWORD dwCertEncodingType, _In_ PCERT_PUBLIC_KEY_INFO pInfo) noexcept
{ {
handle_type h; handle_type h;
if (CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h)) { if (CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h)) {
@ -539,7 +539,7 @@ namespace winstd
/// ///
/// \sa [CryptDeriveKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379916.aspx) /// \sa [CryptDeriveKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379916.aspx)
/// ///
inline bool derive(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTHASH hBaseData, _In_ DWORD dwFlags) inline bool derive(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTHASH hBaseData, _In_ DWORD dwFlags) noexcept
{ {
handle_type h; handle_type h;
if (CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, &h)) { if (CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, &h)) {
@ -565,7 +565,7 @@ namespace winstd
/// ///
/// \sa [CryptDestroyKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379918.aspx) /// \sa [CryptDestroyKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379918.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the key. /// Duplicates the key.
@ -576,20 +576,21 @@ namespace winstd
/// ///
/// \sa [CryptDuplicateKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379920.aspx) /// \sa [CryptDuplicateKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379920.aspx)
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
/// ///
/// DATA_BLOB wrapper class /// DATA_BLOB wrapper class
/// ///
#pragma warning(push)
#pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
class WINSTD_API data_blob : public DATA_BLOB class WINSTD_API data_blob : public DATA_BLOB
{ {
public: public:
/// ///
/// Initializes an empty BLOB. /// Initializes an empty BLOB.
/// ///
inline data_blob() inline data_blob() noexcept
{ {
cbData = 0; cbData = 0;
pbData = NULL; pbData = NULL;
@ -598,7 +599,7 @@ namespace winstd
/// ///
/// Initializes a BLOB from existing data. /// Initializes a BLOB from existing data.
/// ///
inline data_blob(_In_count_(size) BYTE *data, _In_ DWORD size) inline data_blob(_In_count_(size) BYTE *data, _In_ DWORD size) noexcept
{ {
cbData = size; cbData = size;
pbData = data; pbData = data;
@ -611,7 +612,7 @@ namespace winstd
{ {
cbData = other.cbData; cbData = other.cbData;
if (cbData) { if (cbData) {
pbData = (BYTE*)LocalAlloc(LMEM_FIXED, other.cbData); pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
if (!pbData) throw win_runtime_error("LocalAlloc failed."); if (!pbData) throw win_runtime_error("LocalAlloc failed.");
memcpy(pbData, other.pbData, other.cbData); memcpy(pbData, other.pbData, other.cbData);
} else } else
@ -621,7 +622,7 @@ namespace winstd
/// ///
/// Move an existing BLOB. /// Move an existing BLOB.
/// ///
inline data_blob(_Inout_ DATA_BLOB &&other) noexcept inline data_blob(_Inout_ data_blob &&other) noexcept
{ {
cbData = other.cbData; cbData = other.cbData;
pbData = other.pbData; pbData = other.pbData;
@ -644,7 +645,7 @@ namespace winstd
if (pbData) if (pbData)
LocalFree(pbData); LocalFree(pbData);
if (cbData) { if (cbData) {
pbData = (BYTE*)LocalAlloc(LMEM_FIXED, other.cbData); pbData = static_cast<BYTE*>(LocalAlloc(LMEM_FIXED, other.cbData));
if (!pbData) throw win_runtime_error("LocalAlloc failed."); if (!pbData) throw win_runtime_error("LocalAlloc failed.");
memcpy(pbData, other.pbData, other.cbData); memcpy(pbData, other.pbData, other.cbData);
} else } else
@ -657,7 +658,7 @@ namespace winstd
/// ///
/// Move an existing BLOB. /// Move an existing BLOB.
/// ///
inline data_blob& operator=(_Inout_ DATA_BLOB &&other) noexcept inline data_blob& operator=(_Inout_ data_blob &&other) noexcept
{ {
if (this != &other) { if (this != &other) {
cbData = other.cbData; cbData = other.cbData;
@ -674,7 +675,7 @@ namespace winstd
/// ///
/// Get BLOB size. /// Get BLOB size.
/// ///
inline DWORD size() const inline DWORD size() const noexcept
{ {
return cbData; return cbData;
} }
@ -682,7 +683,7 @@ namespace winstd
/// ///
/// Get BLOB buffer. /// Get BLOB buffer.
/// ///
inline const BYTE* data() const inline const BYTE* data() const noexcept
{ {
return pbData; return pbData;
} }
@ -690,11 +691,12 @@ namespace winstd
/// ///
/// Get BLOB buffer. /// Get BLOB buffer.
/// ///
inline BYTE* data() inline BYTE* data() noexcept
{ {
return pbData; return pbData;
} }
}; };
#pragma warning(pop)
/// @} /// @}
} }

View File

@ -84,7 +84,7 @@ namespace winstd
/// - Non zero when \p a is equal to \p b; /// - Non zero when \p a is equal to \p b;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b); inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) noexcept;
/// ///
/// Are EAP method types non-equal? /// Are EAP method types non-equal?
@ -96,7 +96,7 @@ inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE
/// - Non zero when \p a is not equal to \p b; /// - Non zero when \p a is not equal to \p b;
/// - Zero otherwise. /// - Zero otherwise.
/// ///
inline bool operator!=(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b); inline bool operator!=(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) noexcept;
/// @} /// @}
@ -155,7 +155,7 @@ namespace winstd
/// ///
/// Default constructor /// Default constructor
/// ///
EapHostPeerFreeMemory_delete() {} EapHostPeerFreeMemory_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
@ -178,7 +178,7 @@ namespace winstd
/// ///
/// Default constructor /// Default constructor
/// ///
EapHostPeerFreeRuntimeMemory_delete() {} EapHostPeerFreeRuntimeMemory_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
@ -199,14 +199,14 @@ namespace winstd
/// ///
/// Default constructor /// Default constructor
/// ///
EapHostPeerFreeErrorMemory_delete() {} EapHostPeerFreeErrorMemory_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
/// ///
/// \sa [EapHostPeerFreeErrorMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363557.aspx) /// \sa [EapHostPeerFreeErrorMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363557.aspx)
/// ///
void operator()(EAP_ERROR *_Ptr) const void operator()(EAP_ERROR *_Ptr) const noexcept
{ {
EapHostPeerFreeErrorMemory(_Ptr); EapHostPeerFreeErrorMemory(_Ptr);
} }
@ -221,14 +221,14 @@ namespace winstd
/// ///
/// Default constructor /// Default constructor
/// ///
EapHostPeerFreeEapError_delete() {} EapHostPeerFreeEapError_delete() noexcept {}
/// ///
/// Delete a pointer /// Delete a pointer
/// ///
/// \sa [EapHostPeerFreeEapError function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363556.aspx) /// \sa [EapHostPeerFreeEapError function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363556.aspx)
/// ///
void operator()(EAP_ERROR *_Ptr) const void operator()(EAP_ERROR *_Ptr) const noexcept
{ {
EapHostPeerFreeEapError(_Ptr); EapHostPeerFreeEapError(_Ptr);
} }
@ -238,13 +238,15 @@ namespace winstd
/// ///
/// EAP_ATTRIBUTE wrapper class /// EAP_ATTRIBUTE wrapper class
/// ///
#pragma warning(push)
#pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
class WINSTD_API WINSTD_NOVTABLE eap_attr : public EAP_ATTRIBUTE class WINSTD_API WINSTD_NOVTABLE eap_attr : public EAP_ATTRIBUTE
{ {
public: public:
/// ///
/// Initializes a new EAP attribute set to eatReserved. /// Initializes a new EAP attribute set to eatReserved.
/// ///
inline eap_attr() inline eap_attr() noexcept
{ {
eaType = eatReserved; eaType = eatReserved;
dwLength = 0; dwLength = 0;
@ -341,6 +343,7 @@ namespace winstd
public: public:
static const EAP_ATTRIBUTE blank; ///< Blank EAP attribute static const EAP_ATTRIBUTE blank; ///< Blank EAP attribute
}; };
#pragma warning(pop)
/// ///
@ -355,7 +358,7 @@ namespace winstd
/// \param[in] type EAP method property type /// \param[in] type EAP method property type
/// \param[in] value Property value /// \param[in] value Property value
/// ///
inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ BOOL value) inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ BOOL value) noexcept
{ {
eapMethodPropertyType = type; eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtBool; eapMethodPropertyValueType = empvtBool;
@ -370,7 +373,7 @@ namespace winstd
/// \param[in] type EAP method property type /// \param[in] type EAP method property type
/// \param[in] value Property value /// \param[in] value Property value
/// ///
inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ DWORD value) inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_ DWORD value) noexcept
{ {
eapMethodPropertyType = type; eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtDword; eapMethodPropertyValueType = empvtDword;
@ -385,12 +388,12 @@ namespace winstd
/// \param[in] type EAP method property type /// \param[in] type EAP method property type
/// \param[in] value Property value /// \param[in] value Property value
/// ///
inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_z_ LPCWSTR value) inline eap_method_prop(_In_ EAP_METHOD_PROPERTY_TYPE type, _In_z_ LPCWSTR value) noexcept
{ {
eapMethodPropertyType = type; eapMethodPropertyType = type;
eapMethodPropertyValueType = empvtString; eapMethodPropertyValueType = empvtString;
eapMethodPropertyValue.empvString.length = (DWORD)(sizeof(WCHAR)*(wcslen(value) + 1)); eapMethodPropertyValue.empvString.length = static_cast<DWORD>(sizeof(WCHAR)*(wcslen(value) + 1));
eapMethodPropertyValue.empvString.value = (BYTE*)value; eapMethodPropertyValue.empvString.value = const_cast<BYTE*>(reinterpret_cast<const BYTE*>(value));
} }
}; };
@ -422,15 +425,15 @@ namespace winstd
/// - true when creation succeeds; /// - true when creation succeeds;
/// - false when creation fails. For extended error information, call `GetLastError()`. /// - false when creation fails. For extended error information, call `GetLastError()`.
/// ///
inline bool create(_In_ EapCode code, _In_ BYTE id, _In_ WORD size) inline bool create(_In_ EapCode code, _In_ BYTE id, _In_ WORD size) noexcept
{ {
assert(size >= 4); // EAP packets must contain at least Code, Id, and Length fields: 4B. assert(size >= 4); // EAP packets must contain at least Code, Id, and Length fields: 4B.
handle_type h = (handle_type)HeapAlloc(GetProcessHeap(), 0, size); handle_type h = static_cast<handle_type>(HeapAlloc(GetProcessHeap(), 0, size));
if (h != NULL) { if (h != NULL) {
h->Code = (BYTE) code ; h->Code = static_cast<BYTE>(code);
h->Id = id ; h->Id = id;
*(WORD*)h->Length = htons(size); *reinterpret_cast<WORD*>(h->Length) = htons(size);
attach(h); attach(h);
return true; return true;
@ -444,7 +447,7 @@ namespace winstd
/// ///
/// Returns total EAP packet size in bytes. /// Returns total EAP packet size in bytes.
/// ///
inline WORD size() const inline WORD size() const noexcept
{ {
return m_h != NULL ? ntohs(*(WORD*)m_h->Length) : 0; return m_h != NULL ? ntohs(*(WORD*)m_h->Length) : 0;
} }
@ -454,12 +457,12 @@ namespace winstd
/// ///
/// Destroys the EAP packet. /// Destroys the EAP packet.
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
/// Duplicates the EAP packet. /// Duplicates the EAP packet.
/// ///
virtual handle_type duplicate_internal(_In_ handle_type h) const; handle_type duplicate_internal(_In_ handle_type h) const noexcept override;
}; };
@ -474,7 +477,7 @@ namespace winstd
/// ///
/// Constructs an empty array /// Constructs an empty array
/// ///
inline eap_method_info_array() inline eap_method_info_array() noexcept
{ {
dwNumberOfMethods = 0; dwNumberOfMethods = 0;
pEapMethods = NULL; pEapMethods = NULL;
@ -518,8 +521,8 @@ namespace winstd
protected: protected:
/// \cond internal /// \cond internal
void free_internal(); void free_internal() noexcept;
static void free_internal(_In_ EAP_METHOD_INFO *pMethodInfo); static void free_internal(_In_ EAP_METHOD_INFO *pMethodInfo) noexcept;
/// \endcond /// \endcond
}; };
@ -580,7 +583,7 @@ namespace winstd
/// ///
/// Returns EAP method type /// Returns EAP method type
/// ///
inline const EAP_METHOD_TYPE& type() const inline const EAP_METHOD_TYPE& type() const noexcept
{ {
return m_type; return m_type;
} }
@ -589,7 +592,7 @@ namespace winstd
/// ///
/// Returns the reason code for error /// Returns the reason code for error
/// ///
inline DWORD reason() const inline DWORD reason() const noexcept
{ {
return m_reason; return m_reason;
} }
@ -598,7 +601,7 @@ namespace winstd
/// ///
/// Returns root cause ID /// Returns root cause ID
/// ///
inline const GUID& root_cause_id() const inline const GUID& root_cause_id() const noexcept
{ {
return m_root_cause_id; return m_root_cause_id;
} }
@ -607,7 +610,7 @@ namespace winstd
/// ///
/// Returns root cause ID /// Returns root cause ID
/// ///
inline const wchar_t* root_cause() const inline const wchar_t* root_cause() const noexcept
{ {
return m_root_cause_desc.c_str(); return m_root_cause_desc.c_str();
} }
@ -616,7 +619,7 @@ namespace winstd
/// ///
/// Returns repair ID /// Returns repair ID
/// ///
inline const GUID& repair_id() const inline const GUID& repair_id() const noexcept
{ {
return m_repair_id; return m_repair_id;
} }
@ -625,7 +628,7 @@ namespace winstd
/// ///
/// Returns root cause ID /// Returns root cause ID
/// ///
inline const wchar_t* repair() const inline const wchar_t* repair() const noexcept
{ {
return m_repair_desc.c_str(); return m_repair_desc.c_str();
} }
@ -634,7 +637,7 @@ namespace winstd
/// ///
/// Returns help_link ID /// Returns help_link ID
/// ///
inline const GUID& help_link_id() const inline const GUID& help_link_id() const noexcept
{ {
return m_help_link_id; return m_help_link_id;
} }
@ -657,7 +660,7 @@ namespace winstd
} }
inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) noexcept
{ {
return return
a.eapType.type == b.eapType.type && a.eapType.type == b.eapType.type &&
@ -667,7 +670,7 @@ inline bool operator==(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE
} }
inline bool operator!=(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) inline bool operator!=(_In_ const EAP_METHOD_TYPE &a, _In_ const EAP_METHOD_TYPE &b) noexcept
{ {
return !operator==(a, b); return !operator==(a, b);
} }

View File

@ -613,7 +613,7 @@ namespace winstd
/// ///
/// \sa [EventUnregister function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363749.aspx) /// \sa [EventUnregister function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363749.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
/// ///
@ -813,7 +813,7 @@ namespace winstd
/// ///
/// \sa [ControlTrace function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363696.aspx) /// \sa [ControlTrace function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363696.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
protected: protected:
std::unique_ptr<EVENT_TRACE_PROPERTIES> m_prop; ///< Session properties std::unique_ptr<EVENT_TRACE_PROPERTIES> m_prop; ///< Session properties
@ -861,7 +861,7 @@ namespace winstd
/// ///
/// \sa [CloseTrace function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363686.aspx) /// \sa [CloseTrace function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363686.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };

View File

@ -51,7 +51,7 @@ namespace winstd
/// ///
/// Constructs blank encoding session /// Constructs blank encoding session
/// ///
inline hex_enc() inline hex_enc() noexcept
{ {
} }
@ -91,7 +91,7 @@ namespace winstd
/// ///
/// \returns Maximum number of bytes for the encoded data of `size` length /// \returns Maximum number of bytes for the encoded data of `size` length
/// ///
inline size_t enc_size(size_t size) const inline size_t enc_size(size_t size) const noexcept
{ {
return size*2; return size*2;
} }
@ -107,7 +107,7 @@ namespace winstd
/// ///
/// Constructs blank decoding session /// Constructs blank decoding session
/// ///
inline hex_dec() : inline hex_dec() noexcept :
buf(0), buf(0),
num(0) num(0)
{ {
@ -164,7 +164,7 @@ namespace winstd
/// ///
/// Resets decoding session /// Resets decoding session
/// ///
inline void clear() inline void clear() noexcept
{ {
num = 0; num = 0;
} }
@ -177,7 +177,7 @@ namespace winstd
/// ///
/// \returns Maximum number of bytes for the decoded data of `size` length /// \returns Maximum number of bytes for the decoded data of `size` length
/// ///
inline size_t dec_size(size_t size) const inline size_t dec_size(size_t size) const noexcept
{ {
return (size + 1)/2; return (size + 1)/2;
} }

View File

@ -155,7 +155,7 @@ namespace winstd
/// ///
/// \sa [FreeCredentialsHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa375417.aspx) /// \sa [FreeCredentialsHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa375417.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
public: public:
TimeStamp m_expires; ///< Credentials expiration time TimeStamp m_expires; ///< Credentials expiration time
@ -270,7 +270,7 @@ namespace winstd
/// ///
/// \sa [DeleteSecurityContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa375354.aspx) /// \sa [DeleteSecurityContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa375354.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
public: public:
ULONG m_attrib; ///< Context attributes ULONG m_attrib; ///< Context attributes

View File

@ -68,7 +68,7 @@ namespace winstd
/// ///
inline bool create( inline bool create(
_In_opt_ const GUID * ClassGuid, _In_opt_ const GUID * ClassGuid,
_In_opt_ HWND hwndParent) _In_opt_ HWND hwndParent) noexcept
{ {
handle_type h = SetupDiCreateDeviceInfoList(ClassGuid, hwndParent); handle_type h = SetupDiCreateDeviceInfoList(ClassGuid, hwndParent);
if (h != invalid) { if (h != invalid) {
@ -95,7 +95,7 @@ namespace winstd
_In_ DWORD Flags, _In_ DWORD Flags,
_In_opt_ HDEVINFO DeviceInfoSet, _In_opt_ HDEVINFO DeviceInfoSet,
_In_opt_ PCTSTR MachineName, _In_opt_ PCTSTR MachineName,
_Reserved_ PVOID Reserved) _Reserved_ PVOID Reserved) noexcept
{ {
handle_type h = SetupDiGetClassDevsEx(ClassGuid, Enumerator, hwndParent, Flags, DeviceInfoSet, MachineName, Reserved); handle_type h = SetupDiGetClassDevsEx(ClassGuid, Enumerator, hwndParent, Flags, DeviceInfoSet, MachineName, Reserved);
if (h != invalid) { if (h != invalid) {
@ -112,7 +112,7 @@ namespace winstd
/// ///
/// \sa [SetupDiDestroyDeviceInfoList function](https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdidestroydeviceinfolist) /// \sa [SetupDiDestroyDeviceInfoList function](https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdidestroydeviceinfolist)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -121,6 +121,9 @@ namespace winstd
/// ///
class WINSTD_API setup_driver_info_list_builder class WINSTD_API setup_driver_info_list_builder
{ {
WINSTD_NONCOPYABLE(setup_driver_info_list_builder)
WINSTD_NONMOVABLE(setup_driver_info_list_builder)
public: public:
/// ///
/// Construct the builder and builds a list of drivers that is associated with a specific device or with the global class driver list for a device information set. /// Construct the builder and builds a list of drivers that is associated with a specific device or with the global class driver list for a device information set.
@ -130,7 +133,7 @@ namespace winstd
inline setup_driver_info_list_builder( inline setup_driver_info_list_builder(
_In_ HDEVINFO DeviceInfoSet, _In_ HDEVINFO DeviceInfoSet,
_Inout_opt_ PSP_DEVINFO_DATA DeviceInfoData, _Inout_opt_ PSP_DEVINFO_DATA DeviceInfoData,
_In_ DWORD DriverType) : _In_ DWORD DriverType) noexcept :
m_DeviceInfoSet (DeviceInfoSet), m_DeviceInfoSet (DeviceInfoSet),
m_DeviceInfoData(DeviceInfoData), m_DeviceInfoData(DeviceInfoData),
m_DriverType (DriverType) m_DriverType (DriverType)
@ -151,7 +154,7 @@ namespace winstd
/// ///
/// \sa [SetupDiBuildDriverInfoList function](https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdibuilddriverinfolist) /// \sa [SetupDiBuildDriverInfoList function](https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf-setupapi-setupdibuilddriverinfolist)
/// ///
inline BOOL status() const inline BOOL status() const noexcept
{ {
return m_result; return m_result;
} }

View File

@ -145,10 +145,10 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool open(_In_ DWORD dwClientVersion, _Out_ PDWORD pdwNegotiatedVersion) inline bool open(_In_ DWORD dwClientVersion, _Out_ PDWORD pdwNegotiatedVersion) noexcept
{ {
handle_type h; handle_type h;
DWORD dwResult = WlanOpenHandle(dwClientVersion, 0, pdwNegotiatedVersion, &h); const DWORD dwResult = WlanOpenHandle(dwClientVersion, 0, pdwNegotiatedVersion, &h);
if (dwResult == ERROR_SUCCESS) { if (dwResult == ERROR_SUCCESS) {
attach(h); attach(h);
return true; return true;
@ -164,7 +164,7 @@ namespace winstd
/// ///
/// \sa [WlanCloseHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms706610(v=vs.85).aspx) /// \sa [WlanCloseHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms706610(v=vs.85).aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
/// @} /// @}

View File

@ -54,47 +54,47 @@ namespace winstd
/// @{ /// @{
/// @copydoc GetModuleFileNameW() /// @copydoc GetModuleFileNameW()
template<class _Elem, class _Traits, class _Ax> inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// ///
/// Retrieves the fully qualified path for the file that contains the specified module and stores it in a std::wstring string. /// Retrieves the fully qualified path for the file that contains the specified module and stores it in a std::wstring string.
/// ///
/// \sa [GetModuleFileName function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197.aspx) /// \sa [GetModuleFileName function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// @copydoc GetWindowTextW() /// @copydoc GetWindowTextW()
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// ///
/// Copies the text of the specified window's title bar (if it has one) into a std::wstring string. /// Copies the text of the specified window's title bar (if it has one) into a std::wstring string.
/// ///
/// \sa [GetWindowText function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633520.aspx) /// \sa [GetWindowText function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633520.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// @copydoc GetFileVersionInfoW() /// @copydoc GetFileVersionInfoW()
template<class _Ty, class _Ax> inline _Success_(return != 0) BOOL GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue); template<class _Ty, class _Ax> inline _Success_(return != 0) BOOL GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept;
/// ///
/// Retrieves version information for the specified file and stores it in a std::vector buffer. /// Retrieves version information for the specified file and stores it in a std::vector buffer.
/// ///
/// \sa [GetFileVersionInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms647003.aspx) /// \sa [GetFileVersionInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms647003.aspx)
/// ///
template<class _Ty, class _Ax> inline _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue); template<class _Ty, class _Ax> inline _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept;
/// @copydoc ExpandEnvironmentStringsW() /// @copydoc ExpandEnvironmentStringsW()
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// ///
/// Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string. /// Expands environment-variable strings, replaces them with the values defined for the current user, and stores it in a std::wstring string.
/// ///
/// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx) /// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// @copydoc GuidToStringW() /// @copydoc GuidToStringW()
template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str); template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept;
/// ///
/// Formats GUID and stores it in a std::wstring string. /// Formats GUID and stores it in a std::wstring string.
@ -102,7 +102,7 @@ template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringA(_In_ L
/// \param[in ] lpGuid Pointer to GUID /// \param[in ] lpGuid Pointer to GUID
/// \param[out] str String to store the result to /// \param[out] str String to store the result to
/// ///
template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str); template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept;
/// @copydoc GuidToStringW() /// @copydoc GuidToStringW()
#ifdef _UNICODE #ifdef _UNICODE
#define GuidToString GuidToStringW #define GuidToString GuidToStringW
@ -111,7 +111,7 @@ template<class _Elem, class _Traits, class _Ax> inline VOID GuidToStringW(_In_ L
#endif #endif
/// @copydoc StringToGuidW() /// @copydoc StringToGuidW()
_Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd = NULL); _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd = NULL) noexcept;
/// ///
/// Parses string with GUID and stores it to GUID /// Parses string with GUID and stores it to GUID
@ -124,7 +124,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
/// - `TRUE` if GUID successfuly parsed; /// - `TRUE` if GUID successfuly parsed;
/// - `FALSE` otherwise. /// - `FALSE` otherwise.
/// ///
_Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd = NULL); _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd = NULL) noexcept;
/// @copydoc StringToGuidW() /// @copydoc StringToGuidW()
#ifdef _UNICODE #ifdef _UNICODE
#define StringToGuid StringToGuidW #define StringToGuid StringToGuidW
@ -150,7 +150,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
/// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx) /// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx)
/// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx) /// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// ///
/// Queries for a string value in the registry and stores it in a std::wstring string. /// Queries for a string value in the registry and stores it in a std::wstring string.
@ -170,29 +170,29 @@ template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegQueryStringVal
/// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx) /// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx)
/// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx) /// \sa [ExpandEnvironmentStrings function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724265.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue); template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept;
/// @copydoc RegQueryValueExW() /// @copydoc RegQueryValueExW()
template<class _Ty, class _Ax> inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData); template<class _Ty, class _Ax> inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept;
/// ///
/// Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector buffer. /// Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector buffer.
/// ///
/// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx) /// \sa [RegQueryValueEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724911.aspx)
/// ///
template<class _Ty, class _Ax> inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData); template<class _Ty, class _Ax> inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept;
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA #if _WIN32_WINNT >= _WIN32_WINNT_VISTA
/// @copydoc RegLoadMUIStringW() /// @copydoc RegLoadMUIStringW()
template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory); template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory) noexcept;
/// ///
/// Loads the specified string from the specified key and subkey, and stores it in a std::wstring string. /// Loads the specified string from the specified key and subkey, and stores it in a std::wstring string.
/// ///
/// \sa [RegLoadMUIString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724890.aspx) /// \sa [RegLoadMUIString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724890.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory); template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory) noexcept;
#endif #endif
@ -201,21 +201,21 @@ template<class _Elem, class _Traits, class _Ax> inline LSTATUS RegLoadMUIStringW
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Traits, class _Ax> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Traits, class _Ax> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set. /// Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Ax> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Ax> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. /// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _Out_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _Out_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. /// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
@ -224,7 +224,7 @@ template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set. /// Maps a UTF-16 (wide character) string to a std::vector. The new character vector is not necessarily from a multibyte character set.
@ -233,7 +233,7 @@ template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureWideC
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Ax> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Ax> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set. /// Maps a UTF-16 (wide character) string to a std::string. The new character string is not necessarily from a multibyte character set.
@ -242,28 +242,28 @@ template<class _Ax> inline _Success_(return != 0) int SecureWideCharToMultiByte(
/// ///
/// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx) /// \sa [WideCharToMultiByte function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130.aspx)
/// ///
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _Out_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar); template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _Out_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Traits, class _Ax> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr); template<class _Traits, class _Ax> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Ax> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr); template<class _Ax> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr); template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
@ -272,7 +272,7 @@ template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr); template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::vector. The character vector is not necessarily from a multibyte character set.
@ -281,7 +281,7 @@ template<class _Traits, class _Ax> inline _Success_(return != 0) int SecureMulti
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Ax> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr); template<class _Ax> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) noexcept;
/// ///
/// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set. /// Maps a character string to a UTF-16 (wide character) std::wstring. The character string is not necessarily from a multibyte character set.
@ -290,72 +290,72 @@ template<class _Ax> inline _Success_(return != 0) int SecureMultiByteToWideChar(
/// ///
/// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx) /// \sa [MultiByteToWideChar function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072.aspx)
/// ///
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr); template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept;
/// @copydoc LoadStringW /// @copydoc LoadStringW
template<class _Traits, class _Ax> inline _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer); template<class _Traits, class _Ax> inline _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept;
/// ///
/// Loads a string resource from the executable file associated with a specified module. /// Loads a string resource from the executable file associated with a specified module.
/// ///
/// \sa [LoadString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms647486.aspx) /// \sa [LoadString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms647486.aspx)
/// ///
template<class _Traits, class _Ax> inline _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer); template<class _Traits, class _Ax> inline _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer) noexcept;
/// ///
/// Formats and sends a string to the debugger for display. /// Formats and sends a string to the debugger for display.
/// ///
/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) /// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx)
/// ///
inline VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg); inline VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noexcept;
/// ///
/// Formats and sends a string to the debugger for display. /// Formats and sends a string to the debugger for display.
/// ///
/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) /// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx)
/// ///
inline VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg); inline VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) noexcept;
/// ///
/// Formats and sends a string to the debugger for display. /// Formats and sends a string to the debugger for display.
/// ///
/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) /// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx)
/// ///
inline VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...); inline VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) noexcept;
/// ///
/// Formats and sends a string to the debugger for display. /// Formats and sends a string to the debugger for display.
/// ///
/// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx) /// \sa [OutputDebugString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362.aspx)
/// ///
inline VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...); inline VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept;
/// @copydoc GetDateFormatW() /// @copydoc GetDateFormatW()
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatA(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatA(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) noexcept;
/// ///
/// Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date. /// Formats a date as a date string for a locale specified by the locale identifier. The function formats either a specified date or the local system date.
/// ///
/// \sa [GetDateFormat function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318086.aspx) /// \sa [GetDateFormat function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318086.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatW(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCWSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatW(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCWSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) noexcept;
/// @copydoc LookupAccountSidW() /// @copydoc LookupAccountSidW()
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept;
/// ///
/// Retrieves the name of the account for this SID and the name of the first domain on which this SID is found. /// Retrieves the name of the account for this SID and the name of the first domain on which this SID is found.
/// ///
/// \sa [LookupAccountSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379166.aspx) /// \sa [LookupAccountSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379166.aspx)
/// ///
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse); template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept;
/// ///
/// Retrieves a specified type of information about an access token. The calling process must have appropriate access rights to obtain the information. /// Retrieves a specified type of information about an access token. The calling process must have appropriate access rights to obtain the information.
/// ///
/// \sa [GetTokenInformation function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446671.aspx) /// \sa [GetTokenInformation function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446671.aspx)
/// ///
template<class _Ty> inline _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation); template<class _Ty> inline _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) noexcept;
/// @} /// @}
@ -393,7 +393,7 @@ namespace winstd
/// ///
/// \sa [CloseHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211.aspx) /// \sa [CloseHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211.aspx)
/// ///
virtual void free_internal() void free_internal() noexcept override
{ {
CloseHandle(m_h); CloseHandle(m_h);
} }
@ -424,7 +424,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool load(_In_z_ LPCTSTR lpFileName, __reserved handle_type hFile, _In_ DWORD dwFlags) inline bool load(_In_z_ LPCTSTR lpFileName, __reserved handle_type hFile, _In_ DWORD dwFlags) noexcept
{ {
handle_type h = LoadLibraryEx(lpFileName, hFile, dwFlags); handle_type h = LoadLibraryEx(lpFileName, hFile, dwFlags);
if (h != invalid) { if (h != invalid) {
@ -440,7 +440,7 @@ namespace winstd
/// ///
/// \sa [FreeLibrary function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152.aspx) /// \sa [FreeLibrary function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -459,7 +459,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool open(_In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_ DWORD dwProcessId) inline bool open(_In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_ DWORD dwProcessId) noexcept
{ {
handle_type h = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId); handle_type h = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
if (h != invalid) { if (h != invalid) {
@ -486,7 +486,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool create(_In_z_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_opt_ DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, _In_opt_ HANDLE hTemplateFile = NULL) inline bool create(_In_z_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_opt_ DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, _In_opt_ HANDLE hTemplateFile = NULL) noexcept
{ {
handle_type h = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); handle_type h = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
if (h != invalid) { if (h != invalid) {
@ -513,7 +513,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool create(_In_ BOOL bManualReset, _In_ BOOL bInitialState, _In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes = NULL, _In_opt_z_ LPCTSTR lpName = NULL) inline bool create(_In_ BOOL bManualReset, _In_ BOOL bInitialState, _In_opt_ LPSECURITY_ATTRIBUTES lpEventAttributes = NULL, _In_opt_z_ LPCTSTR lpName = NULL) noexcept
{ {
handle_type h = CreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName); handle_type h = CreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName);
if (h != invalid) { if (h != invalid) {
@ -532,7 +532,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool open(_In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_z_ LPCTSTR lpName) inline bool open(_In_ DWORD dwDesiredAccess, _In_ BOOL bInheritHandle, _In_z_ LPCTSTR lpName) noexcept
{ {
handle_type h = OpenEvent(dwDesiredAccess, bInheritHandle, lpName); handle_type h = OpenEvent(dwDesiredAccess, bInheritHandle, lpName);
if (h != invalid) { if (h != invalid) {
@ -572,7 +572,7 @@ namespace winstd
/// ///
/// \return Pointer to critical section /// \return Pointer to critical section
/// ///
inline operator LPCRITICAL_SECTION() inline operator LPCRITICAL_SECTION() noexcept
{ {
return &m_data; return &m_data;
} }
@ -606,7 +606,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool find(_In_ LPCTSTR lpFileName, _Out_ LPWIN32_FIND_DATA lpFindFileData) inline bool find(_In_ LPCTSTR lpFileName, _Out_ LPWIN32_FIND_DATA lpFindFileData) noexcept
{ {
handle_type h = FindFirstFile(lpFileName, lpFindFileData); handle_type h = FindFirstFile(lpFileName, lpFindFileData);
if (h != invalid) { if (h != invalid) {
@ -622,7 +622,7 @@ namespace winstd
/// ///
/// \sa [FindClose function](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findclose) /// \sa [FindClose function](https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findclose)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -650,7 +650,7 @@ namespace winstd
/// - \c true when succeeds; /// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason. /// - \c false when fails. Use `GetLastError()` for failure reason.
/// ///
inline bool create(_In_ DWORD flOptions, _In_ SIZE_T dwInitialSize, _In_ SIZE_T dwMaximumSize) inline bool create(_In_ DWORD flOptions, _In_ SIZE_T dwInitialSize, _In_ SIZE_T dwMaximumSize) noexcept
{ {
handle_type h = HeapCreate(flOptions, dwInitialSize, dwMaximumSize); handle_type h = HeapCreate(flOptions, dwInitialSize, dwMaximumSize);
if (h != invalid) { if (h != invalid) {
@ -667,7 +667,7 @@ namespace winstd
/// - `true` if any blocks found; /// - `true` if any blocks found;
/// - `false` otherwise. /// - `false` otherwise.
/// ///
bool enumerate(); bool enumerate() noexcept;
protected: protected:
/// ///
@ -675,7 +675,7 @@ namespace winstd
/// ///
/// \sa [HeapDestroy function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366700.aspx) /// \sa [HeapDestroy function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366700.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -801,6 +801,9 @@ namespace winstd
/// ///
class WINSTD_API actctx_activator class WINSTD_API actctx_activator
{ {
WINSTD_NONCOPYABLE(actctx_activator)
WINSTD_NONMOVABLE(actctx_activator)
public: public:
/// ///
/// Construct the activator and activates the given activation context /// Construct the activator and activates the given activation context
@ -809,7 +812,7 @@ namespace winstd
/// ///
/// \sa [ActivateActCtx function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374151.aspx) /// \sa [ActivateActCtx function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374151.aspx)
/// ///
actctx_activator(_In_ HANDLE hActCtx); actctx_activator(_In_ HANDLE hActCtx) noexcept;
/// ///
/// Deactivates activation context and destructs the activator /// Deactivates activation context and destructs the activator
@ -828,6 +831,9 @@ namespace winstd
/// ///
class WINSTD_API user_impersonator class WINSTD_API user_impersonator
{ {
WINSTD_NONCOPYABLE(user_impersonator)
WINSTD_NONMOVABLE(user_impersonator)
public: public:
/// ///
/// Construct the impersonator and impersonates the given user /// Construct the impersonator and impersonates the given user
@ -836,7 +842,7 @@ namespace winstd
/// ///
/// \sa [ImpersonateLoggedOnUser function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378612.aspx) /// \sa [ImpersonateLoggedOnUser function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378612.aspx)
/// ///
user_impersonator(_In_opt_ HANDLE hToken); user_impersonator(_In_opt_ HANDLE hToken) noexcept;
/// ///
/// Reverts to current user and destructs the impersonator /// Reverts to current user and destructs the impersonator
@ -855,6 +861,9 @@ namespace winstd
/// ///
class WINSTD_API console_ctrl_handler class WINSTD_API console_ctrl_handler
{ {
WINSTD_NONCOPYABLE(console_ctrl_handler)
WINSTD_NONMOVABLE(console_ctrl_handler)
public: public:
/// ///
/// Construct the console control handler object and pushes the given handler to the console control handler stack /// Construct the console control handler object and pushes the given handler to the console control handler stack
@ -863,7 +872,7 @@ namespace winstd
/// ///
/// \sa [SetConsoleCtrlHandler function](https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler) /// \sa [SetConsoleCtrlHandler function](https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler)
/// ///
console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine); console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) noexcept;
/// ///
/// Pops console control handler from the console control handler stack /// Pops console control handler from the console control handler stack
@ -889,7 +898,7 @@ namespace winstd
/// ///
/// Initializes a new class instance with the memory handle set to INVAL. /// Initializes a new class instance with the memory handle set to INVAL.
/// ///
inline vmemory() : m_proc(NULL) inline vmemory() noexcept : m_proc(NULL)
{ {
} }
@ -899,7 +908,7 @@ namespace winstd
/// \param[in] proc Handle of process the memory belongs to /// \param[in] proc Handle of process the memory belongs to
/// \param[in] h Initial object handle value /// \param[in] h Initial object handle value
/// ///
inline vmemory(_In_ handle_type h, _In_ HANDLE proc) : inline vmemory(_In_ handle_type h, _In_ HANDLE proc) noexcept :
m_proc(proc), m_proc(proc),
handle<LPVOID, NULL>(h) handle<LPVOID, NULL>(h)
{ {
@ -945,7 +954,7 @@ namespace winstd
/// \param[in] proc Handle of process the memory belongs to /// \param[in] proc Handle of process the memory belongs to
/// \param[in] h Initial object handle value /// \param[in] h Initial object handle value
/// ///
inline void attach(_In_ HANDLE proc, _In_opt_ handle_type h) inline void attach(_In_ HANDLE proc, _In_opt_ handle_type h) noexcept
{ {
m_proc = proc; m_proc = proc;
if (m_h != invalid) if (m_h != invalid)
@ -967,7 +976,7 @@ namespace winstd
_In_opt_ LPVOID lpAddress, _In_opt_ LPVOID lpAddress,
_In_ SIZE_T dwSize, _In_ SIZE_T dwSize,
_In_ DWORD flAllocationType, _In_ DWORD flAllocationType,
_In_ DWORD flProtect) _In_ DWORD flProtect) noexcept
{ {
handle_type h = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect); handle_type h = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect);
if (h != invalid) { if (h != invalid) {
@ -983,7 +992,7 @@ namespace winstd
/// ///
/// \sa [VirtualFreeEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366894.aspx) /// \sa [VirtualFreeEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366894.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
protected: protected:
HANDLE m_proc; ///< Handle of memory's process HANDLE m_proc; ///< Handle of memory's process
@ -1021,10 +1030,10 @@ namespace winstd
_In_ DWORD dwOptions, _In_ DWORD dwOptions,
_In_ REGSAM samDesired, _In_ REGSAM samDesired,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL,
_Out_opt_ LPDWORD lpdwDisposition = NULL) _Out_opt_ LPDWORD lpdwDisposition = NULL) noexcept
{ {
handle_type h; handle_type h;
LSTATUS s = RegCreateKeyEx(hKey, lpSubKey, 0, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition); const LSTATUS s = RegCreateKeyEx(hKey, lpSubKey, 0, lpClass, dwOptions, samDesired, lpSecurityAttributes, &h, lpdwDisposition);
if (s == ERROR_SUCCESS) { if (s == ERROR_SUCCESS) {
attach(h); attach(h);
return true; return true;
@ -1047,10 +1056,10 @@ namespace winstd
_In_ HKEY hKey, _In_ HKEY hKey,
_In_opt_z_ LPCTSTR lpSubKey, _In_opt_z_ LPCTSTR lpSubKey,
_In_ DWORD ulOptions, _In_ DWORD ulOptions,
_In_ REGSAM samDesired) _In_ REGSAM samDesired) noexcept
{ {
handle_type h; handle_type h;
LONG s = RegOpenKeyEx(hKey, lpSubKey, ulOptions, samDesired, &h); const LONG s = RegOpenKeyEx(hKey, lpSubKey, ulOptions, samDesired, &h);
if (s == ERROR_SUCCESS) { if (s == ERROR_SUCCESS) {
attach(h); attach(h);
return true; return true;
@ -1066,7 +1075,7 @@ namespace winstd
/// ///
/// \sa [RegCloseKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724837.aspx) /// \sa [RegCloseKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724837.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -1091,7 +1100,7 @@ namespace winstd
/// ///
/// \sa [FreeSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446631.aspx) /// \sa [FreeSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa446631.aspx)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
@ -1100,11 +1109,14 @@ namespace winstd
/// ///
class WINSTD_API process_information : public PROCESS_INFORMATION class WINSTD_API process_information : public PROCESS_INFORMATION
{ {
WINSTD_NONCOPYABLE(process_information)
WINSTD_NONMOVABLE(process_information)
public: public:
/// ///
/// Constructs blank PROCESS_INFORMATION /// Constructs blank PROCESS_INFORMATION
/// ///
inline process_information() inline process_information() noexcept
{ {
hProcess = INVALID_HANDLE_VALUE; hProcess = INVALID_HANDLE_VALUE;
hThread = INVALID_HANDLE_VALUE; hThread = INVALID_HANDLE_VALUE;
@ -1135,7 +1147,7 @@ namespace winstd
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1162,7 +1174,7 @@ inline DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_strin
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
_Elem szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; _Elem szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)];
@ -1187,7 +1199,7 @@ inline DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_strin
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1216,7 +1228,7 @@ inline _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basi
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1245,7 +1257,7 @@ inline _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basi
template<class _Ty, class _Ax> template<class _Ty, class _Ax>
inline _Success_(return != 0) BOOL GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) inline _Success_(return != 0) BOOL GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1261,7 +1273,7 @@ inline _Success_(return != 0) BOOL GetFileVersionInfoA(_In_z_ LPCSTR lptstrFilen
template<class _Ty, class _Ax> template<class _Ty, class _Ax>
inline _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) inline _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1277,7 +1289,7 @@ inline _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFile
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1301,7 +1313,7 @@ inline _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSr
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) { for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) {
DWORD dwSizeIn = dwSizeOut; DWORD dwSizeIn = dwSizeOut;
@ -1323,7 +1335,7 @@ inline _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpS
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) inline VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1337,7 +1349,7 @@ inline VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _T
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) inline VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1351,7 +1363,7 @@ inline VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _T
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -1398,7 +1410,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -1445,7 +1457,7 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_
template<class _Ty, class _Ax> template<class _Ty, class _Ax>
inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -1468,7 +1480,7 @@ inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_z_ LPCSTR lpValueName, _
template<class _Ty, class _Ax> template<class _Ty, class _Ax>
inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<_Ty, _Ax> &aData) noexcept
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -1493,7 +1505,7 @@ inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName,
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA #if _WIN32_WINNT >= _WIN32_WINNT_VISTA
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory) inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory) noexcept
{ {
// According to "Remarks" section in MSDN documentation of RegLoadMUIString(), // According to "Remarks" section in MSDN documentation of RegLoadMUIString(),
// this function is defined but not implemented as ANSI variation. // this function is defined but not implemented as ANSI variation.
@ -1503,7 +1515,7 @@ inline LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Ou
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory) inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory) noexcept
{ {
LSTATUS lResult; LSTATUS lResult;
_Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)];
@ -1529,7 +1541,7 @@ inline LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _O
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1551,7 +1563,7 @@ inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ D
template<class _Ax> template<class _Ax>
inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1572,7 +1584,7 @@ inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ D
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1594,7 +1606,7 @@ inline _Success_(return != 0) int WideCharToMultiByte(_In_ UINT CodePage, _In_ D
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::basic_string<char, _Traits, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1619,7 +1631,7 @@ inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage,
template<class _Ax> template<class _Ax>
inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cchWideChar) LPCWSTR lpWideCharStr, _In_ int cchWideChar, _Out_ std::vector<char, _Ax> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1642,7 +1654,7 @@ inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage,
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ std::basic_string<wchar_t, _Traits1, _Ax1> sWideCharStr, _Out_ std::basic_string<char, _Traits2, _Ax2> &sMultiByteStr, _In_opt_z_ LPCSTR lpDefaultChar, _Out_opt_ LPBOOL lpUsedDefaultChar) noexcept
{ {
CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)]; CHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(CHAR)];
@ -1667,7 +1679,7 @@ inline _Success_(return != 0) int SecureWideCharToMultiByte(_In_ UINT CodePage,
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1689,7 +1701,7 @@ inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ D
template<class _Ax> template<class _Ax>
inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1710,7 +1722,7 @@ inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ D
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1732,7 +1744,7 @@ inline _Success_(return != 0) int MultiByteToWideChar(_In_ UINT CodePage, _In_ D
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1757,7 +1769,7 @@ inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage,
template<class _Ax> template<class _Ax>
inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_z_count_(cbMultiByte) LPCSTR lpMultiByteStr, _In_ int cbMultiByte, _Out_ std::vector<wchar_t, _Ax> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1780,7 +1792,7 @@ inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage,
template<class _Traits1, class _Ax1, class _Traits2, class _Ax2> template<class _Traits1, class _Ax1, class _Traits2, class _Ax2>
inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage, _In_ DWORD dwFlags, _In_ const std::basic_string<char, _Traits1, _Ax1> &sMultiByteStr, _Out_ std::basic_string<wchar_t, _Traits2, _Ax2> &sWideCharStr) noexcept
{ {
WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)]; WCHAR szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(WCHAR)];
@ -1805,7 +1817,7 @@ inline _Success_(return != 0) int SecureMultiByteToWideChar(_In_ UINT CodePage,
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) inline _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept
{ {
// Get read-only pointer to string resource. // Get read-only pointer to string resource.
LPCSTR pszStr; LPCSTR pszStr;
@ -1819,7 +1831,7 @@ inline _Success_(return != 0) int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstanc
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer) inline _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<wchar_t, _Traits, _Ax> &sBuffer) noexcept
{ {
// Get read-only pointer to string resource. // Get read-only pointer to string resource.
LPCWSTR pszStr; LPCWSTR pszStr;
@ -1832,23 +1844,23 @@ inline _Success_(return != 0) int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstanc
} }
inline VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) inline VOID OutputDebugStrV(_In_z_ LPCSTR lpOutputString, _In_ va_list arg) noexcept
{ {
std::string str; std::string str;
vsprintf(str, lpOutputString, arg); try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
OutputDebugStringA(str.c_str()); OutputDebugStringA(str.c_str());
} }
inline VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) inline VOID OutputDebugStrV(_In_z_ LPCWSTR lpOutputString, _In_ va_list arg) noexcept
{ {
std::wstring str; std::wstring str;
vsprintf(str, lpOutputString, arg); try { vsprintf(str, lpOutputString, arg); } catch (...) { return; }
OutputDebugStringW(str.c_str()); OutputDebugStringW(str.c_str());
} }
inline VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) inline VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) noexcept
{ {
va_list arg; va_list arg;
va_start(arg, lpOutputString); va_start(arg, lpOutputString);
@ -1857,7 +1869,7 @@ inline VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...)
} }
inline VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) inline VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept
{ {
va_list arg; va_list arg;
va_start(arg, lpOutputString); va_start(arg, lpOutputString);
@ -1866,7 +1878,7 @@ inline VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...)
} }
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatA(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatA(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) noexcept
{ {
int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0); int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
if (iResult) { if (iResult) {
@ -1881,7 +1893,7 @@ template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) in
} }
template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatW(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCWSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) int GetDateFormatW(_In_ LCID Locale, _In_ DWORD dwFlags, _In_opt_ const SYSTEMTIME *lpDate, _In_opt_z_ LPCWSTR lpFormat, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sDate) noexcept
{ {
int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0); int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0);
if (iResult) { if (iResult) {
@ -1897,7 +1909,7 @@ template<class _Elem, class _Traits, class _Ax> inline _Success_(return != 0) in
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) inline _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1932,7 +1944,7 @@ inline _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemN
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
inline _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) inline _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sName, _Out_opt_ std::basic_string<_Elem, _Traits, _Ax> *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept
{ {
assert(0); // TODO: Test this code. assert(0); // TODO: Test this code.
@ -1967,7 +1979,7 @@ inline _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystem
template<class _Ty> template<class _Ty>
inline _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) inline _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_ std::unique_ptr<_Ty> &TokenInformation) noexcept
{ {
BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(BYTE)]; BYTE szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(BYTE)];
DWORD dwSize; DWORD dwSize;

View File

@ -93,16 +93,6 @@ namespace winstd
} }
///
/// Copies an exception
///
/// \param[in] other Exception to copy from
///
inline ws2_runtime_error(const ws2_runtime_error &other) : num_runtime_error<int>(other)
{
}
/// ///
/// Returns a user-readable Windows error message /// Returns a user-readable Windows error message
/// ///
@ -167,7 +157,7 @@ namespace winstd
/// ///
/// \sa [FreeAddrInfoW function](https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-freeaddrinfow) /// \sa [FreeAddrInfoW function](https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-freeaddrinfow)
/// ///
virtual void free_internal(); void free_internal() noexcept override;
}; };
#endif #endif

View File

@ -47,6 +47,9 @@ namespace winstd
/// ///
class WINSTD_API wintrust class WINSTD_API wintrust
{ {
WINSTD_NONCOPYABLE(wintrust)
WINSTD_NONMOVABLE(wintrust)
public: public:
/// ///
/// Initializes a new class instance. /// Initializes a new class instance.
@ -56,7 +59,7 @@ namespace winstd
m_action(action), m_action(action),
m_wtd(wtd) m_wtd(wtd)
{ {
LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd); const LONG lResult = WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
if (lResult != ERROR_SUCCESS) if (lResult != ERROR_SUCCESS)
throw win_runtime_error(lResult, "WinVerifyTrust failed."); throw win_runtime_error(lResult, "WinVerifyTrust failed.");
} }

View File

@ -32,13 +32,13 @@ winstd::bstr::~bstr()
} }
void winstd::bstr::free_internal() void winstd::bstr::free_internal() noexcept
{ {
SysFreeString(m_h); SysFreeString(m_h);
} }
winstd::bstr::handle_type winstd::bstr::duplicate_internal(_In_ handle_type h) const winstd::bstr::handle_type winstd::bstr::duplicate_internal(_In_ handle_type h) const noexcept
{ {
return SysAllocStringLen(h, SysStringLen(h)); return SysAllocStringLen(h, SysStringLen(h));
} }
@ -48,6 +48,7 @@ winstd::bstr::handle_type winstd::bstr::duplicate_internal(_In_ handle_type h) c
// winstd::variant // winstd::variant
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#pragma warning(suppress: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
winstd::variant::~variant() winstd::variant::~variant()
{ {
VariantClear(this); VariantClear(this);

View File

@ -34,13 +34,13 @@ winstd::cert_context::~cert_context()
} }
void winstd::cert_context::free_internal() void winstd::cert_context::free_internal() noexcept
{ {
CertFreeCertificateContext(m_h); CertFreeCertificateContext(m_h);
} }
winstd::cert_context::handle_type winstd::cert_context::duplicate_internal(_In_ handle_type h) const winstd::cert_context::handle_type winstd::cert_context::duplicate_internal(_In_ handle_type h) const noexcept
{ {
return CertDuplicateCertificateContext(h); return CertDuplicateCertificateContext(h);
} }
@ -57,13 +57,13 @@ winstd::cert_chain_context::~cert_chain_context()
} }
void winstd::cert_chain_context::free_internal() void winstd::cert_chain_context::free_internal() noexcept
{ {
CertFreeCertificateChain(m_h); CertFreeCertificateChain(m_h);
} }
winstd::cert_chain_context::handle_type winstd::cert_chain_context::duplicate_internal(_In_ handle_type h) const winstd::cert_chain_context::handle_type winstd::cert_chain_context::duplicate_internal(_In_ handle_type h) const noexcept
{ {
return CertDuplicateCertificateChain(h); return CertDuplicateCertificateChain(h);
} }
@ -80,7 +80,7 @@ winstd::cert_store::~cert_store()
} }
void winstd::cert_store::free_internal() void winstd::cert_store::free_internal() noexcept
{ {
CertCloseStore(m_h, 0); CertCloseStore(m_h, 0);
} }
@ -97,7 +97,7 @@ winstd::crypt_prov::~crypt_prov()
} }
void winstd::crypt_prov::free_internal() void winstd::crypt_prov::free_internal() noexcept
{ {
CryptReleaseContext(m_h, 0); CryptReleaseContext(m_h, 0);
} }
@ -114,13 +114,13 @@ winstd::crypt_hash::~crypt_hash()
} }
void winstd::crypt_hash::free_internal() void winstd::crypt_hash::free_internal() noexcept
{ {
CryptDestroyHash(m_h); CryptDestroyHash(m_h);
} }
winstd::crypt_hash::handle_type winstd::crypt_hash::duplicate_internal(_In_ handle_type h) const winstd::crypt_hash::handle_type winstd::crypt_hash::duplicate_internal(_In_ handle_type h) const noexcept
{ {
handle_type hNew = invalid; handle_type hNew = invalid;
return CryptDuplicateHash(h, NULL, 0, &hNew) ? hNew : invalid; return CryptDuplicateHash(h, NULL, 0, &hNew) ? hNew : invalid;
@ -155,7 +155,7 @@ bool winstd::crypt_key::create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
// Get the byte length of the key. // Get the byte length of the key.
size_t size_t
size_key = *(DWORD*)&key_blob[12]/8, size_key = *reinterpret_cast<DWORD*>(&key_blob[12])/8,
size_prime = size_key/2; size_prime = size_key/2;
// Modify the Exponent in Key BLOB format // Modify the Exponent in Key BLOB format
@ -163,7 +163,7 @@ bool winstd::crypt_key::create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
// Convert pubexp in rsapubkey to 1 // Convert pubexp in rsapubkey to 1
LPBYTE ptr = &key_blob[16]; LPBYTE ptr = &key_blob[16];
*(DWORD*)ptr = 1; *reinterpret_cast<DWORD*>(ptr) = 1;
ptr += sizeof(DWORD); ptr += sizeof(DWORD);
// Skip modulus, prime1, prime2 // Skip modulus, prime1, prime2
@ -189,7 +189,7 @@ bool winstd::crypt_key::create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
memset(ptr + 1, 0, size_key - 1); memset(ptr + 1, 0, size_key - 1);
// Import the exponent-of-one private key. // Import the exponent-of-one private key.
if (CryptImportKey(hProv, key_blob.data(), (DWORD)key_blob.size(), 0, 0, &h)) { if (CryptImportKey(hProv, key_blob.data(), static_cast<DWORD>(key_blob.size()), 0, 0, &h)) {
attach(h); attach(h);
return true; return true;
} }
@ -201,13 +201,13 @@ bool winstd::crypt_key::create_exp1(_In_ HCRYPTPROV hProv, _In_ DWORD dwKeySpec)
} }
void winstd::crypt_key::free_internal() void winstd::crypt_key::free_internal() noexcept
{ {
CryptDestroyKey(m_h); CryptDestroyKey(m_h);
} }
winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle_type h) const winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle_type h) const noexcept
{ {
handle_type hNew = invalid; handle_type hNew = invalid;
return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : invalid; return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : invalid;
@ -218,6 +218,7 @@ winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle
// winstd::data_blob // winstd::data_blob
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#pragma warning(suppress: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
winstd::data_blob::~data_blob() winstd::data_blob::~data_blob()
{ {
if (pbData != NULL) if (pbData != NULL)

View File

@ -27,17 +27,18 @@
// winstd::eap_attr // winstd::eap_attr
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#pragma warning(suppress: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
winstd::eap_attr::~eap_attr() winstd::eap_attr::~eap_attr()
{ {
if (pValue) if (pValue)
delete []pValue; delete [] pValue;
} }
void winstd::eap_attr::create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize) void winstd::eap_attr::create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKeySize) LPCBYTE pbKey, _In_ BYTE nKeySize)
{ {
BYTE nPaddingLength = (BYTE)((16 - (1 + (DWORD)nKeySize)) % 16); const BYTE nPaddingLength = static_cast<BYTE>((16 - (1 + static_cast<DWORD>(nKeySize))) % 16);
DWORD dwLengthNew = const DWORD dwLengthNew =
4 + // Vendor-Id 4 + // Vendor-Id
1 + // Vendor type 1 + // Vendor type
1 + // Vendor length 1 + // Vendor length
@ -54,7 +55,7 @@ void winstd::eap_attr::create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKey
p[2] = 0x01; // --| p[2] = 0x01; // --|
p[3] = 0x37; // --^ p[3] = 0x37; // --^
p[4] = bVendorType; // Vendor type p[4] = bVendorType; // Vendor type
p[5] = (BYTE)(dwLengthNew - 4); // Vendor length p[5] = static_cast<BYTE>(dwLengthNew - 4); // Vendor length
p[6] = 0x00; // Salt p[6] = 0x00; // Salt
p[7] = 0x00; // --^ p[7] = 0x00; // --^
p[8] = nKeySize; // Key-Length p[8] = nKeySize; // Key-Length
@ -65,6 +66,7 @@ void winstd::eap_attr::create_ms_mppe_key(_In_ BYTE bVendorType, _In_count_(nKey
if (pValue) if (pValue)
delete [] pValue; delete [] pValue;
#pragma warning(suppress: 26812) // EAP_ATTRIBUTE_TYPE is unscoped.
eaType = eatVendorSpecific; eaType = eatVendorSpecific;
dwLength = dwLengthNew; dwLength = dwLengthNew;
pValue = p; pValue = p;
@ -85,16 +87,16 @@ winstd::eap_packet::~eap_packet()
} }
void winstd::eap_packet::free_internal() void winstd::eap_packet::free_internal() noexcept
{ {
HeapFree(GetProcessHeap(), 0, m_h); HeapFree(GetProcessHeap(), 0, m_h);
} }
winstd::eap_packet::handle_type winstd::eap_packet::duplicate_internal(_In_ handle_type h) const winstd::eap_packet::handle_type winstd::eap_packet::duplicate_internal(_In_ handle_type h) const noexcept
{ {
WORD n = ntohs(*(WORD*)h->Length); const WORD n = ntohs(*reinterpret_cast<WORD*>(h->Length));
handle_type h2 = (handle_type)HeapAlloc(GetProcessHeap(), 0, n); handle_type h2 = static_cast<handle_type>(HeapAlloc(GetProcessHeap(), 0, n));
if (h2 == invalid) { if (h2 == invalid) {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return invalid; return invalid;
@ -119,22 +121,22 @@ winstd::eap_method_info_array::~eap_method_info_array()
/// \cond internal /// \cond internal
void winstd::eap_method_info_array::free_internal() void winstd::eap_method_info_array::free_internal() noexcept
{ {
for (DWORD i = 0; i < dwNumberOfMethods; i++) for (DWORD i = 0; i < dwNumberOfMethods; i++)
free_internal(pEapMethods + i); free_internal(pEapMethods + i);
EapHostPeerFreeMemory((BYTE*)pEapMethods); EapHostPeerFreeMemory(reinterpret_cast<BYTE*>(pEapMethods));
} }
void winstd::eap_method_info_array::free_internal(_In_ EAP_METHOD_INFO *pMethodInfo) void winstd::eap_method_info_array::free_internal(_In_ EAP_METHOD_INFO *pMethodInfo) noexcept
{ {
if (pMethodInfo->pInnerMethodInfo) if (pMethodInfo->pInnerMethodInfo)
free_internal(pMethodInfo->pInnerMethodInfo); free_internal(pMethodInfo->pInnerMethodInfo);
EapHostPeerFreeMemory((BYTE*)pMethodInfo->pwszAuthorName); EapHostPeerFreeMemory(reinterpret_cast<BYTE*>(pMethodInfo->pwszAuthorName));
EapHostPeerFreeMemory((BYTE*)pMethodInfo->pwszFriendlyName); EapHostPeerFreeMemory(reinterpret_cast<BYTE*>(pMethodInfo->pwszFriendlyName));
} }
/// \endcond /// \endcond

View File

@ -123,7 +123,7 @@ winstd::event_provider::~event_provider()
} }
void winstd::event_provider::free_internal() void winstd::event_provider::free_internal() noexcept
{ {
EventUnregister(m_h); EventUnregister(m_h);
} }
@ -160,7 +160,7 @@ winstd::event_session::~event_session()
} }
void winstd::event_session::free_internal() void winstd::event_session::free_internal() noexcept
{ {
ControlTrace(m_h, name(), m_prop.get(), EVENT_TRACE_CONTROL_STOP); ControlTrace(m_h, name(), m_prop.get(), EVENT_TRACE_CONTROL_STOP);
} }
@ -197,7 +197,7 @@ winstd::event_trace::~event_trace()
} }
void winstd::event_trace::free_internal() void winstd::event_trace::free_internal() noexcept
{ {
CloseTrace(m_h); CloseTrace(m_h);
} }

View File

@ -36,7 +36,7 @@ winstd::sec_credentials::~sec_credentials()
} }
void winstd::sec_credentials::free_internal() void winstd::sec_credentials::free_internal() noexcept
{ {
FreeCredentialsHandle(m_h); FreeCredentialsHandle(m_h);
delete m_h; delete m_h;
@ -56,7 +56,7 @@ winstd::sec_context::~sec_context()
} }
void winstd::sec_context::free_internal() void winstd::sec_context::free_internal() noexcept
{ {
DeleteSecurityContext(m_h); DeleteSecurityContext(m_h);
delete m_h; delete m_h;

View File

@ -34,7 +34,7 @@ winstd::setup_device_info_list::~setup_device_info_list()
} }
void winstd::setup_device_info_list::free_internal() void winstd::setup_device_info_list::free_internal() noexcept
{ {
SetupDiDestroyDeviceInfoList(m_h); SetupDiDestroyDeviceInfoList(m_h);
} }

View File

@ -32,7 +32,7 @@ winstd::wlan_handle::~wlan_handle()
} }
void winstd::wlan_handle::free_internal() void winstd::wlan_handle::free_internal() noexcept
{ {
WlanCloseHandle(m_h, NULL); WlanCloseHandle(m_h, NULL);
} }

View File

@ -25,7 +25,7 @@
// StringToGuidA // StringToGuidA
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
_Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd) _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCSTR *lpszGuidEnd) noexcept
{ {
GUID g; GUID g;
LPSTR lpszEnd; LPSTR lpszEnd;
@ -44,7 +44,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
ulTmp = strtoul(lpszGuid, &lpszEnd, 16); ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data2 = (unsigned short)ulTmp; g.Data2 = static_cast<unsigned short>(ulTmp);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -52,7 +52,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
ulTmp = strtoul(lpszGuid, &lpszEnd, 16); ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data3 = (unsigned short)ulTmp; g.Data3 = static_cast<unsigned short>(ulTmp);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -60,8 +60,8 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
ulTmp = strtoul(lpszGuid, &lpszEnd, 16); ulTmp = strtoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data4[0] = (unsigned char)((ulTmp >> 8) & 0xff); g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
g.Data4[1] = (unsigned char)( ulTmp & 0xff); g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -69,12 +69,12 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
ullTmp = _strtoui64(lpszGuid, &lpszEnd, 16); ullTmp = _strtoui64(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE; if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
g.Data4[2] = (unsigned char)((ullTmp >> 40) & 0xff); g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
g.Data4[3] = (unsigned char)((ullTmp >> 32) & 0xff); g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
g.Data4[4] = (unsigned char)((ullTmp >> 24) & 0xff); g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
g.Data4[5] = (unsigned char)((ullTmp >> 16) & 0xff); g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
g.Data4[6] = (unsigned char)((ullTmp >> 8) & 0xff); g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
g.Data4[7] = (unsigned char)( ullTmp & 0xff); g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '}') return FALSE; if (*lpszGuid != '}') return FALSE;
@ -88,7 +88,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidA(_In_z_ LPCSTR lpszGuid, _Out_ LP
} }
_Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd) _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUID lpGuid, _Out_opt_ LPCWSTR *lpszGuidEnd) noexcept
{ {
GUID g; GUID g;
LPWSTR lpszEnd; LPWSTR lpszEnd;
@ -107,7 +107,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
ulTmp = wcstoul(lpszGuid, &lpszEnd, 16); ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data2 = (unsigned short)ulTmp; g.Data2 = static_cast<unsigned short>(ulTmp);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -115,7 +115,7 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
ulTmp = wcstoul(lpszGuid, &lpszEnd, 16); ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data3 = (unsigned short)ulTmp; g.Data3 = static_cast<unsigned short>(ulTmp);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -123,8 +123,8 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
ulTmp = wcstoul(lpszGuid, &lpszEnd, 16); ulTmp = wcstoul(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE; if (errno == ERANGE || ulTmp > 0xFFFF) return FALSE;
g.Data4[0] = (unsigned char)((ulTmp >> 8) & 0xff); g.Data4[0] = static_cast<unsigned char>((ulTmp >> 8) & 0xff);
g.Data4[1] = (unsigned char)( ulTmp & 0xff); g.Data4[1] = static_cast<unsigned char>( ulTmp & 0xff);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '-') return FALSE; if (*lpszGuid != '-') return FALSE;
@ -132,12 +132,12 @@ _Success_(return) BOOL WINSTD_API StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ L
ullTmp = _wcstoui64(lpszGuid, &lpszEnd, 16); ullTmp = _wcstoui64(lpszGuid, &lpszEnd, 16);
if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE; if (errno == ERANGE || ullTmp > 0xFFFFFFFFFFFF) return FALSE;
g.Data4[2] = (unsigned char)((ullTmp >> 40) & 0xff); g.Data4[2] = static_cast<unsigned char>((ullTmp >> 40) & 0xff);
g.Data4[3] = (unsigned char)((ullTmp >> 32) & 0xff); g.Data4[3] = static_cast<unsigned char>((ullTmp >> 32) & 0xff);
g.Data4[4] = (unsigned char)((ullTmp >> 24) & 0xff); g.Data4[4] = static_cast<unsigned char>((ullTmp >> 24) & 0xff);
g.Data4[5] = (unsigned char)((ullTmp >> 16) & 0xff); g.Data4[5] = static_cast<unsigned char>((ullTmp >> 16) & 0xff);
g.Data4[6] = (unsigned char)((ullTmp >> 8) & 0xff); g.Data4[6] = static_cast<unsigned char>((ullTmp >> 8) & 0xff);
g.Data4[7] = (unsigned char)( ullTmp & 0xff); g.Data4[7] = static_cast<unsigned char>( ullTmp & 0xff);
lpszGuid = lpszEnd; lpszGuid = lpszEnd;
if (*lpszGuid != '}') return FALSE; if (*lpszGuid != '}') return FALSE;
@ -162,7 +162,7 @@ winstd::library::~library()
} }
void winstd::library::free_internal() void winstd::library::free_internal() noexcept
{ {
FreeLibrary(m_h); FreeLibrary(m_h);
} }
@ -174,7 +174,11 @@ void winstd::library::free_internal()
winstd::critical_section::critical_section() winstd::critical_section::critical_section()
{ {
InitializeCriticalSection(&m_data); __try {
InitializeCriticalSection(&m_data);
} __except(EXCEPTION_EXECUTE_HANDLER) {
throw std::runtime_error("InitializeCriticalSection failed");
}
} }
@ -196,7 +200,7 @@ winstd::find_file::~find_file()
} }
void winstd::find_file::free_internal() void winstd::find_file::free_internal() noexcept
{ {
FindClose(m_h); FindClose(m_h);
} }
@ -215,7 +219,7 @@ winstd::heap::~heap()
} }
bool winstd::heap::enumerate() bool winstd::heap::enumerate() noexcept
{ {
assert(m_h != invalid); assert(m_h != invalid);
@ -243,7 +247,7 @@ bool winstd::heap::enumerate()
} }
} }
DWORD dwResult = GetLastError(); const DWORD dwResult = GetLastError();
if (dwResult != ERROR_NO_MORE_ITEMS) if (dwResult != ERROR_NO_MORE_ITEMS)
OutputDebugStr(_T("HeapWalk failed (error %u).\n"), dwResult); OutputDebugStr(_T("HeapWalk failed (error %u).\n"), dwResult);
@ -254,7 +258,7 @@ bool winstd::heap::enumerate()
} }
void winstd::heap::free_internal() void winstd::heap::free_internal() noexcept
{ {
enumerate(); enumerate();
HeapDestroy(m_h); HeapDestroy(m_h);
@ -265,7 +269,7 @@ void winstd::heap::free_internal()
// winstd::actctx_activator // winstd::actctx_activator
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
winstd::actctx_activator::actctx_activator(_In_ HANDLE hActCtx) winstd::actctx_activator::actctx_activator(_In_ HANDLE hActCtx) noexcept
{ {
if (!ActivateActCtx(hActCtx, &m_cookie)) if (!ActivateActCtx(hActCtx, &m_cookie))
m_cookie = 0; m_cookie = 0;
@ -283,7 +287,7 @@ winstd::actctx_activator::~actctx_activator()
// winstd::user_impersonator // winstd::user_impersonator
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
winstd::user_impersonator::user_impersonator(_In_opt_ HANDLE hToken) winstd::user_impersonator::user_impersonator(_In_opt_ HANDLE hToken) noexcept
{ {
m_cookie = hToken && ImpersonateLoggedOnUser(hToken); m_cookie = hToken && ImpersonateLoggedOnUser(hToken);
} }
@ -300,7 +304,7 @@ winstd::user_impersonator::~user_impersonator()
// winstd::console_ctrl_handler // winstd::console_ctrl_handler
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
winstd::console_ctrl_handler::console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) : winstd::console_ctrl_handler::console_ctrl_handler(_In_opt_ PHANDLER_ROUTINE HandlerRoutine) noexcept :
m_handler(HandlerRoutine) m_handler(HandlerRoutine)
{ {
m_cookie = SetConsoleCtrlHandler(m_handler, TRUE); m_cookie = SetConsoleCtrlHandler(m_handler, TRUE);
@ -325,7 +329,7 @@ winstd::vmemory::~vmemory()
} }
void winstd::vmemory::free_internal() void winstd::vmemory::free_internal() noexcept
{ {
VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE); VirtualFreeEx(m_proc, m_h, 0, MEM_RELEASE);
} }
@ -342,7 +346,7 @@ winstd::reg_key::~reg_key()
} }
void winstd::reg_key::free_internal() void winstd::reg_key::free_internal() noexcept
{ {
RegCloseKey(m_h); RegCloseKey(m_h);
} }
@ -359,7 +363,7 @@ winstd::security_id::~security_id()
} }
void winstd::security_id::free_internal() void winstd::security_id::free_internal() noexcept
{ {
FreeSid(m_h); FreeSid(m_h);
} }

View File

@ -34,7 +34,7 @@ winstd::addrinfo::~addrinfo()
} }
void winstd::addrinfo::free_internal() void winstd::addrinfo::free_internal() noexcept
{ {
FreeAddrInfo(m_h); FreeAddrInfo(m_h);
} }

View File

@ -30,5 +30,5 @@
winstd::wintrust::~wintrust() winstd::wintrust::~wintrust()
{ {
m_wtd.dwStateAction = WTD_STATEACTION_CLOSE; m_wtd.dwStateAction = WTD_STATEACTION_CLOSE;
WinVerifyTrust(m_hwnd, (GUID*)&m_action, &m_wtd); WinVerifyTrust(m_hwnd, &m_action, &m_wtd);
} }