diff --git a/include/WinStd/Cred.h b/include/WinStd/Cred.h index 6e0d94c8..ce647ba1 100644 --- a/include/WinStd/Cred.h +++ b/include/WinStd/Cred.h @@ -33,28 +33,28 @@ namespace winstd static BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr > &cCredentials) noexcept; /// @copydoc CredProtectW() -template -static 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 +static BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType); /// /// Encrypts the specified credentials so that only the current security context can decrypt them. /// /// \sa [CredProtect function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374803.aspx) /// -template -static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType); +template +static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType); /// @copydoc CredUnprotectW() -template -static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sCredentials); +template +static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sCredentials); /// /// Decrypts credentials that were previously encrypted by using the CredProtect function. /// /// \sa [CredUnprotect function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa375186.aspx) /// -template -static BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sCredentials); +template +static BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sCredentials); /// @} @@ -149,10 +149,10 @@ static BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ D } -template -static 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 +static BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType) { - _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char buf[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(buf); // Try with the stack buffer first. @@ -162,7 +162,7 @@ static BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR ps return TRUE; } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]); + std::unique_ptr buf(new char[dwSize]); if (CredProtectA(fAsSelf, const_cast(pszCredentials), cchCredentials, buf.get(), &dwSize, ProtectionType)) { sProtectedCredentials.assign(buf.get(), dwSize - 1); return TRUE; @@ -173,10 +173,10 @@ static BOOL CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR ps } -template -static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType) +template +static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType) { - _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t buf[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(buf); // Try with the stack buffer first. @@ -186,7 +186,7 @@ static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR p return TRUE; } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]); + std::unique_ptr buf(new wchar_t[dwSize]); if (CredProtectW(fAsSelf, const_cast(pszCredentials), cchCredentials, buf.get(), &dwSize, ProtectionType)) { sProtectedCredentials.assign(buf.get(), dwSize - 1); return TRUE; @@ -197,10 +197,10 @@ static BOOL CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR p } -template -static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sCredentials) +template +static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sCredentials) { - _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char buf[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(buf); // Try with the stack buffer first. @@ -210,7 +210,7 @@ static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR return TRUE; } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]); + std::unique_ptr buf(new char[dwSize]); if (CredUnprotectA(fAsSelf, const_cast(pszProtectedCredentials), cchCredentials, buf.get(), &dwSize)) { sCredentials.assign(buf.get(), dwSize); return TRUE; @@ -221,10 +221,10 @@ static BOOL CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR } -template -static BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sCredentials) +template +static BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string &sCredentials) { - _Elem buf[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t buf[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(buf); // Try with the stack buffer first. @@ -234,7 +234,7 @@ static BOOL CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR return TRUE; } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> buf(new _Elem[dwSize]); + std::unique_ptr buf(new wchar_t[dwSize]); if (CredUnprotectW(fAsSelf, const_cast(pszProtectedCredentials), cchCredentials, buf.get(), &dwSize)) { sCredentials.assign(buf.get(), dwSize); return TRUE; diff --git a/include/WinStd/Crypt.h b/include/WinStd/Crypt.h index 3fc93a3e..4e7395a5 100644 --- a/include/WinStd/Crypt.h +++ b/include/WinStd/Crypt.h @@ -31,16 +31,16 @@ namespace winstd /// @{ /// @copydoc CertGetNameStringW() -template -static DWORD CertGetNameStringA(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sNameString); +template +static DWORD CertGetNameStringA(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string &sNameString); /// /// Obtains the subject or issuer name from a certificate [CERT_CONTEXT](https://msdn.microsoft.com/en-us/library/windows/desktop/aa377189.aspx) structure and stores it in a std::wstring string. /// /// \sa [CertGetNameString function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa376086.aspx) /// -template -static DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sNameString); +template +static DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string &sNameString); /// /// Retrieves the information contained in an extended property of a certificate context. @@ -817,28 +817,28 @@ namespace winstd } -template -static DWORD CertGetNameStringA(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sNameString) +template +static DWORD CertGetNameStringA(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string &sNameString) { // Query the final string length first. DWORD dwSize = ::CertGetNameStringA(pCertContext, dwType, dwFlags, pvTypePara, NULL, 0); // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize]); + std::unique_ptr szBuffer(new char[dwSize]); dwSize = ::CertGetNameStringA(pCertContext, dwType, dwFlags, pvTypePara, szBuffer.get(), dwSize); sNameString.assign(szBuffer.get(), dwSize - 1); return dwSize; } -template -static DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sNameString) +template +static DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwType, _In_ DWORD dwFlags, _In_opt_ void *pvTypePara, _Out_ std::basic_string &sNameString) { // Query the final string length first. DWORD dwSize = ::CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara, NULL, 0); // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize]); + std::unique_ptr szBuffer(new wchar_t[dwSize]); dwSize = ::CertGetNameStringW(pCertContext, dwType, dwFlags, pvTypePara, szBuffer.get(), dwSize); sNameString.assign(szBuffer.get(), dwSize - 1); return dwSize; diff --git a/include/WinStd/MSI.h b/include/WinStd/MSI.h index e4af36ec..e8ffff4f 100644 --- a/include/WinStd/MSI.h +++ b/include/WinStd/MSI.h @@ -20,40 +20,40 @@ /// @{ /// @copydoc MsiGetPropertyW() -template -static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string &sValue); /// /// Gets the value for an installer property and stores it in a std::wstring string. /// /// \sa [MsiGetProperty function](https://msdn.microsoft.com/en-us/library/aa370134.aspx) /// -template -static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string &sValue); /// @copydoc MsiRecordGetStringW() -template -static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string &sValue); /// /// Returns the string value of a record field and stores it in a std::wstring string. /// /// \sa [MsiRecordGetString function](https://msdn.microsoft.com/en-us/library/aa370368.aspx) /// -template -static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string &sValue); /// @copydoc MsiFormatRecordW() -template -static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string &sValue); /// /// Formats record field data and properties using a format string and stores it in a std::wstring string. /// /// \sa [MsiFormatRecord function](https://msdn.microsoft.com/en-us/library/aa370109.aspx) /// -template -static UINT MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string &sValue); /// /// Reads bytes from a record stream field into a std::vector buffer. @@ -64,40 +64,40 @@ template static UINT MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::vector<_Ty, _Ax> &binData); /// @copydoc MsiGetTargetPathW() -template -static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Inout_ std::basic_string &sValue); /// /// Returns the full target path for a folder in the Directory table and stores it in a std::wstring string. /// /// \sa [MsiGetTargetPath function](https://msdn.microsoft.com/en-us/library/aa370303.aspx) /// -template -static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string &sValue); /// @copydoc MsiGetComponentPathW() -template -static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string &sValue); /// /// Returns the full path to an installed component. If the key path for the component is a registry key then the registry key is returned. /// /// \sa [MsiGetComponentPath function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa370112.aspx) /// -template -static INSTALLSTATE MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue); +template +static INSTALLSTATE MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string &sValue); /// @} #pragma once -template -static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inout_ std::basic_string &sValue) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -109,7 +109,7 @@ static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inou return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to read the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new char[++dwSize]); uiResult = ::MsiGetPropertyA(hInstall, szName, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -120,10 +120,10 @@ static UINT MsiGetPropertyA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szName, _Inou } -template -static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -135,7 +135,7 @@ static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Ino return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to read the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new wchar_t[++dwSize]); uiResult = ::MsiGetPropertyW(hInstall, szName, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -146,12 +146,12 @@ static UINT MsiGetPropertyW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szName, _Ino } -template -static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string &sValue) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -163,7 +163,7 @@ static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to read the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new char[++dwSize]); uiResult = ::MsiRecordGetStringA(hRecord, iField, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -174,10 +174,10 @@ static UINT MsiRecordGetStringA(_In_ MSIHANDLE hRecord, _In_ unsigned int iField } -template -static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -189,7 +189,7 @@ static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to read the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new wchar_t[++dwSize]); uiResult = ::MsiRecordGetStringW(hRecord, iField, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -200,12 +200,12 @@ static UINT MsiRecordGetStringW(_In_ MSIHANDLE hRecord, _In_ unsigned int iField } -template -static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string &sValue) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -217,7 +217,7 @@ static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _I return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new char[++dwSize]); uiResult = ::MsiFormatRecordA(hInstall, hRecord, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -228,10 +228,10 @@ static UINT MsiFormatRecordA(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _I } -template -static UINT MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -243,7 +243,7 @@ static UINT MsiFormatRecordW(_In_ MSIHANDLE hInstall, _In_ MSIHANDLE hRecord, _I return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new wchar_t[++dwSize]); uiResult = ::MsiFormatRecordW(hInstall, hRecord, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -274,12 +274,12 @@ static UINT MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_ unsigned int iField } -template -static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _Out_ std::basic_string &sValue) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -291,7 +291,7 @@ static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _ return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new char[++dwSize]); uiResult = ::MsiGetTargetPathA(hInstall, szFolder, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -302,10 +302,10 @@ static UINT MsiGetTargetPathA(_In_ MSIHANDLE hInstall, _In_z_ LPCSTR szFolder, _ } -template -static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); UINT uiResult; @@ -317,7 +317,7 @@ static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, return ERROR_SUCCESS; } else if (uiResult == ERROR_MORE_DATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new wchar_t[++dwSize]); uiResult = ::MsiGetTargetPathW(hInstall, szFolder, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), uiResult == ERROR_SUCCESS ? dwSize : 0); return uiResult; @@ -328,10 +328,10 @@ static UINT MsiGetTargetPathW(_In_ MSIHANDLE hInstall, _In_z_ LPCWSTR szFolder, } -template -static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR szComponent, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); INSTALLSTATE state; @@ -343,7 +343,7 @@ static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR return state; } else if (state == INSTALLSTATE_MOREDATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new char[++dwSize]); state = ::MsiGetComponentPathA(szProduct, szComponent, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0); return state; @@ -354,10 +354,10 @@ static INSTALLSTATE MsiGetComponentPathA(_In_z_ LPCSTR szProduct, _In_z_ LPCSTR } -template -static INSTALLSTATE MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue) +template +static INSTALLSTATE MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWSTR szComponent, _Inout_ std::basic_string &sValue) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); INSTALLSTATE state; @@ -369,7 +369,7 @@ static INSTALLSTATE MsiGetComponentPathW(_In_z_ LPCWSTR szProduct, _In_z_ LPCWST return state; } else if (state == INSTALLSTATE_MOREDATA) { // Allocate buffer on heap to format the string data into and read it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++dwSize]); + std::unique_ptr szBuffer(new wchar_t[++dwSize]); state = ::MsiGetComponentPathW(szProduct, szComponent, szBuffer.get(), &dwSize); sValue.assign(szBuffer.get(), state >= INSTALLSTATE_BROKEN ? dwSize : 0); return state; diff --git a/include/WinStd/Sec.h b/include/WinStd/Sec.h index c1a2a74e..9a24501b 100644 --- a/include/WinStd/Sec.h +++ b/include/WinStd/Sec.h @@ -29,16 +29,16 @@ namespace winstd /// @{ /// @copydoc GetUserNameExW() -template -static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sName); +template +static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string &sName); /// /// Retrieves the name of the user or other security principal associated with the calling thread and stores it in a std::wstring string. /// /// \sa [GetUserNameEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724435.aspx) /// -template -static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sName); +template +static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string &sName); #endif @@ -370,12 +370,12 @@ namespace winstd #if defined(SECURITY_WIN32) || defined(SECURITY_KERNEL) -template -static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sName) +template +static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string &sName) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; ULONG ulSize = _countof(szStackBuffer); // Try with stack buffer first. @@ -386,7 +386,7 @@ static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std: } else { if (::GetLastError() == ERROR_MORE_DATA) { // Allocate buffer on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[ulSize]); + std::unique_ptr szBuffer(new char[ulSize]); if (::GetUserNameExA(NameFormat, szBuffer.get(), &ulSize)) { sName.assign(szBuffer.get(), ulSize); return TRUE; @@ -398,12 +398,12 @@ static BOOLEAN GetUserNameExA(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std: } -template -static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sName) +template +static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std::basic_string &sName) { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; ULONG ulSize = _countof(szStackBuffer); // Try with stack buffer first. @@ -414,7 +414,7 @@ static BOOLEAN GetUserNameExW(_In_ EXTENDED_NAME_FORMAT NameFormat, _Inout_ std: } else { if (::GetLastError() == ERROR_MORE_DATA) { // Allocate buffer on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[ulSize]); + std::unique_ptr szBuffer(new wchar_t[ulSize]); if (::GetUserNameExW(NameFormat, szBuffer.get(), &ulSize)) { sName.assign(szBuffer.get(), ulSize); return TRUE; diff --git a/include/WinStd/Shell.h b/include/WinStd/Shell.h index 1809c880..9c837378 100644 --- a/include/WinStd/Shell.h +++ b/include/WinStd/Shell.h @@ -18,41 +18,41 @@ /// @{ /// @copydoc PathCanonicalizeW() -template -static BOOL PathCanonicalizeA(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, _In_ LPCSTR pszPath); +template +static BOOL PathCanonicalizeA(_Inout_ std::basic_string &sValue, _In_ LPCSTR pszPath); /// /// Simplifies a path by removing navigation elements such as "." and ".." to produce a direct, well-formed path, and stores it in a std::wstring string. /// /// \sa [PathCanonicalize function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb773569.aspx) /// -template -static BOOL PathCanonicalizeW(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, _In_ LPCWSTR pszPath); +template +static BOOL PathCanonicalizeW(_Inout_ std::basic_string &sValue, _In_ LPCWSTR pszPath); /// @} #pragma once -template -static BOOL PathCanonicalizeA(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, _In_ LPCSTR pszPath) +template +static BOOL PathCanonicalizeA(_Inout_ std::basic_string &sValue, _In_ LPCSTR pszPath) { assert(0); // TODO: Test this code. // Allocate buffer on heap and read into it. - _Elem szBuffer[MAX_PATH + 1]; + char szBuffer[MAX_PATH + 1]; BOOL bResult = ::PathCanonicalizeA(szBuffer, pszPath); sValue.assign(szBuffer, bResult ? MAX_PATH : 0); return bResult; } -template -static BOOL PathCanonicalizeW(_Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, _In_ LPCWSTR pszPath) +template +static BOOL PathCanonicalizeW(_Inout_ std::basic_string &sValue, _In_ LPCWSTR pszPath) { assert(0); // TODO: Test this code. - _Elem szBuffer[MAX_PATH + 1]; + wchar_t szBuffer[MAX_PATH + 1]; BOOL bResult = ::PathCanonicalizeW(szBuffer, pszPath); sValue.assign(szBuffer, bResult ? MAX_PATH : 0); return bResult; diff --git a/include/WinStd/WLAN.h b/include/WinStd/WLAN.h index a384cd2a..6370466b 100644 --- a/include/WinStd/WLAN.h +++ b/include/WinStd/WLAN.h @@ -37,8 +37,8 @@ namespace winstd { /// Since Wlanapi.dll is not always present, the `pfnWlanReasonCodeToString` pointer to `WlanReasonCodeToString()` /// function must be loaded dynamically. /// -template -static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, __reserved PVOID pReserved); +template +static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string &sValue, __reserved PVOID pReserved); /// @} @@ -165,8 +165,8 @@ namespace winstd } -template -static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string<_Elem, _Traits, _Ax> &sValue, __reserved PVOID pReserved) +template +static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string &sValue, __reserved PVOID pReserved) { DWORD dwSize = 0; @@ -176,7 +176,7 @@ static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_ for (;;) { // Increment size and allocate buffer. dwSize += 1024; - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwSize]); + std::unique_ptr szBuffer(new wchar_t[dwSize]); // Try! DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved); diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index bd3b470d..51e17f08 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -38,28 +38,28 @@ namespace winstd /// @{ /// @copydoc GetModuleFileNameW() -template -static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string &sValue) noexcept; /// /// 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) /// -template -static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string &sValue) noexcept; /// @copydoc GetWindowTextW() -template -static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string &sValue) noexcept; /// /// 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) /// -template -static _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string &sValue) noexcept; /// @copydoc GetFileVersionInfoW() template @@ -74,20 +74,20 @@ template static _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<_Ty, _Ax> &aValue) noexcept; /// @copydoc ExpandEnvironmentStringsW() -template -static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string &sValue) noexcept; /// /// 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) /// -template -static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string &sValue) noexcept; /// @copydoc GuidToStringW() -template -static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept; +template +static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string &str) noexcept; /// /// Formats GUID and stores it in a std::wstring string. @@ -95,8 +95,8 @@ static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _T /// \param[in ] lpGuid Pointer to GUID /// \param[out] str String to store the result to /// -template -static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept; +template +static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string &str) noexcept; /// @copydoc GuidToStringW() #ifdef _UNICODE @@ -146,8 +146,8 @@ static _Success_(return) BOOL StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUI /// \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) /// -template -static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string &sValue) noexcept; /// /// Queries for a string value in the registry and stores it in a std::wstring string. @@ -167,8 +167,8 @@ static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ /// \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) /// -template -static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept; +template +static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string &sValue) noexcept; /// @copydoc RegQueryValueExW() template @@ -185,16 +185,16 @@ static LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, #if _WIN32_WINNT >= _WIN32_WINNT_VISTA /// @copydoc RegLoadMUIStringW() -template -static 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; +template +static LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string &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. /// /// \sa [RegLoadMUIString function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724890.aspx) /// -template -static 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; +template +static LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory) noexcept; #endif @@ -363,28 +363,28 @@ static VOID OutputDebugStr(_In_z_ LPCSTR lpOutputString, ...) noexcept; static VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept; /// @copydoc GetDateFormatW() -template -static _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; +template +static _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 &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. /// /// \sa [GetDateFormat function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd318086.aspx) /// -template -static _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; +template +static _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 &sDate) noexcept; /// @copydoc LookupAccountSidW() -template -static _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; +template +static _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string *sName, _Out_opt_ std::basic_string *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. /// /// \sa [LookupAccountSid function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379166.aspx) /// -template -static _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; +template +static _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string *sName, _Out_opt_ std::basic_string *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. @@ -399,16 +399,16 @@ static _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, /// /// \sa [QueryFullProcessImageNameA function](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-queryfullprocessimagenamea) /// -template -static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<_Elem, _Traits, _Ax>& sExeName); +template +static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string& sExeName); /// /// Retrieves the full name of the executable image for the specified process. /// /// \sa [QueryFullProcessImageNameW function](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-queryfullprocessimagenamew) /// -template -static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<_Elem, _Traits, _Ax>& sExeName); +template +static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string& sExeName); /// @} @@ -1358,12 +1358,12 @@ namespace winstd #pragma warning(push) #pragma warning(disable: 4505) // Don't warn on unused code -template -static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_string &sValue) noexcept { assert(0); // TODO: Test this code. - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; // Try with stack buffer first. DWORD dwResult = ::GetModuleFileNameA(hModule, szStackBuffer, _countof(szStackBuffer)); @@ -1372,9 +1372,9 @@ static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_strin sValue.assign(szStackBuffer, dwResult); return dwResult; } else { - for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; dwCapacity *= 2) { + for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(char);; dwCapacity *= 2) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]); + std::unique_ptr szBuffer(new char[dwCapacity]); dwResult = ::GetModuleFileNameA(hModule, szBuffer.get(), dwCapacity); if (dwResult < dwCapacity) { sValue.assign(szBuffer.get(), dwResult); @@ -1385,10 +1385,10 @@ static DWORD GetModuleFileNameA(_In_opt_ HMODULE hModule, _Out_ std::basic_strin } -template -static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_string &sValue) noexcept { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; // Try with stack buffer first. DWORD dwResult = ::GetModuleFileNameW(hModule, szStackBuffer, _countof(szStackBuffer)); @@ -1397,9 +1397,9 @@ static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_strin sValue.assign(szStackBuffer, dwResult); return dwResult; } else { - for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem);; dwCapacity *= 2) { + for (DWORD dwCapacity = 2*WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t);; dwCapacity *= 2) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]); + std::unique_ptr szBuffer(new wchar_t[dwCapacity]); dwResult = ::GetModuleFileNameW(hModule, szBuffer.get(), dwCapacity); if (dwResult < dwCapacity) { sValue.assign(szBuffer.get(), dwResult); @@ -1410,8 +1410,8 @@ static DWORD GetModuleFileNameW(_In_opt_ HMODULE hModule, _Out_ std::basic_strin } -template -static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basic_string &sValue) noexcept { assert(0); // TODO: Test this code. @@ -1420,14 +1420,14 @@ static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basi // Query the final string length first. iResult = ::GetWindowTextLengthA(hWnd); if (iResult > 0) { - if (++iResult < WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)) { + if (++iResult < WINSTD_STACK_BUFFER_BYTES/sizeof(char)) { // Read string data to stack. - _Elem szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + char szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(char)]; iResult = ::GetWindowTextA(hWnd, szBuffer, _countof(szBuffer)); sValue.assign(szBuffer, iResult); } else { // Allocate buffer on heap and read the string data into it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++iResult]); + std::unique_ptr szBuffer(new char[++iResult]); iResult = ::GetWindowTextA(hWnd, szBuffer.get(), iResult); sValue.assign(szBuffer.get(), iResult); } @@ -1439,8 +1439,8 @@ static _Success_(return != 0) int GetWindowTextA(_In_ HWND hWnd, _Out_ std::basi } -template -static _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basic_string &sValue) noexcept { assert(0); // TODO: Test this code. @@ -1449,14 +1449,14 @@ static _Success_(return != 0) int GetWindowTextW(_In_ HWND hWnd, _Out_ std::basi // Query the final string length first. iResult = ::GetWindowTextLengthW(hWnd); if (iResult > 0) { - if (++iResult < WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)) { + if (++iResult < WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)) { // Read string data to stack. - _Elem szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; iResult = ::GetWindowTextW(hWnd, szBuffer, _countof(szBuffer)); sValue.assign(szBuffer, iResult); } else { // Allocate buffer on heap and read the string data into it. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[++iResult]); + std::unique_ptr szBuffer(new wchar_t[++iResult]); iResult = ::GetWindowTextW(hWnd, szBuffer.get(), iResult); sValue.assign(szBuffer.get(), iResult); } @@ -1500,14 +1500,14 @@ static _Success_(return != 0) BOOL GetFileVersionInfoW(_In_z_ LPCWSTR lptstrFile } -template -static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSrc, _Out_ std::basic_string &sValue) noexcept { assert(0); // TODO: Test this code. for (DWORD dwSizeOut = (DWORD)strlen(lpSrc) + 0x100;;) { DWORD dwSizeIn = dwSizeOut; - std::unique_ptr<_Elem[]> szBuffer(new _Elem[(size_t)dwSizeIn + 2]); // Note: ANSI version requires one extra char. + std::unique_ptr szBuffer(new char[(size_t)dwSizeIn + 2]); // Note: ANSI version requires one extra char. dwSizeOut = ::ExpandEnvironmentStringsA(lpSrc, szBuffer.get(), dwSizeIn); if (dwSizeOut == 0) { // Error or zero-length input. @@ -1524,12 +1524,12 @@ static _Success_(return != 0) DWORD ExpandEnvironmentStringsA(_In_z_ LPCSTR lpSr } -template -static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpSrc, _Out_ std::basic_string &sValue) noexcept { for (DWORD dwSizeOut = (DWORD)wcslen(lpSrc) + 0x100;;) { DWORD dwSizeIn = dwSizeOut; - std::unique_ptr<_Elem[]> szBuffer(new _Elem[(size_t)dwSizeIn + 1]); + std::unique_ptr szBuffer(new wchar_t[(size_t)dwSizeIn + 1]); dwSizeOut = ::ExpandEnvironmentStringsW(lpSrc, szBuffer.get(), dwSizeIn); if (dwSizeOut == 0) { // Error or zero-length input. @@ -1546,8 +1546,8 @@ static _Success_(return != 0) DWORD ExpandEnvironmentStringsW(_In_z_ LPCWSTR lpS } -template -static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept +template +static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string &str) noexcept { assert(0); // TODO: Test this code. @@ -1560,8 +1560,8 @@ static VOID GuidToStringA(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _T } -template -static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string<_Elem, _Traits, _Ax> &str) noexcept +template +static VOID GuidToStringW(_In_ LPCGUID lpGuid, _Out_ std::basic_string &str) noexcept { assert(0); // TODO: Test this code. @@ -1700,8 +1700,8 @@ static _Success_(return) BOOL StringToGuidW(_In_z_ LPCWSTR lpszGuid, _Out_ LPGUI } -template -static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ std::basic_string &sValue) noexcept { LSTATUS lResult; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; @@ -1747,8 +1747,8 @@ static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_ } -template -static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string<_Elem, _Traits, _Ax> &sValue) noexcept +template +static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_ std::basic_string &sValue) noexcept { LSTATUS lResult; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; @@ -1842,8 +1842,8 @@ static LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR lpValueName, #if _WIN32_WINNT >= _WIN32_WINNT_VISTA -template -static 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 +template +static LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Out_ std::basic_string &sOut, _In_ DWORD Flags, _In_opt_z_ LPCSTR pszDirectory) noexcept { // According to "Remarks" section in MSDN documentation of RegLoadMUIString(), // this function is defined but not implemented as ANSI variation. @@ -1852,11 +1852,11 @@ static LSTATUS RegLoadMUIStringA(_In_ HKEY hKey, _In_opt_z_ LPCSTR pszValue, _Ou } -template -static 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 +template +static LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _Out_ std::basic_string &sOut, _In_ DWORD Flags, _In_opt_z_ LPCWSTR pszDirectory) noexcept { LSTATUS lResult; - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES/sizeof(wchar_t)]; DWORD dwSize; Flags &= ~REG_MUI_STRING_TRUNCATE; @@ -1865,11 +1865,11 @@ static LSTATUS RegLoadMUIStringW(_In_ HKEY hKey, _In_opt_z_ LPCWSTR pszValue, _O lResult = RegLoadMUIStringW(hKey, pszValue, szStackBuffer, sizeof(szStackBuffer), &dwSize, Flags, pszDirectory); if (lResult == ERROR_SUCCESS) { // Copy from stack buffer. - sOut.assign(szStackBuffer, wcsnlen(szStackBuffer, dwSize/sizeof(_Elem))); + sOut.assign(szStackBuffer, wcsnlen(szStackBuffer, dwSize/sizeof(wchar_t))); } else if (lResult == ERROR_MORE_DATA) { // Allocate buffer on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[(dwSize + sizeof(_Elem) - 1)/sizeof(_Elem)]); - sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? wcsnlen(szBuffer.get(), dwSize/sizeof(_Elem)) : 0); + std::unique_ptr szBuffer(new wchar_t[(dwSize + sizeof(wchar_t) - 1)/sizeof(wchar_t)]); + sOut.assign(szBuffer.get(), (lResult = RegLoadMUIStringW(hKey, pszValue, szBuffer.get(), dwSize, &dwSize, Flags, pszDirectory)) == ERROR_SUCCESS ? wcsnlen(szBuffer.get(), dwSize/sizeof(wchar_t)) : 0); } return lResult; @@ -2294,13 +2294,13 @@ static VOID OutputDebugStr(_In_z_ LPCWSTR lpOutputString, ...) noexcept } -template -static _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 +template +static _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 &sDate) noexcept { int iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, NULL, 0); if (iResult) { // Allocate buffer on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[iResult]); + std::unique_ptr szBuffer(new char[iResult]); iResult = GetDateFormatA(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult); sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0); return iResult; @@ -2310,13 +2310,13 @@ static _Success_(return != 0) int GetDateFormatA(_In_ LCID Locale, _In_ DWORD dw } -template -static _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 +template +static _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 &sDate) noexcept { int iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, NULL, 0); if (iResult) { // Allocate buffer on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[iResult]); + std::unique_ptr szBuffer(new wchar_t[iResult]); iResult = GetDateFormatW(Locale, dwFlags, lpDate, lpFormat, szBuffer.get(), iResult); sDate.assign(szBuffer.get(), iResult ? iResult - 1 : 0); return iResult; @@ -2326,8 +2326,8 @@ static _Success_(return != 0) int GetDateFormatW(_In_ LCID Locale, _In_ DWORD dw } -template -static _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 +template +static _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string *sName, _Out_opt_ std::basic_string *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept { assert(0); // TODO: Test this code. @@ -2344,8 +2344,8 @@ static _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemN return TRUE; } else if (GetLastError() == ERROR_MORE_DATA) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> bufName (new _Elem[dwNameLen ]); - std::unique_ptr<_Elem[]> bufRefDomain(new _Elem[dwRefDomainLen]); + std::unique_ptr bufName (new char[dwNameLen ]); + std::unique_ptr bufRefDomain(new char[dwRefDomainLen]); if (LookupAccountSidA(lpSystemName, lpSid, bufName .get(), &dwNameLen , bufRefDomain.get(), &dwRefDomainLen, @@ -2361,8 +2361,8 @@ static _Success_(return != 0) BOOL LookupAccountSidA(_In_opt_z_ LPCSTR lpSystemN } -template -static _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 +template +static _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystemName, _In_ PSID lpSid, _Out_opt_ std::basic_string *sName, _Out_opt_ std::basic_string *sReferencedDomainName, _Out_ PSID_NAME_USE peUse) noexcept { assert(0); // TODO: Test this code. @@ -2379,8 +2379,8 @@ static _Success_(return != 0) BOOL LookupAccountSidW(_In_opt_z_ LPCWSTR lpSystem return TRUE; } else if (GetLastError() == ERROR_MORE_DATA) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> bufName (new _Elem[dwNameLen ]); - std::unique_ptr<_Elem[]> bufRefDomain(new _Elem[dwRefDomainLen]); + std::unique_ptr bufName (new wchar_t[dwNameLen ]); + std::unique_ptr bufRefDomain(new wchar_t[dwRefDomainLen]); if (LookupAccountSidW(lpSystemName, lpSid, bufName .get(), &dwNameLen , bufRefDomain.get(), &dwRefDomainLen, @@ -2424,10 +2424,10 @@ static _Success_(return != 0) BOOL GetTokenInformation(_In_ HANDLE TokenHandle, } -template -static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<_Elem, _Traits, _Ax>& sExeName) +template +static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string& sExeName) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(_Elem)]; + char szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(char)]; DWORD dwSize = _countof(szStackBuffer); // Try with stack buffer first. @@ -2436,9 +2436,9 @@ static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProce sExeName.assign(szStackBuffer, dwSize); return TRUE; } - for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(_Elem); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) { + for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(char); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]); + std::unique_ptr szBuffer(new char[dwCapacity]); dwSize = dwCapacity; if (::QueryFullProcessImageNameA(hProcess, dwFlags, szBuffer.get(), &dwSize)) { sExeName.assign(szBuffer.get(), dwSize); @@ -2449,10 +2449,10 @@ static _Success_(return != 0) BOOL QueryFullProcessImageNameA(_In_ HANDLE hProce } -template -static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string<_Elem, _Traits, _Ax>& sExeName) +template +static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProcess, _In_ DWORD dwFlags, _Inout_ std::basic_string& sExeName) { - _Elem szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(_Elem)]; + wchar_t szStackBuffer[WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t)]; DWORD dwSize = _countof(szStackBuffer); // Try with stack buffer first. @@ -2461,9 +2461,9 @@ static _Success_(return != 0) BOOL QueryFullProcessImageNameW(_In_ HANDLE hProce sExeName.assign(szStackBuffer, dwSize); return TRUE; } - for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(_Elem); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) { + for (DWORD dwCapacity = 2 * WINSTD_STACK_BUFFER_BYTES / sizeof(wchar_t); GetLastError() == ERROR_INSUFFICIENT_BUFFER; dwCapacity *= 2) { // Allocate on heap and retry. - std::unique_ptr<_Elem[]> szBuffer(new _Elem[dwCapacity]); + std::unique_ptr szBuffer(new wchar_t[dwCapacity]); dwSize = dwCapacity; if (::QueryFullProcessImageNameW(hProcess, dwFlags, szBuffer.get(), &dwSize)) { sExeName.assign(szBuffer.get(), dwSize);