From 09109171268668b0362ee9349b5b0c5da5a38ce6 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 18 Apr 2017 13:53:27 +0200 Subject: [PATCH 1/4] Copyright extended to 2017 --- include/WinStd/Base64.h | 2 +- include/WinStd/COM.h | 2 +- include/WinStd/Common.h | 2 +- include/WinStd/Cred.h | 2 +- include/WinStd/Crypt.h | 2 +- include/WinStd/EAP.h | 2 +- include/WinStd/ETW.h | 2 +- include/WinStd/Hex.h | 2 +- include/WinStd/MSI.h | 2 +- include/WinStd/Sec.h | 2 +- include/WinStd/Shell.h | 2 +- include/WinStd/WLAN.h | 2 +- include/WinStd/Win.h | 2 +- src/Base64.cpp | 2 +- src/COM.cpp | 2 +- src/Crypt.cpp | 2 +- src/EAP.cpp | 2 +- src/ETW.cpp | 2 +- src/Sec.cpp | 2 +- src/StdAfx.cpp | 2 +- src/StdAfx.h | 2 +- src/WLAN.cpp | 2 +- src/Win.cpp | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/WinStd/Base64.h b/include/WinStd/Base64.h index 1f06900a..be4c2852 100644 --- a/include/WinStd/Base64.h +++ b/include/WinStd/Base64.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/COM.h b/include/WinStd/COM.h index b083a69a..e221453d 100644 --- a/include/WinStd/COM.h +++ b/include/WinStd/COM.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index c73040b2..a5a03af7 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Cred.h b/include/WinStd/Cred.h index 8f1cdeff..001248cf 100644 --- a/include/WinStd/Cred.h +++ b/include/WinStd/Cred.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Crypt.h b/include/WinStd/Crypt.h index 3152b25f..dd156159 100644 --- a/include/WinStd/Crypt.h +++ b/include/WinStd/Crypt.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/EAP.h b/include/WinStd/EAP.h index 04b528b2..e054c616 100644 --- a/include/WinStd/EAP.h +++ b/include/WinStd/EAP.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/ETW.h b/include/WinStd/ETW.h index 6cd915c1..72c65905 100644 --- a/include/WinStd/ETW.h +++ b/include/WinStd/ETW.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Hex.h b/include/WinStd/Hex.h index 8c43e7d6..e9a2565c 100644 --- a/include/WinStd/Hex.h +++ b/include/WinStd/Hex.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/MSI.h b/include/WinStd/MSI.h index 963a1c78..678d2f80 100644 --- a/include/WinStd/MSI.h +++ b/include/WinStd/MSI.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Sec.h b/include/WinStd/Sec.h index 5bb6e78c..27dfecfa 100644 --- a/include/WinStd/Sec.h +++ b/include/WinStd/Sec.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Shell.h b/include/WinStd/Shell.h index 3afbdb3a..ae36cf6c 100644 --- a/include/WinStd/Shell.h +++ b/include/WinStd/Shell.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/WLAN.h b/include/WinStd/WLAN.h index a5f75f1f..4bc01c04 100644 --- a/include/WinStd/WLAN.h +++ b/include/WinStd/WLAN.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index e41bfae7..872587f3 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/Base64.cpp b/src/Base64.cpp index 6e9c1d2e..5193b7b2 100644 --- a/src/Base64.cpp +++ b/src/Base64.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/COM.cpp b/src/COM.cpp index 7d48aa32..488f7237 100644 --- a/src/COM.cpp +++ b/src/COM.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/Crypt.cpp b/src/Crypt.cpp index e741caab..cf6fdd7c 100644 --- a/src/Crypt.cpp +++ b/src/Crypt.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/EAP.cpp b/src/EAP.cpp index e195cc89..5ab75e06 100644 --- a/src/EAP.cpp +++ b/src/EAP.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/ETW.cpp b/src/ETW.cpp index d2ce8bc0..a5c30f19 100644 --- a/src/ETW.cpp +++ b/src/ETW.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/Sec.cpp b/src/Sec.cpp index 3d69fcd2..036f583b 100644 --- a/src/Sec.cpp +++ b/src/Sec.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/StdAfx.cpp b/src/StdAfx.cpp index 4c95ea70..90a0efa6 100644 --- a/src/StdAfx.cpp +++ b/src/StdAfx.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/StdAfx.h b/src/StdAfx.h index f7c17282..d552871b 100644 --- a/src/StdAfx.h +++ b/src/StdAfx.h @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/WLAN.cpp b/src/WLAN.cpp index 2f57a2fb..d88d47c0 100644 --- a/src/WLAN.cpp +++ b/src/WLAN.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. diff --git a/src/Win.cpp b/src/Win.cpp index 97e2ba68..eb05d5a1 100644 --- a/src/Win.cpp +++ b/src/Win.cpp @@ -1,5 +1,5 @@ /* - Copyright 1991-2016 Amebis + Copyright 1991-2017 Amebis Copyright 2016 GÉANT This file is part of WinStd. From e9abc0e7b65a72b19402656987cdbc01947a1b13 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 24 Apr 2017 21:06:37 +0200 Subject: [PATCH 2/4] winstd::file helper class introduced --- include/WinStd/Win.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 872587f3..82680785 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -35,6 +35,7 @@ namespace winstd class WINSTD_API win_handle; class WINSTD_API library; class WINSTD_API process; + class WINSTD_API file; class WINSTD_API heap; template class heap_allocator; class WINSTD_API actctx_activator; @@ -382,6 +383,33 @@ namespace winstd }; + /// + /// File handle wrapper + /// + class WINSTD_API file : public win_handle + { + public: + /// + /// Opens file handle. + /// + /// \sa [CreateFile function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx) + /// + /// \return + /// - \c true when succeeds; + /// - \c false when fails. Use `GetLastError()` for failure reason. + /// + inline bool create(_In_ 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) + { + handle_type h = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); + if (h) { + attach(h); + return true; + } else + return false; + } + }; + + /// /// Heap handle wrapper /// From 79b9ac4371ffc9feb055587a5824e49030deb06d Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 24 Apr 2017 21:07:39 +0200 Subject: [PATCH 3/4] winstd::com_obj "QueryInterface" constructors added --- include/WinStd/COM.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/WinStd/COM.h b/include/WinStd/COM.h index e221453d..4fd8d0f4 100644 --- a/include/WinStd/COM.h +++ b/include/WinStd/COM.h @@ -64,6 +64,32 @@ namespace winstd } + /// + /// Queries the object for another interface and creates new class with it + /// + /// \sa [IUnknown::QueryInterface method](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682521.aspx) + /// + template + inline com_obj(_Out_ _Other **other) + { + assert(other); + other->QueryInterface(__uuidof(T), (void**)&m_h); + } + + + /// + /// Queries the object for another interface and creates new class with it + /// + /// \sa [IUnknown::QueryInterface method](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682521.aspx) + /// + template + inline com_obj(_Out_ com_obj<_Other> &other) + { + assert(other); + other->QueryInterface(__uuidof(T), (void**)&m_h); + } + + /// /// Releases object /// From 50d840e1712b40a74bf79c43962d8957d9dd200a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 25 Apr 2017 00:35:25 +0200 Subject: [PATCH 4/4] Some MSI functions tested and marked as OK --- include/WinStd/MSI.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/WinStd/MSI.h b/include/WinStd/MSI.h index 678d2f80..7ac0412f 100644 --- a/include/WinStd/MSI.h +++ b/include/WinStd/MSI.h @@ -126,8 +126,6 @@ inline UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_ LPCSTR szName, _Out_ s template inline UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_ LPCWSTR szName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) { - assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -182,8 +180,6 @@ inline UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField template inline UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) { - assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -238,8 +234,6 @@ inline UINT MsiFormatRecordA(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_s template inline UINT MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, std::basic_string<_Elem, _Traits, _Ax> &sValue) { - assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -314,8 +308,6 @@ inline UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_ LPCSTR szFolder, _Ou template inline UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_ LPCWSTR szFolder, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) { - assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult;