19template<
class _Traits,
class _Ax>
20static BOOL
CredProtectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<char, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType)
23 DWORD dwSize = _countof(buf);
26 if (
CredProtectA(fAsSelf,
const_cast<LPSTR
>(pszCredentials), cchCredentials, buf, &dwSize, ProtectionType)) {
28 sProtectedCredentials.assign(buf, dwSize - 1);
30 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
32 sProtectedCredentials.resize(dwSize - 1);
33 if (
CredProtectA(fAsSelf,
const_cast<LPSTR
>(pszCredentials), cchCredentials, &sProtectedCredentials[0], &dwSize, ProtectionType))
45template<
class _Traits,
class _Ax>
46static BOOL
CredProtectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sProtectedCredentials, _Out_ CRED_PROTECTION_TYPE *ProtectionType)
49 DWORD dwSize = _countof(buf);
52 if (
CredProtectW(fAsSelf,
const_cast<LPWSTR
>(pszCredentials), cchCredentials, buf, &dwSize, ProtectionType)) {
54 sProtectedCredentials.assign(buf, dwSize - 1);
56 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
58 sProtectedCredentials.resize(dwSize - 1);
59 if (
CredProtectW(fAsSelf,
const_cast<LPWSTR
>(pszCredentials), cchCredentials, &sProtectedCredentials[0], &dwSize, ProtectionType))
67template<
class _Traits,
class _Ax>
68static BOOL
CredUnprotectA(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<char, _Traits, _Ax> &sCredentials)
71 DWORD dwSize = _countof(buf);
74 if (
CredUnprotectA(fAsSelf,
const_cast<LPSTR
>(pszProtectedCredentials), cchCredentials, buf, &dwSize)) {
76 sCredentials.assign(buf, dwSize);
78 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
80 sCredentials.resize(dwSize - 1);
81 if (
CredUnprotectA(fAsSelf,
const_cast<LPSTR
>(pszProtectedCredentials), cchCredentials, &sCredentials[0], &dwSize))
93template<
class _Traits,
class _Ax>
94static BOOL
CredUnprotectW(_In_ BOOL fAsSelf, _In_count_(cchCredentials) LPCWSTR pszProtectedCredentials, _In_ DWORD cchCredentials, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sCredentials)
97 DWORD dwSize = _countof(buf);
100 if (
CredUnprotectW(fAsSelf,
const_cast<LPWSTR
>(pszProtectedCredentials), cchCredentials, buf, &dwSize)) {
102 sCredentials.assign(buf, dwSize);
104 }
else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
106 sCredentials.resize(dwSize - 1);
107 if (
CredUnprotectW(fAsSelf,
const_cast<LPWSTR
>(pszProtectedCredentials), cchCredentials, &sCredentials[0], &dwSize))
176 template<
class _Other>
190#pragma warning(disable: 4505)
193static BOOL
CredEnumerateA(_In_z_ LPCSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIALA[],
winstd::CredFree_delete<PCREDENTIALA[]> > &cCredentials)
noexcept
195 PCREDENTIALA *pCredentials;
197 cCredentials.reset(pCredentials);
209static BOOL
CredEnumerateW(_In_z_ LPCWSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIALW[],
winstd::CredFree_delete<PCREDENTIALW[]> > &cCredentials)
noexcept
211 PCREDENTIALW *pCredentials;
213 cCredentials.reset(pCredentials);
static BOOL CredUnprotectA(BOOL fAsSelf, LPCSTR pszProtectedCredentials, DWORD cchCredentials, std::basic_string< char, _Traits, _Ax > &sCredentials)
Decrypts credentials that were previously encrypted by using the CredProtect function.
Definition Cred.h:68
static BOOL CredProtectA(BOOL fAsSelf, LPCSTR pszCredentials, DWORD cchCredentials, std::basic_string< char, _Traits, _Ax > &sProtectedCredentials, CRED_PROTECTION_TYPE *ProtectionType)
Encrypts the specified credentials so that only the current security context can decrypt them.
Definition Cred.h:20
static BOOL CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count, std::unique_ptr< PCREDENTIALA[], winstd::CredFree_delete< PCREDENTIALA[]> > &cCredentials) noexcept
Enumerates the credentials from the user's credential set. The credential set used is the one associa...
Definition Cred.h:193
static BOOL CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, std::unique_ptr< PCREDENTIALW[], winstd::CredFree_delete< PCREDENTIALW[]> > &cCredentials) noexcept
Enumerates the credentials from the user's credential set. The credential set used is the one associa...
Definition Cred.h:209
static BOOL CredProtectW(BOOL fAsSelf, LPCWSTR pszCredentials, DWORD cchCredentials, std::basic_string< wchar_t, _Traits, _Ax > &sProtectedCredentials, CRED_PROTECTION_TYPE *ProtectionType)
Encrypts the specified credentials so that only the current security context can decrypt them.
Definition Cred.h:46
static BOOL CredUnprotectW(BOOL fAsSelf, LPCWSTR pszProtectedCredentials, DWORD cchCredentials, std::basic_string< wchar_t, _Traits, _Ax > &sCredentials)
Decrypts credentials that were previously encrypted by using the CredProtect function.
Definition Cred.h:94
#define WINSTD_STACK_BUFFER_BYTES
Size of the stack buffer in bytes used for initial system function call.
Definition Common.h:94
CredFree_delete< _Ty > _Myt
This type.
Definition Cred.h:154
CredFree_delete()
Default construct.
Definition Cred.h:159
void operator()(_Other *) const
Delete a pointer of another type.
Definition Cred.h:177
void operator()(_Ty *_Ptr) const noexcept
Delete a pointer.
Definition Cred.h:166
Deleter for unique_ptr using CredFree.
Definition Cred.h:125
CredFree_delete< _Ty > _Myt
This type.
Definition Cred.h:126
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition Cred.h:143
CredFree_delete()
Default construct.
Definition Cred.h:131
CredFree_delete(const CredFree_delete< _Ty2 > &)
Construct from another CredFree_delete.
Definition Cred.h:136