Jump to content
Sign in to follow this  

CredEnumerate Function Call

Recommended Posts


Hello Everybody,

I need to call a API Function called CredEnumerate. It is used to enumerate the credentials of the current user. I have read that this function belongs to advapi32.dll but everythime I try to call it, autoit crashes. I found this page that explains the function's parameters:


If anybody has a idea about how to call this function, please answer.

Thanks in advance

Share this post

Link to post
Share on other sites

Func _CredEnumerate($sFilter, $iFlags)
    Local $aResult
    $aResult = DllCall('advapi32.dll', 'int', 'CredEnumerateW', 'wstr', $sFilter, 'uint', $iFlags, 'uint*', '', 'int*', '')
    If @error Or ($aResult[0] = 0) Then
        ConsoleWrite('Error: ' & @error & @TAB & 'Extended: ' & @extended & @CRLF)
        ConsoleWrite(_WinAPI_GetLastError() & @CRLF)
        Return SetError(1)
    ConsoleWrite($aResult[0] & @TAB & $aResult[3] & @TAB & $aResult[4] & @CRLF)
    If $aResult[3] > 0 Then _
        DllCall('advapi32.dll', 'none', 'CredFree', 'ptr', $aResult[4])

It should be something like this, I can't test it because cred enumeration flag is not supported in Windows XP. If you can enumerate successfully, the return pointer should point to an array of CREDENTIAL (still, not sure I wrote it correctly:

    'ptr Keyword;' & _
    'dword Flags;' & _
    'dword ValueSize;' & _
    'ptr Value;'

Global Const $tagCREDENTIAL = _
    'dword Flags;' & _
    'dword Type;' & _
    'ptr TargetName;' & _
    'ptr Comment;' & _
    $tagFILETIME & ';' & _
    'dword CredentialBlobSize;' & _
    'ptr CredentialBlob;' & _
    'dword Persist;' & _
    'dword AttributeCount;' & _
    'ptr Attributes;' & _
    'ptr TargetAlias;' & _
    'ptr UserName;'

Use can build a string concatenation of $tagCREDENTIAL $aResult[3] times (if greater than zero) and call DllStructCreate(), specifying this string as the first parameter, and $aResult[4], the pointer as the second parameter. Not tested.

Share this post

Link to post
Share on other sites

Thank you Authenticity. You were really helpful. I will try to use your ideas and definetely post the results.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this