Split CredEnumerate to A and W variants

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2022-03-10 14:50:10 +01:00
parent 212ee66296
commit 8244dea1a4

View File

@ -194,16 +194,14 @@ namespace winstd
/// \addtogroup WinStdCredAPI /// \addtogroup WinStdCredAPI
/// @{ /// @{
/// #pragma warning(push)
/// 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. #pragma warning(disable: 4505) // Don't warn on unused code
///
/// \sa [CredEnumerate function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374794.aspx) /// @copydoc CredEnumerateW()
/// static BOOL CredEnumerateA(_In_z_ LPCSTR Filter, _Reserved_ DWORD Flags, _Out_ DWORD *Count, _Inout_ std::unique_ptr<PCREDENTIALA[], winstd::CredFree_delete<PCREDENTIALA[]> > &cCredentials) noexcept
#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<PCREDENTIAL[], winstd::CredFree_delete<PCREDENTIAL[]> > &cCredentials) noexcept
{ {
PCREDENTIAL *pCredentials; PCREDENTIALA *pCredentials;
if (CredEnumerate(Filter, Flags, Count, &pCredentials)) { if (CredEnumerateA(Filter, Flags, Count, &pCredentials)) {
cCredentials.reset(pCredentials); cCredentials.reset(pCredentials);
return TRUE; return TRUE;
} }
@ -211,4 +209,22 @@ static BOOL CredEnumerate(_In_z_ LPCTSTR Filter, _Reserved_ DWORD Flags, _Out_ D
return FALSE; 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<PCREDENTIALW[], winstd::CredFree_delete<PCREDENTIALW[]> > &cCredentials) noexcept
{
PCREDENTIALW *pCredentials;
if (CredEnumerateW(Filter, Flags, Count, &pCredentials)) {
cCredentials.reset(pCredentials);
return TRUE;
}
return FALSE;
}
#pragma warning(pop)
/// @} /// @}