VittGam Posted April 5, 2010 Share Posted April 5, 2010 Hi everyone, I have AutoIt 3.3.6.0 and I'm trying to execute this script: $pUiInfo=DllStructCreate("dword cbSize;hwnd hwndParent;wchar pszMessageText[2048];wchar pszCaptionText[2048];handle hbmBanner") DllStructSetData($pUiInfo,"pszCaptionText","CaptionText") DllStructSetData($pUiInfo,"pszMessageText","MessageText") DllStructSetData($pUiInfo,"hwndParent",0) DllStructSetData($pUiInfo,"cbSize",DllStructGetSize($pUiInfo)) $dwAuthError=0 $pulAuthPackage=0 $defuser="test-user" $defpass="test-pass" $ret0=DllCall("credui.dll","dword","CredPackAuthenticationBufferW","dword",0,"wstr",$defuser,"wstr",$defpass,"ptr",0,"dword*",0) $pPackedCredentials=DllStructCreate("byte["&$ret0[5]&"]") $ret1=DllCall("credui.dll","dword","CredPackAuthenticationBufferW","dword",0,"wstr",$defuser,"wstr",$defpass,"ptr",DllStructGetPtr($pPackedCredentials),"dword*",DllStructGetSize($pPackedCredentials)) $pfSave=0 $dwFlags=0x10001010 $ret2=DllCall("credui.dll","dword","CredUIPromptForWindowsCredentialsW","ptr*",DllStructGetPtr($pUiInfo),"uint",$dwAuthError,"ulong*",$pulAuthPackage,"ptr",DllStructGetPtr($pPackedCredentials),"ulong",DllStructGetSize($pPackedCredentials),"ptr*",0,"ulong*",0,"boolean*",$pfSave,"uint",$dwFlags) MsgBox(64,"CredUIPromptForWindowsCredentialsW return value",$ret2[0]) ; here it returns 160 $pPackedCredentialsOut=DllStructCreate("byte["&$ret2[7]&"]",$ret2[6]) $ret3=DllCall("credui.dll","bool","CredUnPackAuthenticationBufferW","dword",0,"ptr",DllStructGetPtr($pPackedCredentialsOut),"dword",DllStructGetSize($pPackedCredentialsOut),"ptr","","dword*",0,"ptr","","dword*",0,"ptr","","dword*",0) $username=DllStructCreate("wchar["&$ret3[5]*2&"]") $domain=DllStructCreate("wchar["&$ret3[7]*2&"]") $password=DllStructCreate("wchar["&$ret3[9]*2&"]") $ret4=DllCall("credui.dll","bool","CredUnPackAuthenticationBufferW","dword",0,"ptr",DllStructGetPtr($pPackedCredentialsOut),"dword",DllStructGetSize($pPackedCredentialsOut),"ptr",DllStructGetPtr($username),"dword*",DllStructGetSize($username),"ptr",DllStructGetPtr($domain),"dword*",DllStructGetSize($domain),"ptr",DllStructGetPtr($password),"dword*",DllStructGetSize($password)) MsgBox(64,"Results","Username: "&DllStructGetData($username,1)&@CRLF&"Domain: "&DllStructGetData($domain,1)&@CRLF&"Password: "&DllStructGetData($password,1)) It should ask for credentials, but there is no password dialog and the function CredUIPromptForWindowsCredentialsW is returning 160 (ERROR_BAD_ARGUMENTS). I'm running Windows Server 2008 Enterprise Service Pack 2 32-bit. Can anyone help me? Thanks. VittGam Link to comment Share on other sites More sharing options...
trancexx Posted April 5, 2010 Share Posted April 5, 2010 First three steps:expandcollapse popup;STEP 1 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $tCREDUI_INFO = DllStructCreate("dword Size;" & _ "hwnd Parent;" & _ "ptr MessageText;" & _ "ptr CaptionText;" & _ "handle Banner") $tMessageText = DllStructCreate("wchar[32767]") DllStructSetData($tMessageText, 1, "And this is MessageText") $tCaptionText = DllStructCreate("wchar[32767]") DllStructSetData($tCaptionText, 1, "This is CaptionText") DllStructSetData($tCREDUI_INFO, "MessageText", DllStructGetPtr($tMessageText)) DllStructSetData($tCREDUI_INFO, "CaptionText", DllStructGetPtr($tCaptionText)) DllStructSetData($tCREDUI_INFO, "Parent", 0) DllStructSetData($tCREDUI_INFO, "Size", DllStructGetSize($tCREDUI_INFO)) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $pfSave = 0 $dwFlags = 0x10001010 $dwAuthError = 0 $pulAuthPackage = 0 $defuser = "test-user" $defpass = "test-pass" ; STEP 2 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $aCall = DllCall("credui.dll", "dword", "CredPackAuthenticationBufferW", _ "dword", 0, _ "wstr", $defuser, _ "wstr", $defpass, _ "ptr", 0, _ "dword*", 0) $iRequiredSize = $aCall[5] Local $tBuffer = DllStructCreate("byte[" & $iRequiredSize & "]") $aCall = DllCall("credui.dll", "dword", "CredPackAuthenticationBufferW", _ "dword", 0, _ "wstr", $defuser, _ "wstr", $defpass, _ "ptr", DllStructGetPtr($tBuffer), _ "dword*", $iRequiredSize) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; STEP 3 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $Call = DllCall("credui.dll", "dword", "CredUIPromptForWindowsCredentialsW", _ "ptr", DllStructGetPtr($tCREDUI_INFO), _ "dword", $dwAuthError, _ "dword*", $pulAuthPackage, _ "ptr", DllStructGetPtr($tBuffer), _ "ulong", DllStructGetSize($tBuffer), _ "ptr*", 0, _ "dword*", 0, _ "bool*", $pfSave, _ "dword", $dwFlags) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MsgBox(64, "CredUIPromptForWindowsCredentialsW return value", $Call[0]) ; STEP 4 ;... ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
VittGam Posted April 5, 2010 Author Share Posted April 5, 2010 wow! it works. Thank you very much!!! First three steps:expandcollapse popup;STEP 1 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $tCREDUI_INFO = DllStructCreate("dword Size;" & _ "hwnd Parent;" & _ "ptr MessageText;" & _ "ptr CaptionText;" & _ "handle Banner") $tMessageText = DllStructCreate("wchar[32767]") DllStructSetData($tMessageText, 1, "And this is MessageText") $tCaptionText = DllStructCreate("wchar[32767]") DllStructSetData($tCaptionText, 1, "This is CaptionText") DllStructSetData($tCREDUI_INFO, "MessageText", DllStructGetPtr($tMessageText)) DllStructSetData($tCREDUI_INFO, "CaptionText", DllStructGetPtr($tCaptionText)) DllStructSetData($tCREDUI_INFO, "Parent", 0) DllStructSetData($tCREDUI_INFO, "Size", DllStructGetSize($tCREDUI_INFO)) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $pfSave = 0 $dwFlags = 0x10001010 $dwAuthError = 0 $pulAuthPackage = 0 $defuser = "test-user" $defpass = "test-pass" ; STEP 2 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $aCall = DllCall("credui.dll", "dword", "CredPackAuthenticationBufferW", _ "dword", 0, _ "wstr", $defuser, _ "wstr", $defpass, _ "ptr", 0, _ "dword*", 0) $iRequiredSize = $aCall[5] Local $tBuffer = DllStructCreate("byte[" & $iRequiredSize & "]") $aCall = DllCall("credui.dll", "dword", "CredPackAuthenticationBufferW", _ "dword", 0, _ "wstr", $defuser, _ "wstr", $defpass, _ "ptr", DllStructGetPtr($tBuffer), _ "dword*", $iRequiredSize) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; STEP 3 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $Call = DllCall("credui.dll", "dword", "CredUIPromptForWindowsCredentialsW", _ "ptr", DllStructGetPtr($tCREDUI_INFO), _ "dword", $dwAuthError, _ "dword*", $pulAuthPackage, _ "ptr", DllStructGetPtr($tBuffer), _ "ulong", DllStructGetSize($tBuffer), _ "ptr*", 0, _ "dword*", 0, _ "bool*", $pfSave, _ "dword", $dwFlags) ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MsgBox(64, "CredUIPromptForWindowsCredentialsW return value", $Call[0]) ; STEP 4 ;... Link to comment Share on other sites More sharing options...
trancexx Posted April 5, 2010 Share Posted April 5, 2010 So, what now? You will worship me and stuff? Don't forget error checking and double-check parameters an return values types. I wasn't very precise. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
VittGam Posted April 5, 2010 Author Share Posted April 5, 2010 (edited) So, what now? You will worship me and stuff? xDBut the secure password isn't decoded from the secure desktop ($dwFlags = 0x10001010), only when the screen is not in the secure desktop ($dwFlags = 0x10000010)... and I even changed "CredUnPackAuthenticationBufferW","dword",0 to "CredUnPackAuthenticationBufferW","dword",1edit: 1 should be the value for CRED_PACK_PROTECTED_CREDENTIALS, right? Edited April 5, 2010 by VittGam Link to comment Share on other sites More sharing options...
VittGam Posted April 5, 2010 Author Share Posted April 5, 2010 1 should be the value for CRED_PACK_PROTECTED_CREDENTIALS, right or not? because it doesn't work with secure logon [OT]And why can't I edit my posts anymore after some time?[/OT] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now