diff --git a/build/WinStd.vcxproj b/build/WinStd.vcxproj index 56794eb2..06469be9 100644 --- a/build/WinStd.vcxproj +++ b/build/WinStd.vcxproj @@ -73,6 +73,9 @@ + + + Create @@ -80,6 +83,7 @@ Create Create + diff --git a/build/WinStd.vcxproj.filters b/build/WinStd.vcxproj.filters index 8b8ee4be..1509d93f 100644 --- a/build/WinStd.vcxproj.filters +++ b/build/WinStd.vcxproj.filters @@ -20,6 +20,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + diff --git a/include/WinStd/Base64.h b/include/WinStd/Base64.h index 8bfdb5b4..2fc60edb 100644 Binary files a/include/WinStd/Base64.h and b/include/WinStd/Base64.h differ diff --git a/include/WinStd/COM.h b/include/WinStd/COM.h index 68e26897..517ee635 100644 Binary files a/include/WinStd/COM.h and b/include/WinStd/COM.h differ diff --git a/include/WinStd/Crypt.h b/include/WinStd/Crypt.h index 3a8c57a9..69a33cd7 100644 Binary files a/include/WinStd/Crypt.h and b/include/WinStd/Crypt.h differ diff --git a/include/WinStd/EAP.h b/include/WinStd/EAP.h index 77dd89a4..bc555307 100644 Binary files a/include/WinStd/EAP.h and b/include/WinStd/EAP.h differ diff --git a/include/WinStd/ETW.h b/include/WinStd/ETW.h index 91eed86c..04ad166d 100644 Binary files a/include/WinStd/ETW.h and b/include/WinStd/ETW.h differ diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 03cc07f3..a581b60d 100644 Binary files a/include/WinStd/Win.h and b/include/WinStd/Win.h differ diff --git a/src/Base64.cpp b/src/Base64.cpp index 35371139..2bcbd44e 100644 Binary files a/src/Base64.cpp and b/src/Base64.cpp differ diff --git a/src/COM.cpp b/src/COM.cpp new file mode 100644 index 00000000..47072d96 --- /dev/null +++ b/src/COM.cpp @@ -0,0 +1,234 @@ +/* + Copyright 1991-2016 Amebis + Copyright 2016 GÉANT + + This file is part of WinStd. + + Setup is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Setup is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Setup. If not, see . +*/ + +#include "StdAfx.h" + + +////////////////////////////////////////////////////////////////////// +// winstd::bstr +////////////////////////////////////////////////////////////////////// + +winstd::bstr::bstr() : handle() +{ +} + + +winstd::bstr::bstr(_In_ LPCOLESTR src) : handle(SysAllocString(src)) +{ +} + + +winstd::bstr::bstr(_In_ LPCOLESTR src, _In_ UINT len) : handle(SysAllocStringLen(src, len)) +{ +} + + +winstd::bstr::~bstr() +{ + if (m_h) + SysFreeString(m_h); +} + + +void winstd::bstr::free_internal() +{ + SysFreeString(m_h); +} + + +winstd::bstr::handle_type winstd::bstr::duplicate_internal(_In_ handle_type h) const +{ + return SysAllocStringLen(h, SysStringLen(h)); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::variant +////////////////////////////////////////////////////////////////////// + +winstd::variant::variant() +{ + VariantInit(this); +} + + +winstd::variant::variant(_In_ const VARIANT& varSrc) +{ + vt = VT_EMPTY; + VariantCopy(this, &varSrc); +} + + +winstd::variant::variant(_In_ bool bSrc) +{ + vt = VT_BOOL; + boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE; +} + + +winstd::variant::variant(_In_ char cSrc) +{ + vt = VT_I1; + cVal = cSrc; +} + + +winstd::variant::variant(_In_ unsigned char nSrc) +{ + vt = VT_UI1; + bVal = nSrc; +} + + +winstd::variant::variant(_In_ short nSrc) +{ + vt = VT_I2; + iVal = nSrc; +} + + +winstd::variant::variant(_In_ unsigned short nSrc) +{ + vt = VT_UI2; + uiVal = nSrc; +} + + +winstd::variant::variant(_In_ int nSrc, _In_ VARTYPE vtSrc) +{ + assert(vtSrc == VT_I4 || vtSrc == VT_INT); + vt = vtSrc; + intVal = nSrc; +} + + +winstd::variant::variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc) +{ + assert(vtSrc == VT_UI4 || vtSrc == VT_UINT); + vt = vtSrc; + uintVal= nSrc; +} + + +winstd::variant::variant(_In_ long nSrc, _In_ VARTYPE vtSrc) +{ + assert(vtSrc == VT_I4 || vtSrc == VT_ERROR); + vt = vtSrc; + lVal = nSrc; +} + + +winstd::variant::variant(_In_ unsigned long nSrc) +{ + vt = VT_UI4; + ulVal = nSrc; +} + + +winstd::variant::variant(_In_ float fltSrc) +{ + vt = VT_R4; + fltVal = fltSrc; +} + + +winstd::variant::variant(_In_ double dblSrc, _In_ VARTYPE vtSrc) +{ + assert(vtSrc == VT_R8 || vtSrc == VT_DATE); + vt = vtSrc; + dblVal = dblSrc; +} + + +winstd::variant::variant(_In_ long long nSrc) +{ + vt = VT_I8; + llVal = nSrc; +} + + +winstd::variant::variant(_In_ unsigned long long nSrc) +{ + vt = VT_UI8; + ullVal = nSrc; +} + + +winstd::variant::variant(_In_ CY cySrc) +{ + vt = VT_CY; + cyVal.Hi = cySrc.Hi; + cyVal.Lo = cySrc.Lo; +} + + +winstd::variant::variant(_In_z_ LPCOLESTR lpszSrc) +{ + vt = VT_EMPTY; + *this = lpszSrc; +} + + +winstd::variant::variant(_In_z_ BSTR bstr) +{ + vt = VT_EMPTY; + *this = bstr; +} + + +winstd::variant::variant(_In_opt_ IDispatch* pSrc) +{ + vt = VT_DISPATCH; + pdispVal = pSrc; + + if (pdispVal != NULL) + pdispVal->AddRef(); +} + + +winstd::variant::variant(_In_opt_ IUnknown* pSrc) +{ + vt = VT_UNKNOWN; + punkVal = pSrc; + + if (punkVal != NULL) + punkVal->AddRef(); +} + + +winstd::variant::variant(_In_ const SAFEARRAY *pSrc) +{ + assert(pSrc != NULL); + + LPSAFEARRAY pCopy; + HRESULT hRes = SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); + if (SUCCEEDED(hRes)) { + SafeArrayGetVartype((LPSAFEARRAY)pSrc, &vt); + vt |= VT_ARRAY; + parray = pCopy; + } else + assert(0); +} + + +winstd::variant::~variant() +{ + VariantClear(this); +} diff --git a/src/Crypt.cpp b/src/Crypt.cpp new file mode 100644 index 00000000..fe1ecc20 --- /dev/null +++ b/src/Crypt.cpp @@ -0,0 +1,149 @@ +/* + Copyright 1991-2016 Amebis + Copyright 2016 GÉANT + + This file is part of WinStd. + + Setup is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Setup is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Setup. If not, see . +*/ + +#include "StdAfx.h" + + +////////////////////////////////////////////////////////////////////// +// winstd::cert_context +////////////////////////////////////////////////////////////////////// + +winstd::cert_context::~cert_context() +{ + if (m_h) + CertFreeCertificateContext(m_h); +} + + +void winstd::cert_context::free_internal() +{ + CertFreeCertificateContext(m_h); +} + + +winstd::cert_context::handle_type winstd::cert_context::duplicate_internal(_In_ handle_type h) const +{ + return CertDuplicateCertificateContext(h); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::cert_chain_context +////////////////////////////////////////////////////////////////////// + +winstd::cert_chain_context::~cert_chain_context() +{ + if (m_h) + CertFreeCertificateChain(m_h); +} + + +void winstd::cert_chain_context::free_internal() +{ + CertFreeCertificateChain(m_h); +} + + +winstd::cert_chain_context::handle_type winstd::cert_chain_context::duplicate_internal(_In_ handle_type h) const +{ + return CertDuplicateCertificateChain(h); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::cert_store +////////////////////////////////////////////////////////////////////// + +winstd::cert_store::~cert_store() +{ + if (m_h) + CertCloseStore(m_h, 0); +} + + +void winstd::cert_store::free_internal() +{ + CertCloseStore(m_h, 0); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::crypt_prov +////////////////////////////////////////////////////////////////////// + +winstd::crypt_prov::~crypt_prov() +{ + if (m_h) + CryptReleaseContext(m_h, 0); +} + + +void winstd::crypt_prov::free_internal() +{ + CryptReleaseContext(m_h, 0); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::crypt_hash +////////////////////////////////////////////////////////////////////// + +winstd::crypt_hash::~crypt_hash() +{ + if (m_h) + CryptDestroyHash(m_h); +} + + +void winstd::crypt_hash::free_internal() +{ + CryptDestroyHash(m_h); +} + + +winstd::crypt_hash::handle_type winstd::crypt_hash::duplicate_internal(_In_ handle_type h) const +{ + handle_type hNew = NULL; + return CryptDuplicateHash(h, NULL, 0, &hNew) ? hNew : NULL; +} + + +////////////////////////////////////////////////////////////////////// +// winstd::crypt_key +////////////////////////////////////////////////////////////////////// + +winstd::crypt_key::~crypt_key() +{ + if (m_h) + CryptDestroyKey(m_h); +} + + +void winstd::crypt_key::free_internal() +{ + CryptDestroyKey(m_h); +} + + +winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle_type h) const +{ + handle_type hNew = NULL; + return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : NULL; +} diff --git a/src/EAP.cpp b/src/EAP.cpp new file mode 100644 index 00000000..40a57333 --- /dev/null +++ b/src/EAP.cpp @@ -0,0 +1,40 @@ +/* + Copyright 1991-2016 Amebis + Copyright 2016 GÉANT + + This file is part of WinStd. + + Setup is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Setup is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Setup. If not, see . +*/ + +#include "StdAfx.h" + + +////////////////////////////////////////////////////////////////////// +// winstd::eap_attr +////////////////////////////////////////////////////////////////////// + +winstd::eap_attr::eap_attr() +{ + eaType = eatReserved; + dwLength = 0; + pValue = NULL; +} + + +winstd::eap_attr::~eap_attr() +{ + if (pValue) + delete pValue; +} diff --git a/src/ETW.cpp b/src/ETW.cpp index 424fa348..8c915661 100644 Binary files a/src/ETW.cpp and b/src/ETW.cpp differ diff --git a/src/Win.cpp b/src/Win.cpp new file mode 100644 index 00000000..67b37b0c --- /dev/null +++ b/src/Win.cpp @@ -0,0 +1,55 @@ +/* + Copyright 1991-2016 Amebis + Copyright 2016 GÉANT + + This file is part of WinStd. + + Setup is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Setup is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Setup. If not, see . +*/ + +#include "StdAfx.h" + + +////////////////////////////////////////////////////////////////////// +// winstd::library +////////////////////////////////////////////////////////////////////// + +winstd::library::~library() +{ + if (m_h) + FreeLibrary(m_h); +} + + +void winstd::library::free_internal() +{ + FreeLibrary(m_h); +} + + +////////////////////////////////////////////////////////////////////// +// winstd::heap +////////////////////////////////////////////////////////////////////// + +winstd::heap::~heap() +{ + if (m_h) + HeapDestroy(m_h); +} + + +void winstd::heap::free_internal() +{ + HeapDestroy(m_h); +}