- BOOL => bool

- BYTE => unsigned char
- winstd::CAtlLibrary => winstd::library
This commit is contained in:
Simon Rozman 2016-05-16 19:09:32 +02:00
parent a04b6892a1
commit 0a2a6e50b9
4 changed files with 54 additions and 54 deletions

View File

@ -380,15 +380,15 @@ namespace winstd
/// \param[in] h Object handle of existing object /// \param[in] h Object handle of existing object
/// ///
/// \return /// \return
/// - TRUE when duplication succeeds; /// - true when duplication succeeds;
/// - FALSE when duplication fails. In case of failure obtaining the extended error information is object type specific (for example: `GetLastError()`). /// - false when duplication fails. In case of failure obtaining the extended error information is object type specific (for example: `GetLastError()`).
/// ///
inline bool attach_duplicated(_In_opt_ handle_type h) inline bool attach_duplicated(_In_opt_ handle_type h)
{ {
if (m_h) if (m_h)
free_internal(); free_internal();
return h ? (m_h = duplicate_internal(h)) != NULL : (m_h = NULL, TRUE); return h ? (m_h = duplicate_internal(h)) != NULL : (m_h = NULL, true);
} }
// //

View File

@ -75,7 +75,7 @@ inline DWORD CertGetNameStringW(_In_ PCCERT_CONTEXT pCertContext, _In_ DWORD dwT
/// ///
/// \sa [CryptGetHashParam function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379947.aspx) /// \sa [CryptGetHashParam function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379947.aspx)
/// ///
inline BOOL CryptGetHashParam(_In_ HCRYPTHASH hHash, _In_ DWORD dwParam, _Out_ std::vector<BYTE> &aData, _In_ DWORD dwFlags) inline BOOL CryptGetHashParam(_In_ HCRYPTHASH hHash, _In_ DWORD dwParam, _Out_ std::vector<unsigned char> &aData, _In_ DWORD dwFlags)
{ {
DWORD dwHashSize; DWORD dwHashSize;
@ -95,7 +95,7 @@ inline BOOL CryptGetHashParam(_In_ HCRYPTHASH hHash, _In_ DWORD dwParam, _Out_
/// ///
/// \sa [CryptExportKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379931.aspx) /// \sa [CryptExportKey function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa379931.aspx)
/// ///
inline BOOL CryptExportKey(_In_ HCRYPTKEY hKey, _In_ HCRYPTKEY hExpKey, _In_ DWORD dwBlobType, _In_ DWORD dwFlags, _Out_ std::vector<BYTE> &aData) inline BOOL CryptExportKey(_In_ HCRYPTKEY hKey, _In_ HCRYPTKEY hExpKey, _In_ DWORD dwBlobType, _In_ DWORD dwFlags, _Out_ std::vector<unsigned char> &aData)
{ {
DWORD dwKeyBLOBSize; DWORD dwKeyBLOBSize;
@ -138,18 +138,18 @@ namespace winstd
/// Creates the certificate context. /// Creates the certificate context.
/// ///
/// \return /// \return
/// - 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()`.
/// \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_ const BYTE *pbCertEncoded, _In_ DWORD cbCertEncoded) inline bool create(_In_ DWORD dwCertEncodingType, _In_ const unsigned char *pbCertEncoded, _In_ DWORD cbCertEncoded)
{ {
handle_type h = CertCreateCertificateContext(dwCertEncodingType, pbCertEncoded, cbCertEncoded); handle_type h = CertCreateCertificateContext(dwCertEncodingType, pbCertEncoded, cbCertEncoded);
if (h) { if (h) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:
@ -200,18 +200,18 @@ namespace winstd
/// Creates the certificate chain context. /// Creates the certificate chain context.
/// ///
/// \return /// \return
/// - 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()`.
/// \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) 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)
{ {
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)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:
@ -262,18 +262,18 @@ namespace winstd
/// Opens the certificate store. /// Opens the certificate store.
/// ///
/// \return /// \return
/// - 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()`.
/// \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)
{ {
handle_type h = CertOpenStore(lpszStoreProvider, dwEncodingType, hCryptProv, dwFlags, pvPara); handle_type h = CertOpenStore(lpszStoreProvider, dwEncodingType, hCryptProv, dwFlags, pvPara);
if (h) { if (h) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:
@ -310,18 +310,18 @@ namespace winstd
/// Acquires the cryptographic context. /// Acquires the cryptographic context.
/// ///
/// \return /// \return
/// - 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()`.
/// \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_ LPCTSTR szContainer, _In_opt_ LPCTSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags) inline bool create(_In_opt_ LPCTSTR szContainer, _In_opt_ LPCTSTR szProvider, _In_ DWORD dwProvType, _In_ DWORD dwFlags)
{ {
handle_type h; handle_type h;
if (CryptAcquireContext(&h, szContainer, szProvider, dwProvType, dwFlags)) { if (CryptAcquireContext(&h, szContainer, szProvider, dwProvType, dwFlags)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:
@ -358,18 +358,18 @@ namespace winstd
/// Creates the hash context. /// Creates the hash context.
/// ///
/// \return /// \return
/// - 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()`.
/// \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_ HCRYPTKEY hKey, _In_ DWORD dwFlags) inline bool create(_In_ HCRYPTPROV hProv, _In_ ALG_ID Algid, _In_ HCRYPTKEY hKey, _In_ DWORD dwFlags)
{ {
handle_type h; handle_type h;
if (CryptCreateHash(hProv, Algid, hKey, dwFlags, &h)) { if (CryptCreateHash(hProv, Algid, hKey, dwFlags, &h)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:
@ -422,14 +422,14 @@ 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)
{ {
handle_type h; handle_type h;
if (CryptGenKey(hProv, Algid, dwFlags, &h)) { if (CryptGenKey(hProv, Algid, dwFlags, &h)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
/// ///
@ -437,14 +437,14 @@ 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) CONST BYTE *pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags) inline bool import(_In_ HCRYPTPROV hProv, __in_bcount(dwDataLen) const unsigned char *pbData, _In_ DWORD dwDataLen, _In_ HCRYPTKEY hPubKey, _In_ DWORD dwFlags)
{ {
handle_type h; handle_type h;
if (CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h)) { if (CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, &h)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
/// ///
@ -452,14 +452,14 @@ 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)
{ {
handle_type h; handle_type h;
if (CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h)) { if (CryptImportPublicKeyInfo(hCryptProv, dwCertEncodingType, pInfo, &h)) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected:

View File

@ -215,11 +215,11 @@ inline UINT MsiFormatRecordW(MSIHANDLE hInstall, MSIHANDLE hRecord, std::wstring
/// ///
/// Reads bytes from a record stream field into a std::vector<BYTE> buffer. /// Reads bytes from a record stream field into a std::vector buffer.
/// ///
/// \sa [MsiRecordReadStream function](https://msdn.microsoft.com/en-us/library/aa370370.aspx) /// \sa [MsiRecordReadStream function](https://msdn.microsoft.com/en-us/library/aa370370.aspx)
/// ///
inline UINT MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Out_ std::vector<BYTE> &binData) inline UINT MsiRecordReadStream(_In_ MSIHANDLE hRecord, _In_ unsigned int iField, _Out_ std::vector<unsigned char> &binData)
{ {
DWORD dwSize = 0; DWORD dwSize = 0;
UINT uiResult; UINT uiResult;

View File

@ -155,11 +155,11 @@ inline int GetWindowTextW(_In_ HWND hWnd, _Out_ std::wstring &sValue)
/// ///
/// Retrieves version information for the specified file and stores it in a std::string string. /// 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)
/// ///
inline BOOL GetFileVersionInfoA(_In_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<BYTE> &aValue) inline BOOL GetFileVersionInfoA(_In_ LPCSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<unsigned char> &aValue)
{ {
// Get version info size. // Get version info size.
DWORD dwVerInfoSize = ::GetFileVersionInfoSizeA(lptstrFilename, &dwHandle); DWORD dwVerInfoSize = ::GetFileVersionInfoSizeA(lptstrFilename, &dwHandle);
@ -173,11 +173,11 @@ inline BOOL GetFileVersionInfoA(_In_ LPCSTR lptstrFilename, __reserved DWORD dwH
/// ///
/// Retrieves version information for the specified file and stores it in a std::wstring string. /// 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)
/// ///
inline BOOL GetFileVersionInfoW(_In_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<BYTE> &aValue) inline BOOL GetFileVersionInfoW(_In_ LPCWSTR lptstrFilename, __reserved DWORD dwHandle, _Out_ std::vector<unsigned char> &aValue)
{ {
// Get version info size. // Get version info size.
DWORD dwVerInfoSize = ::GetFileVersionInfoSizeW(lptstrFilename, &dwHandle); DWORD dwVerInfoSize = ::GetFileVersionInfoSizeW(lptstrFilename, &dwHandle);
@ -405,11 +405,11 @@ inline LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_
/// ///
/// Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector<BYTE> 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)
/// ///
inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<BYTE> &aData) inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_ LPCSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<unsigned char> &aData)
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -433,11 +433,11 @@ inline LSTATUS RegQueryValueExA(_In_ HKEY hKey, _In_opt_ LPCSTR lpValueName, __r
/// ///
/// Retrieves the type and data for the specified value name associated with an open registry key and stores the data in a std::vector<BYTE> 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)
/// ///
inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<BYTE> &aData) inline LSTATUS RegQueryValueExW(_In_ HKEY hKey, _In_opt_ LPCWSTR lpValueName, __reserved LPDWORD lpReserved, _Out_opt_ LPDWORD lpType, _Out_ std::vector<unsigned char> &aData)
{ {
LSTATUS lResult; LSTATUS lResult;
BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES]; BYTE aStackBuffer[WINSTD_STACK_BUFFER_BYTES];
@ -530,7 +530,7 @@ namespace winstd
/// ///
/// Module handle wrapper /// Module handle wrapper
/// ///
class CAtlLibrary : public handle<HMODULE> class library : public handle<HMODULE>
{ {
public: public:
/// ///
@ -538,7 +538,7 @@ namespace winstd
/// ///
/// \sa [FreeLibrary](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152.aspx) /// \sa [FreeLibrary](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152.aspx)
/// ///
virtual ~CAtlLibrary() virtual ~library()
{ {
if (m_h) if (m_h)
FreeLibrary(m_h); FreeLibrary(m_h);
@ -549,14 +549,14 @@ namespace winstd
/// ///
/// \sa [LoadLibraryEx](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684179.aspx) /// \sa [LoadLibraryEx](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684179.aspx)
/// ///
inline BOOL Load(_In_ LPCTSTR lpFileName, __reserved handle_type hFile, _In_ DWORD dwFlags) inline bool Load(_In_ LPCTSTR lpFileName, __reserved handle_type hFile, _In_ DWORD dwFlags)
{ {
handle_type h = LoadLibraryEx(lpFileName, hFile, dwFlags); handle_type h = LoadLibraryEx(lpFileName, hFile, dwFlags);
if (h) { if (h) {
attach(h); attach(h);
return TRUE; return true;
} else } else
return FALSE; return false;
} }
protected: protected: