From 8244dea1a4de36f93433643c46b32c580c3a6248 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 10 Mar 2022 14:50:10 +0100 Subject: [PATCH] Split CredEnumerate to A and W variants Signed-off-by: Simon Rozman --- include/WinStd/Cred.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/include/WinStd/Cred.h b/include/WinStd/Cred.h index 6b10f23b..4be8f139 100644 --- a/include/WinStd/Cred.h +++ b/include/WinStd/Cred.h @@ -194,16 +194,14 @@ namespace winstd /// \addtogroup WinStdCredAPI /// @{ -/// -/// Enumerates the credentials from the user's credential set. The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled. -/// -/// \sa [CredEnumerate function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374794.aspx) -/// -#pragma warning(suppress: 4505) // Don't warn on unused code -static BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr > &cCredentials) noexcept +#pragma warning(push) +#pragma warning(disable: 4505) // Don't warn on unused code + +/// @copydoc CredEnumerateW() +static BOOL CredEnumerateA(_In_z_ LPCSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr > &cCredentials) noexcept { - PCREDENTIAL *pCredentials; - if (CredEnumerate(Filter, Flags, Count, &pCredentials)) { + PCREDENTIALA *pCredentials; + if (CredEnumerateA(Filter, Flags, Count, &pCredentials)) { cCredentials.reset(pCredentials); return TRUE; } @@ -211,4 +209,22 @@ static BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ D return FALSE; } +/// +/// Enumerates the credentials from the user's credential set. The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled. +/// +/// \sa [CredEnumerate function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374794.aspx) +/// +static BOOL CredEnumerateW(_In_z_ LPCWSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr > &cCredentials) noexcept +{ + PCREDENTIALW *pCredentials; + if (CredEnumerateW(Filter, Flags, Count, &pCredentials)) { + cCredentials.reset(pCredentials); + return TRUE; + } + + return FALSE; +} + +#pragma warning(pop) + /// @}